16 PWM Channels in one Chip

If you build a Huge 7-Segment Clock out of RGB-LED-Strips you will likely run out of PWM channels on your microcontroller. Luckily NXP knew that and designed a whole bunch of different chips to overcome this problem. All of them are connected via I2C.

For my project I decided to use the PCA9685 (that data sheet is really comprehensive). The selection process was eased by the fact that it was the only part able to source via a local distributor (RS Components). The price is 1,79€ per piece when you order 10 of them.

During my research for this chip I found that Adafruit uses this piece for their servo driver board. Not a bad reference.

Now, what is this chip able to do? Well, if you need an excessive amount of PWM channels (a gross in my case), this chip will meet your needs. As mentioned before, it is hooked up via I2C. Six out of seven address bits can be set freely. This allows theoretically 1024 PWM channels (let’s call this a Mega-PWM, shall we?). Practically this is reduced by some reserved addresses, nevertheless these chips will provide enough channels. When you have that many chips on the I2C you may worry about transfer times. This chip can handle bus speeds up to 1 MHz instead of the usual 100 or 400 KHz. Only make sure your microcontroller can handle this, too!

As the number of channels is covered, there are more handy features. Each channel can be set to a different PWM value (this is not always the case!) and the value can be in a 12 bit range. When we hook up an LED to the output (and we sure will), this means 4096 different shades of grey (pun intended). You can not only set the pulse width of the PWM but also the point in time where it is turned on per channel. So why do we need this? Image you have 16 channels with big loads (switched via an external transistor). Now, every time the internal counter of the chip hits 0 all of those channels will fire up together. When you cycle this fast enough chances are that you will kill your power supply if it is a switching one. So it is clever to balance the instances where a channel is turned on over the whole PWM cycle.

Enough PWM, make it light up! These chips are able to sink 25mA per channel. This means you can directly connect your (single) LEDs to this without any additional drivers. The data sheet provides examples for using them directly with LEDs and also with external drivers.

This chip also has a little brother, the PCA9635. It features only 8 bit PWM but has 7 programmable address bits. This will come handy when you need 2048 PWM channels.

Leave a Reply

Your email address will not be published. Required fields are marked *