Monthly Archives: April 2013

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.

Planning a huge clock

SFE-Wall-Clock-35

Once, I randomly stumbled upon an awesome tutorial by Sparkfun Electronics. They built a giant clock out LEDs and Styrofoam. Then they synced it to the GPS for exact timing. What I like most is how ridiculously big this is inside that room. The digits are 60 centimeters high and the clock is 3,6 meters wide. I need one, too.

The guys at Sparkfun used the LED Light Bar from their shop. They used 92 of those bars. When you buy 100 of them, this will cost you about 180€. This is way above of my budget for such a silly awesome project.

Also, why just limit this to one color? Wouldn’t it be cool to change the colors or even animate the change of the digits. This could emulate an old Nixie tube for example. I need RGB-LEDs and PWM dimming.

The idea of using some kind of bars for the segments is nice. Your LEDs are equally spaced and you already have a board and some connectors. Can’t I build this myself? After searching all over the web for cheap RGB-LEDs I found RGB-LED strips at a length of 5 meters for under 20€ complete with controller and remote control on eBay. These strips can be cut every 3 LEDs and that way I get my “bars”. I plan to use 48 of these bars and this way a single 5 meter strip suffices for my clock.

clock_mockup

The image above shows my segments and some strips inside them. Every segment gets a strip of 3 LEDs and every dot gets a single LED as they are way smaller, This will also level the brightness. Note the extra decimal dots. These come in handy when I want to display the current date or when using this as a giant stop watch.

The size of the strips also limits the size of the complete clock. My version will be 1,5 meters wide and 33 centimeters tall. This will still have the desired effect on the wall of my room.