Go Down

Topic: Bus network, multiplexing signals to (theoretically) infinite arduinos (Read 4809 times) previous topic - next topic

manutenfruits

Hey!

I want to be able to communicate several arduinos (I'm talking about 60+ maybe) using a single bus, maybe two. In which way is this possible? I'm going to design it using a central node in charge of all the communications, that sends bits to one arduino and gets replies.

The problems here are in communication. I need to avoid collisions, and I thought that different baud rates would help me do the multiplexing, am I right? But there is still a problem: the main receiver needs threads to listen to every single frequency. I would like to keep it on the cheap, avoiding to buy extra components, and making it completely open source.

I've heard of I2C, but I'm not sure how it works, how expensive the modules are and the "opensourceness" of the protocol itself.

Thanks!

fungus


Hey!

I want to be able to communicate several arduinos (I'm talking about 60+ maybe) using a single bus, maybe two. In which way is this possible? I'm going to design it using a central node in charge of all the communications, that sends bits to one arduino and gets replies.



What's the $ budget for this?

How much bandwidth does it need?
Advanced Arduino

nickgammon

I have a writeup on I2C here:

http://www.gammon.com.au/i2c

One I2C bus can support 119 devices. Any of them can be a master or slave, and you can broadcast. Of course they can't do that all at once, but there is provision for collision detection. If one is the master and sends a query and gets a reply, there should be no collision problems.

There is no extra hardware required (the hardware is built into the Arduino). The source is open, the required library comes with the IDE.

Quote
I thought that different baud rates would help me do the multiplexing, am I right?


No, I don't see how that helps in any way.

Quote
... the main receiver needs threads to listen to every single frequency.


I'm not sure what you mean by that. This is not consistent with:

Quote
I'm going to design it using a central node in charge of all the communications, that sends bits to one arduino and gets replies.


There are other design considerations, like the cable run length, how much data you have, and so on. Obviously if you have 60 devices all wanting to "talk at once" you may have problems, the issue is what sort of delay you can tolerate in servicing them.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

CrossRoads

Use RS485. All parts connect to master via twisted pair & $4 RS485 transceiver.Master talksa, all listen; if a unique slave is addressed,it responds.
For example
http://cds.linear.com/docs/Datasheet/1480fa.pdf
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

manutenfruits

Quote

Quote
I thought that different baud rates would help me do the multiplexing, am I right?


No, I don't see how that helps in any way.


Exactly, I was thinking that has to do with FDM, but that's analog stuff, there would be collisions. Just realised that.

Quote

What's the $ budget for this?

How much bandwidth does it need?


The budget is the lower the better. I can afford to spend more money on the main node, but I was thinking about nodes for less than $10. I don't need too much bandwidth at all, just about 10 bytes request and 10 bytes reply.

The project is oriented to home automation, and I have discarded wireless solutions because of the price and it looks more "robust" if I build it on a bus.

Quote

Any of them can be a master or slave, and you can broadcast. Of course they can't do that all at once, but there is provision for collision detection. If one is the master and sends a query and gets a reply, there should be no collision problems.


There are two typical scenarios. One scenario would be the master node requesting to X node to turn on/off X pin, and a confirmation (a bulb might be broken, but that's a different topic). The other one would be just asking whether X pin on X node is on or off (check if I left the lights turned on), and the answer. There would be no collision if I don't make a second request until I receive ACK for the previous reques (or timeout), but I think that being able to multicast that signal and get replies from them all would make the interface faster, and the system more robust. Of course that involves much more work, but I don't really know how much hard would that be.

Thanks!

fungus



The project is oriented to home automation, and I have discarded wireless solutions because of the price and it looks more "robust" if I build it on a bus.



OK, how long will the wires be...?
Advanced Arduino

manutenfruits




The project is oriented to home automation, and I have discarded wireless solutions because of the price and it looks more "robust" if I build it on a bus.



OK, how long will the wires be...?



Well... It's a three story house, and I'm too bad measuring distances. It will be ramificated most likely (if there is no problem with that), and the longest distance from point to point would be... lets say... 30 meters (100 feet)?

nickgammon

Well that rules our I2C unless you get a repeater that works over long distances. Although the concept could probably be used, if slowed down somewhat.

Some variation of async serial is probably more likely to work, where the slaves have the transmit (to master) lines as high impedance until addressed.


Use RS485. All parts connect to master via twisted pair & $4 RS485 transceiver.Master talksa, all listen; if a unique slave is addressed,it responds.
For example
http://cds.linear.com/docs/Datasheet/1480fa.pdf


Sounds like the sort of thing.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

graynomad

@manutenfruits
I've just finished the PCB layout for a board that will plug onto an Arduino and convert the I2C to RS-485 async then broadcast to as many as 255 other Arduinos.

Unfortunately I haven't written a single line of code yet :) so it won't be ready any time soon. What's your time frame?

_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

manutenfruits

Quote

Use RS485. All parts connect to master via twisted pair & $4 RS485 transceiver.Master talksa, all listen; if a unique slave is addressed,it responds.


Yeah I guess that's just the kind of thing I was looking for. What I first had in mind was just connecting the TX and RX of the ATMegas to the bus, and to the computer. I'm not too experienced on this, but would that work with a computer with a RS-232 serial port directly? I'm talking about addressing the slaves (that's just protocol stuff, I guess), and send bits with a twisted pair. And I guess I could just use the pair that is not used in any UTP cable in an existing Ethernet installation (I'm not taking into account switches for now).

In case I want to use just RS-232 serial port, that would save me the RS-485 transceiver. Because apart from the length constraint, I need help to see the advantages. :)


@manutenfruits
I've just finished the PCB layout for a board that will plug onto an Arduino and convert the I2C to RS-485 async then broadcast to as many as 255 other Arduinos.

Unfortunately I haven't written a single line of code yet :) so it won't be ready any time soon. What's your time frame?

_____
Rob


I'm sorry, I don't get your point  :). I still need to see the advantages of I2C and how it really works, different from RS-485 or any other protocol (just got way more information at the same time that I can process). What application would you give to such adapter?

bubulindo

You can also mix it up... for example:

You have a 3 story house... say that 20 Arduino will be on each floor (Can't imagine what all of them would do). You can connect one on each level to the ethernet network, and then those would be a sort of gateway to the rest of the arduinos in that level. You could also include some XBees for stuff not easily wired.

Is the house built already? Or are you building it and can wire your I2C/RS485/whatever network on it? Because wiring all this around the house if it is already built will probably come out more expensive (time and materials) than getting some Ethernet shields and XBees (or clones).
This... is a hobby.

manutenfruits


You can also mix it up... for example:

You have a 3 story house... say that 20 Arduino will be on each floor (Can't imagine what all of them would do). You can connect one on each level to the ethernet network, and then those would be a sort of gateway to the rest of the arduinos in that level. You could also include some XBees for stuff not easily wired.

Is the house built already? Or are you building it and can wire your I2C/RS485/whatever network on it? Because wiring all this around the house if it is already built will probably come out more expensive (time and materials) than getting some Ethernet shields and XBees (or clones).


Haha, I went too excited whenever I said 60 arduinos  :smiley-sweat: . I'm rethinking it and I think that one per room would do the trick if I don't have to wire up too much.

About the UTP cables I'm talking about just using the unused pair in UTP cables because it's already deployed (OK, it's not, but that would also help me deploy ethernet across the house). It's just about serial, no actual IP or anything applies here. I know it's hard to wire all that up, I wired already like half the house, but if that works I don't mind doing the rest. XBees are more expensive for this matter if I'm considering wiring up the house already.

Also, I won't be using arduinos, but rather the bootloaders on custom made PCBs, I need to save space and money on that.

graynomad

#12
Oct 24, 2011, 07:07 am Last Edit: Oct 24, 2011, 07:09 am by Graynomad Reason: 1
Quote
In case I want to use just RS-232 serial port, that would save me the RS-485 transceiver.

One thing to realize is that RS-232 and 485 are not protocols, they are specifications for voltage levels, speeds, wire lengths etc.

Whatever you decide on to cannot directly connect the serial port to other ports in such an environment, you do need transceivers of some kind.

RS-485 is generally recognized as being the most appropriate for several reasons including

a) Balanced line, not particularly upset by different GND potentials or noise.
b) Long runs, can go up to 1.2k, IIRC RS-232 is limited to 20m although I've seen it go a lot longer.
c) Transmitter disabling, with 485 you can disable the transmitter, this allows a multi-drop topology (essentially all nodes connected to one wire). RS-232 cannot do this and therefore can only be used for point-to-point.

So, in a nutshell RS-232 is not suitable, RS-485 is not only suitable but designed specially for just this sort of application.

Quote
I'm sorry, I don't get your point

No matter what transmission medium you choose you still have to design a protocol that involves either a master-slave arrangement where the master polls each slave in sequence (easy), or a multi-master setup that requires a lot of work to detect clashes etc (hard).

What my gadget is supposed to do is remove just about all that protocol work, you simply send data using the wire library and it is received by all Arduinos. It's a sort of "virtual I2C" link that implements a low-level protocol (the hard part), you still have to provide a simple layer above that.

Sorry if I've scared you off :), you can implement your own protocol fairly easily using RS-485 and a master-slave setup, however if you want a robust network then that's maybe just 30% of the job.

It depends largely on just how robust (reliable) you want the system to be.
______
Rob


Rob Gray aka the GRAYnomad www.robgray.com

manutenfruits

Quote

No matter what transmission medium you choose you still have to design a protocol that involves either a master-slave arrangement where the master polls each slave in sequence (easy), or a multi-master setup that requires a lot of work to detect clashes etc (hard).


In sequence? Can't I just write on the bus "Hey, if you are Arduino2, tell me the status of your pin 3", and then Arduino2 writes on the bus "Here Arduino2: whoever asked for this, my pin 3 is ON"? The slaves don't need to communicate between each other, I can't think of any scenario.


Quote

It depends largely on just how robust (reliable) you want the system to be.


Well, it's my house, the most reliable the better. At first I may just control lights and get warnings about water leaks or anything like that, but going downstairs to close the garage is something I also had in mind, and I wouldn't like the door to be opened in the middle of the night for no reason :)

What kind of multi master setup would be like? What benefits does that give me?

graynomad

#14
Oct 24, 2011, 07:42 am Last Edit: Oct 24, 2011, 07:45 am by Graynomad Reason: 1
Quote
What kind of multi master setup would be like?

I think you should steer clear of multi-master, it is potentially more robust depending on the way it's done (that's why I'm using it for my gadget) but it can be a real can of worms.

Quote
Can't I just write on the bus "Hey, if you are Arduino2, tell me the status of your pin 3", and then Arduino2 writes on the bus "Here Arduino2: whoever asked for this, my pin 3 is ON"?

That's exactly how you would do it, as long as there is only a single master asking the questions.

Quote
In sequence?

There has to be some sequence, no point asking questions to random nodes.

Quote
I wouldn't like the door to be opened in the middle of the night for no reason

That's why you need a reliable protocol. If the difference between "turn heater on" and "open garage door" is say just a single bit and the bit gets flipped in transmission because of noise you have an open door and a cold room. Also the master now has the wrong idea about the system state.


______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up