Design of multi-channel servo controller

Publisher:郑哥Latest update time:2011-03-26 Source: 现代电子技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: In order to realize the control of robots and drones, a method of using a microprocessor to generate multi-channel servo control signals is proposed. This method uses AT89C52 single-chip microcomputer as the control chip, and realizes the generation of 8-channel servo control pulses through experiments. It can be widely used in control systems such as robots and drones, and a simple communication protocol is designed according to the communication requirements of the upper computer and the lower computer to meet the needs of real-time control.
Keywords: robot; servo controller; multi-channel; communication protocol

In the design of motion or execution control devices such as robots and drones, the servo control effect is an important factor affecting the system performance. The servo can be used as a basic output actuator in micro-electromechanical systems and robot systems, and its control and output will involve the generation of multi-channel control signals. For example, the head, shoulder, elbow, wrist, finger joints of the robot, the rudder of the drone, the steering wheel and throttle of the unmanned car, etc., all need to be driven by servo signals, so in this type of controller, multiple PWM signals are needed to control the servo, so as to complete the multi-channel parallel control task.

1.
...


a.JPG



b.JPG
​That is to say, if a certain pulse width is provided to it, its output shaft will remain at a corresponding angle, no matter how the external torque changes, until a pulse signal of another width is provided to it, it will change the output angle to a new corresponding position.

d.JPG
There is a reference circuit inside the servo, which generates a reference signal with a period of 20 ms and a width of 1.5 ms. There is a comparator that compares the external signal with the reference signal to determine the direction and size, thereby generating a rotation signal of the motor. It can be seen that the servo is a position servo driver, which is suitable for those drives that require constant and maintained angles. For example, the joints of robots, the control surfaces of aircraft, and the steering wheels and throttles of unmanned vehicles.

2 Use timers to realize multi-channel servo PWM control signal output
Only one servo is needed to control a robot joint, but in the control process of robots, drones and other systems, it is necessary to realize the control of multiple servos at the same time, that is, multiple PWM signals are required to complete the control task. As shown in Figure 1, a single-channel servo signal has a 20 ms period. Considering the protection time slot, the maximum value of t is 2.5 ms. Therefore, a maximum of 8 control signals can be periodically output within 20 ms (20/2.5=8). If the microprocessor timer is used to implement it, each timer can control 8 outputs, and N timers can output 8N channels.
If the servo controller designed in this paper is based on the MSC-51 microcontroller and uses a 12 MHz crystal oscillator, its time period is 1/12μs, and its machine cycle is 12×(1/12)=1μs. If the effective stroke of the servo is (°)/10μs, the angle timing accuracy of its control can reach 1μs, about 0.1°. Therefore, any type of microcontroller can meet the control accuracy requirements of the servo. The serial communication port of the microcontroller can be used to communicate with the upper PC, thereby realizing the synchronous control of multiple servos. Take AT89C52 as an example to illustrate the implementation process of this method. Suppose the P1 of the microcontroller. Ports O~P1.7 are control outputs, and the 8-way servo control pulses are shown in Figure 4.
e.JPG

In the design of this paper, P1 port is used as the servo signal output control port, corresponding to CH1~CH8 channels respectively. When the crystal oscillator is 12 MHz, the timer mode 1 working mode is adopted.
The software control of the servo controller is divided into two parts, namely the main program and the interrupt service program. The main program completes the work of timer initialization, serial port signaling analysis, and servo position refresh. Set the sequence number of each channel to i, the current timer pulse width timing to Time, and Tab[i] is the latest timing value of each channel. The timer initialization sets the timer working mode and initial value. The position of each servo is initialized to set the position of all servos at 0°, so that the servo is in a state of waiting for instructions. The serial port signaling program parses the received instructions and extracts the latest value of each channel servo in the signaling at any time. The servo position refresh program calculates the latest servo amount in real time and modifies the timing value Tab[i] of each channel for the customized interrupt service program to call. The interrupt program flow chart is shown in Figure 5.
The interrupt reset program modifies the output level of each channel corresponding to the I/O port in turn, and loads the timer count value of the next channel in turn, and the channel number count pointer accumulates. When the count pointer is 8, it indicates that the output of each channel has ended. The remaining time I/O ports are all set to 0, and the next cycle begins.

3 Design of serial communication protocol
In order to meet the real-time control of the upper computer over the servo controller, a simple and universal control protocol can be designed. From the perspective of convenient output control, two signalings, single-channel control and multi-channel control, can be set, using binary command line format and fixed frame length.
This paper adopts the design idea of ​​protocol based on short frames. The control signal corresponding to each servo action is sent frame by frame. The decomposition and step length of the action are completed by the powerful upper computer, while the lower computer is only responsible for completing the corresponding deflection angle execution. A standard serial communication short frame consists of a frame header, data and frame tail. Each part can be defined according to actual needs.
(1) Frame header, indicating the beginning of this data frame, used for data frame synchronization and control type belongs to the serial communication protocol, and is a sign of whether the lower computer receives this data frame. Generally, 0xFE can be set for a single-channel control frame and 0xFF for a multi-channel control frame.
(2) Data, indicating the output channel number of the servo to be controlled by the host computer through the serial port and the servo deflection value corresponding to the channel.
(3) Frame tail, indicating the end of this frame signal, which can generally be represented by 0xF0.
Single-channel control signaling is relatively simple, as shown in Figure 6. Its frame header is 0xFE, CHn indicates the channel number controlled by the frame, Dn indicates the servo deflection value corresponding to the controlled channel, and 0xF0 is used as the mark of the end of the frame. For example, when the frame data is "FE 01 5A F0", it means that the CH1 channel signal is in the middle position (90°=0x5A).
c.JPG

The format of multi-channel control signaling is shown in Figure 7. The frame header is 0xFF. The data length of its control command can correspond to one channel per byte. ±90° can be represented by numbers 0 to 180, and the corresponding binary numbers are 0x00 to 0XB4. For example, when the frame data is "FF 5A 5A 5A 5A 78 78 3C 3C FO", it means that the CH1~CH4 channels are all centered, CH5, CH6 are +30°; CH7, CH8 are -30°.

4 Conclusion
The design method of the multi-channel servo controller proposed in this paper is based on the microprocessor as the core, and uses the timer interrupt to realize the control signal output of multiple servos, and can realize the communication control between the upper computer and the lower computer. It can be applied to robots, drones and other occasions that need to control multiple servos, as well as other systems that need to generate multiple PWM.

Reference address:Design of multi-channel servo controller

Previous article:Motor Control Based on Blackfin BF50x Processor
Next article:Robot arm control system based on ARM core processor

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号