Arduino Forum

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

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

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

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.

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.

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

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.

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

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 :)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.

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

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

(http://howisbabbyformed.info/max3082.gif)

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. ;)Lefty

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

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 ;) 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.(http://howisbabbyformed.info/schematic.gif)

Does that look like it would work? Or do I need to connect the unconnected pins to something too?

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 ;)So I need to connect it to ground on the right side one then.

I found this table in the datasheet:(http://howisbabbyformed.info/3082table1.gif)

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

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.

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

Actually these don't require a common ground between the local and remote chips, that is one of the advantages of the A/B signals being a true differential signal pair. I'm sure some will disagree with this, but I would say hold off until you actually test such a link using independent power sources at each end, it will continue to work without a common ground wire between the pair.

One more question then. Over here (http://www.maximintegrated.com/datasheet/index.mvp/id/1522), Icc is specified as 0.375 mA typical, the PDF datasheet I have says max 1.000 mA. So I assume it will be safe to power the chips from the Arduinos 5V if the local Arduino is USB powered?

One more question then. Over here (http://www.maximintegrated.com/datasheet/index.mvp/id/1522), Icc is specified as 0.375 mA typical, the PDF datasheet I have says max 1.000 mA. So I assume it will be safe to power the chips from the Arduinos 5V if the local Arduino is USB powered?

Yes either can be made to work as long as the driver chip on one end is the same 'flavor' as the receiver chip at the other end.

By the way Wikipedia shows a good three resistor termination method one can use on the receiver end of each path (if using two pair full duplex) which will ensure no false data hits due to noise in case the far end of a link is powered off, it's shown in the first picture showing a series 680 ohm, 120 ohm, 680 ohm resistors wired to the recievers Vcc and ground and A and B signal pins. Good idea.

I finally got around to finishing this up.. And wanted to update the thread with some findings.The first is that the remote/RX end pin 3/DE must in fact be grounded. I just got garbage if I didn't ground it.The other is that B on one end must be connected to B on the other end, and A to A. Connecting B to A and vice versa also gave garbage.It seems to work fine without the resistors too, but I assume that may change with longer distances so I put them there anyway.Figured this stuff might be good to know.

The chips I'm using are MAX3082E. Amazingly everything worked as expected the first time I connected it, I had to actually disconnect some stuff to make sure it wasn't just the software fooling me ;) This weekend we'll test with a longer cable in between.

Another update.. We put the stuff to the test this weekend. Using 75 meters of cat6 cable between the 2 sides, in an electronically noisy outdoor environment, the chips powered by the Arduinos +5V pin, 2 chips per Arduino/side, no common ground. To top it off temperatures were -15C/5F and there was a blizzard going on.

The result of the test was that everything worked perfectly fine, no trouble whatsoever! :)