My Links

Post Categories

Article Categories

Archives

Image Galleries

When driving led strips with pwm, a strobing effect can be noticed when the dutycycle is changed slowly, this is because our eyes' sensitivity to light is logarithmic while pwm is linear, this effectively decreases the perceived resolution, this is noticed especially in the 0% to 10% dutycycle range.

Most rgb controllers have a resolution of 8 bit, why? Because pwm is usually done in software, a timer generates an interrupt every n-th clockcycle, the interrupt causes the controller to jump to a certain section of the program where calculations are performed to determine whether a pin should be at 0 or 1.

This is fine for most applications and doesn't require a very expensive controller, however it's very inefficient, making it impossible to get something like 16 bit pwm at a high enough frequency (at least 100 hertz).

To get pwm at 16 bit resolution a controller is needed with hardware pwm, I chose the dsPIC33FJ12MC201 from microchip, it has three pwm outputs (well six actually, but only three dutycycle generators) which is enough for a single rgb channel.

This is the schematic I came up with:



You might notice that it doesn't have a crystal, that's because it uses the internal oscillator. Internal oscillators are usually not accurate enough for rs232, but there's a simple trick to solve that, the uart of the dsPIC can measure the baudrate when set up correctly and 0x55 is sent to it.
Because most operating systems sent something out the serial port when booting, the dspic is set up to measure its baudrate 64 times in a row, this ensures that the byte used for auto baudrate measurement is really 0x55 and not something else, at least when the software is set up right.
LED1 turns on when the auto baudrate measurement is complete.
It works with baudrates from 50 to 115200 baud.

The protocol used is the LTBL protocol.

It doesn't use a level shifter for rs232, the tx signal is fed directly to the pin using R4 to limit the current, the rx signal is sent through the TSC427 because it had an unused mosfet driver section anyway, R6 is used to limit the current because the TSC427 has a very low output impedance, without R6 the TSC427 will blow up if the output is shorted.

When the controller is not being controlled over rs232, the color can be adjusted with S1, S2 and S3, S1 selects the channel to adjust and S2 and S3 are used to increase or decrease the selected channel's dutycycle. The selected color is stored in the eeprom.

The firmware and sourcecode for the controller can be downloaded here, to program the controller a programmer like the pickit2 is needed, as far as I know there are no simple programmers like the jdm programmer for the dspic.

I built it on some experimentation board and mounted it in a metal case that I got with my lighter from dealextreme.

posted on Sunday, December 14, 2008 8:41 PM

Blog Stats