Detailed explanation of AT89C2051 multi-channel servo control circuit

Publisher:钱币之歌Latest update time:2016-10-09 Source: eechinaKeywords:AT89C2051 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  The servo is a position servo driver. It receives a certain control signal and outputs a certain angle. It is suitable for control systems that require the angle to change continuously and be maintained. In micro-electromechanical systems and aircraft models, it is a basic output actuator. Taking the FUTABA-S3003 servo as an example, Figure 1 is the internal circuit of the FUFABA-S3003 servo .
  The working principle of the servo is: The PWM signal enters the signal demodulation circuit BA66881 from the receiving channel. It is demodulated at the 12th foot to obtain a DC bias voltage . The DC bias voltage is compared with the voltage of the potentiometer, and the voltage difference is output by the 3rd foot of BA6688. The output is sent to the motor driver integrated circuit BA6686 to drive the motor forward and reverse. When the motor speed is constant, the potentiometer R is driven by the cascade reduction gear. Rotate until the voltage difference is 0 and the motor stops. The control signal of the servo is a PWM signal, which changes the position of the servo by changing the duty cycle.
  


  Control method of servo
  The power line and ground line are used to provide energy for the DC motor and control circuit inside the servo. The voltage is usually between 4 and 6V, and 5V is generally used. Note that the power supply to the servo should be able to provide sufficient power. The input of the control line is a periodic square wave pulse signal with adjustable width. The period of the square wave pulse signal is 20 ms (that is, the frequency is 50 Hz). When the pulse width of the square wave changes, the angle of the servo shaft changes, and the angle change is proportional to the change in pulse width. The relationship between the output shaft angle of a certain type of servo and the pulse width of the input signal can be expressed by 3.
  


  Hardware circuit design of servo controller
  From the above control method of servo angle, it can be seen that the control signal of the servo is actually a square wave signal (PWM) with adjustable width. The square wave signal can be generated by FPGA , analog circuit or single-chip microcomputer . The cost of using FPGA is high, and the circuit is more complicated when implemented by analog circuit, which is not suitable for multi-channel output. Single-chip microcomputer is generally used as the controller of the servo. At present, there are many schemes using single-chip microcomputers as servo controllers. PWM can be realized by using the timer interrupt of the single-chip microcomputer. This scheme divides the 20ms periodic signal into two timing interrupts: one timing to realize high-level timing Th; one timing to realize low-level timing T1. The time values ​​of Th and T1 change with the change of pulse width, but Th+T1=20ms. The advantage of this method is that the PWM signal is completely realized by the interrupt of the internal timer of the single-chip microcomputer, and no peripheral hardware needs to be added. The disadvantage is that the PWM signal in one cycle must be completed by two interrupts, and the calculation of the timing values ​​of the two interrupts is more troublesome; in order to meet the 20ms cycle, the frequency of the single-chip microcomputer crystal oscillator must be reduced; multiple outputs cannot be realized. The implementation scheme of single-chip microcomputer + 8253 counter can also be used. This scheme generates counting pulses from the single-chip microcomputer (or the external circuit generates counting pulses) and provides them to 8253 for counting, and the single-chip microcomputer gives the counting comparison value of 8253 to change the output pulse width. The advantage of this scheme is that multiple outputs can be realized and the software design is relatively simple; the disadvantage is that an 8253 counter needs to be added, which increases the hardware cost. Based on the above two MCU servo control schemes, this paper proposes a new design scheme, as shown in Figure 4.
  


  The servo controller of this scheme is based on the AT89C2051 ($0.5940) MCU as the core, and the oscillator composed of 555 is used as the timing reference. The MCU generates PWM signals by counting the pulse signals generated by the 555 oscillator. The MCU in this controller can generate 8 channels of PWM signals, which are output by the P1.0~Pl.7 (12~19 pins) ports of AT89C2051. The output 8-channel PWM signals are transmitted to the next level circuit through optocoupler isolation. Because the signal is inverted during the transmission process through the optocoupler, the signal from the optocoupler must be inverted again through the inverter. After the square wave signal is transmitted through the optocoupler, the leading and trailing edges will be distorted, so the inverter uses the CD40106 ($0.1125) Schmidt inverter to shape the signal transmitted by the optocoupler to generate a standard PWM square wave signal. During the experiment, the author found that the servo absorbs a large current from the power supply during operation . If the servo and the single-chip controller share a power supply, the servo will cause greater interference to the single-chip. Therefore, the servo and the single-chip controller are powered by two power supplies, which are not grounded and isolated by optocouplers. In addition, the power supply for the servo is preferably a switching power supply with a large output power . The servo controller occupies an SCI serial port of the single-chip microcomputer. The serial port is used to receive control commands sent by the host computer to adjust the pulse width of the output signal of each channel. MAX232 ($2.0686) is a level converter that converts the RS232 ($780.5000) level of the host computer into a TTL level.   Principle of realizing multi-channel PWM signals   In analog circuits, PWM pulse signals can be obtained by comparing the DC level with the sawtooth wave signal. In the single-chip microcomputer, the sawtooth wave can be realized by adding 1 to the integer variable, as shown in Figure 5. Assume that an integer variable SawVal is set in the single-chip microcomputer program, and its value range is O~N. The external counting clock signal generated by the 555 oscillation circuit is input to the INTO pin of AT89C2051. Whenever the external counting clock pulse falls, the microcontroller generates an external interrupt and executes the interrupt service program of the external interrupt INT0. Every time an external interrupt is generated, an addition operation is performed on SawVal. If SawVal has reached the maximum value N, SawVal is cleared to 0. The change pattern of the SawVal value is equivalent to a sawtooth wave, as shown in Figure 5. If another integer variable DutyVal is set in the microcontroller program, its value range is O~N. Whenever SawVal is cleared to 0, DulyVal reads the pulse width coefficient value from the control command sent by the host computer, for example, H (0≤H≤N). If DutyVal≥SawVal, the corresponding port outputs a high level; if DutyVal
  


Keywords:AT89C2051 Reference address:Detailed explanation of AT89C2051 multi-channel servo control circuit

Previous article:Design of high-gain data acquisition system based on USB interface
Next article:Design of a Home Security System Based on AT89S52 and CAN Bus

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号