Pages: 1 [2] 3   Go Down
Author Topic: Communicating with an Arduino that is relatively far away  (Read 3007 times)
0 Members and 1 Guest are viewing this topic.
United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here are a couple of other ideas:

1. Emulate the old current loop serial interface using opto isolators connected to the serial port. It wouldn't work at 115200 baud, but should be OK at 9600.

2. Between 2 Arduinos, you could use SPI at a slow clock rate, again with opto isolators.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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

Thanks for the quick reply smiley
Full duplex it is then, I guess! The price is about the same but my favorite shop only has the half-duplex version. But I can get the full-duplex ones elsewhere.

If you are talking about the RS-485 chips you can use a pair of half duplex chips and just 'hardwire' the enable signal(s) one transceiver chip to receive mode for one cable pair and the other chip to transmit mode cable pair. So maybe four chips to support both ends? I haven't really checked out the chips you are considering but most operate the same.

The amount of data being sent back and forth is not a whole lot. The PC sends a request which is at most 20 bytes and the Arduino replies to that, the replies' lengths depend on what kind of request was made and will be anywhere from 1 to maybe around 30 bytes.
To eliminate the need for high-speed communication the Arduino does most of the processing. Basically the Arduino does most of the hard work and just sends an event log to the PC so it know's whats going on. A high estimate would be 100 bytes/sec from Arduino->PC and 200 bytes/sec from PC->Arduino (and much less if I move all the scoreboard code to the Arduino).
So even 115kbps is way more than I need.

Good, so if you do find you have any intermittent garbled data due to noise you could always try and reduce the speed to see if that eliminates the problem. At the refinery I worked at we used many many RS-485 links, many running over a thousand feet at 9600 baud mostly. However we run the twisted pair through hard electrical conduit and used high quality low capacitance cable with overall shielding. Anyway RS-485 is a very reliable method to route serial data over distances, that's what it was designed for.
Lefty

Logged

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

Using 4 would work I guess smiley
I'm having a bit of trouble finding a local source for the low speed full duplex versions but the MAX3082E seems to do what I want so I just need 4 of them then.

So if I'm getting this straight this is how I would hook this up:
For the local TX to remote RX:
Local side: DE to Vcc/+5V, DI to TX.
Remote side: RE to Vcc/+5V, RO to RX.
Local A to remote B, local B to remote A. And a resistor between A and B on both sides.
A 0.1 uF condensor between Vcc and +5V, and GND to ground obviously.

Logged

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

Using 4 would work I guess smiley
I'm having a bit of trouble finding a local source for the low speed full duplex versions but the MAX3082E seems to do what I want so I just need 4 of them then.

So if I'm getting this straight this is how I would hook this up:
For the local TX to remote RX:
Local side: DE to Vcc/+5V, DI to TX.
Remote side: RE to Vcc/+5V, RO to RX.
Local A to remote B, local B to remote A. And a resistor between A and B on both sides.
A 0.1 uF condensor between Vcc and +5V, and GND to ground obviously.



Well you really need to show four chips wired to two separate cable pairs. One the local side one chip (for the local's transmit signal) has DE wired to Vcc and RE wired to Vcc, and DI wired to serial tx pin. The other local chip (for the receive signal) has it's DE wired to ground and RE wired to ground and it's RO pin wired to arduino rec pin. The remote has a similar setup as long as you keep in mind the direction of data flow through each seperate cable pair. And yes, four 150 ohm resistors wired from A to B on all four chips. And good on remembering about the benefits of bypass caps at the Vcc pins to ground for all four chips. Does that help? English is a poor method to talk electronics as a schematic drawing is the true language of electronics.  smiley-wink
Lefty
« Last Edit: November 13, 2012, 12:14:56 pm by retrolefty » Logged

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

Quote
Local A to remote B, local B to remote A
All As together and all Bs together. Have a look in the data sheets, they always have examples.

Quote
And a resistor between A and B on both sides.
Correct.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

I will try and draw a schematic, but knowing my drawing skills I'm afraid it might not make things a whole lot clearer smiley-wink

So A goes to A and B goes to B. The datasheet did have an example but it was a bit unclear to me how they were supposed to be connected because the schematic showed the wires as being twisted and I couldn't figure out what went to what.
Logged

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

Here we go... This is the first time I've ever used Eagle or drawn a schematic and I can't say that I really know what I'm doing smiley-wink So I'm guessing it's not going to be all that great. I found the drawing process a bit frustrating so I only did one side for now.


Does that look like it would work? Or do I need to connect the unconnected pins to something too?
« Last Edit: November 13, 2012, 04:33:34 pm by nicov » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


C1 and C2 look suspicious.
Logged

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


C1 and C2 look suspicious.
I thought so too.. But the example schematic was a bit unclear again to a schematic noob like myself.

This is what's in the datasheet:


If they didn't mean what I had in the previous schematic, how is this one?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


That looks better (the capacitors; someone else will have to comment on the rest).
« Last Edit: November 13, 2012, 06:55:39 pm by Coding Badly » Logged

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

RE is active low, on the right-hand chip it's pulled high.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

RE is active low, on the right-hand chip it's pulled high.

______
Rob
Aha, thanks for that hint! I thought something might be up with it, with the slash after the name or the "overscore". Learning by doing, I guess smiley-wink
So I need to connect it to ground on the right side one then.

I found this table in the datasheet:


So on the left side, RE can be disconnected, DE to VCC.
On the right side, RE to GND, DE can be disconnected.

Like this?
Logged

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

On the remote end you really should ground pin 3, DE, to make sure it's transmit driver is forced off into tri-state mode.

Lefty
Logged

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

On the remote end you really should ground pin 3, DE, to make sure it's transmit driver is forced off into tri-state mode.

Lefty
According to the table it shouldn't care but I guess better safe than sorry smiley-wink

Version 4 then:
Logged

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

Quote
the slash after the name or the "overscore"
Also the small circle on the graphic, on chips that means an active low or inverted signal.

Just some notes about schematic layout.

If you mirror image the remote chip the drawing will be a lot clearer.

When things are tied to power rails it's almost always better (clearer) to have VCC going up and GND going down. Your caps go up.

Most beginners make a real dog's breakfast by running the GND wire to every possible place. You haven't done that which is good, in this case however I would argue that because these chips are physically remote from each other you should draw the GND line between the two to reinforce that they have to have a common GND and that that is formed by a GND wire in the cable.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: 1 [2] 3   Go Up
Jump to: