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
Previous article:MCU controlled switching power supply
Next article:Data processing of servo program
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Common Problems of C2000 in Real-time Control Systems
- LLC parameter design, cannot achieve ZVS
- Soldering methods and precautions for chip crystal oscillators
- Guangzhou Power Chip Sales and FAE Recruitment
- I don't understand why the feedback network of the op amp is connected to the non-inverting terminal. What is the purpose of this?
- Matlab Neural Network Principles and Examples
- Setting the MSP430 main system clock for low power consumption
- TI XDC Tool Overview
- Robotic arm end motion stability evaluation (with Linux real-time waveform client source code)
- SPI bus easy to understand explanation