Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Robotics servo control uses pulse width modulation, or PWM, to send position commands to a motor controller inside a servo. This cheat sheet helps students connect signal timing, angle control, wiring, and starter code in one reference. It is useful when building robot arms, steering mechanisms, grippers, pan-tilt cameras, and other moving parts.

Students need it because small timing or wiring mistakes can cause jitter, weak motion, or damaged components.

The most important idea is that a servo reads the width of a repeating control pulse, not the average voltage like a simple DC motor speed controller. A typical hobby servo expects a pulse about every 20 ms, with about 1.0 ms for one end, 1.5 ms for center, and 2.0 ms for the other end. Duty cycle is calculated with duty cycle = pulse width / period x 100%.

Calibration adjusts the exact pulse limits so the servo moves safely without hitting mechanical stops.

Key Facts

  • PWM stands for pulse width modulation, and it controls a signal by changing how long the signal stays high during each repeating period.
  • Period and frequency are related by frequency = 1 / period, so a 20 ms servo period equals 50 Hz.
  • Duty cycle is calculated with duty cycle = high time / period x 100%, where high time is the pulse width.
  • A common hobby servo range is 1.0 ms to 2.0 ms, with 1.5 ms usually near the center position.
  • For a 20 ms period, a 1.5 ms pulse has duty cycle = 1.5 / 20 x 100% = 7.5%.
  • A simple angle map is pulse width = min pulse + angle / 180 x (max pulse - min pulse) for a 0 to 180 degree servo.
  • Servo power should usually come from a separate 5 V to 6 V supply, but the servo ground and controller ground must be connected together.
  • Calibration means testing and setting safe min, center, and max pulse values before using the servo in a robot mechanism.

Vocabulary

PWM
Pulse width modulation is a control method that sends repeated on-off pulses and changes the high-time of each pulse.
Pulse width
Pulse width is the amount of time a PWM signal stays high during one cycle, often measured in milliseconds or microseconds.
Duty cycle
Duty cycle is the percent of one PWM period during which the signal is high.
Frequency
Frequency is the number of repeating PWM cycles per second, measured in hertz.
Servo calibration
Servo calibration is the process of finding safe pulse values that match the servo's real center and motion limits.
Common ground
Common ground means connecting the ground of the controller and the ground of the servo power supply so they share the same signal reference.

Common Mistakes to Avoid

  • Using duty cycle alone to describe servo position is wrong because most hobby servos respond to pulse width, usually in microseconds or milliseconds.
  • Forgetting to connect common ground is wrong because the servo signal has no reliable voltage reference and the servo may jitter or ignore commands.
  • Powering several servos directly from a small microcontroller pin is wrong because signal pins cannot supply the high current a moving servo needs.
  • Commanding 0 degrees or 180 degrees without calibration is risky because the servo may hit a mechanical stop and draw too much current.
  • Confusing frequency with pulse width is wrong because frequency sets how often pulses repeat, while pulse width sets the commanded servo position.

Practice Questions

  1. 1 A servo signal has a 20 ms period and a 1.0 ms high pulse. What is the duty cycle?
  2. 2 A controller sends a 50 Hz PWM signal. What is the period in milliseconds?
  3. 3 Using pulse width = 1000 microseconds + angle / 180 x 1000 microseconds, what pulse width commands 90 degrees?
  4. 4 Why should a robot use a separate servo power supply with a shared ground instead of powering a servo only from a microcontroller signal pin?