Pages: [1]   Go Down
Author Topic: Communication over a long distance using cable.  (Read 1099 times)
0 Members and 1 Guest are viewing this topic.
Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Guys, I need help.
I want to connect several Arduinos with cable. There will be one master and several slaves. The distance between master and slave will be about 30 meters. I know that I can't use I2C, so I will use serial (RX & TX) and an RS485 communication (with MAX 485). Also, the slaves should read and write data to master, and master should read data from all slaves, and it should write data to every slave. The problem is that for example I want to send data to slave no. 2 but I don't want to send it to slave no. 3.

Is it possible to send data from the master to only one of several slaves? In I2C I could use an adress of the device, but I can't do this with RS485... Am I right?

How to solve that problem?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can define a protocol that includes a header with an address and length.  The slaves not addressed could ignore the remainder of the message.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Devon UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
If you dont ask you will never know
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.
Here is a link that's as good as they come.
http://www.billporter.info/easytransfer-arduino-library/
Easy to understand while adaptable with several nodes.

Regards Antony
Logged

Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys.
I came up with an idea, that I can send data in specified format, for example if the target of the data sent by the master is the device 1 than te data should look like

dev1:data

Then, some logic in the device 1 uC will divide this to "dev1", ":", "data", and check whether the first element equals "dev1" (this will be specified for every device). If so, the data will be used.

Will this solution work?
If it will, will it be efficient? This will take several lines of code...
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, thats exactly what John suggested.
Logged

Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I thought John was saying about some sort of already written protocol.
Thanks!
Logged

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

Depending on the importance of the data it's also common to add various checks and balances to detect errors. For example here's a frame format I'm currently working on



You probably don't need all that but a checksum would be a good idea.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I've already done the schematic, now I'm going to write the code. I used the link given by antony1876 to attach some resistors.

Now there is another question. What sort of cable would you use? Is it a good idea to use a simple UTP cable? Should it be shielded or not? Will this cable work for a 200 meter connection?
Logged

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

Quote
I used the link given by antony1876 to attach some resistors.
smiley-confuse What has Easytransfer got to do with resistors?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I followed the links below and I found somewhere a PDF "Designing RS-485 Circuits" smiley
Logged

Pages: [1]   Go Up
Jump to: