Communicating with an Arduino that is relatively far away

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

I will try and draw a schematic, but knowing my drawing skills I'm afraid it might not make things a whole lot clearer :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.

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 :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?

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?

That looks better (the capacitors; someone else will have to comment on the rest).

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


Rob

Graynomad:
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 :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?

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