Detailed explanation of the servo speed control principle

Publisher:konglingdeyuanLatest update time:2015-05-21 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
      The control of the servo speed is actually to make the servo reach the target position from the initial position not directly, but to divide it into many subtle small processes to gradually reach it. For example, let the initial position of the servo be 0 degrees and let it run to 90 degrees. If the data of 90 degrees is directly input, the servo will almost reach the 90-degree position at once because of its relatively fast response speed. If we create a lot of buffers for it in the process of reaching 90 degrees, that is, let it gradually transition from 0 degrees to 1 degree to 2 degrees, 3 degrees, etc. to 90 degrees, then the effect will be that the servo reaches the target position at a relatively slow speed, and our speed control purpose will be achieved. By controlling the time of each spacing switch, we can get the specific rotation speed we want. Because there are many divided processes, the rotation of the servo looks like a smooth rotation at a speed.

     Although it is theoretically true, it still needs some transformations to be expressed through a program. Here, we assume that the value of the initial position of the servo is x, and the servo needs to run to the target position y. We set a variable a to be 0 at the initial time, and x+(yx)*a/100 is the servo position information we want to input. At the beginning, a is 0, so the input data is x. The servo is still in the initial position. At this time, we add a+1 every fixed time. As a changes, the servo position gradually moves from the initial position to the target position. When a=100, it completely reaches the target position and stops the self-addition of a. However, since a large number of x are introduced in the formula of x+(yx)*a/100, you will find that writing a program is still not so easy to control. My final speed control program transforms this formula to y-(yx)*(100-a)/100. This formula also makes the input information gradually reach the target position as a self-addition. Both formulas can be implemented, but compared with the second program, it will be relatively simple.

     When writing a program, sometimes we not only have to consider the correctness of the program statement, but also the processing power of the microcontroller. For example, there is no error in the statement a=(0x01<<16)>>16. Theoretically, a should still be equal to 1 in the end. But when it is downloaded to the 51 microcontroller, it is not the same. Because in the process of shifting 16 bits to the right, 51 does not have 16 high bits to store data, and the required information will be lost. The final result will be a=0. I also found this problem when writing the program. I just want to explain that the processing power of the microcontroller should be considered when it comes to calculations. x+(yx)*a/100 is 100 differentials for the conversion process from the initial position to the target position of the servo. I originally wanted to perform 1000 differentials, but I found that 100 differentials were completely sufficient, and when it was 100, the unreasonable design of the program calculation process would exceed the calculation power and cause errors.

     A friend asked me what is the principle of my servo speed control program, so I wrote a short article to introduce it, so that everyone can learn from each other. Hehe
The following is the MCU program of the servo:
http://www.51hei.com/mcu/2542.html
http://www.51hei.com/mcu/2543.html
http://www.51hei.com/mcu/2544.html http://www.51hei.com/mcu/2545.html
http://www.51hei.com/mcu/2546.html
http://www.51hei.com/mcu/2547.html http://www.51hei.com/mcu/2554.html

Reference address:Detailed explanation of the servo speed control principle

Previous article:MCU controlled switching power supply
Next article:Data processing of servo program

Latest Microcontroller 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号