How did this guy daisy chain the tlc5940 over a long wire?

devices they use to measure tectonic plate movement. LOL

I have done spi over 10ft at 100khz. If you have issues, it is most likely with capacitance on the line, limited drive or too high of a speed. Using shielded cabling helps and you can always slow down your speed.

You can use RS-485 drivers to get 4000 feet for SPI.


Rob

I noticed in the shiftpwm site, there is a "push-pull line driver" for running data lines a long distance.

http://www.elcojacobs.com/using-shiftpwm-to-control-rgb-leds-with-arduino/

Somehow I doubt that it has anything to do with shielded ethernet cable, those are a couple twisted pairs of wires with a wrapped shield and drain wire, its not very good shielding. Cable TV type cable has braided shield, that would work good if you really need shielding.

Hippynerd:
Somehow I doubt that it has anything to do with shielded ethernet cable, those are a couple twisted pairs of wires with a wrapped shield and drain wire, its not very good shielding.

It's good enough for gigabit data transfers...

Thanks everyone for taking the time to reply to my questions.

I have already bought a bunch of tlc5940, and I want pwm control, so I am pretty much locked into them for now. After seeing this video I did give a 5 ft long cat5e cable a try. I didn't have any female connectors like the guy in the video, so I had to solder the wires to header pins. Maybe I did a crap job on the soldering, but it didn't work. One thing that occurred to me is he is only connecting two tlc5940s. I am trying to connect a 4th one with a long cable. Maybe that is a significant difference?

I have read in other places that reducing clock speed can increase range. But can I do this for the TLCs? That will not interfere with how they communicate/operate? What are the drawbacks?

It seems like RS-485 would solve my problem. But what I am confused by is do I need an arduino at each node? Of course it would not need to be a full arduino, just basically a processor that can talk to the RS485 chip and then send the correct spi signals to the TLC? That sounds like it might be a whole project in of itself. I did some searching for a ready made spi --> RS485 ---> spi device but did not turn anything up. Does anyone know of the existence of a product like that?

I am basically trying to weigh the effort/cost of investigating a node based solution against the pain of just making a bunch of connectors and using a ton of wiring. Going at it from the other direction, is there an efficient way to churn out wires with connectors? 4 segments each needing to connect to each other. The last segment 1 connector, the one before 3 connectors, then 5, then 7 for the first one in the chain and its connecting 7 for a total of 23 connectors. With 18 wires in each connector that is 414 individual connections I have to make! Its amazing how quickly something like this scales up. 10ft of lights didn't really seem like it would be that big of a deal...until I actually tried to do it :slight_smile:

BTW: I really dig that controller for the cricket board.

I saw on the datasheet for the TLC5940 an equation for clock speed depending on the number of devices daisychained ( which they say can be up to 40 )

Figure 22 shows a cascading connection of n TLC5940 devices connected to a controller, building a basic
module of an LED display system. The maximum number of cascading TLC5940 devices depends on the
application system and is in the range of 40 devices. Equation 10 calculates the minimum frequency needed:
where:
f(GSCLK): minimum frequency needed for GSCLK
f(SCLK): minimum frequency needed for SCLK and SIN
f(update): update rate of whole cascading system
n: number cascaded of TLC5940 device

BTW: I really dig that controller for the cricket board.

The first cricket board I made had to be operated by an 80 odd year old scorer, who didn't want any menus or that rubbish :slight_smile: , so I used the thumbwheel switches laid out exactly as the board, WYSIWYG, and its so simple I have stuck to it since.

Boffin1:
I saw on the datasheet for the TLC5940 an equation for clock speed depending on the number of devices daisychained ( which they say can be up to 40 )

Figure 22 shows a cascading connection of n TLC5940 devices connected to a controller, building a basic
module of an LED display system. The maximum number of cascading TLC5940 devices depends on the
application system and is in the range of 40 devices. Equation 10 calculates the minimum frequency needed:
where:
f(GSCLK): minimum frequency needed for GSCLK
f(SCLK): minimum frequency needed for SCLK and SIN
f(update): update rate of whole cascading system
n: number cascaded of TLC5940 device

That's nothing to do with electrical limits of the wires/chips, it's just about having enough time to send all the data for a given update rate (never a problem for cricket).

Hmm, I dont know why you are having trouble then, I thought of perhaps using those chips myself as they have constant current drive, but after seeing the price, and the troubles you are having, I think I will stick to what I have.

For most of my boards I only need 7 pins on a driver behind each display number anyway.

I cant find the screenshot of it, but I checked the waveforms coming out of the micro and that coming out of the 19th display chip and all looked identical on my scope, and thats after say 20 meters of daisychained shiftregisters via ribbon cable....

The RS485 chips are easy to use. No microcontroller communication required.

I've used these recently - http://uk.rs-online.com/web/p/line-transceivers/7327958/

They just need 5v, gnd, and the data signal input. This outputs a balanced signal pair which goes down a twisted pair cable. The same chip can receive this signal and convert it back into the original unbalanced data.

I've tested over >120m of cat5 but apparently you're good for >1000m

Thanks everyone, this has been a great help to me. After much research I have come to the conclusion that using rs485 is the answer. I was resistant at first, but after researching it actually doesn't seem like it will be too difficult. The needed hardware is also much cheaper than I thought it would be. I have ordered a batch of tlc5940s for about $1.10 each, atmega328p batch for $1.20 each, and the max485 for $0.18 each. With a few of the small extra parts needed, I might be able to have addressable long range 16 channel pwm led nodes for under $4 each. That would be amazing...if it works :slight_smile:

There is one thing left that puzzles me. Would I be able to use the max485 to upload my sketches to the remote atmega328s? It would be a bummer if I had to pop the chips out, load the sketches and then put them back every time I wanted to make a change. The following link has a tutorial where this guy is using a max232 wired to tx/rx of the atmega328 and the other end connecting to a pc via serial cable:

If I wired up the max485 in a similar way, would I be able to upload sketches in this manner?

-Sathi

The 328's bootloader is happy as long as you can delivery the bytes to the UART, if that's by RS-485, USB or modulating a flash light it doesn't matter.

The trouble is you have to reset the processor first, and that's normally done with a cap on the DTR pin of the USB interface. Somehow you have to implement that reset to get into the existing bootloader.

The other way is to write your own bootloader that does things differently. Not a task for a beginner, but you could have a protocol that accepted commands form the master device and one of those commands could be to jump to you bootloader.

OK, having written that I wonder if you can fudge the existing setup. Send the special command and have your program jump to location 0. That's easy, the question is does that go into the bootloader? Off hand I don't know, but if it does you may be able for immediately follow the command with the standard avrdude programming.

Just a thought.


Rob

How long must the reset pulse be?

If you sent a certain code to switch an IO pin high, which switches a transistor to pull down the reset pin, would it reset in time?

You could have a pin going low and pull the reset down with a diode, but it might be confusing at startup... ?

You can have the processor hardware reset itself with external hardware to hold the pulse. You can't do it without some form of pulse stretching because as soon as the outputs resets the chip it turns to an input and all bets are off.

A simple diode and cap may do the trick, I've not thought about it much. A uC supervisor chip would be better I think, many of them have an input for a push button, you could control that.


Rob

Yes its a bit of a chicken and egg situation

the outputs resets the chip it turns to an input and all bets are off.

by which time its reset.

I have a test unit on the bench, when I finish my sketch I will hook up a simple delayed idea, just out of ihterest

The great enemy of long wire communications is Line Capacitance and the easy way to counter that effect is to drive more current through the driver, lower the pull-up value from 4K7 to 1K, 470R isn't too much. The net effect of doing this is to lower the impedance seen by the cable and thus begin to provide a better match between the source and the load which is principally the cable capacitance. This is similar to reducing the clock speed. At lower clock rates the capacitive reactance of the cable drops and it isn't as much a load to the source or Arduino. This is also true of really noisy environments too as there is less voltage impressed on the cable by 'stray' electrical noise. I made many 10 meter runs with twisted wire cables... cat 5 sized single pair phone wire at 1MHz speeds.

Bob

Sathi:
Thanks everyone, this has been a great help to me. After much research I have come to the conclusion that using rs485 is the answer. I was resistant at first, but after researching it actually doesn't seem like it will be too difficult. The needed hardware is also much cheaper than I thought it would be. I have ordered a batch of tlc5940s for about $1.10 each, atmega328p batch for $1.20 each, and the max485 for $0.18 each. With a few of the small extra parts needed, I might be able to have addressable long range 16 channel pwm led nodes for under $4 each. That would be amazing...if it works :slight_smile:

Don't forget good decoupling at each node and watch out for power rail oltage droop due to inadequate power wiring over long distances - you don't want the furthest LEDs to be dimmer...

Thanks everyone for all the advice.

Maybe I should clarify that I don't actually need to reprogram the chips remotely, I just want it to be easy to do the initial programming. That is I don't want to have to take the chip out of its socket from its node, put it in something that can upload the sketch, and then put it back. It sounds like I will be able to upload the sketch through the max485 as long as I manually reset the atmega first. Is that correct?

I believe the TLC5940 can handle a maximum of 17v. Can anyone recommend a good voltage to use so I have adequate power to the farthest LEDs? Or should I just run a second power line to the farthest half of the run? I plan on having 60 leds using 20ma each. I plan to use one battery pack to power the atmega328s and TLC5940s at 5v, and another battery pack for the power to the LEDs.

-Sathi

I don't actually need to reprogram the chips remotely, I just want it to be easy to do the initial programming.

If you can do one over the serial link you can do the other. If this is for a project that may require field upgrades this will be a very good feature to implement properly.

It sounds like I will be able to upload the sketch through the max485 as long as I manually reset the atmega first. Is that correct?

It will be a bit like the current Arduino setup when the program stops the bootloader from executing. IE you have to time pressing the reset button just right, so as long as the board and the PC are next to each other I think it should work (you'll need a USB to RS-485 adapter for the PC). If this is just for the initial programming and not in the field it should be OK.

Another option is to do ISP programming using the SPI pins if they aren't already in use.


Rob