LT Simulation of amplifier circuit doesn't match calculations - Page 1
Forum section: electronics / projects

author: Rr42
author_rank: Newbie
timestamp: March 10, 2022, 03:34:09 pm
content: I'm trying to design a cost effective method to measure the current my board draws from its supply (in this case a 5V USB connector).So the design I came up with uses a single 1m ohm shunt and an op amp based differential amplifier circuit to increase the drop across the shunt resistor to a level I can use. I was hoping to start with a simple differential amplifier design with few parts so I can keep the cost and area low.When I setup the circuit in LTspice, the simulated gain/output voltage I get is very different from the value I get using the transfer function I derived for the circuit.I tried re-simulating with different op amps in LTspice but none of them give a result is even close to the theoretical value.My questions:1. Is there something I'm doing wrong here or does it just come down to the op amp models in LTspice?2. If the op amp models are contributing to the difference, is there a way to get the theoretical value in simulation? (just curious)3. As far as I know the single-supply aspect of the design should not effect the output unless the output voltage goes higher than the supply or am I missing something?My circuit:

author: Andy Watson
author_rank: Super Contributor
timestamp: March 10, 2022, 04:11:16 pm
content: The output of the MAX4352 is only good above Vee + 75mV (typically - although it could be as much as Vee + 350mV !) What output voltage are you expecting?

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2022, 04:24:45 pm
content: Your chosen OPAMP has a min. CMRR of only 60dB, and typ. 100dB You are sweeping your circuit's common mode input voltage from 0 to 5V in one ms. During that time, the circuit's differential input voltage that you are trying to measure goes from 0 to 220uV, which is 147dB down on the common mode 'signal' so is totally lost in it.Even if you use high precision 0.01% resistors, at the extremes of their tolerance range, their mismatch may degrade the overall CMRR to no better than 33dB so the results in practice will be even worse.This is why in the real world, designs use much larger value shunt resistors, with typically 50mV to 100mV FSD burden voltage (across the shunt) + laser trimmed instrumentation amplifier ICs purpose designed for high-side current shunt usage.

author: Terry Bites
author_rank: Super Contributor
timestamp: March 10, 2022, 04:28:23 pm
content: MAX4173

author: Rr42
author_rank: Newbie
timestamp: March 10, 2022, 05:33:04 pm
content: Quote from: Andy Watson on March 10, 2022, 04:11:16 pmSo the drop across the shunt is supposed to be 220uV (with 220mS running through it) so with the resistors I have chosen I should get around 421.4uV at the output

author: Rr42
author_rank: Newbie
timestamp: March 10, 2022, 05:37:56 pm
content: Quote from: Terry Bites on March 10, 2022, 04:28:23 pmHmm, I'll take a look at this for the design, but I will not be able to simulate it as it's not there in LTspice

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: March 10, 2022, 05:55:56 pm
content: Hi,Let me use this model to illustrate some of the reasons mentioned by other contributors as to why this is a bad implementation:I have replaced the op-amp with a voltage-controlled voltage source with a gain of 10 million (~130dB). This can be considered an ideal op-amp. This gives the correct answer. The output changes from 0 to around 440uV when the current changes from 0-220mA.In the second circuit I changed the value of just one of the resistors by 1% and the model gives a completely different answer because the CMRR of the circuit is poor.I have attached the model.Regards,Jay_Diddy_BBad Circuit.asc(2.68 kB - downloaded 51 times.)

author: Rr42
author_rank: Newbie
timestamp: March 10, 2022, 06:06:02 pm
content: Quote from: Ian.M on March 10, 2022, 04:24:45 pmThis is the first time I am working with current sensing or amplifying low voltages so it is very interesting to to learn.Since I don't ever expect my board to draw more than 500mA, I can get a 1ohm 0.5% resistor as a shunt? Though this still gives me a simulated output of 413.9mV (it is supposed to be around 431.4mV).I want to avoid going to very high precision amplifier ICs since they can cost a pretty penny.

author: Rr42
author_rank: Newbie
timestamp: March 10, 2022, 06:15:45 pm
content: Quote from: Jay_Diddy_B on March 10, 2022, 05:55:56 pmYeah, I figured I would end up with this issue because of the tolerances of the resistors when designing this circuit but I did not expect the op amp to cause the deviation I am seeing in my simulation.What would be a good way to go about accounting for these kind of variations in tolerances other than using like 0.1% resistors? I want to try avoiding costly precision/instrumentation amplifiers.

author: TimFox
author_rank: Super Contributor
timestamp: March 10, 2022, 06:48:34 pm
content: You can do a "worst-case" analysis by taking a critical pair of components, and setting one of each to 1% high and the other to 1% low, as in R9 and R12 in the reply above. Be careful not to compensate by adjusting more than one such pair at a time.If you need to adjust the circuit for CMRR, replace the fixed resistor R6 or R12 with a slightly smaller resistor in series with a small variable resistor. Put the variable resistor at the "ground" or "common" end of the resistance for ease of adjustment. For example, use 9.1 k in series with a 2 k variable resistor (9100 to 11,100 ohms) or 9.53 k in series with a 1 k variable resistor (9530 to 10,530 ohms).

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2022, 07:30:39 pm
content: Quote from: Rr42 on March 10, 2022, 05:37:56 pmLTspice supports using 3rd party SPICE models and creating your own symbols. In some cases, the model you have found is for a different SPICE program and uses incompatible syntax so needs a little fixing up before LTspice is happy with it.I grabbed the MAX4173T.lib model off the Maxim website. It had a minor incompatibility with LTspice so I fixed that. I couldn't find any model for the ...F (50V/V) and ...H (100V/V) variants, but the gain (20V/V) was set in a single line of the model so I patched it to parameterize the gain and created subcircuits for the other variants.

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2022, 07:56:39 pm
content: Quote from: TimFox on March 10, 2022, 06:48:34 pmUnfortunately tolerances often stack up. e.g. if Jay's R10:R9 divider has R9 0.1% high, and R10 0.1% low, but the R11:R12 divider has each resistor off by the same amount but in the opposite direction, the total mismatch is double the error in a single divider ratio. It is *POSSIBLE* to go through the circuit and work out how the tolerances stack up, but its easy to make a mistake or miss something so it preferable to simply determine which components are critical and let LTspice step through their tolerance limits. Seehttps://www.analog.com/en/technical-articles/ltspice-worst-case-circuit-analysis-with-minimal-simulations-runs.htmlfor how to do that.N.B. the number of runs required is 2Nwhere N is the number of critical components, so if you don't want to be there all day watching it run and maybe run out of disk space, *THINK* which components are actually critical and don't tolerance step more of them than you need to!