Tricky Circuit

Servo: a tiny timing command

Steer a shaft with time

A servo aims a motor shaft at a commanded position. Pulse Width is how long its control signal stays high; ms means millisecond, 1/1000 second. Period T is one complete cycle, fixed here at 20 ms. The control lead carries instructions, not motor power.

Open interactive experiment

EXPERIMENT BENCH

Change the circuit settings, predict the readings, then check a challenge. These are learning models, with the assumptions explained in each lesson.

Sign in to save progress. Guest progress stays on this device.

Open laboratory in a full window

Why it works

This example maps 1–2 ms to 0–180°. Real servo ranges, direction and calibration vary. The display previews a commanded angle; external motor supply, current, load and movement are not simulated.

w is the high-pulse width and θ the example angle in degrees (°). A quarter millisecond changes this example by 45°. GND means Ground, the shared voltage reference: controller and motor supply need a common reference so the servo can interpret the signal.

Difficulty
  1. Build · Build it

    Power on and set w = 1 ms. Command the example angle θ = 0°.

    Need a hint?

    w = 1 ms; T = 20 ms → θ = 0°

  2. Explore · Change the command

    Set w = 1.5 ms. Command θ = 90° while the period stays 20 ms.

    Need a hint?

    w = 1.5 ms; T = 20 ms → θ = 90°

  3. Solve it · Solve the challenge

    Set w = 2 ms. Command θ = 180° using the same 20 ms period.

    Need a hint?

    w = 2 ms; T = 20 ms → θ = 180°

Extra reading and circuit recipes

Steer a shaft with time

Imagine aiming a tiny camera. A brief timing instruction chooses where to point; the motor supply provides the energy to move it.

T = 20 ms; θ = (w / 1 ms − 1) × 180°

Timing and energy have different jobs. The control lead tells the internal controller the target; the separate supply runs the motor. A common ground lets both circuits agree what the signal voltage means.

A useful pattern

At 1 ms the high pulse occupies only 5% of the 20 ms cycle; at 2 ms it occupies 10%. A short message can command a large position change.

Beyond the model

There is no universal pulse-to-angle scale. Two real servos may reach different angles for the same pulse, so the 180° range here is deliberately an example.

A useful trap to avoid

A longer control pulse is not a measurement of motor power or speed. Duty is the high-time fraction of a cycle; position depends on pulse width rather than that fraction alone.

w rises from 1.25 ms to 1.75 ms in this example. The commanded angle changes by…

  1. 45°
  2. 90°
  3. 180°
Read more

The extra 0.5 ms is half the example 1 ms span, so it adds half of 180°.

Build it

Set w = 1 ms and power on. The preview points at the example zero.

w = 1 ms; T = 20 ms; θ = 0°

Change the command

Set w = 1.5 ms. The high pulse grows, the period is unchanged, and the command becomes 90°.

w = 1.5 ms; T = 20 ms; θ = 90°

Try another path

Visit 1, 1.25, 1.5, 1.75 and 2 ms. Predict each 45° jump before moving the slider, then compare the pulse width with the much longer cycle.

learn.adafruit.com