Ethernet sheild and tlc5940

Hi,

I have the arduino made ethernet shield and a tlc5940 in my new project and i'm not having much luck to get them to work together as they use the same pins. I'm using the tlc5940 library (http://code.google.com/p/tlc5940arduino/) and the ethernet library. I've done a google search and after trying what came back none of it was successful. I was wondering if anyone could show me step by step on how to get them to work together. Can it be kept quite simple as im a novice to arduino libraries. I have an arduino mega 2560

i can get them to work individually with no problems

Thanks in advance Dan

Although I would expect that setup (Mega2560, Ethernet Shield and TCL5940) to be possible to work I'd suggest to replace the TLC5940 if ever possible. You didn't tell us what you use the TCL5940 for, so providing alternatives doesn't really make sense. If you want to go the hard way (use the current setup), you have to rewrite the TLC5940 library to use other timers and other pins. Fortunately the Mega2560 should have enough of them and the rest of the pins (synchronous serial communication) use bit-banging only, so there a pin change is easy.

im using the tlc5940 to control random cross ssr for home automation lighting

Do you know the Adafruit breakout with the PCA9685?

http://www.adafruit.com/product/815

It provides also 16 PWM channels with 12bit resolution but is controlled by I2C and so uses only 2 pins of your Arduino. You can even use many of them on the same Arduino. And it works without any problem with the Ethernet Shield installed.

unfortunately i am unable to change the ic at this stage in the product

i was hoping to change pin 10 (blank) on the tlc5940 to another pin everything else seems to work

The pin setup for the Mega is here. Where do you see D10, except in the optional section. Stay away from the optional pins.

When you say they don't work together, what exactly doesn't work? Is it the ethernet shield or the tlc5940 that fails? I don't see a way to disable the SPI input to the tlc5940 like the slave select on the w5100 disables the SPI bus. That would cause problems for that IC when the ethernet library is communicating with the w5100.

The w5100 should work ok since the tlc5940 doesn't connect to the MISO line.

edit: The closest think I see to a slave select on the SPI timing chart is the VPRG pin. It may work like a slave select, but I don't have a tlc5940 to play with here. Otherwise, you will need an IC between the Mega and the tlc5940 that disables the MOSI and SCK pins when communicating with the w5100, like a 74HCT125.

i was hoping to change pin 10 (blank) on the tlc5940 to another pin everything else seems to work

You can try to modify the TLC code but believe me, it's much easier to change the Ethernet library to use another SS line than to change the TLC library.

SurferTim: The pin setup for the Mega is here. Where do you see D10, except in the optional section. Stay away from the optional pins.

When you say they don't work together, what exactly doesn't work? Is it the ethernet shield or the tlc5940 that fails? I don't see a way to disable the SPI input to the tlc5940 like the slave select on the w5100 disables the SPI bus. That would cause problems for that IC when the ethernet library is communicating with the w5100.

The w5100 should work ok since the tlc5940 doesn't connect to the MISO line.

edit: The closest think I see to a slave select on the SPI timing chart is the VPRG pin. It may work like a slave select, but I don't have a tlc5940 to play with here. Otherwise, you will need an IC between the Mega and the tlc5940 that disables the MOSI and SCK pins when communicating with the w5100, like a 74HCT125.

but pins 11 and 12 are still in use by the ethernet and the tlc5940

but pins 11 and 12 are still in use by the ethernet and the tlc5940

Are you really working with a Mega2560? The Ethernet Shield should be connected to pins 11, 12 and 13 on the Mega (it's on 50, 51 and 52).

the ethernet shield works fine, it is using pins 10,11,12,13
the tlc5940 is what i’m having problems with, its using pins 51,52,9,11,12
both of them use pins 11,12
and the tlc5940 doesn’t always work
so i think it because they are using the same pins but the ethernet shield works fine so i am not going to change that

the ethernet shield works fine, it is using pins 10,11,12,13

Not on a Mega. The ethernet shields that have a ICSP connector on the bottom of the board use that connector for the SPI data pins, and nothing is connected to D11 to D13. D10 is used for the SS.

edit: If you need to change the w5100 SS to another pin, I have a library mod around here somewhere that allows you to do that.

after checking my sketch i found that was the problem because it seems to work every time i tested it i put the tlc.update() after a delay so i put it in front and it worked alot better