Author Topic: LT Simulation of amplifier circuit doesn't match calculations  (Read 2387 times)

0 Members and 1 Guest are viewing this topic.

Offline Rr42Topic starter

  • Newbie
  • Posts: 5
  • Country: in
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:
1435591-0
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2340
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #1 on: March 10, 2022, 04:11:16 pm »
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?
« Last Edit: March 10, 2022, 04:20:48 pm by Andy Watson »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14132
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #2 on: March 10, 2022, 04:24:45 pm »
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.
 
The following users thanked this post: Rr42

Offline Terry Bites

  • Super Contributor
  • ***
  • Posts: 3182
  • Country: gb
  • Recovering Electrical Engineer
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #3 on: March 10, 2022, 04:28:23 pm »
MAX4173
 

Offline Rr42Topic starter

  • Newbie
  • Posts: 5
  • Country: in
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #4 on: March 10, 2022, 05:33:04 pm »
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?

So 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
 

Offline Rr42Topic starter

  • Newbie
  • Posts: 5
  • Country: in
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #5 on: March 10, 2022, 05:37:56 pm »
MAX4173

Hmm, 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
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2987
  • Country: ca
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #6 on: March 10, 2022, 05:55:56 pm »
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_B
* Bad Circuit.asc (2.68 kB - downloaded 84 times.)
 
The following users thanked this post: Ian.M, tooki, Rr42

Offline Rr42Topic starter

  • Newbie
  • Posts: 5
  • Country: in
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #7 on: March 10, 2022, 06:06:02 pm »
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.

This 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.
 

Offline Rr42Topic starter

  • Newbie
  • Posts: 5
  • Country: in
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #8 on: March 10, 2022, 06:15:45 pm »
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_B
(Attachment Link)

Yeah, 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.
 

Offline TimFox

  • Super Contributor
  • ***
  • Posts: 12011
  • Country: us
  • Retired, now restoring antique test equipment
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #9 on: March 10, 2022, 06:48:34 pm »
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).
 
The following users thanked this post: Rr42

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14132
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #10 on: March 10, 2022, 07:30:39 pm »
MAX4173
Hmm, 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
LTspice 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.
« Last Edit: March 10, 2022, 07:57:46 pm by Ian.M »
 
The following users thanked this post: Rr42

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14132
Re: LT Simulation of amplifier circuit doesn't match calculations
« Reply #11 on: March 10, 2022, 07:56:39 pm »
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.
Unfortunately 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.  See https://www.analog.com/en/technical-articles/ltspice-worst-case-circuit-analysis-with-minimal-simulations-runs.html for how to do that.   

N.B.  the number of runs required is 2N where 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!
 
The following users thanked this post: Rr42


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->