TLC5940 problems

Hi all,

I've got a bit of a strange problem with the TLC5940, using Alex Leone's library [1].

I have 8x10 leds in a matrix which is configured to be driven by 5 output pins times 16 TLC5940 channels. Ultimately I want to multiplex the matrix to have 80 individually controlled LEDs, but at the moment I'm having problems with whole rows.

I use Arduino digital pins 12, 8, 7, 4 and 2 as output pins, and they all work perfect - apart from pin 12!

Digital pin 12, PB4, is also the arduino MISO pin. When I have all the other rows turned off and pin 12 on, I can see a very faint light. Measuring the outputs I can see they're all at 4.92V, apart from pin 12 which only comes up to 4.75V - and that's with no LEDs on.

I've been looking through the TLC5940 library documentation, the code, and the ATmega168 datasheet, but I can't see any reason why the MOSI pin should be misbehaving. At first I thought it was because of the lib uses hardware SPI, but changing to BITBANG mode doesn't help one bit.

In any case the datasheet says: "When the SPI is enabled, the data direction of the MOSI, MISO, SCK, and SS pins is overridden..." and then a table says that in Master SPI mode, the MOSI pin direction is User Defined, which I take to mean it can be configured as either input or output.

I've tried both Arduino 0011 and 0016 and get the same result.

The code I've used for testing is based on BasicUse.pde from the lib. Nothing complicated or controversial - I'm happy to post it.

I've put a copy of the schematic here [2].

Is there any other part of the Arduino library/runtime code which messes with the MISO pin? Anyone else had any similar experiences? Any ideas?

best,

/m

[1] http://code.google.com/p/tlc5940arduino/ [2] http://blipbox.files.wordpress.com/2010/02/blipbox-v6.png

EDIT: I'm a fool. I'm mixing up my MISOs and MOSIs, making a MISO soup out of the whole thing. Sorry. In SPI master mode, pin 12 / MISO is set as INPUT. However, it still doesn't work in BITBANG mode.

I use Arduino digital pins 12, 8, 7, 4 and 2 as output pins,

From what I can gather you are using the arduino pin as a current source for your row. This means it is trying to supply the current for 10 LEDs? Is this correct? The current output of an arduino pin is 40mA absolute max, any more and you damage the device. Am I misunderstanding something?

Current source is correct - each pin is actually powering up to 16 LEDs!

The max current per channel is calculated as Imax = V(iref) / R(iref) * 31.5 where V(iref) = 1.24V. With a duty cycle of 20% (multiplexing across 5 pins) and a current limiting resistor R(iref) of 3k1, I figure the max total current per pin will be around 40mA -> 1.24/3100*31.5*16/5

I'm not totally sure my duty cycle reasoning is correct, but apart from my pin 12 problems it seems to run very well with no smoke coming out yet.

btw, doesn't the ATmega pins have protection against drawing too much current?

btw, doesn't the ATmega pins have protection against drawing too much current?

NO!

With a duty cycle of 20% (multiplexing across 5 pins) and a current limiting resistor R(iref) of 3k1, I figure the max total current per pin will be around 40mA -> 1.24/3100*31.5*16/5

No I can't follow that but it's not right. I make it (1.24 / 3100) * 31.5 = 12.6 mA per channel. You have 16 of these so total current is 12.6 * 16 = 201.6mA

I am talking about the current from the rows, that is to supply 16 LEDs according to the diagram. You can't say a duty cycle of less than 100% reduces the current, average current yes but not peak current. And it is peak current the arduino has to supply. Avrage current only comes into play when considering power dissipation of a device.

it seems to run very well with no smoke coming out yet.

So over stressing the board is of no concern just because it shows no sign of damage yet. Please read the latter part of this page:- http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

but apart from my pin 12 problems

yes?

Please read the latter part of this page:- http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

I read it just earlier! It's a good text - I also had much help from your power discoupling mini-tutorial. Thanks for putting those online.

I have plans to use something like the UDN2981 8x source driver instead of driving the LEDs directly, it should be more sensible I think.

However for now I'm just trying to solve this little mystery - and I really don't think the cause is that I'm drawing too much current.

Say I have only one LED connected, i.e. using only one channel of the TLC5940. How come I can't drive it with pin 12?

Say I have only one LED connected, i.e. using only one channel of the TLC5940. How come I can't drive it with pin 12?

Well it is either something about the software, like not having set it to be an output pin or something. Or it is a damaged pin, possibly due to too much current.

Just wire up a straight LED to the pin and see if you can make it blink.