Finding safe servo limits with IR control¶
Servo Diagnostics provides a controlled way to find the usable pulse-width limits of a servo after it has been installed in Elena. An IR remote advances the servo in small steps while USB serial reports the commanded pulse width.
Title and date¶
Finding safe servo limits with IR control — September 1, 2026
Development stage¶
Working Raspberry Pi Pico 2 W diagnostic firmware for manual endpoint calibration and automatic sweep testing.
Goal¶
Measure conservative high- and low-end pulse widths for each installed servo. The measured values can be copied into Elena's standard firmware as clamps so later position commands cannot exceed the mechanism's safe travel.
Components used¶
- Raspberry Pi Pico 2 W
- PWM hobby servo
- Suitable external servo power supply
- Demodulating IR receiver connected to GPIO 15
- IR remote learned with the IR Receiver project
- USB serial terminal
What changed¶
The Servo Diagnostics firmware combines the learned IR decoder with a 50 Hz servo output on GPIO 8. Manual mode starts at a 1500-microsecond center pulse. Volume Up and Volume Down adjust the commanded pulse in 50-microsecond steps, making it possible to approach each mechanical endpoint slowly and record the last freely moving value.
Wiring or schematic¶
| Device signal | Raspberry Pi Pico 2 W connection |
|---|---|
| Servo control | GPIO 8 |
| IR receiver data | GPIO 15 |
| IR receiver power | 3.3 V |
| IR receiver ground | GND |
| Servo ground | Common ground with Pico |
| Servo power | External supply appropriate for the servo |
The servo supply and Pico must share ground so the PWM signal has a common reference. A high-current servo must not be powered from a Pico GPIO pin.
Software changes¶
The complete firmware and build instructions are available here:
David Harmor's Servo Diagnostics source code
The manual calibration procedure is:
- With power disconnected, fit the servo horn so the mechanism is approximately 90 degrees at the servo's 1500-microsecond center position.
- Power the system and press Button 1 to enter manual calibration mode.
- Press Volume Up one step at a time. Each press adds 50 microseconds.
- Stop as the high-end limit is approached and record the last pulse width that moved freely without binding, stalling, or straining.
- Use Volume Down to back away, then continue in 50-microsecond steps toward the low end.
- Record the last freely moving low-end value and press Button 1 to stop manual mode.
- Choose final minimum and maximum values slightly inside the observed limits and use them to clamp every servo command in the standard firmware.
The diagnostic search range is 550–2250 microseconds. This range is only a firmware boundary and is not guaranteed to be mechanically safe for every servo or linkage. PWM is disabled 300 milliseconds after each manual command to reduce the risk of holding the servo against a stop.
Test results¶
| Test | Expected result | Status |
|---|---|---|
| IR Button 1 | Toggle manual calibration mode | Implemented |
| IR Volume Up | Increase pulse by 50 microseconds | Implemented |
| IR Volume Down | Decrease pulse by 50 microseconds | Implemented |
| USB serial output | Display each commanded pulse width | Implemented |
| Manual-command timeout | Disable PWM after 300 milliseconds | Implemented |
| Automatic sweep | Move in 50-microsecond steps every 100 milliseconds | Implemented; use only after safe limits are known |
Problems encountered¶
Nominal servo angle specifications do not account for horn alignment, linkage geometry, manufacturing variation, or obstructions in the installed mechanism. A generic 0–180-degree mapping can therefore command a pulse beyond the actual usable travel and cause a stall or mechanical damage.
Solution¶
Center the servo, align the horn near 90 degrees, and use the learned remote to approach each endpoint incrementally. Record conservative pulse limits for that specific installed servo, then add those limits to the production firmware and clamp all requested pulse widths before sending them to the PWM driver.
Stop immediately if the servo chatters, stalls, strains, draws excessive current, or reaches an obstruction. Never reposition the horn while the servo is powered.
Photographs/video¶
Photographs of the servo installation and a calibration demonstration will be added when the final linkage is mounted on Elena.
Next steps¶
- Calibrate each servo in its final installed mechanism.
- Record the measured limits by servo location and serial number.
- Add a safety margin inside each measured endpoint.
- Store the limits in Elena's standard firmware and clamp every command.
- Verify full movement under normal mechanical load without binding or excessive current.