Electronics-Related.com
Forums

LTSpice resistive divider

Started by Piotr Wyderski June 16, 2022
On Friday, 17 June 2022 at 03:45:21 UTC+10, Piotr Wyderski wrote:
> Phil Hobbs wrote: > > > Thanks for the heads-up, Piotr. > No problem, albeit I am shocked that you both can replicate it. I was > sure it was due to my messing up with the Control Panel parameters. Now > I am getting worried: how many planes above my head were simulated with > this tool? ;-) > > It only seems to do it with the "modified trap" integrator--switching to > > plain trapezoid or Gear fixes it, it looks like. > So does tran 40m instead of tran 1 with the default settings. > > That's a super good test case for a bug report! > Reported. > > Best regards, Piotr
FWIW it worked perfectly for me on all PSpice integration methods. To be fair I had updated (Tools->Sync Release) a week ago... -- Cheers, Chris.
This bug showed up after May 2019 in version XVII. 
It is discussed in the LTSpice group.
https://groups.io/g/LTspice/topic/78178224#126082

On Thu, 16 Jun 2022 18:34:36 +0200, Piotr Wyderski
<bombald@protonmail.com> wrote:

>Hi, > >what has recently happened to my Spice? Below is a simple resistor >divider and this is the R2 voltage: > >https://i.postimg.cc/SxPYBV2c/spice.png > >Switching between solvers doesn't make any difference. > > Best regards, Piotr > >Version 4 >SHEET 1 880 680 >WIRE 208 32 96 32 >WIRE 368 32 288 32 >WIRE 368 48 368 32 >WIRE 96 80 96 32 >WIRE 96 176 96 160 >WIRE 368 176 368 128 >FLAG 96 176 0 >FLAG 368 176 0 >SYMBOL voltage 96 64 R0 >WINDOW 123 0 0 Left 0 >WINDOW 39 0 0 Left 0 >SYMATTR InstName V1 >SYMATTR Value SINE(0 320 50) >SYMBOL res 352 32 R0 >SYMATTR InstName R1 >SYMATTR Value 64 >SYMBOL res 304 16 R90 >WINDOW 0 0 56 VBottom 2 >WINDOW 3 32 56 VTop 2 >SYMATTR InstName R2 >SYMATTR Value 10m >TEXT 64 200 Left 2 !.tran 1
This is an old message thread, but I want to let you all know what the "problem" was.

What you are seeing is the effect of LTspice's Modified Trap integration method, and a little more.  Modified Trap is identical to regular Trap except that an additional nonlinear filtering step is applied to waveforms before saving them to disk (it doesn't affect the simulation itself).  It is described on the LTspice Help page for "Integration Methods".

Now, a change was made to LTspice XVII in 2020(?) to disable this nonlinear filtering on only certain signals - namely those that come directly from things like voltage sources, because they should be immune to "Trap Ringing", which was the reason for the nonlinear filter.  I don't know why they changed it, but I guess maybe customers complained that their ideal voltage sources were slightly "off".  That change fixed it.

All good so far.  But the problem comes when you directly compare nearly identical signals where one is ModTrap-filtered and the other is not.  That is the case in your circuit with the signals on the two ends of R2.  R2 is much smaller than R1 so the two voltages on R2's ends are large but nearly equal (millivolts compared to hundreds of volts).  But - and here's the key thing - when saved to disk with Modified Trap selected, the right end of R2 has the ModTrap nonlinear filter, and the left end does not.  Now, depending on the timestep, this can cause the voltage between the ends of R2 to look distorted on account of that nonlinear filter that was applied differently to the two signals.  If both signals had Modified Trap filtering, they would look fine because the nonlinear filter would be applied to both signals.  Also, when looking at any signal by itself (not compared with another), it looks correct because the effect of the nonlinear filter is usually negligible unless there is Trap Ringing.  But because you are looking at the small difference between two large signals, you see something that shouldn't be there.

There are multiple ways to eliminate it:

-  Make the timestep smaller.  Add a Maximum Timestep to the .tran command.

-  Don't use Modified Trap.  Select either (regular) Trapezoidal or Gear.  (Note that you can't force regular Trap by way of ".OPTIONS METHOD=TRAP".  That just picks either Trap or Modified Trap depending on which one was selected in the Control Panel.)

-  Add a dummy resistor from the top of V1 to nowhere.  Give it any value other than 0.  There is exactly zero current through it, so no voltage drop across it.  But LTspice applies the ModTrap's nonlinear filter to the floating end of that added resistor, whereas the driven end (connected to V1) doesn't have the nonlinear filter.  Now if you probe the voltage between that floating end, and the right end of R2, the plotted waveform looks correct again.

Regards,
Andy
On 8/18/22 12:30 AM, Andy I wrote:
> This is an old message thread, but I want to let you all know what the "problem" was. > > What you are seeing is the effect of LTspice's Modified Trap integration method, and a little more. Modified Trap is identical to regular Trap except that an additional nonlinear filtering step is applied to waveforms before saving them to disk (it doesn't affect the simulation itself). It is described on the LTspice Help page for "Integration Methods". > > Now, a change was made to LTspice XVII in 2020(?) to disable this nonlinear filtering on only certain signals - namely those that come directly from things like voltage sources, because they should be immune to "Trap Ringing", which was the reason for the nonlinear filter. I don't know why they changed it, but I guess maybe customers complained that their ideal voltage sources were slightly "off". That change fixed it. > > All good so far. But the problem comes when you directly compare nearly identical signals where one is ModTrap-filtered and the other is not. That is the case in your circuit with the signals on the two ends of R2. R2 is much smaller than R1 so the two voltages on R2's ends are large but nearly equal (millivolts compared to hundreds of volts). But - and here's the key thing - when saved to disk with Modified Trap selected, the right end of R2 has the ModTrap nonlinear filter, and the left end does not. Now, depending on the timestep, this can cause the voltage between the ends of R2 to look distorted on account of that nonlinear filter that was applied differently to the two signals. If both signals had Modified Trap filtering, they would look fine because the nonlinear filter would be applied to both signals. Also, when looking at any signal by itself (not compared with another), it looks correct because the effect of the nonlinear filter is usually negligible unless there is Trap Ringing. But because you are looking at the small difference between two large signals, you see something that shouldn't be there. > > There are multiple ways to eliminate it: > > - Make the timestep smaller. Add a Maximum Timestep to the .tran command. > > - Don't use Modified Trap. Select either (regular) Trapezoidal or Gear. (Note that you can't force regular Trap by way of ".OPTIONS METHOD=TRAP". That just picks either Trap or Modified Trap depending on which one was selected in the Control Panel.) > > - Add a dummy resistor from the top of V1 to nowhere. Give it any value other than 0. There is exactly zero current through it, so no voltage drop across it. But LTspice applies the ModTrap's nonlinear filter to the floating end of that added resistor, whereas the driven end (connected to V1) doesn't have the nonlinear filter. Now if you probe the voltage between that floating end, and the right end of R2, the plotted waveform looks correct again. > > Regards, > Andy >
Interesting, thanks. Cheers Phil Hobbs -- Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC / Hobbs ElectroOptics Optics, Electro-optics, Photonics, Analog Electronics Briarcliff Manor NY 10510 http://electrooptical.net https://hobbs-eo.com
On Wed, 17 Aug 2022 21:30:39 -0700 (PDT), Andy I <ai.egrps@gmail.com>
wrote:

>This is an old message thread, but I want to let you all know what the "problem" was. > >What you are seeing is the effect of LTspice's Modified Trap integration method, and a little more. Modified Trap is identical to regular Trap except that an additional nonlinear filtering step is applied to waveforms before saving them to disk (it doesn't affect the simulation itself). It is described on the LTspice Help page for "Integration Methods". > >Now, a change was made to LTspice XVII in 2020(?) to disable this nonlinear filtering on only certain signals - namely those that come directly from things like voltage sources, because they should be immune to "Trap Ringing", which was the reason for the nonlinear filter. I don't know why they changed it, but I guess maybe customers complained that their ideal voltage sources were slightly "off". That change fixed it. > >All good so far. But the problem comes when you directly compare nearly identical signals where one is ModTrap-filtered and the other is not. That is the case in your circuit with the signals on the two ends of R2. R2 is much smaller than R1 so the two voltages on R2's ends are large but nearly equal (millivolts compared to hundreds of volts). But - and here's the key thing - when saved to disk with Modified Trap selected, the right end of R2 has the ModTrap nonlinear filter, and the left end does not. Now, depending on the timestep, this can cause the voltage between the ends of R2 to look distorted on account of that nonlinear filter that was applied differently to the two signals. If both signals had Modified Trap filtering, they would look fine because the nonlinear filter would be applied to both signals. Also, when looking at any signal by itself (not compared with another), it looks correct because the effect of the nonlinear filter is usually negligible unless there
is
>Trap Ringing. But because you are looking at the small difference between two large signals, you see something that shouldn't be there. > >There are multiple ways to eliminate it: > >- Make the timestep smaller. Add a Maximum Timestep to the .tran command. > >- Don't use Modified Trap. Select either (regular) Trapezoidal or Gear. (Note that you can't force regular Trap by way of ".OPTIONS METHOD=TRAP". That just picks either Trap or Modified Trap depending on which one was selected in the Control Panel.) > >- Add a dummy resistor from the top of V1 to nowhere. Give it any value other than 0. There is exactly zero current through it, so no voltage drop across it. But LTspice applies the ModTrap's nonlinear filter to the floating end of that added resistor, whereas the driven end (connected to V1) doesn't have the nonlinear filter. Now if you probe the voltage between that floating end, and the right end of R2, the plotted waveform looks correct again. > >Regards, >Andy
I love LT Spice except when she lies to me. It's good to always be a bit skeptical.