20140208

Driving WS2812/NeoPixels RGB LEDS over CAT5 Ethernet Cable

I was recently working on a project using Adafruit NeoPixels (WS2812) RGB LED strips where a single controller was supposed to drive five strings of 30 pixels that were physically located several feet apart. I knew right away that there was going to be a couple of problems trying to drive the strings over more than 20 feet of cable. First off there is the voltage drop issue - these strings can draw several amps, and could easily drop around 1 volt or more, depending on the cabling and connectors. The other issue is the integrity of the data signal being sent to the string. The pixels are very timing sensitive, and noise or ringing caused by a long wire run could easily introduce errors, or even result in a completely non-functioning string. This last issue was made even worse by my choice of controller, the Teensy 3.0 which is a 3.3V part, while the pixels require a 5V input. (By the way, the Teensy 3.0/3.1 + the OctoWS2811 library is an awesome choice for driving dozen to hundreds of RGB pixels!)

While it seems that many people have successfully driven NeoPixel/WS2812 strings directly from the Teensy using a small resister to reduce ringing, I was pretty sure that wouldn't work over any appreciable distance. It also appears that the newer WS2812B pixels won't work at all with just a 3.3V signal. It didn't take me too long to come up with the solution for the data issue - RS-422/485 drivers and receivers! Since the pixel data is really just serial data, I figured using RS-485 balanced transmission lines to send the data would work perfectly. The data signal is well within the bandwidth these chips are capable of, and as a bonus, the SN75174 Quad Differential Line Driver IC inputs will easily accept the 3.3V outputs from the controller! On the receiving end, I went with SN75176 Differential Bus Transciever chips because I had several of those on hand in my parts bin. I just needed the receiver part of the chip, and it was quite easy to disable the transmitter portion.

Next up was the power-drop issue. Right about the same time I was dealing with this I discovered these LM2596 DC-DC Buck Converters on Amazon - they were perfect! Their low cost, small size, high efficiency and wide input voltage range made them a snap to integrate into my project. (Just make sure you check/adjust the output voltage on these before you use them!). Now I could feed 12V into my long cables feeding the remote strings, and use these power supplies on the receiving side to drop it down to the needed 5V. Since I was only driving about 30 pixels on each line, the 3A output was more than enough to drive each string.

With all the pieces in place, it was time to test out my ideas. First, I wanted to test out driving the data signal using the differential converts, so I wired up a transmitter and receiver on each end of 100 feet of CAT5 cable, connected up my controller to the transmitter and 5 meters (150 pixels) on the receiving end. For now, I just connected up a beefy 5V/10A power supply at the receiving end to power the string. After connecting everything up, it worked like a charm! Every pixel was responding as though it was sitting right next to the controller.

Next up, I cut the string up into 5 lengths of 30 pixels each, and wired them up as shown below, using the differential transmitters/receivers and the DC/DC converters (again making sure they were adjusted to provide 5V output!), powering everything with a large 12V power supply. Everything worked as expected, the pixels were changing colors as commanded, with no color shift or dimming caused by voltage drops.

Notice that I am calling out the color codes for the CAT5 wiring - it is important that at least the data wires are on twisted pair of conductors (blue/blue-white in this case). I also like to have the power wires paired as well, with all the +V connections on the solid wires and the -V connections on the white-striped wires, which helps with noise immunity on the power lines. In my project, I used 4 position connectors and just tied all the +V wires together on one terminal and all the -V wires on another (with the data on the remaining two terminals). Using all the extra wires in the cable for power helps reduce the resistance, and thus the power drop on the cables.

In the end, my project worked well, with the strips connected via 15 - 25 foot lengths of CAT5 cable all connecting back to my central controller. If you have a project where you need to have several remote RGB pixel strips all controlled from a single controller, hopefully by using this approach you can make your pixels work just like they were connected directly to the controller. As usual, your feedback is always appreciated, and if you have any questions please feel free to leave a comment.

6 comments:

Unknown said...

Clever approach. I like it.

I have always wanted to connect a long row of 100 LED strings (12 - 15 LEDs a piece) spaced 3" apart and control them from a PC to make a pattern. The idea is to make them look like icycles, hanging from the gutter on my roof for Christmas.

The problem is that it would be pretty expensive and the power would be big. Your ideas is to control each LED with a separate CAT5 (I think). My idea is to make them serial and provide power to each LED string.

Any ideas?

teknynja said...

An interesting dilemma – I'm assuming the PC will be located some distance away from the strings, so using the RS-485/422 idea makes sense between the PC and the strings. Power might be more of an issue, as the DC/DC converters I mention in the article aren't big enough to drive more than 30-40 pixels at a time. You could do something similar to what I have done above, powering 2-3 strings of 12-15 pixels off a single converter, thus using 2-3 converters for the entire project. The DC/DC converters I mention are physically very small (and very inexpensive), so that is probably a viable solution. You could easily stuff a few of the converters along with a receiver circuit inside a small project box mounted behind the gutter. Otherwise, you could put a 5 volt, >7 amp power supply near the strings, and then simply run the power wires from each string back to the power supply (that would require running AC up to the strings though).

The data would also be a bit tricky, as you probably don't want to run a separate data line for each string from the PC to each string (that would take 12-16 wires, and 6-8 receivers). You mention the strings would be only about 3 inches apart, so I suspect that you could “daisy-chain” the strings, by running a wire from the data output at the bottom end of each string up the back of the strip (to keep it hidden) and then feed that to the next string in the chain. Running the data lines using just a couple of feet of wire between strings should work fine, although you might need to put a small resistor inline with the data at the receiving end of each chained string to help control ringing, but that way you would only need a single RS-485/422 receiver connected to the input of the first string.

All this should be easy enough to test “on-the-bench”, so you can work out the best approach for your project. Hopefully you find these ideas helpful in bringing your icicles to life!

WIGIV said...

Thank you for this writeup! I am working with artists to implement WS2812's in various interactive projects, and have endured a constant struggle with power and data over long lines.

Many installations require the controls cabinets to be 20 or more feet away from the LED strips, and I think your approach will help immensely.

One difference is that we'll be using LM317 linear regulators instead of the units you mentioned, due to the number required, and the cost.

Will be modifying an existing (problematic) system next week to test.

teknynja said...

@WIGIV - I too was originally thinking about using linear regulators (LM7805) for this project, but with the superior performance and low price ($3), for me the DC/DC converters were the way-to-go.

Even when driving just a few pixels, you have to be careful about power dissipation and the voltage differential with the linear regulators.

The DC/DC converters are so efficient that you don't have to worry about using heatsinks, even when driving them from as much as 24V and pulling 2 amps from them! It also means since less energy is being converted to heat, your main power supply can be smaller and cheaper.

Since they are so small, I actually ended up just soldering leads onto the converters and mounting them directly onto the circuit boards with the receiver circuit.

I am glad to hear my little hack is helping you out. Thanks for taking the time to let me know about your work!

Reverend Dave said...

If you use RJ-45 connectors (more to the point, sockets) for connections, you may want to put +power on one solid/stripe pair, and -power (ground) on a different solid/stripe pair.
Ethernet magnetics are little signal transformers, with each solid/stripe pair going to one winding.
If someone decides to plug their laptop in via ethernet cable, having a power supply with a non-trivial voltage difference across a signal winding will probably fry the laptop's ethernet magnetics. (This is a Known Issue(tm) with equipment that uses passive power-over-ethernet.)

teknynja said...

Reverend Dave makes a good point - if you are planning on using RJ-45 connectors, consider yourselves warned!

I actually connected mine using four position terminal blocks so no worries about accidentally plugging anything into network ports, but I can see the temptation to use network connectors with network cables!

 
Template design by Amanda @ Blogger Buster