Serial Over Long Wire Run - Page 1
Forum section: electronics / beginners

author: Seph.b
author_rank: Regular Contributor
timestamp: April 25, 2018, 10:20:18 pm
content: Hi!I have been tasked with controlling LED strips in our windows (dumb strips, not addressable) that are max 100ft from our 'control' room.To save cost on wiring, which is much higher than any other cost in the project, we want to run power to the windows with 18awg wire and sending a control signal via cat5 to an atmega that generates the PWM to an LED amp locally. That way we don't have to run expensive 18awg 5p wires to each window.I was thinking I could use transistors to switch 5v serial (just 9600) to 12v and back 5v on the other side to prevent the voltage drop from the long run. Looking at the transistor output on my scope, it looks very sawtoothy instead of square. The atmega does not recognize it at all. I am guessing it is because the transistor takes time to fully switch on.I just tested just sending the straight 5v serial over 100ish ft of cat5 and while there is a lot of ringing the atmega actually reads it. I don't know what kind of packet loss I am getting though and just don't trust it in general.Is there anyway my 5v-12v-5v idea will work with transistors? Doing some googling it looks like opamps my be a better choice, but I have never used them.I know RS232 is probably the proper way to go, but was hoping to keep the control boards as simple/cheap as possible.Theoretically I could use ESP8266 to eliminate the control wires, but there are huge brick walls in the way that make that impossible.Does anyone have any ideas that could help me out?Thanks.

author: Seph.b
author_rank: Regular Contributor
timestamp: April 25, 2018, 11:08:49 pm
content: I may have solved my own problem using the two npn transistor solution from this link:https://electronics.stackexchange.com/questions/78170/square-wave-amplifier-5vdc-13vdcCan anyone explain to me how this is any different that just using one transistor? It doesn't look to me like it should really output anything much different than using a single transistor? The explanation in the post is very short just saying it has high gain.I bread boarded it up and it makes nice square wave though.

author: sokoloff
author_rank: Super Contributor
timestamp: April 25, 2018, 11:16:48 pm
content: There are also dedicated line driver chips that you might use.Alternately, with such a low data rate, LoRa or 433 MHz transmission might work through the brick more readily than WiFi.

author: Seph.b
author_rank: Regular Contributor
timestamp: April 25, 2018, 11:22:39 pm
content: I didn't think about 433Mhz. I have everything to do some tests with it too.

author: C
author_rank: Super Contributor
timestamp: April 26, 2018, 12:39:32 am
content: Using todays standards for serial distance you wantRS422 or RS485These are both differential drivers, so you need a pair of wires for each signal path and a common ground.The advantage of RS485 is that these are transceivers and if you use half-dueplex the same pair of wires can be used in both directions. The down side is you have to have logic so that both ends do not try to talk at same time.Old school would be a current loop interface.The easy way is to use an opto-coupler as a receiver.The sender is just turning on the remote led in the opto-coupler.The output of opto-coupler is connected to serial input. You will need a pull-up resistor here. You could try the built in pull-up of the atmega, but if not enough have option of external pull-up.This has a few advantages.You still need a pair of wires but with the opto-coupler you do not need a ground connection to each end that could be at a different voltage level creating a ground loop.Current is not effected by distance.C

author: David Hess
author_rank: Super Contributor
timestamp: April 26, 2018, 09:48:49 am
content: RS-232 drivers have carefully controlled rise and fall times to limit ringing on long unterminated cables. RS-422/RS-485 are much faster but rely on transmission line terminations. If you want to duplicate a single ended standard like RS-232 using logic and level shifting with long unterminated cables, then slew rate and bandwidth needs to be controlled.A larger problem is the ground loop produced between the power ground and signal ground. If the shift in ground voltage crosses the receiver's switching threshold, the receiver will see that as a signal. Differential signaling avoids this problem (1) and RS-232 avoids it by using large signal swings. Another way to handle this is to use galvanic isolation like the MIDI standard which used optocouplers and that would be my first choice because of its simplicity.(1) Using single ended currents also works very well for this but I have never seen it used except when I did it.

author: C
author_rank: Super Contributor
timestamp: April 26, 2018, 01:23:41 pm
content: Quote from: David HessDavid, it's really sad that you were not able to use a telephone.Current loop existed long before MIDI was even an idea.Original telephone system uses a current loop.Off hook is signaled by closing the loop.Rotary dial is mechanical timed opening/closing a switch.The full duplex voice is carried on current.Tteleprinters or Teletypes used current loop. Switches and relays to start with.Current-mode logic is a differential digital current logic.Video DVI & HDMI use this.This logic is better for speed & distance when compared to voltage based logic.Even for analog links, current is king.The AD590 temperature sensor which is current based does not have the huge problems of the many voltage based temperature sensors.Seph.bIf you think of led's you can have many in series.Your control room could be a 1000' from other end.You could have an LED in photo-coupler & a series connected LET showing link is good. You can connect many of these in series if you adjust the open circuit voltage source higher so that enough voltage is present to turn on all leds that form the series chain..The transmitter is a normally closed switch. A transistor that is normally on.You can have many transmitters connected with only one talking at a time. Again photo-coupler or opto-coupler makes this easy.Need to remember ohn's lawVoltage = Current x Resistance.You can use any one of the three to transmit information.C

author: Rerouter
author_rank: Super Contributor
timestamp: April 26, 2018, 01:47:47 pm
content: As they are dumb strips, its likely a 1 way communication, so a RS485 bus would work well, with the master just blasting what it wants without any ACK/NACK its both cheap and highly immune to ground shifts caused by large current changes.

author: David Hess
author_rank: Super Contributor
timestamp: April 26, 2018, 02:57:33 pm
content: Quote from: C on April 26, 2018, 01:23:41 pmWhat you are describing is a current loop with a separate current return. What I described, *singed ended* current, is so rare that it has no proper name. It is like using one half of LVDS which is current based with one signal line instead of two with the ground providing the return. The analog implementation is done using a transconductance amplifier on the sending side (a Howland current pump works) and any operational amplifier on the receiving side with a current shunt to ground.I have occasionally used it to transmit audio where large amounts of common mode noise existed but single ended compatibility was required. It only requires adding a single resistor at the receiver and *not* connecting the cable shield or ground which is kind of weird but necessary or it will not work.

author: Cliff Matthews
author_rank: Unknown
timestamp: April 26, 2018, 03:27:12 pm
content: Seems this application is *sending commands only (not traffic intensive). For longer RS232 STP cable runs, use a lower bit-rate. 200ft is fine at 2400 bps (but connect the shield at one end only). 35-years ago we regularly ran 200ft double-braided at 9600 bps (SDLC clocked synchronous) at the 3-acre main Bank of Montreal mainframe complex, without issues.SDLC? Yeah, I know I'm old already..

author: C
author_rank: Super Contributor
timestamp: April 26, 2018, 04:37:44 pm
content: David HessWas not picking on you.I think it is safe to say that most think first of voltage.Think this is sad.Is it a loop or single ended. There have been telephones with only one wire with earth the return.Just think a telephone is a very good example of what you can do with current based system. Here you provide power, signaling and full duplex audio.As for rare, could be how you look at it.You have many things that very the resistance. At a distance using current change can give better results then voltage. I have seen and used current based systems often.Back in the 80's, HP built a pressure sensor for use in the oil field. It was attached to wire line often up to 15,000 feet long. Wire line for those who do not know is a braided steel cable with an insulated conductor in center for signal built to lift a load(often in 100's or 1000's of pounds). Yet with this poor connection, supplied power to pressure sensor which had an output of 0-15,000.00 psi. Yes to 100th of pound. The wire line was often 15,000 feet long and the pressure sensor could be working at 200 C.A current change was used to transmit.That 200 C might sound high to people here, but very limiting in wells. Last I looked they were up to 350 C and keeping the smoke in. Normal solder and plastic packages do not survive, chip might.=====Any way Op's problem for 100 feet can be easy with many ways to cure problem.But if I was Op putting an atmega in the window controlling LED strips, I would use part of that compute power to verify proper operation. Failure to check proper operation can lead to embarrassing problems.C

author: Seph.b
author_rank: Regular Contributor
timestamp: April 26, 2018, 09:33:32 pm
content: Wow, thanks everyone for the wealth of information. This definitly gives me plenty of options.Luckly it is just important to get the LEDs in the windows now and I have some time to work out the control.

author: Seph.b
author_rank: Regular Contributor
timestamp: April 26, 2018, 09:50:23 pm
content: The MAX485 really looks like the way to go.

author: Eka
author_rank: Regular Contributor
timestamp: April 26, 2018, 09:59:09 pm
content: Power your 18 awg wire using 48 VDC, then use a DC to DC converter to change it to 5VDC at the window. Wide input range DC to DC converters are available for reasonable. You'll need some big input capacitors because the input is highly inductive.As for the signal. Almost any differential line driver pair can do 100 feet. If you are running small amounts of data over the link, then RS485 drivers will do. If you want to push a lot of data, then look at using ethernet. Put a smart ethernet NIC on the atmel. There are smart ethernet interfaces that will sent the data from the packets serially on to the atmet. All the atmel has to do is do a small bit of configuring, then receive the data. No ethernet management duties. If the amount of watts you need for the LEDs is low enough, then POE may work, but my guess is that isn't enough. I can't power my LED art with POE links.For all my LED displays that are remote, I use a Raspberry Pi with built in WIFI to communicate to them. The APA102 based displays are directly driven by the Raspberry PI. I just need to find a power source at the display site, and give the Raspberry PI the SSID for the network. That can be written to the right files on the microSD card before putting it into the Raspberry PI. I use 48VDC over 18 to 12 awg wire from the nearest wall outlet to power them. With high line losses they can be a few hundred feet from the power supply. I try to stay under 40 feet for efficiency.

author: Seph.b
author_rank: Regular Contributor
timestamp: April 26, 2018, 10:34:11 pm
content: We are going to run 12v over the 18awg wire, probably measure it at the end and adjust the voltage to be right at 12v.I just use 7805s for the 5v to run atmegas. I know it is not as efficient as a switch mode, but they are cheap and quick.

author: hamster_nz
author_rank: Super Contributor
timestamp: April 26, 2018, 10:52:22 pm
content: In the early 90s I ran a 20mA current loop from a computer room, down 5 flights in a building riser, out the door, across power poles over a pedestrian mall (using bylaws designed for cable TV), into another building up three levels, and then into a the terminating device. Worked fine at 19200 baud.Also, if you are electrically connected you need to be careful about ground moving around as you switch loads. Save the hassle and use an Optoisolator.

author: Jwillis
author_rank: Super Contributor
timestamp: April 27, 2018, 01:40:31 am
content: More gain with 2 transistors.