Can someone explain the values of the resistors? - Page 1
Forum section: electronics / beginners

author: UncookedCorn
author_rank: Contributor
timestamp: November 12, 2023, 11:59:22 pm
content: Why were the 220and 47chosen and in those particular spots? Will they be the same for any other 18650 3.7V battery?

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 13, 2023, 12:04:34 am
content: Each 1n4007 drops 0.7V, so a lower resistor is needed to provide same current through the led.Eventually the battery goes too low to power the leds at the end of the circuit.Though the yellow led resistor seems wrong.

author: xrunner
author_rank: Super Contributor
timestamp: November 13, 2023, 12:16:13 am
content: The fully charged voltage of that battery could be up to 4.2 V. So 3 x 0.7V (diode drops) is 2.1V. 4.2 - 2.1V = 2.1V. The green LED will drop about 2.1 or so volts so a small current limiting R is OK. As the battery drops in voltage the other LEDs will gradually go dark as you can find out yourself with simple calculations. Eventually no LEDs will be lit ...

author: UncookedCorn
author_rank: Contributor
timestamp: November 13, 2023, 12:32:21 am
content: So would the current through one of the nodes be the (potential before the LED - voltage drop of the LED) / R?

author: UncookedCorn
author_rank: Contributor
timestamp: November 13, 2023, 12:53:16 am
content: Why does the yellow LED resistor seem wrong?

author: xrunner
author_rank: Super Contributor
timestamp: November 13, 2023, 12:56:18 am
content: Quote from: UncookedCorn on November 13, 2023, 12:53:16 amFirst let me ask you: Why do you say it "seems" wrong? What leads you to this comment. You must have your own reason to think it seems wrong.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 13, 2023, 01:02:04 am
content: Because I said so.The yellow led has 220 ohms, while it's right next to the last one (Green), which has 47 ohms.They should be closer in value, this way the yellow led will be a lot dimmer than all others.

author: xrunner
author_rank: Super Contributor
timestamp: November 13, 2023, 01:05:29 am
content: Quote from: DavidAlfa on November 13, 2023, 01:02:04 amOh I thought UncookedCorn was sayinghethought it seemed wrong. He said that becasue you said it I suppose.

author: vk4ffab
author_rank: Frequent Contributor
timestamp: November 13, 2023, 01:07:35 am
content: Quote from: xrunner on November 13, 2023, 12:56:18 amA yellow diode has a higher voltage drop compared to a red diode. Without doing some actual math I think the yellow diode would appear a lot dimmer because its much more current limited compared to either the red or the green in that circuit.Math wins of course and I am to lazy right now to work out the currents at each node.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 13, 2023, 01:30:16 am
content: Rough simulation... Seems another dumb circuit from internet.

author: ArdWar
author_rank: Frequent Contributor
timestamp: November 13, 2023, 06:59:34 am
content: This is those kind of a too simple circuits that may work as intended or not with about equal chance. You really need to verify the operation with components you actually have on hand considering that these days there can be multiple process available for certain LED color. Red for example can be anywhere from 1.2V to 2.5V, some green are even 3.5V+

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 13, 2023, 07:28:09 am
content: Quote from: UncookedCorn on November 13, 2023, 12:32:21 amIf by "node" you mean "the LED and its accompanying resistor", then yes.The particular resistor values were chosen based on the voltage before the LED, the voltage drop of that particular LED, and to minimize the number of different resistor values needed. It is all a rough compromise, really.

author: wraper
author_rank: Unknown
timestamp: November 13, 2023, 07:44:37 am
content: Quote from: Nominal Animal on November 13, 2023, 07:28:09 amResistor values were pulled out of an ass IMHO. D1 and D3 LEDs are of the same type, yet current through D3 will be much higher with low Vf LED. Then let's assume they're super bright type with high Vf, in that case 220R for yellow LED makes no sense if you want to achieve equal brightness.

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 13, 2023, 10:03:42 am
content: Quote from: wraper on November 13, 2023, 07:44:37 amYeah; I agree: bad choices for the resistors – the designer obviously emphasized "the least number of different resistor values" too much. In the "original" or "proper" design, I am assuming very specific types of LEDs were used.How about we investigate how one wouldproperlyselect the resistor values?Let's assume we have four LEDs with suitable forward voltages \$V_{f1}\$ through \$V_{f4}\$ at corresponding currents \$I_{f1}\$ through \$I_{f4}\$ where they are visually equally bright. The diodes have an instantaneous forward voltage of 0.7V at 10mA, so we want all four LEDs to light up at 4.1V:$$\left\lbrace \begin{aligned}\frac{4.1 - 3 \times 0.7 - V_\text{f4}}{R_4} &= I_\text{f4} \\\frac{4.1 - 2 \times 0.7 - V_\text{f3}}{R_3} &= I_\text{f3} \\\frac{4.1 - 1 \times 0.7 - V_\text{f2}}{R_2} &= I_\text{f2} \\\frac{4.1 - 0 \times 0.7 - V_\text{f1}}{R_1} &= I_\text{f1} \\\end{aligned} \right . \quad \iff \quad \left\lbrace \begin{aligned}R_4 &= \frac{2.0 - V_\text{f4}}{I_\text{f4}} \\R_3 &= \frac{2.7 - V_\text{f3}}{I_\text{f3}} \\R_2 &= \frac{3.4 - V_\text{f2}}{I_\text{f2}} \\R_1 &= \frac{4.1 - V_\text{f1}}{I_\text{f1}} \\\end{aligned} \right .$$We also need \$V_\text{f4}\$ to have a forward voltage drop of about \$4.1 - 3 \times 0.7 = 2\$ volts, so that it only lits up when the voltage is high enough.As the useful voltage range of a Lithium ion cell is between 3.0V and 4.2V –– there isn't much energy left in the cell when its voltage drops below 3.0V –– the third LED should only light up above say 3.8V (so its forward voltage \$V_\text{f3}\$ should be about \$3.8 - 2 \times 0.7 = 2.4\$ volts), the second LED above 3.5V (so its forward voltage \$V_\text{f2}\$ should be about \$3.5 - 0.7 = 2.8\$ volts), and the first led above 3.2V (so its forward voltage \$V_\text{f1}\$ should be about \$3.2\$ volts). We could use additional diodes or Schottky diodes in series with each LED to increase the voltage drop by 0.7V or 0.25V, respectively.Of course, we should look at the cell discharge curve, and pick voltages that divide the area under the curve into equal sizes; but it's pretty linear except for the last 20% or so of charge, so 0.3V steps like I used above (3.2V, 3.5V, 3.8V, 4.1V) should work fine.We'd also want the LEDs to stay equally bright when just three are lit:$$\left\lbrace \begin{aligned}R_3 &= \frac{2.4 - V_\text{f3}}{I_\text{f3'}} \\R_2 &= \frac{3.1 - V_\text{f2}}{I_\text{f2'}} \\R_1 &= \frac{3.8 - V_\text{f1}}{I_\text{f1'}} \\\end{aligned} \right .$$where the currents \$I_\text{f1'}\$ through \$I_\text{f3'}\$ are now necessarily smaller due to the lower input voltage, but should correspond roughly to equal brightnesses. Similarly for just the two first LEDs:$$\left\lbrace \begin{aligned}R_2 &= \frac{2.8 - V_\text{f2}}{I_\text{f2''}} \\R_1 &= \frac{3.5 - V_\text{f1}}{I_\text{f1''}} \\\end{aligned} \right .$$Of course, we wouldn't want to spend too much money on getting precise resistors, so the values should probably be chosen from E3, E6, or E12 series. Compromises would have to be made, and the results would very much depend on the properties of the LEDs we used.

author: xrunner
author_rank: Super Contributor
timestamp: November 13, 2023, 12:13:23 pm
content: I'm going to breadboard it today or tomorrow because I want to observe the brightness levels as has been discussed. I do think it will work correctly in the gross sense, meaning all the LEDs will be ON with a full charge and go off one by one as the voltage decreases. It can hardly fail in that sense.However, I don't think it will look very pleasing to the eye. That means (to me) if all the LEDs are ON they won't look like equal "steps" as far as the apparent brightness is concerned. It won't be a smooth display of battery charge because some will appear brighter than others. This of course can be "fine tuned" by adjusting R values. Anyway, I might be wrong let's see.

author: wasedadoc
author_rank: Super Contributor
timestamp: November 13, 2023, 12:25:45 pm
content: No-one answered the OP's second question. The answer to that is yes. The resistor values (whatever the correct ones are) do not change with other single cell lithium rechargeables.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 13, 2023, 12:42:41 pm
content: The circuit is too simplistic. It is unworkable, IMHO. One could try to fine-tune resistor values, number of series diodes and LED types until cows come home, but at the end of the day, all LEDs would be lit to various degrees. This is a good textbook example of a circuit where the mental model ("diode forward voltage drop is a constant value") is too far from the truth and therefore not usable. In reality, diode voltage dropisdependent on current, but also temperature, unit-to-unit variation etc. Current dependency alone makes diode circuit not sharp at all, so if you want things to turn on/off at certain voltage thresholds, you need so-called comparator circuit.

author: xrunner
author_rank: Super Contributor
timestamp: November 13, 2023, 12:55:03 pm
content: LOL, I just searched "18560 lithium 3.7v battery level indicator" ...There's a lot of different pictures (real wired up circuits) and schematics on many sites. It must have come from somewhere originally.

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 13, 2023, 01:06:46 pm
content: Quote from: wasedadoc on November 13, 2023, 12:25:45 pmIf it works for one 18650 cell, it will work for any other 18650 cellusing the same chemistry. Nominal 3.7V does indicate typical lithium ion chemistry, as opposed to say LiFePO₄ (nominal 3.2V voltage). The different chemistries have different discharge curves, so the voltage where they have say 50% of charge left, varies. Fortunately, for the 18650 cell chemistries with nominal 3.7V, the differences are not significant enough to worry about, considering the typical variances between cells and components.Quote from: Siwastaja on November 13, 2023, 12:42:41 pmAt that point, I suppose a cheap Padauk MCU with an ADC, a 2.5V shunt voltage reference or regulator, and PWM'ing the LEDs so that only one of them is lit at the same time (charlieplexing three pins giving 6 LEDs, so even SOT23-6 package would work), would yield the cheapest but pretty precise implementation. Padauks' ADC seem to handle 10kΩ input, so a simple voltage divider (halver) will bring the supply down to the measurable range, with 0.4mA or lower current draw. I count six resistors (two for the voltage divider, three for the charlieplexed pins, one for minimal load on the shunt reference), one 100nF-1µF bypass capacitor, the low-current (<15mA) voltage regulator or reference, the Padauk MCU in SOT23-6 or SO-8, and up to six LEDs.If one cares, one could even use summation-based PDM to pulse the highest LED indicating charge levels at higher precision.

author: xrunner
author_rank: Super Contributor
timestamp: November 13, 2023, 03:38:24 pm
content: Well I wired the thing up. First, I was surprised that the LEDs don't really look all that bad as far as the brightness levels and how they extinguish. But the scaling isn't all that useful.The pics show the LEDs all fully on and at each voltage where they progressively go off.All ON at 4.2V. Note: green will get brighter if the voltage goes up a few more tenths of a volt.Green OFF at 3.8VYellow OFF at 2.9VSecond red OFF at 1.9VALL OFF at 1.5VNow, is the scale really useful? The 18650 batt. is fully charged at 4.2V, and depending on your source, the fully discharged point is between 2.5V and 3.0V. So it would seem the two red LEDs are not very useful. If you want to use four LEDs you need to move the scaling up so the first red goes out at 2.5V. Draw your own conclusions ...

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 13, 2023, 06:53:39 pm
content: As said, that circuit is crap. Not that mine is great, but some TL431 will do a much better job.A Li-ion battery is mostly discharged at 3.7-3.6V... pushing it further greatly shorts lifespan while providing very little extra energy.

author: wasedadoc
author_rank: Super Contributor
timestamp: November 13, 2023, 08:38:05 pm
content: Quote from: DavidAlfa on November 13, 2023, 06:53:39 pmPeople seem to be assuming that the three different colour LED all require the same current for equal subjective brightness.1. Is that true?2. If it is true, then making all the resistors the same value is not going to give equal subjective brightness because the cell voltage is different when each one is activated.3. For sure DavidAlfa's R1 and R2 should not be equal resistance as both D2 and D3 are the same type LEDs.

author: vk4ffab
author_rank: Frequent Contributor
timestamp: November 13, 2023, 09:08:24 pm
content: Quote from: wasedadoc on November 13, 2023, 08:38:05 pmFor a given series of LED's this should remain true. If you look in the datasheet of most LED's they will plot Luminous Intensity verses forward current. So having the 4 LED's using the same current should equal similar luminous intensities and thus a different resistor value for each led, as long as that is what the datasheet suggests. It is for parts I regularly use, but might not hold true for others.You know, its electronics and everything is filled with caveats.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 13, 2023, 09:16:48 pm
content: Quote from: wasedadoc on November 13, 2023, 08:38:05 pmBecause....? It's just a bar indicator.At full level all leds are lit. LED current will reduce slightly between 4.2 and 3.7V, not a huge deal.This point makes no sense, it's a generic circuit, there's an entire world of led technologies out there.The important part is the TL431 working as comparator, what you drive with it is up to you!.

author: wasedadoc
author_rank: Super Contributor
timestamp: November 13, 2023, 10:10:22 pm
content: Quote from: vk4ffab on November 13, 2023, 09:08:24 pmEqual objective luminous intensity does not mean equal subjective brightness.https://www.researchgate.net/figure/The-Relationship-Between-Eye-Sensitivity-and-Colour-Wavelength-and-Colour-Luminosity_fig4_269300186https://www.nde-ed.org/NDETechniques/PenetrantTest/Introduction/lightresponse.xhtml

author: vk4ffab
author_rank: Frequent Contributor
timestamp: November 14, 2023, 08:10:12 am
content: Quote from: wasedadoc on November 13, 2023, 10:10:22 pmLuminous intensity is a measure of the wavelength-weighted power emitted by a light source. So it should also mean that for a given current, LEDs of different colours within the same series of LEDs producing a similar luminous intensity should appear to have the same relative level of brightness because the measure accounts for it. The key words being wavelength weighted.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 14, 2023, 08:42:06 am
content: Quote from: DavidAlfa on November 13, 2023, 06:53:39 pmNo, 3.65V is most definitely close to 50% SoC. 50% in charge and maybe 40% in energy in my opinion is not "very little". And there is absolutely no reduction in lifespan by deeper discharge, although one might want to prevent the last 10-15% i.e. below 3.50V OCV, but that could be as low as 2.5V under load.Quite the opposite, it's most harmful to fully charge, especially at combination of high currents and low temperatures, so if you choose to cycle between 100% and 50% instead of, say 75% and 25%, you are doing yourself a disservice.You don't need to make this stuff up, just look how it's done normally. Normal cut-off voltage is somewhere around 2.0V to 3.0V. Also see datasheets for discharge curves.

author: MrAl
author_rank: Super Contributor
timestamp: November 14, 2023, 08:44:09 am
content: Quote from: DavidAlfa on November 13, 2023, 06:53:39 pmHi,That's not a bad idea for an Li-om battery cell checker.

author: MrAl
author_rank: Super Contributor
timestamp: November 14, 2023, 08:47:21 am
content: Quote from: UncookedCorn on November 12, 2023, 11:59:22 pmThis circuit looks like it was meant to be a very cheap Li-ion battery cell tester. Depending on how the LEDs light up, you can get some idea of what the battery voltage is on the cell.It's about as cheap as you can get, and should be used at the same temperature for every measurement.We could probably improve it greatly by just changing some resistors and maybe added a few more diodes. It will not be super accurate, but if used indoors it might be ok.A better unit would use more accurate set points such as you might get from using a few comparators.I myself have to check the status of AA batteries and Li-ion cells and I use a cheap commercial unit that takes any size cylindrical cell. You can get them on sites like Amazon pretty cheaply.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 14, 2023, 08:57:42 am
content: Quote from: MrAl on November 14, 2023, 08:47:21 amI would suggest an even simpler one with only two parts: a blue LED with series resistor (e.g. 220 ohms), nothing else.Bright -> maybe 30% - 100%, depending on brightnessDim -> emptyVery dim to the point of not being clearly visible in room illumination -> cell overdischarged, check using a separate meter.

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 14, 2023, 12:31:23 pm
content: I'm actually very surprised nobody has made a Li-ion/LiFePo₄ fuel gauge using PadaukPMS171Byet. It is programmable using the Free PDK toolchain, and costs only about 8 cents in sets of five at LCSC. A Diodes Inc. AZ431AN-ATRE1 2.5V 0.4% shunt voltage reference costs three cents. If you run the PMS171B from the Li cell voltage, the reference will read 152 at 4.2V, 156 at 4.1V, 168 at 3.8V, 183 at 3.5V, 200 at 3.2V, and 213 at 3.0V; i.e. 8-bit ADC readingNcorresponds to voltage 640/Nvolts. (Resolution 0.025V around 4V, 0.016V around 3V.)With three output pins, you can light one of four different LEDs at a time (without high-Z), each with their own resistor. You can do PWM/PDM to compensate for the varying current if running from the 3.0V - 4.2V Li cell voltage. In the SO8 package, there is even a pin free for doing a low-side switch using an N-channel MOSFET, so that a button press turns connects the circuit to the real negative rail, with the MCU pin keeping it connected so it can turn itself off after a time limit, not consuming any current while turned off.Or, you can run the circuit off the shunt voltage reference, and measure the cell voltage for example via an opamp that subtracts the 2.5V from the cell voltage, yielding about 0.01V precision. The LEDs would then run off the 2.5V I/O levels, too.By my count, the components for that would cost under 30 cents in sets of five at LCSC, add maybe 15-20 cents for a suitable TI RRIO opamp for the more precise version.I like the idea of having the most significant LED blink at say 2 Hz, with duty cycle indicating the fraction (or constant on time, but off time and period varies).With the SO-16 version of PMS171B, you could even use a two-segment LED display to show the charge as percent between 00 and 99.

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 14, 2023, 02:40:42 pm
content: IP stolen or not, I prefer Puya ARM 1000 times over a weird mcu architecture and custom programming interfaces.