Go Down

Topic: TLC5940 + ULN2803 (Read 5082 times) previous topic - next topic

emueyes


Sorry to bring this up again; it's been talked about a few times here, but somehow never reached a conclusion that I could see or understand.

My wish, as that of the other posters, is to use the PWM outputs of a 5940 to control a couple of 2803s and hence a bunch of LEDs. More specifically I have a string of LEDs on each output and the proper resistor to run the series string @ 12V and about 18mA, give or take the variances of the LEDs and resistors.

I've seen mentioned that I need to pull the 5940 outputs high, ok, but also seen that I'll lose the PWM ability of their output. This last bit I don't understand. I was hoping that the PWM output would just switch the 2803s also with PWM and hence control the LEDs.

This is a lighting project, I'm using an NFET for the main 12V 7W led, works great with both rotary encoder and IR remote- I've got a bit of a clue, but know enough to ask for advice too. These extra strings are meant as 'ambient' lighting to alter the overall colour of the lamp. They aren't RGB, just plain amber.

I mention all that because if using a board full of FETs is the best way to do this then that's what I'll do. Something that takes up a bit less space (and takes less effort to implement) is what I'm asking about.

I have seen these too http://www.adafruit.com/products/1455 perhaps the cleanest solution to this problem; seems to do exactly what I want in general terms - control a bunch of LEDs with PWM - and at that price it's just right. Can't seem to find the TLC59711 chip it uses anywhere though.




fungus


My wish, as that of the other posters, is to use the PWM outputs of a 5940 to control a couple of 2803s and hence a bunch of LEDs. More specifically I have a string of LEDs on each output and the proper resistor to run the series string @ 12V and about 18mA, give or take the variances of the LEDs and resistors.


Why do you need a TLC5940 to control two outputs? The Arduino has 6 PWM outputs which will work.
Advanced Arduino

PaulRB


My wish, as that of the other posters, is to use the PWM outputs of a 5940 to control a couple of 2803s and hence a bunch of LEDs. More specifically I have a string of LEDs on each output and the proper resistor to run the series string @ 12V and about 18mA, give or take the variances of the LEDs and resistors.


The 5940 can sink 160mA per output, so do you really need the 2803s at all?


I've seen mentioned that I need to pull the 5940 outputs high, ok, but also seen that I'll lose the PWM ability of their output. This last bit I don't understand. I was hoping that the PWM output would just switch the 2803s also with PWM and hence control the LEDs.


I agree - I don't understand why that wouldn't work either. Or rather you are pulling the 2803's inputs high with the resistors, then the 5940 pulls them low to make the PWM. But I also don't understand why you want to use 2803s...


These extra strings are meant as 'ambient' lighting to alter the overall colour of the lamp. They aren't RGB, just plain amber.


As fungus says, why do you need 5940 at all for this? You would only need 5940 if you need individual PWM control of 16 groups of LEDS, for animation or colour control of RGB LEDs. Sounds like you just need to control the amber LEDS as a single group.

Sorry its all questions and no answers!

Paul


emueyes

I've just realised that a 5940 isn't a PWM device, it's a constant current device; I'd seen in other posts, though, that same question about the 5940 / 2803 combo being used, without that being pointed out as kind of a major flaw in the design.

How many PWM outputs do I need? I don't know, 8 or so. It's a kind of open ended project, of the type that keeps using up pins. I'd like it to have WiFi, too, for eg.

There's a document from TI at http://www.ti.com/lit/an/slva280/slva280.pdf describing how to use a FET with a 5940 to enable series LEDs operating at a higher voltage than the normal 5V, but even the way the FET is used in that document has me puzzled, working out the value of the resistor they're using to control it is hard.

emueyes

Sorry, I mayn't have been clear about what I was talking about. I'm using strings of LEDs just to get the required brightness, then having 5, or 6 or however many strings, where the strings need individual control.

PaulRB


I've just realised that a 5940 isn't a PWM device, it's a constant current device


Its both. So you don't need any series resistors when using it to directly sink current from LEDS. The constant current sources removes the need for series resistors and compensates for the small differences in Vff between individual LEDs. The PWM controls the brightness. If using the 5940 in conjunction with 2803s, the PWM aspect would still work, but you loose the constant current advantage and have to use series resistors instead. But as per my previous post, do you need the 2803s at all?


How many PWM outputs do I need? I don't know, 8 or so. It's a kind of open ended project


Some Arduinos with Atmega328 only have 6 PWM outputs becuase they use the 28-pin DIP chip. Others have 8 because they use the surface mount chip that has more pins.


There's a document from TI at http://www.ti.com/lit/an/slva280/slva280.pdf describing how to use a FET with a 5940 to enable series LEDs operating at a higher voltage than the normal 5V.


The 5940 data sheet says "LED Power Supply Voltage up to 17 V"...

I'm not trying to pick holes in your decisions or anything, honest! Just seems you have been given some strange advice, perhaps arising out of confusion over what you are attempting.

emueyes

Thanks for the info on the 5940, it seems remarkable that it can do both. I realise I have to supply my own current limiting resistors, now knowing that PWM will still work is great.

What I have atm is this. A Uno, a 12V 7W white LED, and potentially, 6,7,8,? strings of amber LEDs (four in series will run off 12V).

The Uno has an IR receiver, a momentary action pushbutton that in software latches the white LED on/off, and a rotary encoder for dimming. The onboard switch etc are just duplicated in functionality by the remote. That's used a few pins, and I'm really trying to not use the SPI so that I can have Ethernet.

The switch and encoder are both interrupt driven, hence the encoder only gets 1 interrupt, seems to work OK though.

Now I have the strings of amber LEDs, which will physically be inside the lampshade, and (I imagine) slowly fade in and out, creating a wonderful effect. Or it may look horrible. I don't know that bit yet.

I've breadboarded the amber LEDs and they do look kinda cool. I've only got a 2008 and 7 strings (bunches, really)  atm.

If I can take the 12V 'main power line', use a bunch of the amber LEDs and connect them directly to a 5940 pin then that's great. The TI article on that topic was quite complicated. I know I can run them straight to the Uno, but I really want more strings/bunches than it has PWM outs.

I've used up the Unos IRQs and a lot of its pins, I might be better of using a Mega for this, and doing away with auxiliary chips altogether. Or, if the 5940 will work by itself that's good too. 

That's pretty much the whole story. If I've over complicated things thinking I'd need a 2003/2803 that's not needed I'm very happy to not use it. I do need more PWM outs than the Uno has though.

PaulRB


Some Arduinos with Atmega328 only have 6 PWM outputs becuase they use the 28-pin DIP chip. Others have 8 because they use the surface mount chip that has more pins.


Sorry, ignore that bit, I was talking gibberish. (Getting ADC inputs and PWM ouputs mixed up)

PaulRB

#8
Sep 30, 2013, 04:47 pm Last Edit: Sep 30, 2013, 04:55 pm by PaulRB Reason: 1

That's used a few pins, and I'm really trying to not use the SPI so that I can have Ethernet.


No problem, with only one 5940 to communicate with, you will be fine using the shiftout() and can use any pins.


The switch and encoder are both interrupt driven, hence the encoder only gets 1 interrupt, seems to work OK though.


Again, no problem. If you need more than 2 interrupts, there is library that enables interrupts on any pins.

http://code.google.com/p/arduino-pinchangeint/


If I can take the 12V 'main power line', use a bunch of the amber LEDs and connect them directly to a 5940 pin then that's great.


I think that will work.


I do need more PWM outs than the Uno has though.


I wonder if there is a library that will allow PWM on more outputs, through software emulation? The Arduino should be more than fast enough to allow this.

Edit: yes there is: http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation

fungus


I wonder if there is a library that will allow PWM on more outputs, through software emulation? The Arduino should be more than fast enough to allow this.


Yep. There's one called "SoftPWM".

It's very easy to write your own PWM code if you need high resolution. No need for hardware timers, just count down inside loop() and change the pins when they match the counter.

Advanced Arduino

emueyes



That's used a few pins, and I'm really trying to not use the SPI so that I can have Ethernet.


No problem, with only one 5940 to communicate with, you will be fine using the shiftout() and can use any pins.


I'm not sure what you mean by this.


The libraries for interrupts and manual PWM sound very interesting, I'll be investigating them thoroughly. In particular, the existing IO is event driven so I can loop whatever I like, and it certainly doesn't need microsecond accuracy.

I know that we live next door to eBay where a 5940 only costs a dollar, but I don't like destructive experiments; at least now I have some recommendation that I'm not going to toast a 5940, and also that I'd overthought and overengineered things.


PaulRB




That's used a few pins, and I'm really trying to not use the SPI so that I can have Ethernet.


No problem, with only one 5940 to communicate with, you will be fine using the shiftout() and can use any pins.


I'm not sure what you mean by this.


If you had a string of say 20 5940s and needed fast updates, you might need the speed that the SPI outputs provide to communicate with them (see SPI Library). For one 5940 with modest update rates, the shiftOut() function will be plenty fast enough and you can choose any 2 pins you like, keeping the SPI pins free for Ethernet.

http://arduino.cc/en/Reference/ShiftOut

Go Up