Skip to content
Tactiverge

Electrical engineering · also Computer engineering, Robotics

Timers and pulse-width modulation

A hardware timer counts clock pulses, so it can measure time intervals or trigger events at precise moments without the processor watching. Pulse-width modulation, or PWM, uses a timer to switch an output on and off rapidly. The duty cycle is the fraction of each period that the signal is on. Because a motor or LED responds to the average of a fast enough signal, changing the duty cycle controls speed or brightness. Hobby servos use a different convention: the width of a repeated pulse encodes the angle they should move to.

Why it mattersA small robot's wheel speeds are set by the PWM duty cycle sent to its motor driver.

Learn it

  1. 1Timers and pulse-width modulationEmbedded Systems · Microcontrollers