Go Down

Topic: How did this guy daisy chain the tlc5940 over a long wire? (Read 3889 times) previous topic - next topic

mrboni

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

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 :)

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:

http://www.youtube.com/watch?v=VY0kiJNI5oE

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

-Sathi

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

Boffin1

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...  ?

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

Boffin1

Yes its a bit of a chicken and egg situation   
Quote
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

Docedison

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
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

MarkT


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 :)



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...
[ I won't respond to messages, use the forum please ]

Sathi

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

Graynomad

Quote
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.

Quote
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

Rob Gray aka the GRAYnomad www.robgray.com

Go Up