PCA9685 board/Why this board/01. Sixteen pulses on two wires
Why this board · 01 of 13

Sixteen pulses on two wires

A hobby servo wants one short pulse every 20 ms, forever, on its own wire. Sixteen of them would tie up sixteen pins and sixteen timers. The PCA9685 makes all sixteen pulse trains by itself, and the microcontroller only speaks to it, over two I²C wires, when a position has to change.

What a servo asks for

A hobby servo has three wires: ground, power, and a signal. On the signal wire it expects a pulse about every 20 ms, 50 times a second. The width of that pulse, somewhere near 1 to 2 ms, is the position. Stop the pulses and the servo stops being told where to be.

A microcontroller can make that pulse on one pin with a hardware timer. Sixteen servos need sixteen pins and sixteen timer channels, all running at once, and a sketch that never blocks them.

Handing the pulses to a chip

The host sends a change; the chip keeps the pulses
before the write
The chip is pulsing sixteen channels. The host is idle.
Host sent
nothing yet
Periods since
none
Pulses the chip made
16 every 20 ms
The chip is already doing the work. Sixteen pulses every 20 ms, at whatever widths it was last told, with the host doing nothing at all. Press the button to change one channel.

The PCA9685 is a chip that keeps sixteen PWM outputs running from its own oscillator. The microcontroller writes each channel's pulse width into the chip once, over I²C, and then does something else. The pulses continue, unchanged, until it writes a new width.

So the traffic on the two wires is only the changes. A servo that holds still costs the bus nothing, and the sixteen pulse trains never jitter because the sketch was busy.

Two wires, and the two they need

I²C is two signal lines, SDA (data) and SCL (clock), plus a shared ground. The board also needs VCC, the supply for the chip itself. Those four wires are all a microcontroller gives it.

Every board on the same two wires needs its own address. Six solder pads on the underside set it, and the datasheet counts 62 usable addresses, so one pair of pins can reach far more than sixteen servos.

What the chip does not do

It does not power the servos. Their current comes from a separate supply on the board's V+ rail, and that split is the most important thing in this book: V+ and VCC.

It does not know about angles either. It sends pulse widths, and which width means which angle is up to each servo: A pulse, not an angle.

When it does not work

Can I still drive one servo straight from a GPIO pin?

Yes. One or two servos on a microcontroller's own PWM pins work fine. The board earns its place when the count grows, when the pins are needed for something else, or when the sketch must never stall the pulses.

Does the board know what angle my servo is at?

No. It sends a pulse width and nothing comes back: a servo has no wire to report its position. The sketch has to remember what it last sent.

Can each channel run at a different frequency?

No. The chip has one prescaler, so all sixteen channels share one frequency. Each channel sets only its own pulse width. For servos that is 50 Hz on every channel, which is what they all want anyway.

Where this goes next

Three boards, and every header, pin and pad on them.

What is in the box →

Edit this page — content/books/pca9685/sixteen-pulses-two-wires.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

PCA9685 16-Channel Servo Driver Board, USB-C Powered

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →