# Long chain... RS-485?

Hi All, i would like to have 50-100 Arduino netwoked togheter on a long chain let's say 200 meters. I suppose that 485 is a good solution, i look at http://www.arduino.cc/playground/Learning/DMX/DMX_Shield but "unfortunatelly" it operate only as transmitter instead i need a chain on slave arduino mastered by a PC. Any idea or suggestion?

thanks. Ciao, Alessandro

Hi Alessandro , I have no direct experience with this item: http://www.dealextreme.com/details.dx/sku.6040 but for $5.95 shipped free its worth checking out. It's looks to be an RS232 to RS485 bi-directional converter for working up to 1200m on the RS485 side. I am curious to know what it is that your making? Hi thanks for the link seem to be very intresting ;) I am curious to know what it is that your making? Oh i'm envisionig for realize an exibition\concert light sistem composted by 50 columns 2 meters high. each column will be governed by an arduino that controll 50 shiftbrite hosted in the column, the 485 will be the network between the coloums (slave) and the control PC (master) on PC will run a custom sw (maybe written in LabVIEW) able to controll sequence of color, pattern, animation and so on. Ciao, OK, just to say that as well as getting the physical connections going it will pay back in the long run if you get your protocol robust as well. With something as big as this bits will go missing. I should also put a lot more line suppression in than is show on that page. Basically MOVs with small capacitors across the inputs and small resistors (100R) in line with the signals and diodes catching excursions above and below the supply voltages. Best of luck Hi Alessandro , I have no direct experience with this item: http://www.dealextreme.com/details.dx/sku.6040 but for$5.95 shipped free its worth checking out.

It's looks to be an RS232 to RS485 bi-directional converter for working up to 1200m on the RS485 side.

I am curious to know what it is that your making?

The tool is very intresting definitivelly, only one concern regarding the triple conversion 485->232->USB required to connect an arduino, may be simpler use arduino serial, is it available in some shop?

OK, just to say that as well as getting the physical connections going it will pay back in the long run if you get your protocol robust as well. With something as big as this bits will go missing.

I should also put a lot more line suppression in than is show on that page. Basically MOVs with small capacitors across the inputs and small resistors (100R) in line with the signals and diodes catching excursions above and below the supply voltages.

Best of luck

Sure, the protocol is a very critical part of that project also for the distance and the data size each led 24 bits each column 1200 bits (50 leds) enterire stage 7500 Bytes too much on a single line also using 115kbouds i could obtain 2 fps. Solution can be split in differente 485 subnet in order to have al least 25fps or use use USB and USB hub so 1 port for each columns can be addressed parallely by control SW but USB is very limited in distance max cable 5meters max daisy chain using 5 hubs 25 meters... i'm a bit confused at this point.

Ciao, Alessandro

It might be worth considering a low cost Ethernet board with SPI interface if the data rates need to be high.

Perhaps something like this: http://www.ekitszone.com/index.php?main_page=product_info&cPath=1&products_id=3

The cost of that plus a runtime board without USB or serial may not be much more expensive than a serial board with rs485 adapter.

I was thinking ethernet, too, but I was thinking of the wiznet module. There's a lot more of the stack taken care of by the peripheral than with the Microchip device.

-j

I was thinking ethernet, too, but I was thinking of the wiznet module. There's a lot more of the stack taken care of by the peripheral than with the Microchip device.

-j

It probably doesn't need anything more than tcp, and even udp could be sufficient. Assuming it's a private network, probably the easiest thing to do would be to broadcast all the packets and have a heartbeat check every second or so to make sure that all the towers are responding.

I have one of these boards on order but don't have it yet so can't comment on how easy it is to get going. Are you using wiznet? Do you like it?

I was thinking ethernet, too, but I was thinking of the wiznet module. There's a lot more of the stack taken care of by the peripheral than with the Microchip device.

-j

It probably doesn't need anything more than tcp, and even udp could be sufficient. Assuming it's a private network, probably the easiest thing to do would be to broadcast all the packets and have a heartbeat check every second or so to make sure that all the towers are responding.

I have one of these boards on order but don't have it yet so can't comment on how easy it is to get going. Are you using wiznet? Do you like it?

i was thinking ethernet too, www.ekitszone.com seem to be simple to use, wiznet require some adaption in order to live with arduino. But 485 have one advantage i can use a go-in go-out (from\to the tower) topology i don't know if this is possible using eth www.ekitszone.com i guess i need to use a double connector eth device. otherwise 485 is more simple than eth also if i decide to use UDP that is sufficient for my point of view.

Ciao

Using TCP you still run into a bit of a headache.. you need to create software to open all those open TCP connections to each device on the network.. If you change crystals and recompile the arduino core to run a different frequency you can run it at 921k(?) For instance 14.7 crystal will support that rate. 16mhz is not 'evenly divisible' by many baud rates over 56k which is why that is the max the ard. software allows. Look in the Atmega168 manual as it details how to pick crystal frequency when a specific baud rate is needed. You may even be able to use something like 18.432mhz(?or some similar freq)...)

Do you really need 24 bits for an image that course? Might be much simpler to go 5-bit for each color. Then you could stuff all 3 colors into a 16 bit word. It gives you 32 shades each color, 32k colors. With dots far apart You really won't notice the difference in color depth.. and you will reduce the load on the serial not having to pump so much data thru..

Using TCP you still run into a bit of a headache.. you need to create software to open all those open TCP connections to each device on the network.. If you change crystals and recompile the arduino core to run a different frequency you can run it at 921k(?) For instance 14.7 crystal will support that rate. 16mhz is not 'evenly divisible' by many baud rates over 56k which is why that is the max the ard. software allows. Look in the Atmega168 manual as it details how to pick crystal frequency when a specific baud rate is needed. You may even be able to use something like 18.432mhz(?or some similar freq)...)

Do you really need 24 bits for an image that course? Might be much simpler to go 5-bit for each color. Then you could stuff all 3 colors into a 16 bit word. It gives you 32 shades each color, 32k colors. With dots far apart You really won't notice the difference in color depth.. and you will reduce the load on the serial not having to pump so much data thru..

i agree ETH is too much complicated in this case. also agree regarding the 5bits\color i was calculating on 8bits\color in order to consider the worst case 5bits is agood compromise between speed and resolution To cut the head of the bull (is an italian common saying) i decide to use the USB at first stage in not so expandible (in terms of lenght) but is the simpler way to interface an arduino

Ciao

I've got a shield built (home etched) for the wiznet module and follower's code (web site seems to be down at the moment) working. I've got a project in mind, waiting on a sensor to arrive to begin prototyping. If it works out and the price is right, I may end up building 15 or 20 of them.

As far as complexity, design that serial hardware and protocol, make it fast and reliable, then check out UDP and/or TCP and get back to me. (: TCP's got a bit of overhead, but that price gets you a lot in terms of reliable communication.

-j

How were you planning to map 5 bit values to shiftbrite's 10 bits? I might add some of that functionality to the shiftbright library I put together.

Sorry, I phrased that poorly. I meant to say that may be an interesting functionality to add to the library. If you do have a way already thought out, I'd be interested in asking if I could include it.

If you mapped a lower bit depth to ShiftBrites, you could implement a curve that corresponds more to what the eye sees. The most visible differences appear to happen below 400 on the 1023 value scale. The difference in brightness between 800 and 1023 is hardly detectable.

RS485 is a good idea as far as physical layers are concerned, but you'd probably need multiple channels. The distances you're discussing may limit communication to 200Kbits/sec, meaning that the refresh rate could be quite slow. You may be able to use the Arduino's considerable power to make each column intelligent; send a value that is interpreted as a specific pattern, implement some type of compression, etc. You could have commands that set gradients, graphs, etc and only take a few bytes per column. That would allow very fast animations of a limited nature, while a full pixel image could still be created a couple times per second. If you split the system in half, you double the potential speed.

You could use one or a few of these to get serial comms out into the system from a remote computer: http://www.byterunner.com/byterunner/category=Ethernet+Serial+Device+Servers. The Netcom 413 even does RS485/RS422 natively. You could then use raw TCP mode to blast bytes into each serial port, or use the VScom drivers to make each serial port appear as a local RS232 port on your computer.

I've made a new version of the ShiftBright library I've put together, hopefully some of the improvements will help you out in your project:

1. It now uses a much higher performance shiftOut function and other speed ups (courtesy of MartinFick and mem). Hopefully this improves the usability and decreases visual lag when having long chains of ShiftBrites linked together.
2. You can now use 5bit values to specify colors, either as individual RGB channels, or as all three channels packed into a 16 bit int (discards the most significant bit, as only 15 bits are used). 5 bit values are set via a lookup table. The included LUT is a very simple 2 point linear table (first 26 entries are 0-400, remaining are 400-1023). It's also the same for each channel. I'm not sure how to make a more accurate LUT, so that's what I went with. It's pretty easy to replace my LUT with whatever you want though.

I have it as a zip file, and would rather upload that then making a post for every file. Since I don't have a place to upload it yet, I can email it to you if you're interested.

Hi chippey, yes i'm very instrested in your implementation! 5 bit for color is a good idea and LUT is the faster way to implemet it, of course we can always improove it, should be simple using resurce like this http://en.wikipedia.org/wiki/Color_vision and some excel calculations. My mail is alessandro [dot] ricco and the domain is gmail [dot] com. I spent some hours during my vacation on this project i'm still convinced that USB is a good solution for connecting multiple Arduinos with a PC, ETH is more expensive and add too much sw layers, i want to keep the project standard and simple as possible.

PS i have doubt using Shiftbrite now, i mean i'll use Allegro chip carried by shift brite but i need to drive 5 LED with 1 Allegro chip so i'm planing to produce my custom hardware basically a shift brite whit 5 superflux rgb led instead of 1, i'm looking for a PCB producer whit reasonalbe cost for 500 pcs quantity, any idea?

I think that controlling many Arduinos through USB (especially over distance) wil be problematic as the USB cable can only run a few metres.

You should take a second look at RS485 as it can run at least a kilometre in multidrop mode.

have a look at these: http://www.futurlec.com/Mini_RS422.shtml.

I think that controlling many Arduinos through USB (especially over distance) wil be problematic as the USB cable can only run a few metres.

You should take a second look at RS485 as it can run at least a kilometre in multidrop mode.

have a look at these: http://www.futurlec.com/Mini_RS422.shtml.

Yes i know the issue about the distance and tha maximun jump over hubs but at the first stage i need to cover a 10x6 meter suface with 10 devices (arduino) and i guess to be able to do this also using UBS, anyway your link is very very very intresting only 5 USD to add 485 to arduino, impressive but what about connecting it whit arduino, i mean i need to "remove" the FTDI chip or i can connect in parallel to it?

Thanks

I can modify the shiftbrite PCB to support more LEDs, and in fact have a few designs in partial completion. You want to use five of those LEDs? They would have to be in parallel, which may cause big problems unless you place dropping resistors on the LED input lines. That is probably a good idea anyway, though it may result in small variations in brightness between each LED modules, due to the tolerance of the resistors.

My plan was to use a single bright 100mA LED I found, one for each channel of red, green, and blue. The final board would be not much larger than the existing shiftbrite. Perhaps you wanted color bars instead of dots, though....