# LED resistor calculation with variable voltage

I apologize as the original question was not accurate. I have updated the question.

My main goal is to design a polarity tester for battery packs. It will be used for multiple ranges of batteries to test their polarity. So the battery's voltage starting from 3.5 volts to 60 volts with different output current. The schematic below shows the exact diagram and PCB I made with Fusion 360.

I want to calculate the value of the resistor. The LED forward voltage is 2.5 volt, and the current of LED is 130 mA. 2.25 V Red LED 5mm Through Hole, Kingbright L-53HD.

The power source is variable from 3.5 volts to 60 volts with the variable unknown current. So, each time I connect the circuit to any voltage from 3.5-60 volts one of the LEDs will turn on. The problem is that as the source voltage is variable what type of resistor I need to resist the variable voltage so the LED does not burn.

I used 4 diodes, to block and allow the current for two LEDs, from one side one LED with green colour will light up and it will show that the polarity is correct. If the polarity is wrong then the red LED will light up.

I used U1 as a Bourns 1kΩ Thick Film SMD Resistor ±1% 25W - PWR163S-25-1001F for dropping the voltage. I know this might not be suitable but as the problem, I have with different voltage I thought this might work.

The power for the circuit will be taken from the battery packs and there will no external power supply for the circuit board.

On circuit "JP3" and "JP4" are circuit power input, JP1 and JP2 are LEDs.

• What you want (one LED and one resistor) isn't going to deliver a constant current of 250 mA into your LED over a voltage range of 3 volts to 60 volts. So don't specify what you want in terms of component count because it ain't happening. – Andy aka Oct 9 at 13:55
• Why don't you edit your question and explain what the real problem you are trying to solve is? (1) Where is the 3 to 60 V supply coming from? (2) How is that variable supply able to provide 250 mA over such a wide output voltage? (3) Is there a fixed supply available to power the LED and use the 3 to 60 V as a trigger to power the LED? If you hide information from us you'll get bad and irrelevant answers and waste a lot of people's time. – Transistor Oct 10 at 0:10
• @HabibAnwari Now that I understand what this does, you can just use a relaxation oscillator with an LED. It will blink faster with higher voltages and it can be designed NOT to blink at all below a threshold voltage. Trivial and safe and extremely low power! So this not only tells you polarity, it also tells you if the voltage is high or low and provides an indication of voltage by the pulsing rate. I build these all the time here. Sheesh. I had no idea. You should have added all this, earlier, I think. – jonk Oct 10 at 1:01
• Why does a polarity tester require a 250 mA LED? Why would a high-brightness 5 mA LED not suffice? If you need to load the battery then use a separate circuit to do that, not the LED. – Transistor Oct 10 at 1:06
• "So are you saying that I use a 10mA resistor in the circuit and it will be fine with 3.6V to 60 volts?" The very first comment explained to you that a single resistor will not solve this problem for you. From $V = IR$ you get $I = \frac V R$ so as the voltage across the resistor goes from 1 V (on a 3 V battery) to 58 V (on a 60 V battery) your current will increase by a factor of 58. – Transistor Oct 10 at 8:38

The maximum current for the LED in the datasheet you provided is 25mA (130mA is a peak current).

The LEDs also have a diode in series, so 3.5V will allow for very little current on a green LED. Let's assume 2V for each LED.

At 60V the current must be < 25mA (let's use 20mA so as not to be too close), so R = 57.3/0.02 = 2.9K. The dissipation will be 1.13W, a bit high for a 1W resistor, so let's use 3.3K.

So the current with 60V in will be about 57.3V/3.3K = 17.4mA.

With 3.5V in, you'll have 0.8V/3.3K = 240uA (probably a bit more because the drops will be a bit lower).

240uA is not a whole lot of current but it may be acceptable with bright LEDs.

You can get a bit more current at the low end by replacing the diodes with Schottky diodes. Because your eyes respond logarithmically, the visual brightness difference will not be 70:1 as the current ratio, but it will be substantial. Only you can decide if it's acceptable.

Anything that is going to give you a more constant current will involve more parts, however since you're really going for a much lower current than originally stated, it will be simpler.

By the way, it would be better to use one resistor and have the two LEDs back-to-back:

simulate this circuit – Schematic created using CircuitLab

That increases the current at 3.5V to 450uA, about double, with fewer parts.

• @PeterCordes One LED diode protects the other. The reverse voltage will never exceed a couple of volts, which is well within the (conservative) -5V rating of most LEDs. – Spehro Pefhany Oct 10 at 11:26
• Oh right! I see now, thanks. That's why it can work better at low voltages, because you can drop the series protection diodes. – Peter Cordes Oct 10 at 11:27
• @SpehroPefhany, – Habib Anwari Oct 11 at 21:49
• 3.3K ohms, 1000x more. – Spehro Pefhany Oct 11 at 22:44
• @SpehroPefhany electrovo.com/wp-content/uploads/2020/10/… – Habib Anwari Oct 12 at 23:30

## You Cannot Just Use a Resistor

With zero voltage overhead (the difference between the lowest supply voltage you want to support and the LED voltage), there is no possibility of regulating the current through the LED.

A relevant equation is:

\begin{align*} \frac{\%\,I_\text{LED}}{\%\,V_\text{CC}}=\frac{\left[\frac{\text{d}\,I_\text{LED}}{I_\text{LED}}\right]}{\left[\frac{\text{d}\,V_\text{CC}}{V_\text{CC}}\right]}&=\frac{1}{1-\frac{V_\text{LED}}{V_\text{CC}}} \end{align*}

(The development can be found here.)

You want to support $$\3\:\text{V}\le V_{\text{CC}}\le 60\:\text{V}\$$. Note that with the smaller value of $$\3\:\text{V}\$$ the above equation has a 0 in the denominator. In effect, this means that if you used $$\V_{\text{CC}}= 3\:\text{V}\$$ with your LED, the resistor would be $$\0\:\Omega\$$ (the only way to get a voltage drop of $$\0\:\text{V}\$$ with some given LED current) and, obviously, the current regulation it offers would be non-existent.

Also, you are talking about $$\\frac{60\:\text{V}-\sqrt{3\:\text{V}\:\cdot\:60\:\text{V}}}{\sqrt{3\:\text{V}\:\cdot\:60\:\text{V}}}\approx \pm 350\:\%\$$ supply voltage variation range around the value of $$\\sqrt{3\:\text{V}\:\cdot\:60\:\text{V}}\approx 13.4\:\text{V}\$$. The above equation would predict current regulation of about $$\\pm 450\:\%\$$ if you used a resistor sized for $$\V_\text{CC}\approx 13.4\:\text{V}\$$.

Even if there was a way, your resistor would need to dissipate as much as $$\250\:\text{mA}\,\cdot\,\left(60\:\text{V}-3\:\text{V}\right)\approx 15\:\text{W}\$$ in the worst case situation. And that's only if you could handle only $$\V_\text{CC}=60\:\text{V}\$$ and nothing lower than that.

In short, there's no good solution using a resistor.

## Linear Current Regulation Is Not Possible, $$\V_\text{CC}=V_\text{LED}=3\:\text{V}\$$

And there's no possible solution, active or otherwise, if you need to support $$\V_\text{CC}=V_\text{LED}\$$. There is always at least some (it can be tens of millivolts but it must be non-zero) need for voltage overhead so that an active circuit can operate.

Have a look here for a lengthy design discussion about one approach. But it does require that you relax your requirements to $$\4.5\:\text{V}\le V_{\text{CC}}\le 60\:\text{V}\$$. You could also use current mirror techniques which would work well for $$\3.5\:\text{V}\le V_{\text{CC}}\le 60\:\text{V}\$$, but would require more than a couple of active devices.

P.S. The above assumes you have only the one supply, itself. If you have access to another supply rail then the above discussion may not apply.

Finally, you could get reasonable results if you are willing to further relax the requirements to $$\6\:\text{V}\le V_{\text{CC}}\le 60\:\text{V}\$$. In this case, the following would circuit would regulate the current so that $$\20\:\text{mA}\le I_{\text{LED}}\le 25\:\text{mA}\$$ over that range:

simulate this circuit – Schematic created using CircuitLab

Again, though, there are heat dissipation problems in any of the above thoughts. It just does not go away.

Let's look at a crazy-eddie idea that's active and linear and doesn't involve switching. This will just be a sketch-up and not realistic. But it will push the limits to see what can be done and you'll see that you are still stuck with heat problems:

simulate this circuit

Here, $$\Q_3\$$ will have to handle a monstrous heat dissipation load if the rail is $$\60\:\text{V}\$$. But the above circuit will technically (if you can somehow imagine that heat isn't a problem) handle your requirements almost down to $$\3\:\text{V}\$$. (Not quite.) The current regulation might be designed to hit as little as 2:1 over the entire supply range. Maybe. (I'm not going to work on it long enough to find out, though.)

I think by now you can see why you must consider the idea of a switcher circuit. And these are not cheap. Worse, I don't know of a single IC solution that supports your full input range of $$\3\:\text{V}\le V_\text{CC} \le 60\:\text{V}\$$. Some will go as low as the low end, but won't reach up to the higher end. Others will go as high as you need, but then won't reach down as low as you require. That wide range you specified is just over the top. Perhaps someone else knows of a part. I don't.

## Switchers

Once you have bought into the idea of a switcher, it will pay you to target an output voltage as close as possible to the worst-case LED voltage when operating at $$\250\:\text{mA}\$$, but with sufficient voltage overhead to control the current well. This can be modest with a current mirror arrangement or it can be a little more wasteful using one of the above linear circuits.

But just as a final reminder, your source has a dynamic range of 20:1! That requirement is pretty tough to meet with a switcher. Slewing a PWM, for example, from 10% to 90% (9:1) is tough enough to control well. A 20:1 dynamic range means slewing under clean, good control from 5% to 95%, roughly. Not so easy.

I don't know what your source is, or if it is isolated, but if you need to add isolation, too, this would likely require a high frequency DC-to-DC switcher using a small transformer and with some output voltage optical feedback. Worst case. You might be able to pack that into a 1" x .5" by .5" volume for the $$\1\:\text{W}\$$ output you need.

## Crazy-Eddie's Linear Design

Okay. So you are truly crazy. And you want a non-swicher, linear design that will "just work right."

Here it is:

simulate this circuit

I've used TO-220 versions for $$\Q_1\$$ and $$\Q_2\$$ so that they can dissipate power, like crazy! And I used a basic Wilson mirror to avoid the Early Effect on LED currents (which is substantial on those two BJTs.)

This circuit will actually work well down to $$\3.3\:\text{V}\$$ supply rails, too! And it will work fine for up to $$\60\:\text{V}\$$ power supply values, with at most $$\1.5\:\text{W}\$$ into the two big TO-220 BJTs. (They can handle that, easily.)

It's absolutely insane. But it will work, too. (It includes protection against excessive reverse-biased base-emitter junctions, as well.)

If you want a little bit of protection against BJT vagaries then the absolutely final insane version is:

simulate this circuit

The above version will adapt to BJT variations and work right all the time, every time.

You'll have to be truly crazy to use it. It includes two TO-220 packages, plus another (10) SOT-23-3 BJTs, plus another (10) SMT resistors. Not to mention the LEDs or BAT46 protection diodes.

(The small-signal BJTs with marked by the red '*' will need to have $$\V_\text{CEO}\ge 60\:\text{V}\$$. Not all manufacturers specify that high of a value in their Absolute Maximum Specifications. So make sure you use appropriately specified parts for those. [The D44H11 and D45H11 will be fine and the LEDs won't be exposed to excessive reverse voltage, either.])

Here's LTspice's plot at $$\27\,^\circ\text{C}\$$ and $$\55\,^\circ\text{C}\$$ (using 1N4148 diodes, though, so the actual performance with the BAT46's will be a little better):

(The colors of the traces match the LED colors.)

## Footnote

I still personally would take the relaxation oscillator approach. Extremely low power, no large packaged devices, and the BJTs are never exposed to high voltages. It's just superior in every way. Perhaps I'll add a design for that. If I get a moment and the inclination.

• Comments are not for extended discussion; this conversation has been moved to chat. – Voltage Spike Oct 12 at 22:08

... what type of resistor I need to resist the variable voltage and Led does not burn.

I'm glad you are considering unusual types of resistor. Ideally what you would like is something that lets a constant current through.

The nearest you will come to that is a filament lamp. As the LED will handle 250 mA, you could use a lamp rated at 15 watts, which will draw 250 mA at 60 V.

The nice thing about filament lamps is that they have a strongly positive temperature coefficient of resistance (PTC). The 60 V 15 watt lamp may have a resistance of 240 Ω when hot, but it could be as low as 24 Ω when cold, giving you an improved light output at lower voltages.

60 V might be an unusual voltage for a lamp, a series string of five 12 V 3 watt lamps may be more readily obtained.

Actually, once you have sourced the filament lamp, you may not need the LED.

You might be able to find suitably rated PTC thermistors. However, if you want the LED to run at 250 mA, they are also going to be dissipating 15 watts.

• Wouldn't the cold filament immediately destroy the LED when initially connected to 60 volts? – Chris Stratton Oct 9 at 15:25
• @ChrisStratton Mmm, probably! Best to add a warning not to do that. – Neil_UK Oct 10 at 11:46
• A constant-current diode (aka a JFET with a resistor) also comes to mind. – Hearth Oct 11 at 13:03

You could use a linear regulator or DC-DC converter with 3V or 5V output (see in the datasheet before if 60V isn't too much). wiki

Then, with a constant voltage, you can use the Kirchhoff's Voltage Law to know the resistance to use.

• Thanks for the reply, I checked the linear regulator in the mouser website, I found one Mfr. No: LM317HVK STEEL/NOPB I think as other folks said, the switching regulator is more efficient than linear. And As well I am after the SMD component. I can find SMD in switching regulator but not in linear. – Habib Anwari Oct 9 at 23:01
• LM317 has maximum input voltage of only 40V, Few integrated linear regulators have max voltage ratings above ~40V.. One of the few that does is the TL783. The reason that there are relatively few linear regulators in SMT is because they dissipate considerable power which makes the smaller size unhelpful. – Graham Stevenson Oct 10 at 2:48

The current drawn by an LED in series with a resistor as voltage is increased from zero (Vin=0) until the LED starts to conduct at it's 'knee voltage' is zero. For a LED that's rated for Vf=3V @250ma, let's imagine that Vknee=2.5V. So, from the point where Vin=Vknee onwards, current will be drawn through resistor R. You have set a limit on the maximum forward current (If) for the diode of 250mA. This maximum will be drawn when the input voltage is at its maximum (Vin=60). From this the value of R can be calculated, using LED forward voltage Vf=3.

R = (Vmax-Vf)/If = (60-3)/0.25 = 228 ohms

Having calculated R, it's now apparent that the current through the LED will vary approximately in accordance with applied voltage, Vin. e.g. @ Vin=30 and taking an estimate of Vf @ 1/2 max operating current to be Vf=2.75 we get the diode current, using the equation I = (Vin-Vf)/R = (30-2.75)/228 = 119mA

By limiting the operating current of the LED to 250mA, it is presumed that this is within its normal parameters and it will not reach an unacceptable temperature. Power dissipated by the LED at maximum Vin is given by If.Vf = 3*0.25 = 750mW

Power dissipated in resistor R is given by ((Vin(max)-Vf)^2)/R (228) = (30-3)^2/228 = 3.19W

A 5 watt resistor will be adequate

Until such time as you change your question, this the best answer possible.

Should you wish to consider such a change, think of the following.

An immediate improvement is to change the series R to a constant current 'source'. Note that it's not actually a source of anything, it's just the name used. This will conduct at the design current over a wide range of applied voltage.

Another improvement that reduces power consumption would be to use a switching regulator to drive the LED that will work from a widely varying input voltage.

• Thanks for your reply. As you said at the end that the best thing will be to use a switching regulator, so I think that is the best option. I have to use LEDs as it takes a small space and cheap and affordable. – Habib Anwari Oct 9 at 23:04
• PLease delete, The question has many false assumptions – Tony Stewart Sunnyskyguy EE75 Oct 10 at 4:32
• @TonyStewartSunnyskyguyEE75, it is ok, An engineer has to come out of it still. – Habib Anwari Oct 12 at 16:33
• This answer neglects thermal resistance and neglects the erroneous specs of this obsolete 25 mA LED. Look up the Kingbright specs then delete this answer based on false info – Tony Stewart Sunnyskyguy EE75 Oct 12 at 16:58

You don't even need a PCB for this probe. +/-2V to +/-70V

A sliding bar-switch improves brightness sensitivity at low ranges.

Here with a +/- 70v sweep gen for testing

suggested Mouser parts

Instead of through hole LED, use an SMD LED. They can shine with much less current than THT ones and give enough visual effect over a broad range of voltages. However, 3.5 to 60 V is still too broad. To reduce the range, use a 10V Zener diode. This will reduce the range to 3.5V - 10V. Chose R2 to fit with 10V, bearing in mind that there is already R1 limiting the current to the LED. The LED will still shine enough with 3.5V.

R1 should be chosen to limit the current through the Zener diode according to its maximum power dissipation on a 50V difference. You can chose a 20V Zener or higher to have less dissipation but a wider final range. The wider the final range the dimmer the LED will be at the lowest voltage.

The values on the schematic are only an orientation. You will have to calculate them exactly according to the Zener diode specification, tested visual effects and other preferences.

D1 is to oppose reverse polarity. To test both polarities you have to duplicate the same circuit up side down.

simulate this circuit – Schematic created using CircuitLab

• The diode is named after Clarence Melvin Zener. Capital Z, one 'n'. Fixed. – Transistor Oct 10 at 15:03
• Fredled, Your circuit needs a little bit of work. As the wrong polarity will light up one LED (red) and the right polarity will light up the Green led. @Transistor, Shouldn't the naming of inventions be taken from Latin or Greek words or it is the inventor choice to be on his name? – Habib Anwari Oct 12 at 10:28
• @Habib, I think the devices are named after the inventor, not by them. Zener, Schottky, Darlington (I think), Hall, etc., are all named after their inventors / discoverers. – Transistor Oct 12 at 10:34
• @Transistor, I think the inventions named after their inventors and Discoveries are not. Stigler's law of eponymy, proposed by the University of Chicago statistics professor Stephen Stigler in his 1980 publication Stigler’s law of eponymy, states that no scientific discovery is named after its original discoverer. Examples include Hubble's law, which was derived by Georges Lemaître two years before Edwin Hubble, the Pythagorean theorem, although it was known to Babylonian mathematicians before Pythagoras, and Halley's Comet, which was observed by astronomers since at least 240 BC. – Habib Anwari Oct 12 at 10:51
• continues: (although its official designation is due to the first-ever mathematical prediction of such astronomical phenomenon in the sky, not to its discovery). Stigler himself named the sociologist Robert K. Merton as the discoverer of "Stigler's law" to show that it follows its own decree, though the phenomenon had previously been noted by others. – Habib Anwari Oct 12 at 10:52

Depletion FETs like DN2540 are ON with Vgs=0V. Similar to a JFET, adding a resistor in series with the source pin makes a constant current source. Since this MOSFET has a body diode, we need two in series so it acts like a current source in both directions. Only one resistor is needed. Unlike a JFET, this one withstands pretty high voltage. This makes a nice bipolar current limiter.

Wiring the LEDs in antiparallel ensures their max reverse voltage spec won't be exceeded.

The LED should light dimly as soon as battery voltage exceeds its Vf, and then the FETs will limit the current to a safe value. 5mA is already pretty bright for a good quality (not ebay counterfeit) high brightness LED. It will be visible in full sunlight at this current.

• Hi, I tried this solution with 60V 1Amp battery and it failed, See this link: link The LED start burning. – Habib Anwari Oct 11 at 22:42
• If it gives too much current, increase the value of 330R resistor. – bobflux Oct 12 at 7:30
• I was wrong about my simulation as I used a current source in the circuit that I should use. So that has given me the wrong result. I will redo the simulation and I think it should be ok. I will bring the result here. – Habib Anwari Oct 12 at 10:24

You can solve all of this difficulty, complexity and heat management by using a centre-zero moving coil meter. (And, yes, I realise that this is not a direct answer to the question at the top of the page. It is an alternative.)

Figure 1. A μA moving coil meter movement. Image source: [ESR}(http://esr.co.uk/electronics/test-panel5.htm).

Many of these are available with interchangeable calibration scales. You can mark yours -100 to +100 or -60 to +60 and calibrate it with a series resistor and, perhaps, a trim-pot. This meter not only doesn't require its own power supply (which seems to be one of your requirements) but also gives an indication of the charge of the battery.

For a 50 μA movement your series resistor will be given by $$\ R = \frac {V_{fs}} I = \frac {60}{50\mu} = 1.2\ \text {M}\Omega \$$. Component count = 2. One meter + one resistor.

• This was the very first thing that came to my mind. But then the LEDs were there. So I gave up the idea. Nice, though. It's really the way to go. – jonk Oct 12 at 3:03

OK, let me add another fantasy suggestion about the nature of the resistor:) As you need only a polarity detector, why not replace the resistor with a capacitor... or better by a network of a capacitor and (protecting) resistor in series? So, add only a capacitor to the Spehro's circuit. I think 1-10 nF (non-electrolytic) and 1 k resistor will do the job.

Note this would be a pulse indicator. In addition, it will be an indicator with memory. Depending on the polarity, when connecting it to the battery, one of the LEDs will light (I hope you know what a differentiating circuit is). You have only to discharge the capacitor after the measurement by short connecting the probes; then the other diode will light.

Thus, this detector will indicate the polarity twice - first, at the time of connection and later, when the probes are short-circuited.

In addition to the polarity, it will give some idea about ​​the value of the measured voltage... and in two ways - through the brightness of the light and through its duration. And finally, it will consume very little battery power... and will utilize the stored energy for a second light pulse:)

Here is how much the humble capacitor will give you...

(There is only a "small" problem - if, immediately after a measurement, you swap the probes and connect them to the battery, the voltage stored in the capacitor will be added to the battery voltage. BTW this trick is used in voltage doublers.)