Non Linear Resistor in LTspice

Jun 14, 2020 31 Replies

I was looking at a simulation of a current regulator circuit to figure out why the voltage on a current sense resistor is not a nice sine wave-ish lik e the applied voltage to the circuit. I expected a bit of distortion aroun d the zero crossing points but otherwise a rectified sine wave.



After mucking with the circuit thinking it had to do with transistor curren ts I realized the issue was MUCH more fundamental. The current through the resistor is as expected, pretty much a rectified sine wave with a bit of d istortion near the zero crossing points... but the voltage is terribly dist orted. What finally sunk in was that these were the measurements directly on the resistor as if the resistance was varying!!!



Plotting Vr/Ir in LTspice sure enough gave a rather ragged waveform for res istance much like the voltage waveform. The measured values are not weird extremes that might be from parasitic effects, ~3 volts, ~13 mA, 121 ohms. I even tried using a specific resistor part number to make sure the resist or didn't have some weird default parasitic value on it.



WTF???!!!



How can a resistance not model as a proper resistance in a circuit simulato r? The calculated resistance value over the cycle not near the zero crossi ngs ranges from 120 ohms to 240 ohms.


Rick C. - Get 1,000 miles of free Supercharging - Tesla referral code - https://ts.la/richard11209

Does selecting "alternate solver" from the control panel -> SPICE menu make any difference?

out why the voltage on a current sense resistor is not a nice sine wave-ish like the applied voltage to the circuit. I expected a bit of distortion a round the zero crossing points but otherwise a rectified sine wave.

rrents I realized the issue was MUCH more fundamental. The current through the resistor is as expected, pretty much a rectified sine wave with a bit of distortion near the zero crossing points... but the voltage is terribly distorted. What finally sunk in was that these were the measurements direc tly on the resistor as if the resistance was varying!!!

resistance much like the voltage waveform. The measured values are not we ird extremes that might be from parasitic effects, ~3 volts, ~13 mA, 121 oh ms. I even tried using a specific resistor part number to make sure the re sistor didn't have some weird default parasitic value on it.

lator? The calculated resistance value over the cycle not near the zero cr ossings ranges from 120 ohms to 240 ohms.

It was already on "alternate" but to make sure I also ran it on "normal" wi th the same result.

Very weird. One resistor in the voltage divider has the same effect and th ey are both connected to a common net. That net has a nice smooth rectifie d sine wave on it. Nothing strange about it.

This just makes no sense. No matter what, the voltage across a resistor sh ould be proportional to the current and so the two waveforms should have th e same shape.

Rick C. + Get 1,000 miles of free Supercharging + Tesla referral code - https://ts.la/richard11209

e out why the voltage on a current sense resistor is not a nice sine wave-i sh like the applied voltage to the circuit. I expected a bit of distortion around the zero crossing points but otherwise a rectified sine wave.

currents I realized the issue was MUCH more fundamental. The current throu gh the resistor is as expected, pretty much a rectified sine wave with a bi t of distortion near the zero crossing points... but the voltage is terribl y distorted. What finally sunk in was that these were the measurements dir ectly on the resistor as if the resistance was varying!!!

or resistance much like the voltage waveform. The measured values are not weird extremes that might be from parasitic effects, ~3 volts, ~13 mA, 121 ohms. I even tried using a specific resistor part number to make sure the resistor didn't have some weird default parasitic value on it.

mulator? The calculated resistance value over the cycle not near the zero crossings ranges from 120 ohms to 240 ohms.

with the same result.

they are both connected to a common net. That net has a nice smooth rectif ied sine wave on it. Nothing strange about it.

should be proportional to the current and so the two waveforms should have the same shape.

Did you want to share the file? to get a 2nd opinion?

Are you sure you're measuring the voltage /across/ the resistor? - right click on one side, hold down and release on other side IIRC.

Cheers Clive

He should avoid complicated stuff like simulation. He obviously isn't compatible with Spice.

John Larkin Highland Technology, Inc Science teaches us to doubt. Claude Bernard

out why the voltage on a current sense resistor is not a nice sine wave-ish like the applied voltage to the circuit. I expected a bit of distortion a round the zero crossing points but otherwise a rectified sine wave.

rrents I realized the issue was MUCH more fundamental. The current through the resistor is as expected, pretty much a rectified sine wave with a bit of distortion near the zero crossing points... but the voltage is terribly distorted. What finally sunk in was that these were the measurements direc tly on the resistor as if the resistance was varying!!!

resistance much like the voltage waveform. The measured values are not we ird extremes that might be from parasitic effects, ~3 volts, ~13 mA, 121 oh ms. I even tried using a specific resistor part number to make sure the re sistor didn't have some weird default parasitic value on it.

lator? The calculated resistance value over the cycle not near the zero cr ossings ranges from 120 ohms to 240 ohms.

You mean left click, correct? Yes, not only did I verify the text in the w aveform display, I also entered it as a formula, V(x)-V(y) and saw the same waveform.

I am so spooked by this I thought maybe there is something weird/corrupted in the file for those two parts, so I replaced them. I've looked for net n ame shorts and everything else I can think of. The commonality of these tw o resistors is a net from a zero volt voltage source to provide a current m easurement. The voltage on that of course is zero at all times.

Even if there was a short or other error in the schematic, that could cause a strange waveform, but not the current to deviate from the voltage.

Rick C. -- Get 1,000 miles of free Supercharging -- Tesla referral code - https://ts.la/richard11209

Sounds like he's not measuring the differential voltage across the resistor properly, perhaps, if you have e.g. a bridged amplifier that's driving a sine current into a resistor the current waveform will look like a sine but the single-ended voltage to ground will look "terribly distorted" nothing unusual about that.

Could be something like that. But LT Spice is arguably over-tuned for speed, so a sine wave can look segmented if you really zoom up on it. The fundamental knob that you have to tune in any simulator is dt, the time step size.

He started hostile to Spice, it doesn't work for him, so he should go back to doing analytical math.

I'd hate to have to chose between LT Spice and, say, my wife or chocolate or my new ski boots.

John Larkin Highland Technology, Inc Science teaches us to doubt. Claude Bernard

Stock it basically comes tuned to make their switchers look as good as possible I think, so it's set on "normal" solver with the "Trtol" parameter set very low.

For general work I find it works better to set "alternate" (which slows it down by about 2-4x but improves roundoff error about 1000 times) and then bump the Trtol up a bit, and adjust time step as required.

For real. It's not perfect, it's not totally drag-n-drop or Web 2.0 but it's fast, accurate and flexible and doesn't get in the way, and if you need to do something weird there's probably a way to do it with a little thought and some programming.

If JL and I agree on something I'd say it's probably user error...

(that is to say they tune it that way for noobs to sim so their switchers don't show simulation artifacts but it still simulates quickly; if you have an idea of what a simulation artifact on a switcher looks like and those don't phase you tho, you can tweak those and you can get it back to about the same speed but with much better overall precision)

I haven't found alternate to be much slower, and I have a couple of sims that will stall, never finish, unless I use the alt solver. One of those simulates an LTC switcher! (LTM8078 converting +24 to -5 and

-2.5)

Playing with some of those abstol type things can help too, sometimes.

We can't have that, now can we? I mean agreeing.

John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

As Anthony suggested, post your file for help with this.

That might be amusing.

John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

Possibly. I was hoping to see for myself and puzzle over it.

On Monday, June 15, 2020 at 2:07:59 PM UTC-4, John S wrote:

out why the voltage on a current sense resistor is not a nice sine wave-ish like the applied voltage to the circuit. I expected a bit of distortion a round the zero crossing points but otherwise a rectified sine wave.

rrents I realized the issue was MUCH more fundamental. The current through the resistor is as expected, pretty much a rectified sine wave with a bit of distortion near the zero crossing points... but the voltage is terribly distorted. What finally sunk in was that these were the measurements direc tly on the resistor as if the resistance was varying!!!

resistance much like the voltage waveform. The measured values are not we ird extremes that might be from parasitic effects, ~3 volts, ~13 mA, 121 oh ms. I even tried using a specific resistor part number to make sure the re sistor didn't have some weird default parasitic value on it.

lator? The calculated resistance value over the cycle not near the zero cr ossings ranges from 120 ohms to 240 ohms.

Ok... It's a bit long. I'm pretty sure all the parts are from the LTspice library.

Version 4 SHEET 1 1144 680 WIRE 512 -368 368 -368 WIRE 784 -368 512 -368 WIRE 496 -320 464 -320 WIRE 544 -320 496 -320 WIRE 688 -320 624 -320 WIRE 720 -320 688 -320 WIRE 784 -320 784 -368 WIRE 368 -304 368 -368 WIRE 464 -304 464 -320 WIRE 720 -208 720 -320 WIRE 784 -208 784 -240 WIRE 784 -208 720 -208 WIRE 160 -80 144 -80 WIRE 192 -80 160 -80 WIRE 320 -80 272 -80 WIRE 368 -80 368 -112 WIRE 368 -80 320 -80 WIRE 464 -80 464 -112 WIRE 496 -80 464 -80 WIRE 592 -80 496 -80 WIRE 752 -80 688 -80 WIRE 800 -80 752 -80 WIRE 464 -32 464 -80 WIRE -352 0 -368 0 WIRE -224 0 -352 0 WIRE -96 0 -160 0 WIRE -32 0 -96 0 WIRE 144 0 144 -80 WIRE 192 0 144 0 WIRE 304 0 272 0 WIRE -32 32 -32 0 WIRE -32 32 -112 32 WIRE 48 32 -32 32 WIRE 304 32 304 0 WIRE 352 32 304 32 WIRE 416 32 352 32 WIRE 560 32 512 32 WIRE 608 32 608 -32 WIRE 608 32 560 32 WIRE 144 48 144 0 WIRE -112 64 -112 32 WIRE 48 64 48 32 WIRE 304 64 304 32 WIRE 608 64 608 32 WIRE 800 64 800 -80 WIRE -368 128 -368 0 WIRE -112 160 -112 128 WIRE -112 160 -176 160 WIRE 48 160 48 128 WIRE 96 160 48 160 WIRE 144 160 144 128 WIRE 144 160 96 160 WIRE 304 160 304 144 WIRE -176 176 -176 160 WIRE 608 176 608 144 WIRE 800 176 800 128 WIRE -112 192 -112 160 WIRE 48 192 48 160 WIRE -112 288 -112 256 WIRE -32 288 -112 288 WIRE 48 288 48 256 WIRE 48 288 -32 288 WIRE -368 336 -368 208 WIRE -336 336 -368 336 WIRE -224 336 -336 336 WIRE -96 336 -160 336 WIRE -32 336 -32 288 WIRE -32 336 -96 336 FLAG 800 176 0 FLAG 496 -80 Vb FLAG 752 -80 Vbatt FLAG 304 160 0 FLAG 352 32 Ve FLAG -176 176 0 FLAG -352 0 Tip FLAG -96 0 AC1 FLAG 160 -80 Rect FLAG -336 336 Ring FLAG -96 336 AC2 FLAG 560 32 Vg1 FLAG 608 176 0 FLAG 320 -80 Vsense FLAG 688 -320 V- FLAG 496 -320 RingDet FLAG 512 -368 V+ FLAG 96 160 Brdg SYMBOL voltage -368 112 R0 WINDOW 0 36 65 Left 2 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName V1 SYMATTR Value SINE(0 100 20 0 0 0) SYMBOL res 288 48 R0 SYMATTR InstName R1 SYMATTR Value 470k SYMBOL cap -160 -16 R90 WINDOW 0 0 32 VBottom 2 WINDOW 3 32 32 VTop 2 SYMATTR InstName C1

SYMBOL pnp 512 -32 R90 WINDOW 0 50 63 VLeft 2 WINDOW 3 78 71 VLeft 2 SYMATTR InstName Q1 SYMATTR Value 2N5401 SYMBOL cap 784 64 R0 SYMATTR InstName C2 SYMATTR Value 10mF SYMBOL diode -96 128 R180 WINDOW 0 24 64 Left 2 WINDOW 3 20 4 Left 2 SYMATTR InstName D1 SYMATTR Value RF04UA2D SYMBOL diode 32 64 R0 WINDOW 3 -106 61 Left 2 SYMATTR Value RF04UA2D SYMATTR InstName D2 SYMBOL diode -128 192 R0 WINDOW 3 -107 57 Left 2 SYMATTR Value RF04UA2D SYMATTR InstName D3 SYMBOL diode 64 256 R180 WINDOW 0 24 64 Left 2 WINDOW 3 21 6 Left 2 SYMATTR InstName D4 SYMATTR Value RF04UA2D SYMBOL cap -160 320 R90 WINDOW 0 0 32 VBottom 2 WINDOW 3 32 32 VTop 2 SYMATTR InstName C3

SYMBOL res 592 48 R0 SYMATTR InstName R4 SYMATTR Value 5Meg SYMBOL voltage 144 144 R180 WINDOW 0 -62 79 Left 2 WINDOW 123 0 0 Left 0 WINDOW 39 -87 11 Left 2 WINDOW 3 -54 44 Left 2 SYMATTR InstName V2 SYMATTR SpiceLine Rser=0 SYMATTR Value 0 SYMBOL pmos 688 -32 M270 WINDOW 0 65 6 VRight 2 WINDOW 3 65 54 VRight 2 SYMATTR InstName M1 SYMATTR Value IRF9640 SYMBOL Optos\\PC817A 416 -208 R270 WINDOW 0 19 90 VCenter 2 WINDOW 3 -12 119 VCenter 2 SYMATTR InstName U1 SYMBOL voltage 784 -336 R0 WINDOW 0 36 65 Left 2 WINDOW 123 0 0 Left 0 WINDOW 39 24 124 Left 2 SYMATTR InstName V3 SYMATTR SpiceLine Rser=0 SYMATTR Value 5 SYMBOL res 528 -304 R270 WINDOW 0 32 56 VTop 2 WINDOW 3 0 56 VBottom 2 SYMATTR InstName R5 SYMATTR Value 10k SYMBOL res 176 16 R270 WINDOW 0 34 23 VTop 2 WINDOW 3 33 71 VTop 2 SYMATTR InstName R2 SYMATTR Value 10k SYMBOL res 176 -64 R270 WINDOW 0 32 30 VTop 2 WINDOW 3 32 73 VTop 2 SYMATTR InstName R6 SYMATTR Value 121 TEXT 128 -288 Left 2 !.tran 8

Rick C. -+ Get 1,000 miles of free Supercharging -+ Tesla referral code - https://ts.la/richard11209

e out why the voltage on a current sense resistor is not a nice sine wave-i sh like the applied voltage to the circuit. I expected a bit of distortion around the zero crossing points but otherwise a rectified sine wave.

currents I realized the issue was MUCH more fundamental. The current throu gh the resistor is as expected, pretty much a rectified sine wave with a bi t of distortion near the zero crossing points... but the voltage is terribl y distorted. What finally sunk in was that these were the measurements dir ectly on the resistor as if the resistance was varying!!!

or resistance much like the voltage waveform. The measured values are not weird extremes that might be from parasitic effects, ~3 volts, ~13 mA, 121 ohms. I even tried using a specific resistor part number to make sure the resistor didn't have some weird default parasitic value on it.

mulator? The calculated resistance value over the cycle not near the zero crossings ranges from 120 ohms to 240 ohms.

Forgot to mention it is R2 and R6 that are acting up.

Rick C. +- Get 1,000 miles of free Supercharging +- Tesla referral code - https://ts.la/richard11209

ure out why the voltage on a current sense resistor is not a nice sine wave

-ish like the applied voltage to the circuit. I expected a bit of distorti on around the zero crossing points but otherwise a rectified sine wave.

r currents I realized the issue was MUCH more fundamental. The current thr ough the resistor is as expected, pretty much a rectified sine wave with a bit of distortion near the zero crossing points... but the voltage is terri bly distorted. What finally sunk in was that these were the measurements d irectly on the resistor as if the resistance was varying!!!

for resistance much like the voltage waveform. The measured values are no t weird extremes that might be from parasitic effects, ~3 volts, ~13 mA, 12

1 ohms. I even tried using a specific resistor part number to make sure th e resistor didn't have some weird default parasitic value on it.

simulator? The calculated resistance value over the cycle not near the zer o crossings ranges from 120 ohms to 240 ohms.

apart from complaints about a floating node on the output side of the opto, I don't see anything unusual. I(R6) and V(rect)-V(vsense) match and so doe s I(R2) and V(rect)-V(Ve)

On Tuesday, 16 June 2020 09:01:32 UTC+10, Lasse Langwadt Christensen wrote :

igure out why the voltage on a current sense resistor is not a nice sine wa ve-ish like the applied voltage to the circuit. I expected a bit of distor tion around the zero crossing points but otherwise a rectified sine wave.

tor currents I realized the issue was MUCH more fundamental. The current t hrough the resistor is as expected, pretty much a rectified sine wave with a bit of distortion near the zero crossing points... but the voltage is ter ribly distorted. What finally sunk in was that these were the measurements directly on the resistor as if the resistance was varying!!!

rm for resistance much like the voltage waveform. The measured values are not weird extremes that might be from parasitic effects, ~3 volts, ~13 mA,

121 ohms. I even tried using a specific resistor part number to make sure the resistor didn't have some weird default parasitic value on it.

t simulator? The calculated resistance value over the cycle not near the z ero crossings ranges from 120 ohms to 240 ohms.

o, I don't see anything unusual. I(R6) and V(rect)-V(vsense) match and so d oes I(R2) and V(rect)-V(Ve)

+1 though I didn't get any 'floating node' warnings

LTSpice XVII(x64) updated Jun 10 2002

Cheers, Chris.

On Monday, June 15, 2020 at 7:01:32 PM UTC-4, Lasse Langwadt Christensen wr ote:

igure out why the voltage on a current sense resistor is not a nice sine wa ve-ish like the applied voltage to the circuit. I expected a bit of distor tion around the zero crossing points but otherwise a rectified sine wave.

tor currents I realized the issue was MUCH more fundamental. The current t hrough the resistor is as expected, pretty much a rectified sine wave with a bit of distortion near the zero crossing points... but the voltage is ter ribly distorted. What finally sunk in was that these were the measurements directly on the resistor as if the resistance was varying!!!

rm for resistance much like the voltage waveform. The measured values are not weird extremes that might be from parasitic effects, ~3 volts, ~13 mA,

121 ohms. I even tried using a specific resistor part number to make sure the resistor didn't have some weird default parasitic value on it.

t simulator? The calculated resistance value over the cycle not near the z ero crossings ranges from 120 ohms to 240 ohms.

o, I don't see anything unusual. I(R6) and V(rect)-V(vsense) match and so d oes I(R2) and V(rect)-V(Ve)

The shape of the voltage waveform is a half sine wave just like the current ???

formatting link

This is what I see and the program has been restarted a number of times. T here are no custom parts or anything that should upset LTspice. WTF!?

To be certain about the error you saw, I added a Gohm resistor to ground fr om the floating side, then made it 1 Meg and still get the distorted voltag e waveforms.

I also see V(Rect,Vb) distorted, but that's no surprise since that is the r esistor R6 in series with the opto LED. The voltages elsewhere are a bit l arge for this to show up for certain since the distortion is only about a v olt on a 100 volt signal. With a 50 Vp signal those two resistor voltage w aveforms are similarly distorted and the other waveforms are not.

I'm running LTspice XVII(x64), May 13, 2020.

Rick C. ++ Get 1,000 miles of free Supercharging ++ Tesla referral code - https://ts.la/richard11209 Yeah, ,

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required