Communicating with an Arduino that is relatively far away

For my latest project, I need to have a PC communicate with an Arduino that is going to be relatively far away, up to about 150 feet cable length or a 75 feet straight line if I were to communicate wireless.
We won't be able to boost the signal anywhere in between, if it needs to be done we'll have to do it either at the PCs end or the Arduinos end, or both ends. To make matters worse we're going to be in a noisy environment too..

Communication needs to go both ways and must obviously be reliable. Speed is less important, even 2400 baud would be okay, altho 9600 would be nice for fast response times. But data integrity is the most important thing here.

As far as I understand, communicating anywhere over 16 ft using a plain USB cable is not going to work so I guess we can scrap that right away.
USB over CAT5/6 looks pretty interesting and from the sound of it it would handle distance too. But I have no experience whatsoever with it, it definitely sounds like the easiest solution.

RS232 would work probably work fine too if we could get a real RS232 connection over a CAT6 cable, I'm not so sure about TTL and its low voltages, but again no experience. The PC doesn't have a real RS232 port so we're stuck with either having another Arduino there or a USB-serial adapter, and neither of those give a real 12V serial signal. That can be solved with some circuitry but I would ideally want to use as little parts as possible to keep the clutter down.
Wireless might be a problem because we're in noisy environment, and there will be lots of cellphones and what not around too. On top of that it'd probably be the most expensive solution.

What do you suggest would be the best way to do this?
Thanks in advance :slight_smile:

Edit: I should add that the Arduino will have its own power supply and does not need to be powered by USB.

RS-485
CANBUS
Ethernet

To make matters worse we're going to be in a noisy environment too

As in...
• People shouting at each other?
• 16,500 volt motors going on and off?
• Run-of-the-mill 110 volt lines?

[quote author=Coding Badly link=topic=132089.msg993569#msg993569 date=1352747232]

To make matters worse we're going to be in a noisy environment too

As in...
• People shouting at each other?
• 16,500 volt motors going on and off?
• Run-of-the-mill 110 volt lines?[/quote]
Thanks for the suggestions, gives me something more to read up about!

Noisy both sound wise (racing engines with undampened exhausts, anything from 50cc mopeds to huge V8s) and probably worse than that: electromagnetic interference from the ignition systems on those engines.

You are welcome.

nicov:
electromagnetic interference from the ignition systems on those engines

Distance from the ignition wires to the communications wires?

The distance will vary but will in some cases be as little as a couple of feet if we need to have the wire go over one of the lanes or dig it into the ground if for some reason we can't hang it. That'd just be a spot though, most of the cable will be at least 10 feet away from any ignition wires.

Right now we're using a Labjack at the PC end, and parallel communication so basically one wire+ground to every sensor and output. This solution has been working trouble-free but the wiring is a complete mess.
We're using 3 CAT6 cables at the moment which is bad enough, we're adding more sensors now and would need a 4th one to have enough leads.

We figured it'd be much nicer to have all communication from and to the PC go through a single cable. We need the Arduino anyway to control the 16 7-segment displays we're adding as well, so I figured we might as well switch to some form of serial communication while we're at it.

There are lots of options, and I think the main choice comes down to what sort of technology you're most comfortable using.

If you put a remote PC at the Arduino site, you can use various mechanisms to access the remote USB locally at your main PC, or you could leave the USB remote and tunnel the serial port over the network, or do everything you want at the remote PC and access whatever application you want to access remotely using whatever remote session technology you prefer. Or you can use a serial link and a USB-to-serial adapter to bring the serial link in to a virtual serial port.

I would have thought your best chance of getting reliable comms over that distance starting from a noisy environment would be to use the remote PC and a LAN connection.

RS-232 is not a good option here. My personal choice would be RS-485, it's designed for industrial environment and simple to use as to the software it's just a serial connection.

Ethernet is probably OK as well (there is an industrial Enet spec isn't their?). I think it would be more complex to get working, but that's probably just my lack of knowledge on it showing through.


Rob

We're using 3 CAT6 cables at the moment which is bad enough, we're adding more sensors now and would need a 4th one to have enough leads.

So have you disconnected a couple of the existing wires and tried TTL/rs232 communication over them? Instead of speculating do some testing.

What's your budget? Fibre-optic is immune to noise.

MAX232 and MAX233 have nominal ±10V outputs.

.

Using a 2nd PC would definitely make things easier for communication but wouldn't be very practical for us otherwise, and it's probably way more than we need.
This stuff is always outdoors when used (except for the control PC) and needs to be weather proof.

All this is for a portable drag racing timing system that I built together with a couple of friends. Like I said we're using parallel communication at the moment. We have 6 inputs (reaction time, trap speed and elapsed time optical sensors, times 2) and 14 outputs (the lights on the tree). Communication to the outside goes through 3 CAT6 cables which go to our "hub" which is built in in the tree itself. In there the cables are split up and go to whatever destination they're supposed to go to: one of the relay boards for the lights or the connector for the sensors.
We're expanding a bit now and are going to add a time display which would needs another 4 wires that need to go outside, and we also want to add more sensors. In the end we'd probably end up having 5 cables and connectors at the PC end..

These cables are the main problem, they're a pain in the *ss to install every time we go to a different event, especially if the organizer does not have the control room/hut in the middle between the lanes because that means our 3 cables have to cross one of the lanes.
Having a single cable here would make life a whole lot easier on those early saturday mornings when we have to install the stuff :slight_smile:

We've looked at cables with more leads because just having a single cable instead of 3 seperate ones would help a lot, but they are pricey too. If we had to we could afford it but we get CAT6 for free and now we'd rather have a non-parallel solution so it's future proof.
I guess my budget is around $100, don't want to spend too much money on something that's not essential. The current stuff works and adding more cables for the new stuff would work too, but it would be a lot nicer to have it all go to the tree over one cable.

You can get USB to RS-485 dongles for the PC that just look like a serial port.

This is half-duplex but you could make your own full-duplex version easily. The FTDI data sheets have examples but it's pretty simple.

And at the Arduino end you can get an RS-485 shield, once again I think half-duplex but that doesn't really matter and you could make your own full-duplex version for maybe $20.

Full- or half-duplex doesn't matter much, it just determines how you write your code.


Rob

I've been trying to get my USB-serial cable (PL2303) to work with a Uno but so far no luck with that. Seems like I tried every possible port setting but I always end up getting loads of errors. And this is with about 4 ft of cable.. I'm pretty sure I must be doing something wrong or maybe the cable is just rubbish.
So the next approach was to try and use a Leonardo as a proxy. It forwards whatever it gets on Serial (USB) to Serial1 (RX1/TX1 pins) and vice verca. That actually seems to work so now I got my PC talking to my Uno through the Leo. And more importantly, using a signal that I can do something with.

RS485 sounds like it'll do the job.
I'm looking at half duplex MAX3082 transceivers or maybe full duplex MAX3081. Would that work?
I'm pretty sure I'm not going to need full duplex though. These do 115kbps which is already more than I need. But there's faster versions too, would there be any use in getting a faster one

RS485 sounds like it'll do the job.

That would be my choice also. Be sure to read up on proper wiring methods for RS-485 links. This usually involves wiring 150 ohm termination resistor across the data+ and data- terminals at the both the local and remote receivers inputs terminals. Also using shield cable is helpful, grounding the overall shield at only one end of the cable run.

I'm looking at half duplex MAX3082 transceivers or maybe full duplex MAX3081. Would that work?
If you go with the two pair full duplex option you won't have to modify the arduino serial library code to properly generate the transmit enable/rec enable signal required to 'turn around' the voltage translator chips. This required serial code modification is now even more tricky sense the arduino serial library has gone to interrupt based transmit buffering. Using two pair full duplex makes the whole link more transparent to the standard arduino software, at the extra expense of a second wire pair of course, a better tradeoff in my opinion as your cable run is not all that long or expensive.
I'm pretty sure I'm not going to need full duplex though. These do 115kbps which is already more than I need. But there's faster versions too, would there be any use in getting a faster one

Probably not, but that really depends on the amount of data you have to move and what you are doing with the data at each end. General advice is to run only as fast as you require and no faster.
Lefty

Thanks for the quick reply :slight_smile:
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.

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.

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.

nicov:
Thanks for the quick reply :slight_smile:
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

Using 4 would work I guess :slight_smile:
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.

nicov:
Using 4 would work I guess :slight_smile:
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. :wink:
Lefty

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.

And a resistor between A and B on both sides.

Correct.


Rob