Pages: [1] 2   Go Down
Author Topic: Connection multiple arduinos via RS485  (Read 4818 times)
0 Members and 1 Guest are viewing this topic.
Portugal
Offline Offline
Edison Member
*
Karma: 28
Posts: 1436
Tomorrow I will know a BIT more than yesterday
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone have some shematic how to connect multiple arduinos using rs485 protocol.I want to connect 4 arduinos but I cant find a very good example how can I use max485
Logged

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.gammon.com.au/forum/?id=11428
Logged

Portugal
Offline Offline
Edison Member
*
Karma: 28
Posts: 1436
Tomorrow I will know a BIT more than yesterday
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Nick thanks for your answer. I that shematic there are just a master and a slave, it is a start point to me but I need 4 arduinos, can I just hook it on the same line A B using the same circuit?
Doesn't I need to add a terminator resistor on the last one?
Logged

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


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

I can't believe you couldn't find a 100 examples with google.

No matter how many nodes you have on a multi-drop bus all As connect together and all Bs connect together. You should have 120R terminating resistors at each end of the bus as well (if the speeds are high). Also failsafe resistors can be added as Nick shows but most modern transceivers have this feature inbuilt.

What speed and distance will you have?

Quote
rs485 protocol
RS-485 is not a protocol, it's an electrical specification. You will have to design and write your own protocol. This will either be easy or very difficult depending on the robustness you need.

______
Rob
« Last Edit: May 14, 2012, 08:23:10 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Portugal
Offline Offline
Edison Member
*
Karma: 28
Posts: 1436
Tomorrow I will know a BIT more than yesterday
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The speed I will use is 9600 bps and the distance will be approximately 150 meters between each arduino.Thanks for you well explanation about rs485, I will study more precise the implementation of it
Logged

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


Offline Offline
Sr. Member
****
Karma: 1
Posts: 314
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you only want to connect 4 Arduinos, what about using I2C?

I am sure there are many reasons not to us I2C, distance being one of them but if it will work, it is cheap and easy.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 443
Posts: 23842
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maxim has a good application note on doing what you want with RS485 and some chip suggesions for doing it.

http://www.maxim-ic.com/app-notes/index.mvp/id/723
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

Quote
I2C
Quote
150 meters
Not normally possible although there are driver chips that may make it although I think 50m is about their limit.

In short RS-485 is made for this, may as well us it.

@HugoPT
You don't necessarily have to address each Arduino, you can use a publish/subscribe model whereby you send all data to the network (with a "data type" identifier) and each Arduino uses what it wants.

______
Rob
« Last Edit: May 14, 2012, 05:21:13 pm by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Sr. Member
****
Karma: 1
Posts: 314
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My bad.  The distance was not in the original description of the problem and I did not pick up on the distance in the later post.
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 24
Posts: 1766
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone running other protocols on top of RS485??

This is interesting: http://real2electronics.blogspot.it/2009/09/arduino-and-rs485-english-version.html

I am probably going to work on implementing this with these:  http://goo.gl/S1lFR 

I understand RS-485 needs a common ground (that the differential is related to)..  Can this just be "local Green Ground" in a few different rooms? Buildings? Or does the wiring have to include 1 or more ground conductors?

Anyone using CAT5 for this?  2-pair telephone wire? 

DISCLAIMER: Mentioned stuff from my own shop...
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Portugal
Offline Offline
Edison Member
*
Karma: 28
Posts: 1436
Tomorrow I will know a BIT more than yesterday
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
I understand RS-485 needs a common ground (that the differential is related to)
Is this really true?
From what I had read the rs-485 just need 2 wires A and B.The ground is just in case we use a long link right?
I found this after a brief search
Quote
Connecting a multidrop 485 network. The EIA RS-485 Specification labels the data wires "A" and "B", but many manufacturers label their wires "+" and "-". In our experience, the "-" wire should be connected to the "A" line, and the "+" wire to the "B" line. Reversing the polarity will not damage a 485 device, but it will not communicate. This said, the rest is easy: always connect A to A and B to B.

Signal ground, don't forget it. While a differential signal does not require a signal ground to communicate, the ground wire serves an important purpose. Over a distance of hundreds or thousands of feet there can be very significant differences in the voltage level of "ground." RS-485 networks can typically maintain correct data with a difference of -7 to +12 Volts. If the grounds differ more than that amount, data will be lost and often the port itself will be damaged. The function of the signal ground wire is to tie the signal ground of each of the nodes to one common ground. However, if the differences in signal grounds is too great, further attention is necessary. Optical isolation is the cure for this problem. Contact B&B Technical Support for more details.
« Last Edit: May 15, 2012, 06:15:27 am by HugoPT » Logged

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 24
Posts: 1766
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, Hugo...

I'll have to do some testing when I get this going.  I'm mostly interested in running in a house and close by buildings like a barn etc., running from the same AC distribution transformer. 

The "Neutral" might bounce a couple of volts with unbalanced loads, but the Green Ground as I've tested it, should be less different than that.

I want to be able to locate a few Arduinos in appropriate locations and coordinate them from one Arduino or a PC.

A friend and I are working on shields for a Mega2560 that would have several ports for Home Automation, including RS-485, X-10 etc.. and another with WiFi and several other RF communications standards (http://davehouston.org/Zarduino.htm  - Mega Boards) .  But I want to get a simple multi-Arduino RS-485 system running sooner..
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

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

Quote
Is this really true?
You bet.

Quote
The ground is just in case we use a long link right?
Wrong.

Quote
does the wiring have to include 1 or more ground conductors?
I'm not completely sure, if there is a common ground connection maybe but no way I would trust a connection via who-knows-what, the "ground" could be several volts different. 485 is very forgiving in this regard (that's one reason it's the default standard) but every system I've every seen uses a ground wire in the cable.

AFAIK two wires will usually work but it's not best practice.

Quote
Anyone running other protocols on top of RS485??
I'm working on one now, a ring network of Mega1284s.

Quote
Anyone using CAT5 for this?
I'm using cat5/6, I need 4 conductors for signal and that leaves 4 to run power.

Quote
But I want to get a simple multi-Arduino RS-485 system running sooner..
I'm designing a PCB for a prototype, my network needs two serial ports per node though hence my use of the 1284s. The plus side is reliability, with a redundant ring network you can cut the wire with no appreciable affect on the traffic.

______
Rob
« Last Edit: May 15, 2012, 07:03:51 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

Following on from the above, I know everyone uses multi-drop for control networks but I have these issues with that topology

•   A single short circuit and the entire network is down.
•   A single rogue processor and the entire network is down.
•   A cut wire and some or all of the network is down.
•   Has to be either master-slave or use difficult bus-clash and arbitration techniques.
•   If the master dies the entire network is down.

A redundant-ring network has none of those problems, any of the above faults have little or no effect on the network.
It does however require twice as many wires and does insert delays in the data transmission. As I’m more interested in reliability than absolute speed I’ve decided to use a ring topology, despite spending a lot of time designing a multi-drop version at first.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 24
Posts: 1766
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Rob,

I know you were working on an earlier one... The process you went thru is helping me understand.

Are you using RS-485 4 -wire (Nodes transmit on 1 pair, receive on the other)?   

Years ago I worked on IBM Token Ring networks.  After a lot of thrashing about GM MAP, Ethernet etc, we went with Token Ring for a new Semiconductor factory.  Worked out well, with multiple levels of rings..

I was always uncomfortable with the concept of MAP as a peer-network.  Who's in charge in a big system?  I used to say, "You can't get 500 guys and build a bridge when you are all peers". I got yelled at by the Manufacturing Strategy guys at headquarters. But you know what?? MAP died, along with DISCO. 

Can you point to any of your current work/ideas?? 
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Pages: [1] 2   Go Up
Jump to: