How to interface Servo Motor with 8051 Microcontroller (AT89C51)
The first pin of port P1 (P1^0) of AT89C51 microcontroller is set as the output pin to provide control signal to the servo motor. Before connecting to the control wire of servo, the output from the microcontroller is fed through a comparator IC (LM324) so that the signal is protected from any loss due to overloading.
In the program, one of the 8051 timers is configured to generate flag after every 50 µs. Usually the pulse durations corresponding to 0° and 180° angular positions are 1ms and 2ms, but these durations may vary for different servos. Here, a pulse with ON time of 700 µs sets the motor closer to 0° and a pulse of 5500 µs sets the motor to 180°. A variable is taken which is initialized to a value 14. A function using timer is written that has the variable mentioned above as an argument. This function generates time delay in the multiples of 50 µs. Initially when the microcontroller executes program, a pulse with ON time of 700 µs (14 x 50 µs) followed by OFF time of 18 ms is generated. This shifts the servo horn to 0° angle.
LM324 is a 14pin IC consisting of four independent operational amplifiers (op-amps) compensated in a single package. Op-amps are high gain...