PWM Servo Calculator
Calculate PWM pulse width, duty cycle, and servo angle.
Period = 20000 µs (1/50 Hz)
How the PWM Servo Calculator works
The PWM servo calculator converts between servo angle (0°–180°), pulse width (1–2 ms), and duty cycle for the standard 50 Hz servo control frequency. It also computes the timer compare register value (CCR) for STM32 timers and the analogWrite or microsecond values for Arduino and ESP32 — eliminating manual PWM calculations during RC robot, gimbal, and CNC project development.
Standard servo PWM protocol
RC servos are controlled by a 50 Hz PWM signal (20 ms period). The pulse width encodes position: 1 ms (1,000 µs) corresponds to 0° (full left), 1.5 ms (1,500 µs) to 90° (centre), and 2 ms (2,000 µs) to 180° (full right). Some servos accept a wider range of 0.5–2.5 ms for extended travel. The calculator allows customisation of the minimum and maximum pulse widths to match the specific servo's datasheet range.
Duty cycle calculation
At 50 Hz, the period is 20 ms. A 1 ms pulse gives a duty cycle of 1/20 = 5%. A 2 ms pulse gives 10% duty cycle. The Arduino Servo library handles these conversions internally via writeMicroseconds() — but if you are using raw PWM (analogWrite on a 490 Hz or 980 Hz channel), the duty cycle values differ significantly and the calculator provides the corrected values for both 8-bit (0–255) and 16-bit (0–65535) timer resolutions.
STM32 timer CCR values
On STM32 microcontrollers, servo PWM is generated using a timer channel in PWM mode. The ARR (auto-reload register) sets the period; CCR (capture-compare register) sets the pulse width. For a 72 MHz clock with prescaler 71 (1 MHz timer clock) and ARR = 19999 (50 Hz), a 1 ms pulse requires CCR = 999 and a 2 ms pulse CCR = 1999. The calculator outputs CCR values for any timer clock frequency and target angle.
ESC calibration for brushless motors
Electronic speed controllers (ESCs) for brushless motors use the same 50 Hz PWM protocol as servos but interpret the pulse range differently — 1 ms is minimum throttle (stop), 2 ms is maximum throttle (full speed). ESC calibration requires sending a 2 ms pulse at power-on (arming), then a 1 ms pulse to complete calibration. The calculator's ESC mode provides the exact microsecond values and Arduino code snippet for the full calibration sequence.
Frequently asked questions
- What PWM frequency do servos use?
- Standard analog RC servos use a 50 Hz PWM signal with a 20 ms period. The pulse width within each period — from 500 µs to 2500 µs — controls the servo shaft angle from 0 to 180 degrees. Some digital servos support higher update frequencies up to 333 Hz for faster response and more precise position holding, but require a compatible controller.
- What is the standard servo pulse range?
- Most hobby and RC servos use 1000 µs to 2000 µs (1 ms to 2 ms) as their safe working pulse range, with 1500 µs representing the center position at 90 degrees. Many servos physically accept the wider range of 500 µs to 2500 µs for an extended angle range, but exceeding the servo's mechanical limits can damage the gears. Always check your specific servo's datasheet.
- How do I calculate the 16-bit timer compare value?
- For a 16-bit hardware timer configured for 50 Hz output, the compare register value is: compare value = (pulse width in µs / 20000 µs) × 65535. For example, for a center position pulse of 1500 µs at 50 Hz: (1500 / 20000) × 65535 = 4915. Load this value into the timer's OCR (Output Compare Register) to produce the correct pulse width.
Related tools
- Resistor Color Code Calculator
Decode resistor color bands. Supports 4-band and 5-band.
- Ohm's Law Calculator
Calculate voltage, current, resistance, or power using Ohm's Law.
- Voltage Divider Calculator
Calculate output voltage for a resistor voltage divider.
- 555 Timer Calculator
Calculate frequency, duty cycle, and timing for 555 timer circuits.
- CRC Calculator Online — CRC-8, CRC-16, CRC-32 & Modbus
Calculate CRC checksums online — CRC-8, CRC-16/MODBUS, CRC-16/CCITT, CRC-32, CRC-32C and more. Shows HEX, DEC and BIN. Supports text and hex input. Browser-only, no upload.