Expand description
NXP PCA9685 16-channel, 12-bit PWM controller.
The PCA9685 drives sixteen independent PWM outputs at one shared frequency, which is what makes it the usual way to run a bank of servos, dimmable LEDs, or the speed and direction inputs of motor drivers from a single I2C device. This module builds the values that program it: the prescaler that sets the output frequency, the address of each channel’s registers, and the 12-bit on/off word that sets a channel’s phase and duty, with the full-on and full-off encodings the datasheet defines.
It is pure logic: a caller writes the bytes to the device over whatever performs the I2C transfers.
Modules§
Structs§
- Pwm
- A channel’s PWM setting: when in the period it turns on and when it turns off.
Constants§
- CHANNELS
- The number of PWM channels.
- COUNTS
- The number of counts in one PWM period (12-bit resolution).
- INTERNAL_
OSC_ HZ - The frequency of the internal oscillator, 25 MHz.
- MODE1_
RESET - The power-on value of MODE1 (0x11): sleeping, responding to the All Call address.
- PRE_
SCALE_ RESET - The power-on value of the PRE_SCALE register (0x1E), about 200 Hz at 25 MHz.
Functions§
- channel_
register - Returns the address of a channel’s first register (its on-count low byte).
- frequency_
for_ prescale - Computes the PWM frequency a PRE_SCALE value produces.
- prescale_
for_ frequency - Computes the PRE_SCALE value for a desired PWM frequency.