Pages: [1]   Go Down
Author Topic: Full duplex between arduinos over about 60 feet of distance  (Read 1215 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I believe that what I need is either RS-485 or RS-422, though I'm not clear on the difference as one web site intimates that with two of their RS-485 to UART boards I can get  the equivalent.

In any event I want to have two arduinos be able to communicate back and forth between each other (just two, point to point, no daisy chaining), over a distance of about 60 feet or more, in a somewhat noisy automotive environment.  115kbs is plenty of speed; 9600 might even be fast enough.  My aim is mainly to have one arduino act as a monitor and UI (simple 2-line screen, and some buttons) for another arduino that does the real processing and controls a pump.  I'll work out a very simple serial protocol. 

So do I need maybe two of this sort of adapter on each arduino, one for TX and one for RX? http://www.emartee.com/product/42231/RS485%20Module%20%20Make%20Your%20Arduino%20Talk%20With%20Each%20Other

Or is there another chip that I can use to get duplex communication (standard UART-style connection on the arduino) over a cat-5 cable?  I can certainly wire up my own adapters.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I believe that what I need is either RS-485 or RS-422, though I'm not clear on the difference as one web site intimates that with two of their RS-485 to UART boards I can get  the equivalent.

In any event I want to have two arduinos be able to communicate back and forth between each other (just two, point to point, no daisy chaining), over a distance of about 60 feet or more, in a somewhat noisy automotive environment.  115kbs is plenty of speed; 9600 might even be fast enough.  My aim is mainly to have one arduino act as a monitor and UI (simple 2-line screen, and some buttons) for another arduino that does the real processing and controls a pump.  I'll work out a very simple serial protocol. 

So do I need maybe two of this sort of adapter on each arduino, one for TX and one for RX? http://www.emartee.com/product/42231/RS485%20Module%20%20Make%20Your%20Arduino%20Talk%20With%20Each%20Other

Or is there another chip that I can use to get duplex communication (standard UART-style connection on the arduino) over a cat-5 cable?  I can certainly wire up my own adapters.

For just 60 ft and willing to go down to 9600 baud if you have to, I would hold off on buying anything other then cable and just try it direct. Pick a shielded cable with two conductors (or get 4 conductor with shield in case you want to go with full duplex RS-485 later) and wire rx to tx and tx to rx and ground to ground.

 We use to run temporary RS-232 test equipment runs at over 150-200ft at 9600 using simple unshielded ribbon cable and never had any problems at work. So give it a shot, you can always go with the extra driver hardware if you don't like the results.

Lefty
Logged

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

Guess it is worth a shot.  There are other 12 V cables (power and signaling) in the vicinity that could cause interference.    I will try this.  EDIT: I don't think this will work as RS-232 is very different than running a pair of wires from arduino pins to arduino pins.  Though maybe I can use a TTL to RS232 adapter.

Bu tin the meantime, if I were to want to use a more robust serial connection with either Rs-422 or RS-485, how would I do full-duplex communication?  I've been reading people's posts for over an hour and most people are doing simplex or half-duplex, and trying daisy-chain multiple devices.  I only need point-to-point and full-duplex.  
« Last Edit: February 01, 2013, 11:07:14 pm by torriem » Logged

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

So from what I've been reading, neither rs-422 or rs-485 are full-duplex.  At best they are half-duplex.  Which might be okay for my needs if I write a careful protocol. 

Also looks like it wouldn't be hard to just use two chips per arduino, and use one twisted pair for data going one way, and one twisted pair for data going the other way.  I can get rs-485 transceiver chips for just a dollar or two.  Since I'm not wanting to build an actual network, even the older, cheaper chips should work.  I'm currently looking at the DS75176 chip because it's easy for me to get a hold of. 
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
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

rs-422 or rs-485 are full-duplex:  use one twisted pair for data going one way, and one twisted pair for data going the other way.  That's full duplex.
Even RS232 will do what you want, with a single wire each direction, uses a higher voltage swing (like +/-10V) for increased noise immunity.
RS485 & RS422 use twisted pairs with lower voltage swing, both pick up the same noise which gets cancelled out by the receiver.
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.

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

Can I do full-duplex RS-485 communication with just one DS75176 transceiver chip per arduino?  Because it looks like the way most transceiver chips are, the chip listens on the twisted pair until the arduino asserts the DE (if I recall correctly) pin on the transceiver, and then the chip transmits until the DE line is lowered.  This is the standard half-duplex method.  And it's really the only way to do it if more than two nodes are involved (IE full-duplex only makes sense point to point).

Using two twisted pairs and full-duplex would require two chips per arduino in general, correct?  One where the chip is always receiving, and one always has the DE pin asserted.  Am I completely off base?  I have heard there are chips that have what it takes to run two twisted pairs (four wires) off of one chip, but I do not know what chips to look for.

Thanks.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can I do full-duplex RS-485 communication with just one DS75176 transceiver chip per arduino?  Because it looks like the way most transceiver chips are, the chip listens on the twisted pair until the arduino asserts the DE (if I recall correctly) pin on the transceiver, and then the chip transmits until the DE line is lowered.  This is the standard half-duplex method.  And it's really the only way to do it if more than two nodes are involved (IE full-duplex only makes sense point to point).

The problem with that is that the arduino hardware serial library offers no support for controlling DE output pin, so the user has to included it wrapped around every serial output command, plus with the issue of buffered and interrupt driven serial transmission now used by the serial library one has to include a flush plus a one or two character time delay to make sure any out going serial data has actually been sent before 'flipping' the DE output pin, otherwise transmitted characters will get chopped off. It can be done but it's kind of kludgy. However if one uses two pairs with two sets of driver/receiver translator chips then the link can be run in full duplex mode fully transparent to the arduino hardware serial driver. However that only works if there is but one master and one slave working on the link. If there is more then one slave attached then each slave has to be able to turn it's transmitter enable to the chips off so as to not step on other slaves use of the link, so the compatibility problem with the arduino serial library has just been moved from the master to all the slave devices.

But as the OP is using a single master, single slave application the use of two pair fully duplex is a very viable method and the one I would use, and allow his sketch to not even care (or have to do anything) that it's not a simple TTL serial link attached.
Lefty


Using two twisted pairs and full-duplex would require two chips per arduino in general, correct?  One where the chip is always receiving, and one always has the DE pin asserted.  Am I completely off base?  I have heard there are chips that have what it takes to run two twisted pairs (four wires) off of one chip, but I do not know what chips to look for.

Thanks.
« Last Edit: February 02, 2013, 01:07:11 pm by retrolefty » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
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

MAX488 & 490 both do full duplex RS485 comm's with just 1 8-pin chip per arduino.

http://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf

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.

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

Sweet.  Thanks to both of you.  Depending on ease of chip availability, shipping, and so forth I will either do the two-chip per arduino method, or go for the MAX488 or MAX490 which looks to be ideal for my purposes.
Logged

0
Offline Offline
Tesla Member
***
Karma: 118
Posts: 8956
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
EDIT: I don't think this will work as RS-232 is very different than running a pair of wires from arduino pins to arduino pins.  Though maybe I can use a TTL to RS232 adapter.

I've read that at lower baud rates rs232 can be used over some fairly long distances. I think the TTL to rs232 chips  have charge pumps when capacitors are added to get the transmission voltages up to the 10v-12v range.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
EDIT: I don't think this will work as RS-232 is very different than running a pair of wires from arduino pins to arduino pins.  Though maybe I can use a TTL to RS232 adapter.

I've read that at lower baud rates rs232 can be used over some fairly long distances. I think the TTL to rs232 chips  have charge pumps when capacitors are added to get the transmission voltages up to the 10v-12v range.

It really depends. RS232 defines signal levels as anything between +3 to +15 and -3 to -15vdc for the logic states, so on the lower end it's not much more signal swing then TTL serial. I think the typical RS232/TTL converter chips use +/- 10 volt swings. Either way RS232 and TTL are alike in that they are single ended signals using a common ground reference where as the RS485/422 use true differential signalling which will always have greater rejection of common source noise.

Lefty
Logged

0
Offline Offline
Tesla Member
***
Karma: 118
Posts: 8956
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Seems the OP has been sold on the RS485/422. 
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

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

Just found my post again after doing some other searches on google for other things about my project.  I thought I might write about what I settled on.

First of all, as I pondered on what I wanted to communicate over the serial link, it occurred to me that serial links aren't that reliable.  Beside the potential for noise, it could be unplugged, or one end or the other reset and I needed a way to handle that . So I began to think a command-based solution might be what I need, regardless of the underlying link.  Something that could help me detect errors, and communication drops.  And with a formal command structure my two arduinos could re-connect after an outage and figure out where they were in the process scheme of things.  I decided to implement a very simply system using modbus functions 3 and 15.  Yes I know, now I have two problems. smiley  But it's actually working out very well.  I am just having the master node query runtime registers on the client to get updates for monitoring.  And I have several registers (modbus terminology) where the master can write a command instruction to, and the slave can respond.  So far it works pretty well. 19200 baud more than keeps up with my needs.  I'm using the SimpleModbus arduino library.

On the link layer, since I was using the master/slave idea that modbus implements, suddenly half-duplex RS-485 wasn't an issue.  So that's indeed what I've settled on.  It's electrically very simple to hook to arduino, and should provide enough reliability for my needs.  I feel more comfortable with RS-485 than RS-232, since it was designed for the sort of environment I'm using it in (potentially noisy 12V wires everywhere). I'm still in the breadboard testing phases though.

 
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
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

Sounds like a good solution; positive feedback on what you are communicating.
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.

Pages: [1]   Go Up
Jump to: