Long distance serial communication - Page 1
Forum section: electronics / beginners

author: grimmjaw
author_rank: Regular Contributor
timestamp: April 16, 2015, 05:21:59 am
content: Hi guys,I have two microcontroller that need to send data to each other.The distance between this two micros is 100meter.Has anyone has suggestion for the best communication protocol and type of cabel for long distance communication.The communication need to be very reliable and doestn't need to be fastThanks

author: BradC
author_rank: Super Contributor
timestamp: April 16, 2015, 05:30:12 am
content: Quote from: grimmjaw on April 16, 2015, 05:21:59 amI've done nearly that far on a pair of salty wet strings. It wasn't fast, but it was reliable and won me a bet.I'd just use RS422/485 and be done with it. 8 pin transceivers are cheap these days and you'll push a lot of bits over only 100 metersIf it was _really_ slow you could use a hacked up one wire style protocol. Again cheap and reliable, but RS485 buys you speed and noise immunity.

author: LabSpokane
author_rank: Super Contributor
timestamp: April 16, 2015, 05:43:19 am
content: 422/485 is your huckleberry.

author: Psi
author_rank: Super Contributor
timestamp: April 16, 2015, 06:05:14 am
content: Yep 422/485.Ideally at a low voltage like 2V.The faster you switch the worse the problem gets and the lower the voltage you need.Unless its super slow, like 100baud, a 12V digital signal down 100m of cable will get high voltage ringing from the cable inductance and something will blow.When I tried 24V I got 160V !!!

author: AndyC_772
author_rank: Super Contributor
timestamp: April 16, 2015, 07:11:15 am
content: The baud rate won't make the slightest difference to the voltage generated by inductive ringing. If it's an issue at all - and in 10 years' designing serial equipment professionally I never once saw a problem - then the edge speed (dV/dt) is the governing factor, not the number of edges per second.Terminate the signal properly at the receiver and you won't have a problem.

author: tggzzz
author_rank: Super Contributor
timestamp: April 16, 2015, 07:25:36 am
content: Make very sure that there is electrical isolation between the two ends.You can getverylarge voltages where you don't expect them for a wide range of reasons, ranging fromnearbylightning strikes, to different mains phases, to generated or environmental noise.Fibre optic cables can have a very long range and are inherently isolated. Seriously consider using them in preference to copper.

author: Zero999
author_rank: Super Contributor
timestamp: April 16, 2015, 07:52:06 am
content: Quote from: Psi on April 16, 2015, 06:05:14 amThe disadvantage with low voltages is susceptibility to noise.QuoteThat's because you didn't properly terminate the cable. If you'd terminated the cable properly you could've gone much faster and not had any problems with ringing or high voltages.

author: AndyC_772
author_rank: Super Contributor
timestamp: April 16, 2015, 07:56:44 am
content: Does the cable between the two micros ever leave the building, or are the two units both inside the same building and connected to the same electrical distribution system?

author: electr_peter
author_rank: Unknown
timestamp: April 16, 2015, 08:10:18 am
content: RS485 - differential pair, good serial speed, robust, 100-300m or longer lines (termination and impedance matching of cables is needed), can provide small power as well. Isolators on each end can be added if that is deemed necessary.

author: Psi
author_rank: Super Contributor
timestamp: April 16, 2015, 09:18:00 am
content: Quote from: Hero999 on April 16, 2015, 07:52:06 amTrue, but 2V is good enough for ethernet 100Megbit at 100MetersSo it's good enough for some serial coms over 100Meters without noise issuesAnd you can get +/- 2V easy enough from 5V

author: Cliff Matthews
author_rank: Unknown
timestamp: April 16, 2015, 10:24:41 am
content: Grimmjaw, you given no application specifics.There's a bucket-load of Linear devices here -http://www.linear.com/parametric/rs485|422_transceiversand TI has more.Also, Jameco has ~160 devices under $5 and many have ESD protection to 10kv:

author: tggzzz
author_rank: Super Contributor
timestamp: April 16, 2015, 11:14:37 am
content: Be aware that ESD protection may be insufficient for you, since ESD implies short duration and low current.You may encounter long durations and high currents. Seriously consider electrical isolation.

author: Howardlong
author_rank: Super Contributor
timestamp: April 16, 2015, 11:27:28 am
content: About 15 years ago I ran 300bps simplex serial comms over a single coax run that was 180' between my flat in the basement of a block up to the roof where I had my antennas and preamps etc. The comms allowed me to change antennas and switch the preamps on and off remotely. The coax also ran RF from HF up to 1.3GHz, and 24V DC.The signalling was a simple UART stream, with largish inductors at each end to pass the serial stream and DC power but reject the RF that was sniffed off with a 10nF cap. That was up there for about ten years.I wrote it up too.http://www.g6lvb.com/remote_control_of_mast_mounted_e.htmI guess you'd call it a one-wire solution, but it's much simpler than the Dallas/Maxim 1-wire protocol.

author: Quark-elec
author_rank: Contributor
timestamp: April 16, 2015, 12:28:25 pm
content: do you need something remote controller that control the switch?

author: Cliff Matthews
author_rank: Unknown
timestamp: April 16, 2015, 01:49:44 pm
content: I vote for the diminutive, 39-cent, 8-pin TI SN75176 Info:http://www.ti.com/product/sn75176aApplicable serial comms page:http://www.siongboon.com/projects/2006-03-06_serial_communication/and a project on daisy chaining the Arduino:http://geodesicsphere.blogspot.ca/2012/12/daisy-chaining-serial-connections.htmlIt sounds like I should break-the-bank and buy a few... - I like the comment Andres G. on December 3, 2012 posts:Go with RS485 at a normal 9600 baud rate: no daisy chain but parallel connected slave nodes on a single line is the way to go (DMX anyone?). Still you would need to address them but c'mon it's a lot easier and faster to program "snif for your address" than "repeat the whole stream of data while you search for your part." Burning the address on the eeprom is not that hard and doesn't require IO pins, just the usb programming in case of arduinos. Also that way you make sure that the remote controlled flame thrower doesn't shoot because you connected the terminal cables in the wrong order.As a bonus everything works directly from +5V, can connect everything with the cheapest ugliest twisted pair you can find and still get range, also the RS485 converter chip (SN75176) cost something like ten cents each.

author: TimFox
author_rank: Super Contributor
timestamp: April 16, 2015, 02:36:38 pm
content: For unidirectional signals, an RS-422 differential output, being current limited, can drive an opto-isolator LED directly (add a PN diode across the LED for reverse voltage).

author: plazma
author_rank: Frequent Contributor
timestamp: April 16, 2015, 02:38:37 pm
content: Extend the I2Chttps://www.google.fi/url?sa=t&source=web&rct=j&ei=PskvVdfLAsr9ygO-2IDgAQ&url=http://www.nxp.com/documents/application_note/AN10658.pdf&ved=0CBkQFjAA&usg=AFQjCNHDGumqUNtsum_IPisOPCl75Dm5Jg&sig2=Sqt5AWS_KBNaqVPpzgYwEw

author: grimmjaw
author_rank: Regular Contributor
timestamp: April 16, 2015, 03:19:41 pm
content: seem likes Rs485is the best bet.I'm not sure i understand the need to be insulator tho.the cabel is inside the same building

author: Cliff Matthews
author_rank: Unknown
timestamp: April 16, 2015, 03:40:10 pm
content: Quote from: grimmjaw on April 16, 2015, 03:19:41 pmYou never know who's going to drag your cable over some polyester carpet, or what other ESD lurks around (not trying to spread FUD here though..) but I see 73-cent TVS diode-based line protectors here:http://www.mouser.com/Texas-Instruments/Circuit-Protection/ESD-Suppressors/TPD2E007-Series/_/N-jy72Z1yyuwnyZ1z0zls6Could save you a lot of pain later... your choice.Grimmjaw, You never stated your application (cable length, speed, devices etc..), care to elaborate?

author: LabSpokane
author_rank: Super Contributor
timestamp: April 16, 2015, 04:28:56 pm
content: Quote from: grimmjaw on April 16, 2015, 03:19:41 pmIt's all too easy to get a ground loop or induced interference over that distance if each unit is powered separately.

author: tggzzz
author_rank: Super Contributor
timestamp: April 16, 2015, 04:33:15 pm
content: Quote from: grimmjaw on April 16, 2015, 03:19:41 pmSometimes you will encounter sockets running on different phases of the mains.Often you find different neutral leads at different potentials above ground potential, especially if there is heavy machinery or a higher load on one phase than another.In some circumstances different bits of ground can be at very different potentials (that's why, if you are caught in the open in a thunderstorm, you shouldn't stand with legs apart, or kneel down!). "Ground" and "earth" are a convenient fiction in both RF and mains suppliesAnd then there are the gross wiring/installation faults that have - so far - gone unnoticed.If you connect a conductor whereanyof those are present, a current will flow until the magic smoke is emitted from something or someone.Notice I haven't even bothered to mention interference that might corrupt your signal - that's comparatively trivial.

author: grimmjaw
author_rank: Regular Contributor
timestamp: April 17, 2015, 03:11:10 am
content: i see..make sense since the devices with be main powered.I think i will isolate the signal with optocoupler.BTW abit information regarding the project, the secondary uCoi will read a few sensors and will send the information back to main uCon (console)The secondary uCon just need to send data once every hour.

author: SeanB
author_rank: Super Contributor
timestamp: April 17, 2015, 04:28:41 am
content: If it is only a low data rate the simplest is just to go and use TOSLINK units, like they use for audio data, and the cabling. The transmitter and receiver units are cheap, as they are in pretty much every DVD player and many PC sound cards, and the cabling itself is cheap as well, though you will have to use real glass fibre for longer distances. That will work for up to 115k data rate, though if you want bidirectional communication you will need 2 cables, which comes as a pair that looks like a thicker speaker figure 8 cable.

author: Laura
author_rank: Contributor
timestamp: April 17, 2015, 07:40:28 am
content: Quote from: grimmjaw on April 17, 2015, 03:11:10 amOnce upon a time, a lot of communicating devices had an option for a 20ma current loop in place of, or in addition to, an RS232 interface. The implementation usually used an optocoupler. The data was as async serial using some suitably low baud rate.

author: BradC
author_rank: Super Contributor
timestamp: April 17, 2015, 07:44:58 am
content: Quote from: Laura on April 17, 2015, 07:40:28 amSounds a lot like MIDI

author: tggzzz
author_rank: Super Contributor
timestamp: April 17, 2015, 08:00:18 am
content: Quote from: grimmjaw on April 17, 2015, 03:11:10 amDon't forget about grounds, shields and any other bits of wire going between each end. The physics doesn't care what youcallthe wireI strongly suggest you do some research into how industrial systems are constructed,and why. You are, after all, building an industrial system, not a domestic system. I'll note, again, that a fibre optic link simply, visibly (ho ho),automaticallyresolvesallthese issues.I'm afraid that I don't have a collection of useful references for this topic, since I've never had to design such equipment. The best I can offer as astarting pointis Tim William's Circuit Designer's Companion, as onhttps://entertaininghacks.wordpress.com/library-2/bookshelf/

author: Zero999
author_rank: Super Contributor
timestamp: April 17, 2015, 08:49:41 am
content: Quote from: Cliff Matthews on April 16, 2015, 01:49:44 pmI agree. The SN75176 is designed for this. Just add the appropriate termination resistors and off you go.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: April 17, 2015, 09:12:45 am
content: Quote from: Hero999 on April 17, 2015, 08:49:41 am75176 is pretty ancient and power hungry - there are better low-cost devices from ST (ST485 and ST3485) and Intersil (ISL83xxx).If you need isolation, AD's ADM2582E is nice as it integrates the data isolator and isolated power. A little expensive - Silabs and others have some cheaper isolators but you need a seperate DC/DC.For a 1-way link, I like the NVE passive input isolators, as they don't need isolated power or a ground connection.

author: andersendr
author_rank: Regular Contributor
timestamp: April 21, 2015, 04:28:05 am
content: Instead of rolling your own solution, why not just buy an off the shelf Ethernet module. They are a serial device and can handle your distance without issue. If you want a complete standalone solution, drop a RS232 converter on your board and run a simple serial server (http://www.digi.com/products/serialservers/digionesp). I'm sure you can get other transceivers for other protocols also.

author: LabSpokane
author_rank: Super Contributor
timestamp: April 21, 2015, 06:11:28 am
content: Quote from: andersendr on April 21, 2015, 04:28:05 amLantronix makes many board-level solutions for this as well. And for an air-gapped network it's a great solution. One it hits the interwebs, you become responsible for security and that configuration and testing process can become far more involved - even though the manucturer assures you that the device is "secure." Serial to IP devices do a lot of wonderful things, but the more a device can do, the dangerous it is in inexperienced hands.http://www.mouser.com/Search/Refine.aspx?Keyword=Lantronix+xport