Reducing serial interference

I've got some issues with interference and I'm not sure what to do to reduce them. Both cases involve a long wire which is likely where the problem lies.

First, I've got an Arduino duemilanove in my attic that is collects temperature measurements from around the house. It is located in the center of the house and connected to a laptop by a USB cable that's about 16 feet long. I realize this is a little long for USB so I put a powered USB hub at the computer end which seems to boost the signal enough to allow programming about 80% of the time and serial communications 100% of the time at a low baud rate. Once in a while when I programing (via avrdude on the console) it gets about 70-80% of the way done and fails, saying the programmer is not responding - sometimes I can just reprogram it again and other times it will soft-brick it and I need to unplug it from the USB and plug it back in before programming works. I'm pretty much chalking this down as "my USB cable is just too long".

In the second case, I have the same device connected to a 4x20 char LCD via a 14 foot Cat 5e cable - this is used to display the zone temperatures on my wall. The Arduino is connected to the LCD with three wires: Vcc (+5vdc), GND and Serial TX. I have the baud rate set to 9600. When the connecting wire was short everything worked flawlessly, but with the longer wire, occasionally I get some strange characters on the screen which are quickly written over when the screen is updated. I'm sure the problem is the wire but I'm trying to figure out what I can do to resolve it. Besides shortening the wire, what are my options? Since the wire is UTP, should I put the serial TX wire on a wire that is twisted with the GND? Maybe isolate it completely? Are there some filter circuits that I can use, or ferrite cores or something?

I'm not 100% sure how a serial signal works, but from what I understand it transmits data by leaving the line up or down for a precise amount of time, which is then measured and compared to the baud rate, so if it's up for say, 100 usec and down for 20 usec, it might mean 5x "1" bits and 1x "0" bit. If this is the case, then lowering my baud rate should stretch out the I/O and make the bits easier to differentiate - what do you think? Also, I suppose I could take something like a 5v-3.3v dual level shifter and put it half way down the cable, then shift the TX down to 3.3v and back up to 5v, effectively cleaning the signal.

You could go wireless for the 2nd part of that. Have the attic arduino transmit via virtual wire to the display arduino - put an ardweeny or RBBB at the recieve end, transmitter/receiver from sparkfun.

lowering my baud rate should stretch out the I/O and make the bits easier to differentiate

Yes you can get further by slowing down the speed.

The other way is to have a proper line driver, something like a MAX202 (or similar) at each end.

Indeed - I've got a couple RBBs and a Pro Mini laying around but I don't have any transceivers handy. I'm also hesitant to buy the cheapest ones on Sparkfun because of people's reviews. I will be adding more features at the LCD's location like buttons and such, so I will need bidirectional communications - maybe two of these would do the trick: http://www.sparkfun.com/products/9582

Ah, I wasn't sure what difference a line driver would make. I've got a MAX232 laying around - assuming I grab another one, you're saying that this would improve transmission quality? I wouldn't mind sticking a Pro Mini 328 down by the LCD's location.

you're saying that this would improve transmission quality?

Yes, the transmit voltage is larger and the threshold for 0 and 1 is much better defined. It will go further at any given baud rate.

I see - higher voltage and therefore a higher tolerance for interference. This might just be the way to go - looks like I'll be making a road trip for a $0.50 IC tomorrow (and battling all the Frye's customers since it's Christmas Eve :P )

You may also need to get some capacitors to go with the MAX232.

I've got a handful of random caps laying around and a bunch of boards I could salvage some from - I haven't looked at the datasheet for the 232 yet, what are the caps for?

I think the chip has an internal charge pump that charges the caps to ~12v to supply the higher voltage on the lines.

Ah, gotcha - I'll make sure I've got what I need before I battle the traffic, thanks for the heads-up!

RS-232 isn't great for long distances. It's an ancient interface that relies on a common ground reference for noise rejection. Slowing the link down doesn't help this much.

Why not go with RS-422 or RS-485? It uses differential drivers/receivers designed to drive twisted pair, like CAT5, reliabily at high speed over long distances. You could drive it as fast as you want.

Interesting - do you know where I can get a 5v UART <-> RS485 DIP? I found a breakout on Sparkfun (http://www.sparkfun.com/products/9823) but I don’t have a 3.3vdc regulator on my boards and $10 seems a little high for a single IC :stuck_out_tongue:

Slowing the link down doesn't help this much

Not true it helps a lot.

RS-232 isn't great for long distances.

It's a lot better than TTL.

If you have an open collector transistor at one end and a pull up resistor to 12V at the other along with an input transistor. You can go half a kilometer at 2800 baud.

This will let you run RS422 which is just two units, RS485 is multiple units.

http://www.kmitl.ac.th/~kswichit%20/Rs422/Rs422.html
http://www.kmitl.ac.th/~kswichit%20/Rs422/Rs422.pdf

2 of these

http://compare.ebay.com/like/380293107523?ltyp=AllFixedPriceItemTypes&var=sbar&rvr_id=189339477907&crlp=1_263602_304662&UA=L*F%3F&GUID=b2c77c1a1280a02652c40644ffb6fac4&itemid=380293107523&ff4=263602_304662

one of these
http://cgi.ebay.com/10pcs-MAX232-MAX232EPE-RS232-Drivers-Receivers-Maxim-/250548495759?pt=LH_DefaultDomain_0&hash=item3a55daa58f

You might look at this. It has a USB to 485 and 485 to ttl. I think
http://cgi.ebay.com/USB-2-0-RS422-RS-422-RS485-Converter-Adapter-Serial-/370366576617?pt=LH_DefaultDomain_0&hash=item563b9177e9

Wow, you really are Grumpy!

Not true it helps a lot.

You're taking me out of context. When I said "Slowing the link down doesn't help this much", the "this" word referred to the previous sentence where the topic was common-mode noise rejection. I believe you've confused noise rejection with the ability of the transmitter to drive line capacitance. Of course, you could slow the link down and filter the receiver to increase noise tolerance, but we weren't talking about that.

It's a lot better than TTL.

This is forum bait. If you recommend that someone add line drivers and receivers to a project, why not recommend something that was designed for distance?

Merry Christmas. :)

USB -->> RS232 http://cgi.ebay.com/USB-RS232-Serial-DB9-9-PIN-Cable-Adapter-PDA-GPS-D13-/320613181145?pt=LH_DefaultDomain_0&hash=item4aa608e6d9

RS232 -->> RS485 http://cgi.ebay.com/RS232-RS485-Data-Communication-Adapter-PTZ-CCTV-/110529228002?pt=LH_DefaultDomain_0&hash=item19bc0e2ce2

This combination was tested on CCTV speed dome cameras and Access control devices.

This is forum bait. If you recommend that someone add line drivers and receivers to a project, why not recommend something that was designed for distance?

Like transoceanic fiber optics? Why not? He is looking for a replacement for a 16' USB cable. :)

Like transoceanic fiber optics?

This is funny. I recommend using RS-422 instead of RS-232 because the transceivers are both cheaper and better for this application. And you resort to hyperbole to denigrate. Nice.

Is this forum more about roasting others or tying to help the OP?

Is this forum more about roasting others or tying to help the OP?

In this case it is more about letting the OP know that he is possibly being told to buy a bunch of stuff that he may not actually need.