Servo motor driver may be used to control a single servo or even a group of servo motors. In many projects where servo motor controlling is the mainstay of the task to be accomplished, the controller must drive more than one servo. An example of this is an RC airplane, which uses many servos.
Essential Components
- A micro-controller
- A power supply unit
Miscellaneous Components
- A potentiometer
- Connectors, wires etc.
Micro-controller
A servo motor is driven by applying the voltage signal to it regular intervals. The servo is sensitive to timing variations. A pulse of specific width has to be applied at specific intervals of time. Typically, the duration of pulse varies from 0ms to 2.2ms and the repetition rate is 50Hz to 60Hz. For precise position control, the controller that is chosen must have timers that have the required resolution. Also, if more than one motor has to be controlled simultaneously, the processor clock must be fast enough. For a single motor control, an 8051 can be used like a AT89s51 or a P89v51RD2. But for more than one motor, we must use a PIC, like a PIC18F or a ATMEGA, so that it’s internal PWM can be utilized. However, the selection of micro-controller depends totally on the designer and the project requirements.
Power Supply
The design of the power supply unit servo motor controller depends on the number of servo motors that are interfaced to the board. Servo motors operate from 4.8V to a 6V supply voltage. The typical value is 5V. Applying voltages greater than the supply voltage is not advisable as it may render the motor permanently useless. The current draw of the motor is variable and depends on the torque that it generates. Also it will draw less current when in idle mode and more current when it is running. A servo motors maximum current draw is given as its stall current. This is the maximum current it will draw when running with the maximum torque before it stops due to overload. This current value can be as high as 1 A for some motors.
For a single motor control, a voltage regulator like a LM317 can be used along with a suitable heat sink. But when multiple motors need to be interfaced, a high-quality supply with higher current rating must be used. An SMPS (Switched mode power supply) can be a good option.
Block Diagram below-showing interconnections in a Servo Motor Driver
Controlling Servo Motor
The servo motor has three terminals.
- Position signal(PWM Pulses)
- Vcc (From Power Supply)
- Ground
The servo motor angular position is controlled by applying PWM pulses of specific width. The duration of pulse varies from about 0.5 ms for 0 degree rotation to 2.2 ms for 180 degree rotation. The pulses need to be given at frequencies of about 50Hz to 60Hz.
In order to generate the PWM (Pulse Width Modulation) waveform, as shown in the figure below, one can use either the internal PWM module of the micro-controller or the timers can be used. Using the PWM block is more flexible as most micro-controller families design, and this PWM block better suits the needs of applications such as a servo motor. For different widths of PWM pulses, we need to program the internal registers accordingly.
Now, we also need to tell the microcontroller how much it has to rotate. For this purpose, we can use a simple potentiometer and use an ADC to get the rotation angle or for more complex applications an accelerometer can be used.
Program Algorithm
Let us design the Program to control a single servo and the position input is given via the potentiometer connected to a pin of controller.
- nitialize the port pins for input/output.
- Read the ADC for desired servo position.
- Program the PWM registers for the desired value.
As soon as you trigger the PWM module, the selected PWM channel pin goes high (logic 1) and after the required width is reached, it will again go low (logic 0). So after triggering the PWM, you must start a timer with a delay of about 19 ms and wait until the timer overflows - Go to step 2
There are various modes of PWM available which you can use depending on the microcontroller you choose. Some degree of optimization should be done in the code to control the servo.
If you plan to use more than one servo than you will require as many PWM channels. Each servo can be given the PWM signal sequentially. But you must take care that the pulse repetition rate for each servo is maintained. Otherwise the servo will run out of synchronization.