TLC5940 PWM output to Analog

Hi we are building a lighting project that involves AC Dimmers. The AC Dimmers use analog input between 0-2.65V. Using the Arduino's PWM output with an RC filter (510ohm + 100uF) everything works great. The AC Dimmer is smooth and responds quickly (HIGH or LOW over 0.1 seconds).

Here's where things get tricky. We are going to have 20 AC Dimmers and as such we decided to get two TLC5940's to control them (the thought being to put the same RC filter on each PWM ouput). The first problem we ran into was that the TLC5940's has sink outputs rather than a source output. To solve this we added a PNP transistor between the sink output and RC filter.

It works but using the same resistor + capacitor combination as before it isn't working as well. The light doesn't seem as "responsive" to changes perhaps because the capacitor is smoothing too much? My question is why would the RC filter between a regular Arduino PWM output behave differently with the TLC5940 PWM output? How can we construct a filter that will convert the TLC5940 PWM output to analog?

Hi, post schematics please! Both the Arduino pin version that works and the tlc version with the transistor, that doesn't.

Did you try simply attaching a pullup resistor to the tlc outputs and no transistor? This would reverse the dimming effect (almost off becomes almost on etc) but you can correct for that in your sketch.

I am thinking your problems may be down to the fact that the tlc outputs are constant current sinks.

Paul

Thanks for the response!

I attached two schematics. The first shows the PWM output of the Arduino going through a low pass filter to the AC Dimmer (works). The second shows the PWM sink output of the TLC5940 going through a PNP transistor then the low pass filter to the AC Dimmer (doesn't work).

I spent most of today trying to debug this without any resolution. I think the problem is related to the voltage range. The AC Dimmer is tolerant up to 5v but anything above 2.65 and the light is fully on. Thus the code limits the output to 2.65v. I'm thinking that when attempting to change the output sink into a source the voltage is coming out wrong due to the transistor or pull up resistor starting at 5v? Not entirely sure.

Also not sure I wired in the pull up resistor correctly. I put a 10k resistor between the 5v rail and the TLC5940 output sink. Then connected the breadboard row to the LPF leading to the AC Dimmer.

Any ideas?

Not sure you understood my comment earlier, so I will expand. Perhaps this will give you a clue. Apologies if you already know this.

An Arduino output will source current when set to HIGH. It will sink current when set to LOW. This current is not limited internally (and too much can damage it). In your first curcuit, the LP cap is charged by the Arduino pin when it is HIGH and discharged through the Arduino pin when it is LOW.

The TLC outputs cannot source any current. They can only sink current. During their PWM cycle, when the output is "on" it will sink current, but when "off" no current flows (it floats). The output voltage is adjusted automatically by the chip to achieve a particular current. I don't know what happens if the load's resistance is too high or too low for chip to achieve that current.

I suspect that your pnp will not switch off without a pullup resistor on its base, e.g. 10K. You should probably limit the base current with a 200~500R. You may also need a means for the cap to discharge.

Let's see the diagrams. Attachments don't work.

Increase R1 to 10k and put a 12k resistor across the capacitor. Use 22k for Iref of the TLC5940 thus setting the base current to the transistor at 1.7 mA and put a 470 Ohm resistor between base and emitter which will absorb 1.5 mA of that.

This should constrain the resultant analog voltage to just over 2.7 V at maximum.