Escolar Documentos
Profissional Documentos
Cultura Documentos
Servos
Servos are DC motors with built in gearing and feedback control loop circuitry. And no motor drivers required. They are extremely popular with robot, RC plane, and RC boat builders. Most servo motors can rotate about 90 to 180 degrees. Some rotate through a full 360 degrees or more. However, servos are unable to continually rotate, means they can't be used for driving wheels, unless they are modified, but their precision positioning makes them ideal for robot legs and arms, rack and pinion steering etc. To use a servo, simply connect the black wire to ground, the red to a 4.8-6V source, and the yellow/white wire to a signal generator (such as from your microcontroller). Vary the square wave pulse width from 1-2 ms and your servo is now position/velocity controlled. Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a processor's digital outputs. The general concept is to simply send an ordinary logic square wave to your servo at a specific wave length, and your servo goes to a particular angle . The wavelength directly maps to servo angle.
Schematic Diagram -
/****************************************************** ***** Example Servo Motor Control electroons.com 8051 CD Code by- devesh@electroons.com Control signal is connected to P1_0 AT89S52 is working on 11.0592 MHz 1 machine cycle = 1.085usec For 20msec --> time required is 20000/1.085 counts = 18433 counts Timer 1 count => 65535-18433 => 0xB7FE Timer 0 count => For 1msec => 0xFC65 (0 degree) For 2msec =>0xF8CB (180 degree) ******************************************************* *****/ #include < at89x52.h> // Header file for AT89S52
void timer1_ovf(void) interrupt 3 // timer 1 for 20ms { TH1=0xB7; TL1=0xFE; P1_0=1; TR0=1; } void timer0_ovf(void) interrupt 1 // timer 0 for various shaft position { if(P2_0==0) //PB2 pressed { TH0=0xFC; //0 degree shaft position TL0=065; } else if(P2_1==0) // PB1 pressed { TH0=0xF8; //180 degree shaft position TL0=0xCB; } P1_0=0; TR0=0; } void main(void) { P2=0xFF; // Using PORT2 as input TMOD=011; ET1=1; ET0=1; TH1=0xB7; TL1=0xFE; TR1=1; EA=1; while(1){} }