Hi! Can anyone kindly explain the determination of the resistor value (normally) placed on the data line between the MCU GPIO output and the first LED?
Adafruit best practices guide suggests 300-500Ω. It also states “if you’re not sure, add one… there’s no harm in doubling up”
The WLED getting started page shows a 62Ω resistor, but with the note “value depends on the wiring configuration”
But, looking at any of the WS28xx datasheets, there’s no resistor shown in any of the example application circuits. There’s also no mention of it at the advanced “wiring” page.
It certainly seems that there’s no exact value, but is there at least an approximate rule of thumb I should follow, or some values I can measure to determine the correct value? (It seems that not even all sources agree on the purpose of the resistor… is it for signal conditioning and reduce ringing, or to limit current as a protection to the first LED?!)
62 Ohm is near the termination resistance for RF lines. 330 Ohm is a safe value, to protect a GIPO against short circuit. This value isn’t critical. With zero Ohm it will also working
Thankyou for the reply. Yeah, I’m aware that there certainly seems to be a wide range of accepted tolerance, but I guess what I really want to know is what is considered “best practice” (and, even better, why that is the case). Even though it appears to work without a resistor at all, there is presumeably a downside to that… (interesting that you mentioned protecting the GPIO - most guides suggest it’s there to protect the LED!)
If it’s related to the parasitic capacitance or inherent resistance in the strip itself, the length of run or distance between MCU and the first LED etc. then it feels like it should be possible to calculate the optimum value for a given setup?
It’s a current limiter. If there were a short circuit on the LED line, 3.3v / 62 ohm = Imax ~53mA, which is above the 40mA limit of an ESP32, but the tolerances may keep it safe. 83 Ohms would keep Imax below the max. As @Superluminal stated it can be much higher. It’s like insurance, you only need it if something goes wrong…
Thanks for the reply (and thanks also for the welcome!)
I agree with the principle of your calculation and reasoning, but if that’s the case I still don’t see where the recommended 62Ω value came from!
As you say, 53mA is still outside the 40mA max limit for an ESP32, and well above the 12mA limit on the GPIOs of an ESP8266 (which is the MCU that appears to be depicted in most of the WLED wiring diagrams), so if it’s only there as a safety measure, it doesn’t seem an ideal value… I’m wondering how WLED came up with that value when Adafruit’s suggestion of 330Ω would seem better?
The big name controllers for xLights shows all use 33Ω to be most compatible with 3 core xConnect/Ray Wu style wiring. (Kulp, Falcon…)
Also adding the wrong value can 100% disrupt the data signal. Basically if they flicker or flash here n there. Try a resistor. If it fixes it problem solved. If it’s worse try another value. Every setup has the potential to be different. No one can guarantee what wire/connections anyone will use.
Thankyou - the explanation in that article looks to be exactly what I was looking for! (just a shame that it didn’t show up in any Google searches, lol).
Thanks all for your input - really appreciated, cheers.
Armed with that information, why not always have a potentiometer at the ready to “fine tune” the output? I wonder how to figure out the “perfect” value. Would you adjust it so that, all else equal, the most total current flows without any noticeable flickering, or just adjust it until the flickering stops?
The best way would be to tune it with a scope. I am sure there is some crazy math that can be done, but does it really matter? We are not running lighting on the space shuttle here
Would we be looking for the “cleanest” square wave or the highest effective voltage? It would probably need to be redone with different effects and speeds to account for changes due to frequency???
you want the cleanest square wave and it is not dependent on frequency (which is fixed by the way, alway around 0.8MHz for most LEDs).
the topic is something that is hard to understand, even for professionals. In a nutshell: you want to match the impedance. It can all be calculated but in the end has to be measured as there are uncontrollable variables in a real setup, unless you do very (very) clean wiring.
The closer together (and thinner) your wires are, i.e. data and GND, the smaller your resistor value. For loose wiring something in the range of 300R should work best. For a twisted 22AWG wire, probably more like 50R
Edit: fun fact: the ESP would have built-in resistors (sort of) but since LEDs require a levelshifter, this feature is useless.
It’s been marked as solved, but I do want to link this very detailed post specifically about this subject (not how to determine the resistance, but why it is usually necessary).
That link sounds like a valid explanation, but it goes down a couple of invalid rabbit holes.
There’s no appreciable power consumed by the data line the required current for activating a WS281x LED input is on the order of a few uA’s
There may be some transmission line effects on the data line. The analysis of output impedance for an ESP GPIO pin is dodgy at best, there are many other factors that can affect the data connection. Wire choice will probably overshadow many others for most setups.
I wouldn’t promote that description of the data line effects…
100% agree with divsys. This is a very dodgy, incomplete and oversimplified explanation. While partially true, the conclusions are wrong.
The simple explanation is just: the resistor is for impedance matching.
The long (and correct) explanation fills a book. For anyone interested: read about transmission lines and impedance matching.
I’ve been playing with this. I have 500 ohm trimmers in-line right after the level shifter outputs. I never get a “clean” square wave, either the beginning has a “rollercoaster” (which is what the signal looks like between the gpio and the shifter’s input), so it’s like 4.4v than 4 then 4.3, 4, 4.2, etc. for about .25 of the positive half wave, or the flank has tiny “steps” and is not really vertical, or the top of the wave is full of ripples, or the flank is curved. So, when considering “Best”, what is the best? Should it be as close to a reference square wave as possible, or have the highest amplitude, or the straightest vertical flank, etc?
I ask because it seems nowhere between 0 and 500 ohms do I get a flicker free output. I have (basically) 3 sets of 3 8x32 matrices, for each set there are multiple injection points, have one 1000 uF capacitor close to each of the first panels as mini-buffer for the supply voltage. One set has no issues, one is decent, but the third lights up or flashes a few random pixels every few seconds.
that wiring looks a mess. clean that up, dont cross power and data, keep the lines short, make sure you have a clean ground connection. what matters is the signal at the end. if you have any screenshots of the scope, then I can explain. take shots of the signal at shifter input and output.
Lol. Yes it is. I went with dupont connecters to make joining the components easier, but even the short ones are too long (what do you say to rolling them bi-filar to prevent induction?). I have to figure out how to get screenshots from the scope as it is stand alone, but worst case I can take photos. It probably won’t be today.