Troubleshooting
Why a hobby servo sweeps 0 to 180 instead of holding position
Short answer
A hobby servo holds whichever angle the pulse width at its connector commands, and only while that same width keeps arriving at the frame rate. A shaft that sweeps end to end is never given a steady hold command: the output pauses, the width changes too soon, or the timing is wrong. Measure high time and rising-edge interval at the connector, run one width continuously, then calibrate width to angle from settled measurements.

On this page
A three-wire hobby servo holds whichever angle its command pulse describes, and it holds it only while that same width keeps arriving at the frame rate. If the shaft sweeps from one end of travel to the other, often in one direction only, the servo is not refusing to hold position: it is never being given a steady hold command. In almost every case the fault is in the generating program. Each width is sent once, or for a short burst, and then the output pauses; or the width changes before the shaft settles; or the software timing does not match the written numbers. An oscilloscope or logic analyzer at the servo connector settles it in minutes. This article gives the interface numbers, the causes ordered by how cheap they are to check, a worked timing example, and the decision for each case.
The interface: the width carries the angle, the repetition carries the hold #
Hobby servos run on the de facto radio-control pulse interface that every maker of these servos builds to: one active-high pulse on the control wire per 20 ms frame, a 50 Hz train, with the high time as the command. Across the conventional span, a width of 1.0 to 2.0 ms moves the output from one end of travel to the other, and 1.5 ms sits at mid travel on most analog types. Treat those figures as the interface convention, not as a calibration for your part: the usable span and the mechanical travel belong to the exact servo, so take its endpoints from that servo's datasheet before you command the ends.
The hold is not a state the servo stores; it is the repetition. Internal feedback compares the commanded width with the shaft's actual position, and the motor is driven only while the two disagree. When pulses stop arriving, the servo's electronics decide what happens next, and most types stop driving, leaving the shaft slack or drifting under load; nothing in the program can hold an angle across that gap. The command is the high time alone. Divide the width by the frame time and the endpoint and center widths come out at 5%, 7.5% and 10% duty: properties of the waveform, not an angle scale. The names PWM and PPM both blur exactly the quantity that matters.
Why the shaft sweeps instead of holding #
The reported symptom, the horn traveling the full range and not returning whatever width the code intends, points at the command side. Work through the causes in this order, cheapest to check first:
-
The output pauses between widths. A routine that sends one pulse, or one short burst, and then idles for seconds stretches the interval between rising edges far past one frame. Confirming check: the interval measured at the connector is seconds long, with dead time visible on the scope. Decision: run the train continuously; a dwell means repeating one width for many frames, not stopping the output.
-
The width changes before the shaft settles. The motor needs time to reach each new target, and code that advances every frame or two walks the target away faster than the horn can follow. Confirming check: the horn is still moving at the moment the width changes. Decision: keep the train running at the new width and change nothing until the shaft stops and the supply current falls back to its holding level.
-
The written timing is not the delivered timing. Millisecond delay routines rely on the CPU clock constant matching the real crystal, and interrupts stretch them further. Confirming check: the measured high time at the pin differs from the value in the source, which convicts the timing, not the servo. Decision: correct the clock configuration or generate the frame from timer hardware, then retest.
-
Test widths outside the servo's travel endpoints. Widths beyond the span drive some servos past their ends by design and slam others against the mechanical stop, where the motor stalls and heats. Confirming check: high time outside the span together with a current jump at the end of travel. Decision: start every test at the mid-travel width and step outward, backing off as soon as the current rises.
-
Everything checks out but the shaft still will not hold. Then the generator is not the fault: a speed-geared output has no angle to hold at any width, and a position type that hunts around a steady width has an internal-loop or mechanical problem. Both cases are decided in the last section below.
Measure at the connector, not at the code #
Ground offsets, wiring faults, supply dips and software timing errors all make the signal the servo receives different from the one the code describes, so measure where the servo receives it, powered and connected. One safety note for the first powered test: disconnect the load linkage, keep hands and cables clear of the horn, and remove power promptly if the servo drives hard against a stop and buzzes there.
| Quantity | Target | Where to read it |
|---|---|---|
| Rising-edge interval | One pulse per frame, about 20 ms on the conventional interface | Oscilloscope or logic analyzer on the control wire |
| High-pulse duration | Start at the mid-travel width of 1.5 ms and keep tests inside the 1.0–2.0 ms span unless the datasheet allows more | Pulse-width measurement referenced to servo ground |
| Signal amplitude | Inside the servo's documented logic-input range | High and low levels of the waveform |
| Supply voltage under load | Inside the servo's documented operating range | Meter across power and ground at the connector |
| Supply current and case temperature | Against the datasheet limits and the unloaded value | Inline current measurement; check temperature only with power off |
Worked example: reading a broken loop from its timing #
Take a loop written to send three widths: a 0.6 ms high time, a 19.4 ms low time, then a 2000 ms pause before the next width. These are example inputs for the method, not a rating of any servo.
Rising-edge interval = high time + low time + pause = 0.6 ms + 19.4 ms + 2000 ms = 2020 ms.
Frames against the conventional interval: 2020 ms ÷ 20 ms = 101, so the servo receives one valid frame for every 101 it needs. The train is effectively absent, and the sweep and the one-way travel follow from those gaps, not from the width values; on the instrument the fix shows as the interval collapsing to the frame time and staying there.
Even a corrected loop that repeats each width for 10000 frames before switching is a sequence, not a hold: 10000 × 20 ms = 200 s at one width, then the target jumps to the next. That is fine for a bench sweep and wrong for a machine that must sit at one angle.
Once the train is steady, calibrate width against settled angle: record two points away from the stops, let the shaft settle at each, and approach each point from both directions to expose backlash. Example measurements: 1.5 ms gives a settled 92°, and 2.0 ms gives a settled 168°. Interpolating for a 1.75 ms command, with every width term in milliseconds and every angle term in degrees:
angle = 92 + (1.75 ms - 1.5 ms) × (168° - 92°) ÷ (2.0 ms - 1.5 ms) = 92 + 0.25 × 76 ÷ 0.5 = 92 + 19 ÷ 0.5 = 92 + 38 = 130°
That 130° is a calculated example for those two measurements, not a property of the servo. If successive pairs disagree by more than a few degrees, the travel is nonlinear over the span and you should interpolate segment by segment.
When the train is correct and the shaft still will not hold #
Three cases remain, each with its own decision:
- The output turns through every width and never stops: the servo is geared as a speed type with no position feedback, so no width will ever fix it. The article on continuous rotation servos and XY gantry positioning explains what that means for holding an angle, and the decision is to fit a position type.
- The shaft hunts around one steady, verified width: the command is right and the fight is inside the servo or in the mechanics. The article on why a servo oscillates between two positions covers that fault, and the decision is to treat the loop and the mechanics, not the code.
- A correct command drives the horn hard into a stop and the case heats: the motor is stalling. The article on why a hobby servo robot arm smokes and how to fix it walks that failure path, and the decision is to back the test width toward mid travel and free the mechanism before the next power-up.
The overall decision is short. Steady width at the frame rate, measured at the connector, means the servo holds that angle. Gaps, early width changes or wrong timing on the instrument mean fix the generator and retest. A correct train with a speed-geared output means change the servo. A correct train with hunting means loop and mechanics, and the width numbers above no longer apply.
Questions asked
What supply does a hobby servo need, and can it share the controller board's supply?
Take the supply voltage and current from the servo's own datasheet rather than from the controller board: a hobby servo's motor current under load commonly exceeds what an on-board regulator can deliver, and a sagging supply appears as weak holding, chatter or resets. Power the servo from its own regulated source, join the grounds at one point, and measure the voltage across the servo's power and ground while the motor runs.
Why does the listing say 180 degrees when the usable pulse span gives less?
The degree figure on the housing or the listing describes the output's mechanical travel, while the conventional 1.0–2.0 ms span is the interface convention, not a calibration for that exact part. Endpoints differ between families and even between samples. Command the center width, record the settled angle, step outward through the span, and build the width-to-angle table for your own servo from settled measurements.
Can the pulses keep coming from software delay loops instead of a timer?
For a bench test, yes, provided the clock configuration matches the real crystal and interrupts stay short, because both stretch the delays. For anything that runs unattended, generate the frame from timer hardware so other code cannot distort it, and re-verify the high time and the interval at the connector after every firmware change, because a timing fault introduced by an update looks identical to the original one.
The servo holds for a while, then drifts or starts buzzing under load — is that the same fault?
No. The sweep fault is a command fault and shows up on the instrument immediately. Drift or buzzing with a verified steady width means the servo is fighting an external force, a mechanical bind, or a supply that sags when the motor draws current. Measure the voltage across the servo's power and ground while it is loaded before touching the control code.


