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.

UPDATE: I've just added a new post that goes into more detail about using the SN75176A chip in this design, for those of you who have asked about variations of the above circuit.

38 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!

Anonymous said...

I wanted to thank you for sharing your approach to controlling a LED strip over a distance. I want to control two strips of 4 meter at a distance of about 6 meter and was struggling with the power and the data signal. I tried your solution and it worked! You saved me allot of time :)
I power each meter with a separate DC/DC converter, and I see no dimmed LED's at the end.
The only thing I did different was that I used the SN75176 for both the transmitting and receiving of the data signal.

chad said...

Do you think this system could be modified to control 7 sets of 8 pixels 20ft apart? The big problem is that I need to daisy chain the wiring as the conduit isnt large enough to fit all the cables in.

teknynja said...

I haven't tested a daisy-chained configuration, but it seems like it should work just fine. You would simply "bus" the 12 volt power to all of the strip's voltage regulators, and then use the data output from each strip to drive a RS-485 driver feeding the next strip's receiver. Since you are only using a single data line to drive all the segments, you could also use just a single SN75176 at the controller end instead of the quad SN75174.

If you do build this, be sure to post back to let us know how things worked out!

Chad Penney said...

I will do that.. I plan to order some of the SN75176 chips this week

Chad Penney said...

I was able to make this work over lengths of 4wire RGB cable no less. I posted a link in your thread on the AdaFruit Forums.

http://forums.adafruit.com/viewtopic.php?f=47&t=49543&p=326405#p326405

teknynja said...

Very cool! I think you have open the door to many new applications with your twist on this idea. Thanks!

Chad Penney said...

Thanks. Another twist I tried out which was kinda neat was to connect them in a bus setup. Basically all the strips did the same thing at the same time. I could see lot's of uses for a setup like that. Next step is to see how many of these I can chain together.

Sam Clayton said...

I'm working on lighting for an interactive art project, and this is perfect for the way we're going to need to distribute small clusters of 2812s around the space. We were thinking along the same lines (serial + power over CAT5), so it's good to see someone else's implementation. Thank you!

Greg Woods said...

Thanks for sharing this. I've already ordered the parts for my NeoPixel setup, and due to the position of my 2x 4m strips, I have no data cable over 1.5m using a star topology.
I had to go with 8AWG cable and a 30A PSU though, so the buck convertor idea is great. I may consider this and/or the cat5+RS485 solution if I ever do another project.

john said...

How would I hook up the 75176 on the controller end

teknynja said...

The 75176 is actually a transceiver device, so you can also use it to drive a single RS485 channel by tying the DE & ~RE signals high (either directly to VCC or through a pull-up) and then applying the controller data to the D input. This will then give you a RS485 output on the A & B pins that you can use to drive another 75176 (configured as a receiver as shown) on the remote receiver end.

Vadim CLEMENT said...

Hello,

Following our emails coming back to you through your blog.

I made the schematic ( http://img4.hostingpics.net/pics/967756MainboardEmmitReceiv.jpg ) for the transmission part and the reception part. Based on the SN75176 (the one used in your schematic. It better and more features than the MAX485). I just have some doubt about the connections with D/DE and R/RE.
I added a resistor (R3) and a pullup resistor (R2) Pulldown is this good?

Thank you for you precious help

teknynja said...

Vadim -

Referring to your diagram, you are close, but for the emitter/transmitter circuit you would tie DE & /RE high (VCC) to configure the IC as a transmitter, and leave R (pin 1) disconnected, since it is an output, you do not want to connect it to power or ground.

Also, since the length of the transmission line is only a few meters, you can skip one or both of the termination resistors (R1). R2 & R3 are typically only used if you expect the bus will be disconnected during normal operation, in which case they pull the inputs into a known state. If the wires will be normally be connected all the time, you can eliminate those as well. Basically, for the purposes of driving WS2812 style LEDs for less than 10 meters you eliminate all but the one termination resistor at the receiving side, as shown on my schematic above.

Let us know how your project turns out, it sounds like it could be quite interesting!

Vadim CLEMENT said...

Thank you for your help Teknynja,
So I changed my schematic for DE & / RE as well as A. I have a small question. Why D is connected to GND in Receiver mode? I guess you can also leave D disconnected Receiver mode? ( http://img4.hostingpics.net/pics/897867MainboardEmmitReceivEdit.jpg )

I preferred them in case I want to use these modules in other projects (with longer cables). So I can leave R2 & R3 without problem and leave R1 on Receiver side?
Last question which will be appearing stupid. One line A B for DI and one line for DO? Basically it is a new line between two modules.

And it is with pleasure that I would give news of my project, schematic and photos ^^
It's really kind to take time to answer me, thank you again!

teknynja said...

It is usually a good idea to force unused inputs (such as the D input) to a known state even if they aren't being used. This is because if you leave an input floating, the input voltage may switch between states, causing unpredictable behavior or glitches.

As for the A & B signals, they are "differential" signals, meaning when one goes high the other goes low. This is the reason the signal can be driven much further, as instead of having to compare a single signal line to a fixed threshold voltage, you compare one signal line to the other. If A is more positive than B you treat it as a "one", and if B is more positive than A you treat it as a "zero". See this Wikipedia article for a more detailed explanation of differential signals.

Vadim CLEMENT said...

Thank you for your explanations about the pin D.

I understood functioning of A and B, but what I mean is that I have to use the same line A B sends data to the line A B that returns DOUT.
Basically sent and received on a single wire pair? Is is fast enough for the round trip latency-free? Because it takes that sent finishes for the return. I would have more tended to think that using a pair (blue and blue / white) for sending and another pair (orange and orange / white) for return.
( Here is a small drawing ( http://img15.hostingpics.net/pics/173808Explain.jpg )

Sorry if I have difficulty to understand: /

Thank you Teknynja

teknynja said...

The only way you could share the A/B pair would be to control the DE pins to enable only one transmitter at a time - without controlling the DE pin the transmitter is always driving A and B and having another transmitter on the same pair will cause a conflict. It is much simpler to just use 2 pairs (in the same CAT5 cable) as you have shown in schematic #2.

The RS-485 specification does allow for multiple transmitters in a bus configuration, but it requires some kind of control scheme to ensure that only one transmitter is enabled at a time. The WS2811 don't provide any way to control the transmit enable.

Oliver said...

Hey Teknynja!
Thanks for this awesome tutorial! Its been a great help wrapping my head around this whole LED/distance problem. I am planning on building a modular LED tube setup (10x 1m WS2812b). I want to use the SN75176 as drivers and receivers.

In your second picture where you show the wiring you put a 4.7K resistor between 5V and (I believe) pin 4 of the quad driver (SN75174). Is this also recommended when using the SN57176 as a driver? What kind of resistor would I need, what pin would I need to connect it to and why is this even necessary?
Also in the Adafruit NeoPixel Überguid they are recommending putting a 1000uF capacitor between 5V and ground of the power supply to prevent power spikes. They also suggest using a 470ohm resistor between the signal line of the Arduino and the LED strip. Do you also recommend this in your setup? If so where would they go? On every „receiver module“? Is this dependent on the board you are using (Arduino/ Teensy)?

Lots of questions. Hope they arent to much. I am trying to plan ahead the best I can before putting in this big order.
Have a nice day!

teknynja said...

Thank Oliver!

Let's take these questions one by one. Pins 4 and 12 on the SN75174 is the output enable pins, which when driven high allow the devices to drive the bus (CAT5 in this case). I am using the 4.7K resistors to pull them high thus constantly enabling the outputs. Using the resistor is not completely necessary and you could simply tie the enable inputs directly to the 5v line to save costs if desired. The resistor is there just to limit the amount of current flowing into the pin. Its value is not that important, and since there isn't much current flowing through it, a small 1/8 watt resistor is fine. You'll note that on the SN75176 side of the circuit I'm simply connecting the various enable pins to 5v or ground needed without using resistors. For this application it would be fine to skip the resistors and just connect the inputs to 5v or ground as needed.

As for the 1000uF capacitor, I chose not to use them since the power supply on the receiver is so close to the strips, there isn't a huge amount of voltage drop/inductance in the power wires (And also to save space, as I put the receivers in a very small enclosure). I am also relying on the DC/DC converter to have a built-in smoothing capacitor on its output. If you find that your pixels are exhibiting "flaky" behavior, then you may need to add this capacitor, but in this configuration it wasn't needed.

Finally, the 470Ω resistor between the receiver output and the strip input is there to match the impedance of the driver to the LED strip. If there is a bit of distance between the driver and the LED strip, this resistor would help prevent "ringing" in the signal which could distort the data signal. Again, since the wire between the receiver chip and the LED strip is so short, it is not really required.

In summary, the components you have inquired about make for a slightly more robust design at the expense of size and cost, and because the connection between the driver circuit and the LED strip is so short, their inclusion is not really needed.

Good luck with your design, and feel free to post a link to your project here so we can see the results!

Vadim CLEMENT said...

Hello Teknynja,

I order my pcbs at OSHPark few weeks ago, I would put some pictures when I have received and tested (hopefully everything works ^^)

Thanks ^^

Oliver said...

Thanks you for your fast and detailed replay. Im really looking forward in building this project. :)

Oliver said...

I stumbled upon another problem... what do you think, how much amp can a CAT6 cable handle? I am really worried about cable fire.
I want to drive 5x 2m LED strips about 10-15m away from a beefy 12v 40a power supply. Following your guide I figure this should be possible without worrying. I also wanted to be able to daisy chain them together (applying power every meter), but I am really worried that a CAT6 cable cant handle 30amp and eventually everything will go up in flames. Any ideas or suggestions?

teknynja said...

Based on a quick check of standard wire gauge for CAT5/6 and a chart on the web, solid core CAT5/6 cable can carry about 2A (less if it's stranded core wire). Even with paralleling the 3 "extra" pairs in the cable, you would only be able to push about 6A through it. Based on the tables I saw, you would need to use 10 gauge wire to carry 30A.

Keep in mind that the 12V current requirements of the DC/DC converters will be less (roughly half, depending on their efficiency) of the current draw of the 5V output, so you may need less power than you think.

You may also be able to get away with using non-CAT (without twisted pairs) for a 10-15 meter run, which means you could use a beefier 4 or more conductor cable between the transmitter and receiver. Twisted pair is always nicer, but at the low speed of the data signal you can probably do without them.

Finally, if all else fails you could run 2 cables (one for data, and a higher gauge pair for power), although that seems like the ugliest of the approaches.

If you could introduce power nearer to the receivers at multiple points, that could be your solution as well. You could still daisy-chain the data between each segment, but I would start a new power run at each segment (not connect the power between segments). That would let you distribute the load between different chunks of CAT5/6 to keep the current below the limit.

Hope this helps!

Oliver said...

Thanks for your input! I wasnt aware that the current is cut in half when voltage is doubled. Basic physics hello again! :D
By paralleling the extra pins you mean 2 pins for data signal, 3 pins for 12v and 3 pins for ground. Like I show in your diagram (thats what I was planing on doing) or am I mistaking?
I am now planing it like this: every CAT5/6 cable that comes out of my controller box (Teensy + 12V / 30A power supply) can power 2x 1m LED strip "out of the box". If I want to daisy chain them all together, I would either run cables from a free slots of the controller box (if there are any at the time) or I would apply power near the LED strips from a different source.
That should be save, should it not? That would mean every cable coming from the controller would need to carry 3A at 12V. Would that work if I run the cable lines like shown in your diagram? If it turns out that it can carry more than 3A an I could hook up another 1m strip, than yeah for me. :)

Have a nice day! And thanks again for taking the time, helping me!

teknynja said...

Yes you are correct when I referred to paralleling the extra pins (which distributes the current across the wires).

Your plan to have multiple short segments driven by several outputs of the Teensy and all powered by the same 12V/30A power supply should work fine - in fact that is exactly what I did on the project that inspired this post. I even used a Teensy controller!

Sounds like you are definitely on the right track!

Oliver said...

Hey teknynja, its Oliver, back from the workshop again. :) But I am having problems getting it running. I have tried to test it with the "BasicTest.ino" from the OctoWS2811 lib. I verified that my Teensy is working correctly with a Blink sketch.
Could you take a look at my wiering and tell me if I made an error there? -> http://i.imgur.com/XEPLN5h.png

teknynja said...

Oliver -

I'm not sure if it's just missing on your diagram, but you must connect pins 15 & 16 on the Teensy together in order for the OctoWS2811 library to work. (See the diagram under the "Hardware Requirements" section of the library's documentation at https://www.pjrc.com/teensy/td_libs_OctoWS2811.html). Other than that, it looks like things should be working based on your diagram.

Oliver said...

It works! :D But it wasnt the pins 15 & 16 (I had those connected) but it was the wrong wiring on the receiver. I mistakenly soldered the VCC (8) and R/DataOut (1) lines the wrong way to my PCB board. This also resulted in damaging the SN75176 driver on the receiver. So I soldered the lines together the right way and switched out the driver and voila it works!
Here is a picture of my test setup, maybe others con benefit from it: http://i.imgur.com/0JynUnM.jpg

Have a nice day!

teknynja said...

Due to several inquiries both in the comments and in emails, I have added a new post that goes into more detail on how the SN75176A is used in this design, and it should provide enough information for you to use the chip in other projects as well. Have fun, and thanks for all the great feedback!

allanGEE said...

RE: "After connecting everything up, it worked like a charm! Every pixel was responding as though it was sitting right next to the controller."

Did you test it without the driver/receiver setup? I'd be interested in how the results compare with each other.

teknynja said...

@allanGEE - Glad it worked for you. I did try driving the NeoPixels directly, but even playing with various termination resistors I wasn't able to get any kind of consistent behavior, the pixels seemed to only respond in random patterns. Some people in other forums claim to have been able to drive them over significant distances just using matching resistors, but it didn't work for me. I'm not sure if they tried running them at 100 feet like I did!

Vadim CLEMENT said...

Hello Everyone, sorry for the time to reply my result :/

Some pics of my project :
The first project is WS2811 with SN75176, one for emitter and one for receiver. 3 modules for driving 10W RGB Led based on PT4115

The other projet is also based on WS2811. One version with SN75176 and one without.

https://drive.google.com/open?id=0B2iTOfCf_w5HNFg5MEVWMWFJVGRGcmlyR3gxY056ZnlZZ2tV
https://drive.google.com/open?id=0B2iTOfCf_w5HMW9PVFQ5elBBY1BzRlJBLXdYdG45dU01QUZN
https://drive.google.com/open?id=0B2iTOfCf_w5HR1dDQV9qNktHQnRpaXJVdVN1dWl3VGt3TzlJ
https://drive.google.com/open?id=0B2iTOfCf_w5HNXVodUhzdEJxMHNzZTdNTXNFb2x5b0kyUjFN

So thank you Teknynja for help to understand the SN75176!

 
Template design by Amanda @ Blogger Buster