Published 2026-03-03
Do you often encounter this situation when playing withservos: You bought the same model, but when it turns, it shakes like a sieve, or the angle is wrong? After struggling for a long time, I discovered that the problem lies in the mysterious pulse width modulation (PWM) signal. Don’t worry, today we will understand it thoroughly and make your product move steadily and accurately.
Simply put, PWM is like a lamp that can be dimmed. For theservo, it controls rotation through high and low level pulses. You can think of it like you are commanding a person to run: high level represents "run", low level represents "stop", and the duration of "running" determines the position of theservo.
This "running" time is called pulse width in technical terms. A standard servo usually receives an instruction every 20 milliseconds, and the duration of the high level varies between 0.5 milliseconds and 2.5 milliseconds. The length of this time directly corresponds to the rotation angle of the servo from 0 degrees to 180 degrees.
So when you find that the servo is not obeying the command, it is probably because the "running time" issued to it is not calculated accurately.
Many friends directly use the PWM output of the development board, but find that there is always a difference when the servo is turned to 90 degrees. The reason behind this is actually quite unfair: your code may directly write "1500 microseconds" to represent 90 degrees, but the control chip inside each servo is slightly different.
It's like giving two people the instruction to "walk fast". One person interprets it as jogging, and the other person interprets it as walking. The servo itself has no feedback mechanism to tell the controller "I'm in position", it just executes blindly.
The first step to solve this problem is to confirm whether your signal source is stable. Use an oscilloscope to see if the actual output high-level time is exactly the same as what is written in the code. Often just a few tens of microseconds can make a huge difference in the performance of the servo.
Don’t just start writing code, do a small experiment first. Connect your servo, start with the minimum pulse width (such as 500 microseconds), and gradually increase it while observing the rotation limit position of the servo.
You will find that within a certain range, the servo does not move at all. This is its mechanical limit. Continue increasing until you start to turn, note this starting value. Then continue to increase until the servo no longer rotates, and record the end value. This range is the real working range of your steering gear.
The nominal value of many servos is 0.5ms to 2.5ms corresponding to 0 to 180 degrees, but the actual measurement may be only 0.6ms to 2.4ms. Use actual measured data to program, so that your servo can hit where you want it.
In addition to pulse width, the frequency of PWM is also critical. For ordinary hobby servos, 50Hz (i.e. 20 millisecond cycle) is standard. But some friends use higher frequencies for convenience.
Once the frequency becomes higher, the period shortens. The command was originally sent once every 20 milliseconds, but now it is sent once every 10 milliseconds. The circuit inside the servo may not have had time to respond to the last command, and the next command comes again. The result is that the servo is always trying to catch up, which manifests itself as heat and jitter.
️ Remember this principle: Unless your servo clearly supports wide-band control, just stick to 50Hz. Industrial-grade digital servos may have higher refresh rate requirements, but that depends on the specific data sheet and cannot be taken for granted.
After determining the pulse range and frequency, the next step is programming. Don't write the linear relationship between angle and pulse width and apply it directly. Because some servos are particularly sensitive near the neutral point, but slow to respond on both sides.
You can introduce a mapping function to make a table from the measured angle points and pulse width. For example, measured 0 degrees corresponds to 600 microseconds, 45 degrees corresponds to 1200 microseconds, and 90 degrees corresponds to 1500 microseconds. Then in the code, based on the target angle, look up the table and interpolate to calculate the real pulse width.
In this way, when you want the robotic arm to draw a circle, the tiny rotations of each joint will be very smooth, and there will be no feeling of rushing forward one by one. Although the code has a few more lines, the texture of the product is completely different.
If you have done all the above correctly and the servo is still shaking, then you need to check the power supply. The current when the servo is started is very large. If your control board and servo share the same power supply, voltage fluctuations will interfere with the PWM generation of the microcontroller.
1. Provide a separate power supply to the servo, and connect the control signal ground wire and the power supply ground wire together.
2. Connect a large capacitor (above 470uF) in parallel to both ends of the servo's power supply to absorb the startup surge.
3. Check the length of the PWM control wire. If it exceeds 30 cm, it is recommended to use a shielded wire or add a magnetic ring to prevent interference.
In addition, the refresh of the control signal must be stable, and do not use delay to generate PWM in the loop, which can easily be interrupted by other interrupts, causing the pulse width to be long and short. Using hardware PWM is the most worry-free option.
After seeing this, you should have a good idea of how to use the servo. If you want to make cooler products, the key is to adjust every detail of the PWM signal to be docile. What is the most troublesome problem you have encountered when debugging the servo? Welcome to leave a message in the comment area, and we will discuss and solve it together. If you find it useful, don't forget to like and share it so that more friends can say goodbye to the troubles of steering gears.
Update Time:2026-03-03
Contact Kpower's product specialist to recommend suitable motor or gearbox for your product.