Some networking fun: 28 arduinos linked in a network

You can use RS-485 with nodes daisy-chained, with that topology you get 4000' for each link. Normally however it is used as a bus so the 4000-5000' is a max, and that's at ~100kbps.

I know nothing about Ethernet so won't argue for or agin it, except to say that it has to be more expensive I would think.


Rob

No matter what transport system you use (Serial, Network, RF) there could be a lot of traffic (depends on switch frequency) and I worry your going to have either a lot of missed data or network collisions.

The most robust and extendible network for noisy environments is CAN, but it has a steep learning curve. It is an arbitrated, error-checking, asynchronous messaging system that runs at up to 1Mbit over km lengths. Messages normally are continuously resent until correct receipt is acknowledged. It is used in automobiles, earth moving equipment, medical devices, wheelchairs, aerospace. There is a "basic" CAN standard and a wide variety of higher-level overlays that while not easy to implement can provide even higher levels of protection. For example, in the most safety critical flavor of CANopen (think overhead load cranes or atomic submarines) both the message and its complement are sent so that, over and above CRC and so on, if these two don't match the message is rejected. But that's extreme; for most applications, even a wheelchair who's user can't jump out if there's a problem, basic CAN, properly implemented, is very reliable. If you're going to use your network to control machinery and if errors induced by factory noise might put people at risk, I would seriously consider learning CAN. If your network is only going to be monitoring information, then RS-485 or ethernet should be fine. Ciao, Lenny

Very intersting project. I hope you'll keep us updated :slight_smile:

My 2 cents worth of advice is about data collection: excel is going to prove a very limiting choice IMHO. You should plan for a data collection program to be run on a (possibly industrial type) pc with an ethernet port or a rs485 interface card, that would put the read values into a database.
A simple table with timestamp, sensor number and sensor value would probably be enough, at least at the beginning. From there on you have endless possibilities regarding graphs, averages, etc.

(I'm sure there are countless commercial packages that can do this already - haven't done any search yet - but as always it comes down to choosing the balance point between time-to-completion and DIY fun :wink: )

RyanF121:
Can I get a small list of pros and cons of each of the three connection types you posted?

RS-485
Least expensive. Assuming you use proper cables, you will be able to span the distance you mentioned (3132 feet) using a "low" baud rate. Differential signal provides a reasonable immunity to electrical noise. You are responsible for the on-wire signal. Need a CRC on that packet? You do it. Need a way of addressing nodes? You do it.

Ethernet
Most expensive. There is no way you can cover that distance without repeaters or using fiber optic cable. Differential signal provides a reasonable immunity to electrical noise. Ethernet controller is responsible for the on-wire signal.

CANBUS
A bit more than RS-485. Assuming you use proper cables, you will be able to span the distance you mentioned (3132 feet) using a "low" baud rate. Highly resistant to electrical noise and cable faults. CANBUS controller is responsible for the on-wire signal.

@LROBBINS' reply above is spot-on (with one exception: you can have high speed or long distance but not both).

If "CRC", "address", or "state machine" are unfamiliar terms, Ethernet or CANBUS are better choices unless you have the time and inclination to learn the gritty details about network protocols.

If you can afford it, fiber optic cable is usually a slightly better choice in a factory. All three can be made to work over fiber optic cable.

Thanks everyone. I have decided on ethernet. We already have a 24 port gigabit switch that we can mount in the ceiling of the center of the building. From there we can go the furthest distance the ethernet cables will go and then just use two wires from the arduino to the switch. Simple, right? I have been playing with some of the stuff at home with our apple time machine to connect the arduino to the LAN, but for some reason the computers don't recognize it as a web page even though I'm running the examples included in the arduino programming software. Is this due to the network collisions? Its using just 8' of cable right now. And one more issue, my 2nd arduino doesn't want to accept software. I select upload and the computer compiles the program and starts uploading but stops and this shows up:
avrdude: stk500_getsync(): not in sync: resp=0x00
Does anybody know how to fix this issue? I have re-installed the driver repeatedly but still cant get it to work.

I have just bought an e-book about the arduino. Up to this point I have been learning by reverse-engineering the code and haven't learnt much. Now that I have some literature to go by I might actually be able to learn this.

In the arduino IDE have you looked at Help > Getting started?

RyanF121:
for some reason the computers don't recognize it as a web page even though I'm running the examples included in the arduino programming software.

What do you mean by "computers don't recognize it as a web page"? Please explain what you're doing, in as much detail as possible. Are you trying to access the Arduino with a browser? Which browser? What URL are you entering? What happens on the screen - does the browser connect? Does it get an HTTP response back? Does the HTTP response include a page? Does the page render? If not, what is in the page source?

RyanF121:
Is this due to the network collisions?

No.

Do you have a proxy ? Is the browser configured to use it ? If yes, try to select "direct connection to internet". Ask the company sysadmin if you need help with these details.

PeterH:
What do you mean by "computers don't recognize it as a web page"? Please explain what you're doing, in as much detail as possible. Are you trying to access the Arduino with a browser? Which browser? What URL are you entering? What happens on the screen - does the browser connect? Does it get an HTTP response back? Does the HTTP response include a page? Does the page render? If not, what is in the page source?

I mean that the computer (a mac running google chrome)doesn't recognize it as being a valid address. I load the original example with the arduino software and change the IP address that it uses to 192.168.1.187. The shield flashes like it is connected to the network but when I enter the IP address in the browser it doesn't even act like it found a server on its IP.

tuxduino:
Do you have a proxy ? Is the browser configured to use it ? If yes, try to select "direct connection to internet". Ask the company sysadmin if you need help with these details.

There is no proxy around my house and our browsers work just fine although verrrrrrrrrrry slow due to the fact we live in the middle of nowhere. I am currently using an Apple Time Machine for the network switch, so no issues with LAN speed. I can't contact the sysadmin without looking like a seriously mentally ill child. Reason why? I am the sysadmin around the house. I would have to talk to myself. I already have enough issues related to aspergers and autism, the last thing I need is to be seen talking to myself.

"Please contact your system administrator"

I love that, it gets MS off the hook and tells me that I'm out of my depth :slight_smile:


Rob

RyanF121:
I mean that the computer (a mac running google chrome)doesn't recognize it as being a valid address. I load the original example with the arduino software and change the IP address that it uses to 192.168.1.187. The shield flashes like it is connected to the network but when I enter the IP address in the browser it doesn't even act like it found a server on its IP.

Exactly what URL are you entering in the browser's address field?

RyanF121:
Thanks everyone. I have decided on ethernet. We already have a 24 port gigabit switch that we can mount in the ceiling of the center of the building. From there we can go the furthest distance the ethernet cables will go and then just use two wires from the arduino to the switch. Simple, right? I have been playing with some of the stuff at home with our apple time machine to connect the arduino to the LAN, but for some reason the computers don't recognize it as a web page even though I'm running the examples included in the arduino programming software. Is this due to the network collisions? Its using just 8' of cable right now. And one more issue, my 2nd arduino doesn't want to accept software. I select upload and the computer compiles the program and starts uploading but stops and this shows up:
avrdude: stk500_getsync(): not in sync: resp=0x00
Does anybody know how to fix this issue? I have re-installed the driver repeatedly but still cant get it to work.

Ok I don't understand "...and then just use two wires from the arduino to the switch", can you explain? What type of wires and what kind of communication are they carrying (Ethernet, extension with cable between the arduino and the ethernet shield, ?)?.

You should be aware that standard for ethernet cables says 100 meter max length. It is not a hard cutoff but considering it is in a factory maybe interference will actually be a problem.

The gigabit switch is overkill but if you already have it and no use for it...
10 Mbps is enough for this task, that's why I urge you to look into 2nd hand market. Actually seems hard to find pure 10Mbps but 10/100Mbps seems cheap also. The problem is the shipping so if you can find any local supplier that is good. Looked at an ebay auction, 3 NETGEAR FS524. That is 3x 24 ports. Start price is 30 bucks and no bids yet. As an example.

I haven't tried out my ethernet shield yet but remember that it is far from a full blown web server. E.g. it says at the product page that it can handle "up to" 4 sockets simultaneously. If all the sensor arduinos reports their results via TCP it will quickly fill the central arduino. A PC in the center is a requirement.

RyanF121:

tuxduino:
Do you have a proxy ? Is the browser configured to use it ? If yes, try to select "direct connection to internet". Ask the company sysadmin if you need help with these details.

There is no proxy around my house and our browsers work just fine although verrrrrrrrrrry slow due to the fact we live in the middle of nowhere. I am currently using an Apple Time Machine for the network switch, so no issues with LAN speed. I can't contact the sysadmin without looking like a seriously mentally ill child. Reason why? I am the sysadmin around the house. I would have to talk to myself. I already have enough issues related to aspergers and autism, the last thing I need is to be seen talking to myself.

I was thinking about the factory... I didn't understand you were experimenting a thome. Sorry :cold_sweat:

I've been thinking of the network control here, and the cost of the devices. Ethernet simplifies some things, but is expensive, and still leaves you with a bit of programming to do.

Can the nodes be polled, or do they react to an event to transmit data?

If they can be polled, I believe I'd :

  • Buy $4 RS-485 boards off eBay
  • Give each node a node-id.
  • Put each node in listen-mode (in RS485 terms)
  • Use EasyTransfer for the transfers back & forth, as this simplifies programming, adds checksums etc. It also simplifies management of data types, you can send an arbitrary struct.
  • Have the Master send a package to each node in turn, then have Master go to "listen mode".
  • A node having received "his" package prepares his return data, enables transmit mode, sends data, and goes to "listen" again.
  • The master receives data, handles this in an appropriate way, enables transmit, and repeats.
  • The master needs to handle a time-out
  • You might get electrical problems on the RS485 bus if a node gets stuck in transmit enable mode.

btw: the avrdude issue usually means that you have something hogging the serial port on the Arduino - a device is hooked up to TX/RX and conflicts with the IDE trying to use the same pins.

What you describe is standard procedure for an RS-485 bus protocol.

You might get electrical problems on the RS485 bus if a node gets stuck in transmit enable mode.

Or a shorted wire, cut wire etc etc. This is a potential problem with a bus topology.

You'd better write reliable code :slight_smile:

What's your time frame to get this all working?


Rob

PeterH:
Exactly what URL are you entering in the browser's address field?

I am entering 192.168.1.187 and the browser adds the http:// part automatically if the address I enter doesn't show up. I have also entered some other things into the IP address field within the code including the endings 1.177 and 1.30

Aqualize:
Ok I don't understand "...and then just use two wires from the arduino to the switch", can you explain? What type of wires and what kind of communication are they carrying (Ethernet, extension with cable between the arduino and the ethernet shield, ?)?.

You should be aware that standard for ethernet cables says 100 meter max length. It is not a hard cutoff but considering it is in a factory maybe interference will actually be a problem.

The gigabit switch is overkill but if you already have it and no use for it...
10 Mbps is enough for this task, that's why I urge you to look into 2nd hand market. Actually seems hard to find pure 10Mbps but 10/100Mbps seems cheap also. The problem is the shipping so if you can find any local supplier that is good. Looked at an ebay auction, 3 NETGEAR FS524. That is 3x 24 ports. Start price is 30 bucks and no bids yet. As an example.

I haven't tried out my ethernet shield yet but remember that it is far from a full blown web server. E.g. it says at the product page that it can handle "up to" 4 sockets simultaneously. If all the sensor arduinos reports their results via TCP it will quickly fill the central arduino. A PC in the center is a requirement.

By two wires I mean having literally two wires going to a switch. These will most likely be some stranded shielded wire connecting the arduino to a relay, photo eye, switch, etc. I understand I will have to deal with relay jitter but that can be done by putting a half second delay in after it reads the contacts open/close.

tuxduino:
I was thinking about the factory... I didn't understand you were experimenting a thome. Sorry :cold_sweat:

Yep, I plan on doing all my first tests at home and then bringing it out to the company.

thoger:
I've been thinking of the network control here, and the cost of the devices. Ethernet simplifies some things, but is expensive, and still leaves you with a bit of programming to do.

Can the nodes be polled, or do they react to an event to transmit data?

If they can be polled, I believe I'd :

  • Buy $4 RS-485 boards off eBay
  • Give each node a node-id.
  • Put each node in listen-mode (in RS485 terms)
  • Use EasyTransfer for the transfers back & forth, as this simplifies programming, adds checksums etc. It also simplifies management of data types, you can send an arbitrary struct.
  • Have the Master send a package to each node in turn, then have Master go to "listen mode".
  • A node having received "his" package prepares his return data, enables transmit mode, sends data, and goes to "listen" again.
  • The master receives data, handles this in an appropriate way, enables transmit, and repeats.
  • The master needs to handle a time-out
  • You might get electrical problems on the RS485 bus if a node gets stuck in transmit enable mode.

btw: the avrdude issue usually means that you have something hogging the serial port on the Arduino - a device is hooked up to TX/RX and conflicts with the IDE trying to use the same pins.

I was orrigionally thinking of making them all react to the switch closing but now that you mention it, it might be a better idea to have the arduinos count for 5 min then send and stagger the times they send out so the main computer isn't overloaded.
I already have some of the stuff for the ethernet setup. I was searching around the office there and I found some spools of ethernet cable. The previous computer technician always had a good stock of everything including a large box of canned air. I guess his willingness to be ready turned out to be good for this project.

Graynomad:
What you describe is standard procedure for an RS-485 bus protocol.
What's your time frame to get this all working?


Rob

I have no time frame to get this done. For all that matters I could put this off for several years and get by with it.

Another idea I have been thinking of and have mentioned above is using a Mux shield. I can run cables a long distance from the machine and put a slightly higher voltage into the lines like 7v so the wires' resistance brings it down to 5. From the Mux shield I can use the arduino to output a serial signal to the PC and have the computer do the work or I could go from the arduino to an ethernet shield to the LAN and have the arduino serve a webpage.

RyanF121:

PeterH:
Exactly what URL are you entering in the browser's address field?

I am entering 192.168.1.187 and the browser adds the http:// part automatically if the address I enter doesn't show up. I have also entered some other things into the IP address field within the code including the endings 1.177 and 1.30

Presumably we should expect the Arduino to be accepting incoming TCP connection on port 80 at that IP address, but do you know for sure that the Arduino has bound to that address and is listening for connections on port 80?

What does the browser do when you try to open http://192.168.1.187/ in the browser? Does it give you an error message, and if so what message?