Pages: [1] 2   Go Down
Author Topic: Communication between a number of Arduino's?  (Read 2660 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone,

I've undertaken a project that requires me to light up 5 or more LED's on a sign, with 5 signs.

Quick diagram to help explain:

Sign ------- Sign -------- Sign -------------------- Controller --------------------------------------Sign ------- Sign

|-----3m-----|-----3m----|------------7m-------------|--------------------10m--------------------|----3m-----|

Basically, each "sign" entails 3 led strips. There is also 2 LED's, and a buzzer. Each sign will only have one LED strip on at a time. The banks of lights are split physically by a divider, so I'm addressing these as 'left bank' and 'right bank' of lights.

My problem is, there are TOO MANY communication options. What I had in mind was either a barebones Arduino (RBBB or a Diavolino or similar) at each sign, and then an Uno at the "controller". I've got 6 core alarm cable running in a chain from the leftmost sign to the rightmost sign, however 4 of those cables I'd like to use for power. I can run more cable if need be.

I'm not looking for super-high data speeds either, just ideally if someone flicks a switch on the controller, the lights are updated within the second.

My question is, what is the best way to control all these?
-SPI communication? The master outputs a long serial string for each bank. Each sign then extracts the information it requires and then sends serial to the next ardiuno.

-I2C? I'm not sure on the hardware limits (i.e. bus length) of this protocol, but I've got 2 data lines plus a ground line already wired. It can't be too hard to bit bang commands out.

-ShiftOut/ShiftIn? I've contemplated just shifting out a long string of data every second or so, and having each device extract it's info and pass it onto the next device. If this is the case, do I even need Arduino's?

-OneWire? Someone mentioned this might be a possibility, but it isn't easy to implement.

(edit)
-RS485? I've also heard good things about this protocol, such as it's reliability.
(/edit)

Can any kings (and queens!) of Arduino shed some light and wisdom of the optimal communications protocol I should be using? As long as it's fairly reliable (the occasional flicker is acceptable, it's not exactly mission-critical), I'm not too fussed.

Thanks in advance!
« Last Edit: November 08, 2011, 08:28:28 pm by Fudge » Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

SPI and shiftOut are essentially the same thing. You could use them and have shift regs at each sign. This will need 3 wires + GND/PWR.

I2C is not really designed for these lengths although there are extender chips. 2 wires + GND/PWR.

1-wire can be used here I think as long as you don't use parasitic power, I don't know much about it though. You would need some 1W port expander chips if that exist (I'm sure they do). 1 wire + GND/PWR.

You didn't mention async serial. 1 wire + GND/PWR.

RS-485 is not a "protocol", it's a spec for the physical interface. It is specifically designed for such projects. You could use it with SPI for example or with async serial.

So, if you are happy to have a RBBB at each sign I'd use RS-485 with async serial and multi-drop all the displays off the one line. 2 wires + GND/PWR.

That's my preferrence but an I2C or 1W guru will probably have different ideas smiley 

______
Rob
« Last Edit: November 09, 2011, 12:18:29 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5351
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My question is, what is the best way to control all these?
-SPI communication? The master outputs a long serial string for each bank. Each sign then extracts the information it requires and then sends serial to the next ardiuno.

SPI could work but you'll need to drop the speed way down because of the long wires.

-ShiftOut/ShiftIn? I've contemplated just shifting out a long string of data every second or so, and having each device extract it's info and pass it onto the next device. If this is the case, do I even need Arduino's?

If it was me I'd do it this way. Using the Arduino as an SPI slave is tricky. It's also easy to set the size of the word transmitted.

You'll need three wires. One to mark the start of a transmission (eg. when it goes low, that's the start), another one for clock and another one for data. After that it's mostly just a case of fiddling to find a clock speed that works reliably. You probably don't need to get each Arduino to pass the message along, just get them all to listen to the master directly. You probably ought to add transistors to the master Arduino's output pins to pull the lines low more reliably (depending on your cable).

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One good thing about using shiftOut() is that you don't even need Arduinos at the signs, just shift registers.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Madrid
Offline Offline
Sr. Member
****
Karma: 5
Posts: 481
Life isn't about finding yourself, life is about creating yourself!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Having those distances I would definitly go for RS485.

Take a look here:

http://real2electronics.blogspot.com/2009/09/arduino-and-rs485-english-version.html
Logged

Engineering is the art of
making what you want from
things you can get.

     

[SOLUCIONADO]

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As long as it's fairly reliable (the occasional flicker is acceptable, it's not exactly mission-critical), I'm not too fussed.

Async serial should do fine. You only need 2 wires (Tx from the controller to Rx on each slave) plus Gnd. In other words, all slaves will "listen" and the controller will "talk". You then just send something like "slave 3, show xyz".

A low baud rate will compensate for any capacitance on the line, and probably a RS485 driver chip at each end will help with the long distances.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the help everyone. I'm tossing up between serial and shiftout. Shifting bits would be easier and cheaper as I don't need more Arduino's, but I think serial is the way to go. In the future, if the signs ever get upgraded (LED Matrix anyone?), it would be nice to be able to send more than on/off signals. Plus, I won't have to run more cables that way smiley-grin

(edit)

Forgot to ask, are 485 driver chips a necessity? I imagine I only need one per serial "string", correct?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try it and see. I am guessing that after a few (tens of) meters the 5V signal might degrade (due to resistance) too low to register. But depending on the cables it might work. In which case serial and shifting would be the same cost.

Mind you, for 13m, it might just work "raw".
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes they are necessary if you are using RS485.

You need one transmitter for the master and a receiver for each slave. As they don't sell transmitters and receivers separately that means one "transceiver" for every Arduino (node).

If you use shift regs that will be 3 transceivers for every node.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This could be a job for "BreakWire LAN"!

http://sheepdogguides.com/arduino/aht8brklan.htm

... a simple "LAN" where just two wires go from machine to machine to machine, and the "LAN interface" is just two opto-isolators at each machine. Actually, for your app, you'd only need one opto isolator.

That's the good news.

The bad news is that "BreakWire LAN" is nothing more than a discussion paper, so far. But for your app, it would give you LOTS of what you need.

PS- sorry about the typo that was in the URL until a moment ago, and, in light of a comment below, which is quite right!, I should stress that this is a very, very simple "LAN". It won't do to run the Toyota assembly line, but it might give a hobbyist some fun! It may be that going with the RS-485 interface discussed below has advantages over what I have suggested.... I'm not sure if it allows the sort of things that "BreakWire" allows... i.e. just two wires between nodes, peer-to-peer, and no (fatal) problems in the event of two clients trying to transmit at the same time.
« Last Edit: November 14, 2011, 09:05:26 am by tkbyd » Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
"BreakWire LAN"
Interesting, a lot of limitations but has potential for a simple network. I like that the nodes are isolated.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As a proof of concept I wired together two Arduinos using RS485 transceivers (LTC1480CN) which cost me around $6 each.

Assuming for the moment that I had one transmitter and multiple receivers I set up the receivers for "receive only" (by grounding the DE pin).



Master (controller) sketch was:

Code:
#include <NewSoftSerial.h>

NewSoftSerial rs485 (2, 3);  // receive pin, transmit pin

void setup()
{
  rs485.begin(28800);
  pinMode (4, OUTPUT);  // driver output enable
  digitalWrite (4, HIGH);  // enable sending
}

long counter;

void loop()
{
  rs485.print (++counter, DEC);
  rs485.println (" - hello world.");
  delay (500);
}  // end of loop

Receiving end:

Code:
#include <NewSoftSerial.h>

NewSoftSerial rs485 (2, 3);  // receive pin, transmit pin

void setup()
{
  Serial.begin (115200);
  rs485.begin(28800);
}

void loop()
{
 if (rs485.available ())
   Serial.print ((char) rs485.read ());
}  // end of loop

That appeared to work fine at 28800 baud, which should be fine for sending messages to signs. I had 20m of cable (just ordinary speaker cable, not twisted, not shielded) in the middle, which is well over what the OP wanted between controller and slave.

My only slight doubt is that the transceiver was supposed to work on 3.3V, with an absolute maximum rating of 7V VCC, and I was putting 5V into it.

If you needed to get responses back it would be a bit more complex, but you could address each slave and do something like "slave 3, what is the temperature?" and then turn off output enable at the master end, and turn on output enable at the slave end, for the duration of the response.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Further tests reveal that with the 20 m cable, I could crank the baud rate up to 57600, seemingly without error. Of course, a noisy path might influence that a bit.

Also it's worth noting that you connect A to A, and B to B (pins 6 and 7) together when wiring the transceivers up. You don't swap them over like you do with Rx and Tx.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In you should be able to do 10Mbps with a short cable like this (even up to 35Mbps according to what you read and what drivers you use) and 100kbps for lengths up to 1.2k. So it's the Arduino that will struggle, not the drivers although the cable presumably makes a difference as well.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well even normal serial maxed out to 115200 baud is only 115.2  Kbps, well short of 10 Mbps.
Logged

Pages: [1] 2   Go Up
Jump to: