What resistor tolerance for LM324 as differential amplifier? - Page 1
Forum section: electronics / beginners

author: Heisen
author_rank: Contributor
timestamp: December 26, 2020, 12:58:43 am
content: Hi,I want to measure individual 18650 cell voltage, so that if any cell goes down below 3.4v , I want to cut the circuit. I am trying to make this with two LM324 one LM339 and a TL431 for cut off reference voltage.This is a sub circuit of bigger circuit. I am particularly interested in tolerance of resistors for LM324, cause I am using it as a differential amplifier. Like how much off I would be with 10% , 5% , 1% resistors. How much it will drift from the actual 3.4v set voltage.While we are on this subject, is this circuit solid enough? I tried this in LTspice it takes very long time to simulate. No idea why it takes so long.Attaching LTspice file at bottom.

author: ledtester
author_rank: Super Contributor
timestamp: December 26, 2020, 04:30:14 am
content: Here's my mathematical approach to the problem -- I imagine there are some engineering shortcuts to arrive at the solution.Following the analysis of a differential amplifier found here:https://www.electronicshub.org/differential-amplifier/we have$$V_o = \frac{ \left(1+R_3/R_1 \right) }{ \left(1+R_2/R_4 \right) }V_2 - \frac{R_3}{R_1}V_1$$Set \$a = R_3/R_1\$ and \$b = R_2/R_4\$. For 10% tolerance parts a and b will lie in the range [0.82, 1.22].Rewriting \$V_o\$ in terms of \$a\$ and \$b\$ gives us:$$V_o = \left( \frac{ 1+a}{1+b} \right) V_2 - a V_1$$There will be two kinds of error -- common mode and gain. We can analyze them by writing \$V_o = A (V_2+V_1) + B (V_2 - V_1)\$. Ideally A will be 0 and B will be 1. Solving for A and B in terms of a and b yields:\begin{align*}A & = \frac{1}{2} \left( \frac { 1+a} {1+b} \right) - a \\& = \frac{a}{2} \left( \frac{1}{\left(b+1\right)} - 1 \right) + \frac{1}{2 \left(b + 1\right)} \\\end{align*}Similarily, we find\begin{align*}B & = \frac{1}{2} ( \frac { 1+a} {1+b} ) + a \\& = \frac{a}{2} \left( \frac{1}{\left(b+1\right)} + 1 \right) + \frac{1}{2 \left(b + 1\right)} \\\end{align*}From these formulas you should be able to convince yourself that the extreme values of A occur at a = b = 0.82 and a = b = 1.22 where A is 9% and -11% respectively. For B the extreme values occur at a,b = 0.82,1.22 and 1.22,0.82 where B achieves 0.82 and 1.22.In summary, up to +/- 10% of the sum of the input voltages could be seen on the output plus anywhere between 80% and 122% of the difference. Of course, these two errors are linked so you won't see both of these extremes at the same time.In practice you can minimize these errors by simply measuring and picking well-matched resistors for R1/R3 and R2/R4. If you get them within 1% of each other the errors in A and B will be about 0.5 %.

author: mikerj
author_rank: Super Contributor
timestamp: December 26, 2020, 12:17:24 pm
content: This circuit is likely to be drawing ~3mA from your battery pack, which means you are going to have to be careful not to leave your battery unused for any significant time.

author: David Hess
author_rank: Super Contributor
timestamp: December 26, 2020, 08:53:28 pm
content: The resistor tolerance affects the common mode rejection as shown in the link below:https://e2e.ti.com/blogs_/b/analogwire/archive/2013/10/29/what-you-need-to-know-about-cmrr-the-instrumentation-amplifier-part-2

author: Doctorandus_P
author_rank: Super Contributor
timestamp: December 27, 2020, 03:51:35 am
content: To keep it simple, the common mode rejection is directly proportional to the mismatch in both voltage dividers.Mismatch: CMMR:10% results in 20dB1% results in 40dB0.1% results in 60dB0.01% results in 80dBExcept that you have two voltage dividers, so worst case is twice as bad, which is 6dB less.

author: Zero999
author_rank: Super Contributor
timestamp: December 27, 2020, 12:07:12 pm
content: There is no need for unity gain buffers on the batteries, which already have a very low impedance, so U2 to U4 and their associated current drain, can be eliminated. U1 and U5 can also go, if U6 is made to have the same gain as the other differential amplifiers. A differential amplifier with a gain of 1 will have a common mode range extending to the positive rail, because the op-amp inputs will never go beyond half the supply voltage.The resistor values can also be increased by an order of magnitude to reduce the power consumption by half. If 100k of output impedance is too high, then use the spare op-amp in the LM324 package to buffer it, but the rise fall times will be longer and it won't quite reach the positive rail. Consider using lower power comparators and op-amps, or adding a circuit to completely disconnect the battery, when the output goes low.

author: Heisen
author_rank: Contributor
timestamp: December 27, 2020, 08:00:00 pm
content: Quote from: ledtester on December 26, 2020, 04:30:14 amThanks for the explanation, but I got lost at "There will be two kinds of error -- common mode and gain." I need to study the basics clearly. I thought it's gonna be as easy as picking the CMRR value from the data sheet plugging that into some equation and get the worst value for the output voltage. Clearly there are many things at play here which determines the total error.Sure I will be using 1% resistors.Quick question :- If the difference between the input voltages V1 and V2 is higher, will it result in less error as compared to low difference in input voltages?Quote from: mikerj on December 26, 2020, 12:17:24 pmYes, it probably will draw more than 3mA there is one TL431 which will takes at least 1mA. I guess it's down side of not using fancy chips for this job. Although Zero9999 down here in thread has improved the circuit further.Quote from: David Hess on December 26, 2020, 08:53:28 pmQuote from: Doctorandus_P on December 27, 2020, 03:51:35 amInteresting read !!!Quote from: Zero999 on December 27, 2020, 12:07:12 pmClearly this is a much better circuit, Thanks. Yes no load current is about 3-4mA which is high. Better op-amps and comparator is a solution. I do turn off a P channel mosfet with this signal which cuts of the VCC line to the load, but these opamps and comparator is connected before the P channel mosfet. How would I completely disconnect the battery, like all the four wires B1+, B2+, B3+ and VCC plus the power to opamps and comparator? Is giving them power after the pass transistor is a good approach, or are there any downsides?I do have a main power switch, but achieving zero quiescent (which I am trying to, not really important though) after battery cut off signal is quite hard. A relay is tempting option.If interested this is the circuit after :-LTspice file

author: Zero999
author_rank: Super Contributor
timestamp: December 28, 2020, 11:34:53 am
content: You should be able to power the op-amps and comparator, from M1's source connection. A differential amplifier, with a gain of one, will be work with its inputs slightly above the positive rail, so it's no problem. The LM324 and LM339 can both tolerate their inputs being powered, with their +V pins unpowered. The only concern could be the output pins, of the LM324, might not tolerate, being connected to 16V, via 200k, when the chip is unpowered, but a diode from each output to the +V pin would fix that.This is something which will require breadboarding. It might not work in simulation, because SPICE models will not simulate the behaviour or an unpowered IC very well.

author: Heisen
author_rank: Contributor
timestamp: December 29, 2020, 03:55:44 am
content: Curiously, I did the exact following circuit on the breadboard, like you said with the diode, to examine any effects.Quote from: Zero999 on December 28, 2020, 11:34:53 amI don't understand the use of diode. How it would prevent anything? On the breadboard,when I disconnect the VCC power, without the diode, there is 1V on the output pin and 200mV on the V+ of the opamp, with the diode it's 840mv on the output pin and 330mV on the V+ pin. Is that how it suppose to be?

author: BlackICE
author_rank: Regular Contributor
timestamp: December 29, 2020, 04:55:44 am
content: It sounds like you're trying to recreate a BMS. Unless you like to do it for a academic exercise it would be easier to buy a BMS chip or a BMS PCB.

author: Heisen
author_rank: Contributor
timestamp: December 29, 2020, 05:56:48 am
content: I am just a beginner wandering in the world of electronics. Want to learn as much as possible by practical but traps are all over the place.Yes ultimately it will be a BMS (no idea how implement charging yet), my problem with those board is they don't offer any adjustment, like protection boards have cut off voltage set 2.5 or 3.0 volts, no adjustable end of charge voltage, they always go to that 4.2 volts. Charge current most of time 1 amp. I want it lower. Current limiting? Never saw that one. Most of them are optimized for longer run time. Nothing wrong with them though.I am sure they will be more safer than what I will end up making. Dave says, it's okay if you fail, then you have troubleshoot it and you'll learn something. But I don't want to fail with a blast. Hence, asking questions here.

author: BlackICE
author_rank: Regular Contributor
timestamp: December 29, 2020, 06:16:20 am
content: Depending on the voltage and capacity of the battery pack you want make and use this will be primary academic. I was going down the same path but discovered that using the same batteries and charger from my cordless tools are less expensive compared to buying new brand name reliable batteries, building packs with BMS. Especially if you plan to by a battery welder. If you are willing to go down the path of using recycled/used batteries or questionable ones from China that is another case. I had an experience where I was using rechargeable CR123 type batteries. I had a metal flashlight with 2 cells inside just sitting on a shelf inside a wood cabinet. My family heard a loud explosion after some time later I found the flashlight with the glass bezel blown off in pieces and a charred wooden shelf. It could have been worst! I don't have a lot of faith in the safety of unknow Li Ion batteries.Currently I'm using end user packs and charger but still have to make a circuit to cut the battery pack before becomes overly discharged.

author: ledtester
author_rank: Super Contributor
timestamp: December 29, 2020, 06:22:58 am
content: For configurability and versatility I would look into using a microcontroller, e.g. this guys "Arduino BMS Project":https://youtu.be/MRjxQVYBM_kor this project:https://simple-ee.com/2019/07/20/arduino-4s-bms-version-7/which has a ton of configurable parameters and operational features.

author: ledtester
author_rank: Super Contributor
timestamp: December 29, 2020, 07:46:06 am
content: Back on the analysis front, I found this which slogs through all of the algebra I was trying to do in my first reply:https://www.embeddedrelated.com/showarticle/557.php

author: Zero999
author_rank: Super Contributor
timestamp: December 30, 2020, 05:58:25 pm
content: Quote from: Heisen on December 29, 2020, 03:55:44 amThe idea was to use the diode to clamp the op-amp's output voltage to a safe level. If it only goes to 1V, without the diode, then it's probably unnecessary. I'd expect the op-amp should be able to withstand around 5V applied to its output, when unpowered. This is based on the fact that BJTs can normally be reversed biased to 5V, without damaging them.