¿ªÔÆÌåÓý


Re: Possible g;itch in stepping parameters

 

¿ªÔÆÌåÓý

On 01/05/2025 02:37, Andy I via groups.io wrote:
Remember that all .MEAS commands are evaluated after all simulations are complete.? I think it means that user-defined PARAMeters hold their final values, at the last .STEP in the sequence.? Voltages and currents can be recalled from each .STEP, but parameter values can not.
That's not quite true. In order for them to captured and printed in the logfile, the braces need to be removed. Then it will work.

--
Regards,
Tony


Re: Possible g;itch in stepping parameters

 

¿ªÔÆÌåÓý

Remove all the braces, then it will work as you want. You never need braces anyway with .param directives.

If used with .meas xxx param yyy, you will only get one measured value, as you observed. Sometimes, this can be what you want, but not this time.

--
Regards,
Tony

Of course, the error is more likely with me, but:

I¡¯m experimenting with a simple solar cell/array simulator I can reuse with larger models.
It¡¯s working and stable, at a wide range of open circuit voltages and short circuit currnts, and with different Diode models.
(A current source across a string of ¡®N¡¯ diodes of known Vfwd)

But when I inserted a .step of the Voc parameter, while it seems to simulate correctly, I got a weird .measure result.
.param Voc 75
.step param Voc list 32 45 75
.param Vc 0.8921
.param Vc2 0.7451
.param Isc 1.2

.param nCells {Voc/Vc}
.param nCells2 {Voc/Vc2}
.meas nC PARAM {nCells}???????????????????????? ; here to annotate in the log file
.meas nC2 PARAM {nCells2}???? ?????????????? ; here to annotate in the log file

From the log file:

.step voc=32
.step voc=45
.step voc=75

Measurement: nc
? step??? 84.0712924560027
???? 1??????? 84.0713
???? 2??????? 84.0713
???? 3??????? 84.0713

Measurement: nc2
? step??? 100.657629848343
???? 1??????? 100.658
???? 2??????? 100.658
???? 3??????? 100.658

How can nc or nc2 remain the same at all three different values of Voc?
The voltages and currents correvtly follow the stepped Voc, but just those two .measures are wrong/


Re: Possible g;itch in stepping parameters

 

The reason this happens is the braces on the?
.meas xxx param yyy lines.

That has a special effect of fixing the meas result to the first one. Remove all the braces! You don't ever need them for .param directives, anyway.

--
Regards,
Tony


On Thu, 1 May 2025, 01:43 Bell, Dave via , <Dave.Bell=[email protected]> wrote:

Of course, the error is more likely with me, but:

?

I¡¯m experimenting with a simple solar cell/array simulator I can reuse with larger models.

It¡¯s working and stable, at a wide range of open circuit voltages and short circuit currnts, and with different Diode models.

(A current source across a string of ¡®N¡¯ diodes of known Vfwd)

?

But when I inserted a .step of the Voc parameter, while it seems to simulate correctly, I got a weird .measure result.

?

.param Voc 75

.step param Voc list 32 45 75

.param Vc 0.8921

.param Vc2 0.7451

.param Isc 1.2

?

.param nCells {Voc/Vc}

.param nCells2 {Voc/Vc2}

.meas nC PARAM {nCells}???????????????????????? ; here to annotate in the log file

.meas nC2 PARAM {nCells2}???? ?????????????? ; here to annotate in the log file

?

From the log file:

?

.step voc=32

.step voc=45

.step voc=75

?

Measurement: nc

? step??? 84.0712924560027

???? 1??????? 84.0713

???? 2??????? 84.0713

???? 3??????? 84.0713

?

Measurement: nc2

? step??? 100.657629848343

???? 1??????? 100.658

???? 2??????? 100.658

???? 3??????? 100.658

?

How can nc or nc2 remain the same at all three different values of Voc?

The voltages and currents correvtly follow the stepped Voc, but just those two .measures are wrong/

?

Dave

?

?


Re: Possible g;itch in stepping parameters

 

¿ªÔÆÌåÓý

Thanks for the nudge, Andy!

Yep, the give-away was that the values for Ncells was always for the last Voc step.

?

At one point, I did have voltages for Ncells/2, but thought it looked kludgy, and ¡°fixed it¡± by .meas PARAM!

?

Dave

?

From: [email protected] <[email protected]> On Behalf Of Andy I via groups.io
Sent: Wednesday, April 30, 2025 5:38 PM
To: [email protected]
Subject: EXTERNAL: Re: [LTspice] Possible g;itch in stepping parameters

?

I need to refresh my memory about this.? However, ...

?

Remember that all .MEAS commands are evaluated after all simulations are complete.? I think it means that user-defined PARAMeters hold their final values, at the last .STEP in the sequence.? Voltages and currents can be recalled from each .STEP, but parameter values can not.

?

To overcome that, you could use voltages to 'save' each parameter value from every .STEP.

?

Andy

?


Re: Modeling Constant Power Load with AC Source in LTspice

 

Eaglesea,
?
This is probably not much of an answer yet to your questions.
?
LTspice has a lot of trouble.? Sometimes I had "timestep too small" aborts, but mostly I see math errors where it displays values such as "1.#QNAN" or "1.#IND" volts or amps.? Those are math error codes meaning "Not a Number" or "Indefinite/Indeterminate".? That is not a good sign.? Also there was a lot of Trap Ringing, for what it's worth (which is not much).
?
I wonder if it works having a constant power load with a time-varying sinusoidal waveform.? It needs to be very nonlinear, and I think the interaction between that nonlinearity and the series impedance causes havoc.
?
Does that load mimic anything real?
?
Just an FYI - inductance is mostly a function of the loop area enclosed by the wires.? There is a misconception that inductance depends entirely on the wires themselves.? You can find formulas for wire self inductance, but they are often mis-applied.
?
Andy
?
?


Re: Modeling Constant Power Load with AC Source in LTspice

 

On Wed, Apr 30, 2025 at 12:04 PM, Bell, Dave wrote:

Andy, I am surprised at your response; you are typically very on point!

The OP stated:

¡°convergence failure when I run transient analysis¡±

Yes, I missed that fact!
?
It shows that I am still human, after all.? :-)
?
So, ignore most of what I wrote that pertains to .AC analysis.
?
Andy
?
?


Re: Possible g;itch in stepping parameters

 

I need to refresh my memory about this.? However, ...
?
Remember that all .MEAS commands are evaluated after all simulations are complete.? I think it means that user-defined PARAMeters hold their final values, at the last .STEP in the sequence.? Voltages and currents can be recalled from each .STEP, but parameter values can not.
?
To overcome that, you could use voltages to 'save' each parameter value from every .STEP.
?
Andy
?


Possible g;itch in stepping parameters

 

¿ªÔÆÌåÓý

Of course, the error is more likely with me, but:

?

I¡¯m experimenting with a simple solar cell/array simulator I can reuse with larger models.

It¡¯s working and stable, at a wide range of open circuit voltages and short circuit currnts, and with different Diode models.

(A current source across a string of ¡®N¡¯ diodes of known Vfwd)

?

But when I inserted a .step of the Voc parameter, while it seems to simulate correctly, I got a weird .measure result.

?

.param Voc 75

.step param Voc list 32 45 75

.param Vc 0.8921

.param Vc2 0.7451

.param Isc 1.2

?

.param nCells {Voc/Vc}

.param nCells2 {Voc/Vc2}

.meas nC PARAM {nCells}???????????????????????? ; here to annotate in the log file

.meas nC2 PARAM {nCells2}???? ?????????????? ; here to annotate in the log file

?

From the log file:

?

.step voc=32

.step voc=45

.step voc=75

?

Measurement: nc

? step??? 84.0712924560027

???? 1??????? 84.0713

???? 2??????? 84.0713

???? 3??????? 84.0713

?

Measurement: nc2

? step??? 100.657629848343

???? 1??????? 100.658

???? 2??????? 100.658

???? 3??????? 100.658

?

How can nc or nc2 remain the same at all three different values of Voc?

The voltages and currents correvtly follow the stepped Voc, but just those two .measures are wrong/

?

Dave

?

?


Re: Modeling Constant Power Load with AC Source in LTspice

 

All,
Thank you all for the different responses. I truly appreciate it. I am new to LTspice so all comments are educational. for that thank you
I notice the schematic runs fine with an ideal wire. the issues starts when I add a series components?


Re: Modeling Constant Power Load with AC Source in LTspice

 

¿ªÔÆÌåÓý

Andy, I am surprised at your response; you are typically very on point!

The OP stated:

¡°convergence failure when I run transient analysis¡±

?

That zero crossing¡­

?

That said, with two devices, I was having no problems with convergence:

?

V: SINE(0 170 60)

BI: P=if(abs(V(V))<5, 0, 500)

.tran {1/30}

?

Dave

?

From: [email protected] <[email protected]> On Behalf Of Andy I via groups.io
Sent: Tuesday, April 29, 2025 1:19 PM
To: [email protected]
Subject: EXTERNAL: Re: [LTspice] Modeling Constant Power Load with AC Source in LTspice

?

  • Would a smoother soft-transition function (instead of if()) work better?

Smoother functions are almost always better, in terms of stability and avoiding instability.

  • Are there other tricks to avoid convergence failures near zero crossing?

What zero crossing?? If it is an .AC analysis that you're doing, there are no zero-crossings.? There are no time-varying waveforms in .AC analysis.? Signals are assumed to be single-frequency, therefore they represent the amplitudes of sine waves, but there are no sine waves anywhere in the simulation when you are doing an .AC analysis.? A "1V" sinusoidal signal in .AC analysis is represented by the quantity "1", not by a time-varying sine wave.

?

That can also lead to confusion about whether a "1V" signal is an RMS level or a peak level.? The truth is that it doesn't matter.? You get to decide, as long as you are consistent about it.? If you decide that "1V" is the RMS amplitude, then everything is RMS.? If you decide that "1V" is the peak amplitude - or even peak-to-peak - then that is what it is and everything else in the simulation is measured the same way.? Because everything is strictly linear, it makes no difference.? Just be consistent about it, and you're OK.

?

So -- if you think you are experiencing difficulty because of zero crossings of sine waves, you are not.? There are no sine waves in the simulation itself.

?

Andy

?


Re: Modeling Constant Power Load with AC Source in LTspice

 

For AC analysis of an active network, isn't the "gain" at the operating point used? If so, does that load function provide a stable operating point - that is, can an operating point really be found? Constant power loads are inherently negative resistance loads.
?
Jim Wagner

On 04/29/2025 1:19 PM PDT Andy I via groups.io <ai.egrps+io@...> wrote:
?
?
  • Would a smoother soft-transition function (instead of if()) work better?

Smoother functions are almost always better, in terms of stability and avoiding instability.
  • Are there other tricks to avoid convergence failures near zero crossing?
What zero crossing?? If it is an .AC analysis that you're doing, there are no zero-crossings.? There are no time-varying waveforms in .AC analysis.? Signals are assumed to be single-frequency, therefore they represent the amplitudes of sine waves, but there are no sine waves anywhere in the simulation when you are doing an .AC analysis.? A "1V" sinusoidal signal in .AC analysis is represented by the quantity "1", not by a time-varying sine wave.
?
That can also lead to confusion about whether a "1V" signal is an RMS level or a peak level.? The truth is that it doesn't matter.? You get to decide, as long as you are consistent about it.? If you decide that "1V" is the RMS amplitude, then everything is RMS.? If you decide that "1V" is the peak amplitude - or even peak-to-peak - then that is what it is and everything else in the simulation is measured the same way.? Because everything is strictly linear, it makes no difference.? Just be consistent about it, and you're OK.
?
So -- if you think you are experiencing difficulty because of zero crossings of sine waves, you are not.? There are no sine waves in the simulation itself.
?
Andy
?


Re: Modeling Constant Power Load with AC Source in LTspice

 

  • Would a smoother soft-transition function (instead of if()) work better?

Smoother functions are almost always better, in terms of stability and avoiding instability.
  • Are there other tricks to avoid convergence failures near zero crossing?
What zero crossing?? If it is an .AC analysis that you're doing, there are no zero-crossings.? There are no time-varying waveforms in .AC analysis.? Signals are assumed to be single-frequency, therefore they represent the amplitudes of sine waves, but there are no sine waves anywhere in the simulation when you are doing an .AC analysis.? A "1V" sinusoidal signal in .AC analysis is represented by the quantity "1", not by a time-varying sine wave.
?
That can also lead to confusion about whether a "1V" signal is an RMS level or a peak level.? The truth is that it doesn't matter.? You get to decide, as long as you are consistent about it.? If you decide that "1V" is the RMS amplitude, then everything is RMS.? If you decide that "1V" is the peak amplitude - or even peak-to-peak - then that is what it is and everything else in the simulation is measured the same way.? Because everything is strictly linear, it makes no difference.? Just be consistent about it, and you're OK.
?
So -- if you think you are experiencing difficulty because of zero crossings of sine waves, you are not.? There are no sine waves in the simulation itself.
?
Andy
?


Re: Modeling Constant Power Load with AC Source in LTspice

 

On Tue, Apr 29, 2025 at 03:48 PM, <thunderboy.johnson86@...> wrote:
  • Where P is set dynamically using an if() function:

  • P = if(V(vout)<5,5,500)

I am not sure how that relates to the circuit elements and their equations that you used.? But note that the formula for P has a significant discontinuity at V(vout) = 5.? The discontinuity also means the derivative is not a continuous function, and that is (almost by definition) the recipe for instability.
?
SPICE wants all functions and their first derivatives to be continuous everywhere.
?
Andy
?


Re: Modeling Constant Power Load with AC Source in LTspice

 
Edited

On Tue, Apr 29, 2025 at 03:48 PM, <thunderboy.johnson86@...> wrote:

I'm trying to model a constant power load fed by a single-phase AC source in LTspice. I seem to run into convergence failure when I run transient analysis

LTspice has a constant power load already.? See:
?
However, that is intended for .TRAN or .OP or .DC analysis, and I do not know how well it behaves for .AC analysis.? Maybe it's just fine, or maybe not.? .AC analysis is strictly linear with constant unvarying circuit elements, and a constant power load needs to vary dynamically as a function of the signal amplitude - therefore making it nonlinear (and non-constant).? It seems like that could be a real problem for .AC analysis.
?
(I am assuming that you did actually mean .AC analysis, and not time-varying signals, right?)
?
Your question implies a possible interaction between the load and the rest of the circuit.? Maybe the interaction between your circuit and the load's need to vary, result in the stability problem?? That is just a guess.
?
For a better answer, considering uploading your simulation to the group for all to see.? As always, check the guidelines on this group's webpage before attempting to upload anything.
?
Andy
?


Modeling Constant Power Load with AC Source in LTspice

 

Hi all,

I'm trying to model a constant power load fed by a single-phase AC source in LTspice. I seem to run into convergence failure when I run transient analysis

What I¡¯m doing:

  • I¡¯m using a behavioral current source with this formula:
    I = P/V(vout)

  • Where P is set dynamically using an if() function:

  • P = if(V(vout)<5,5,500)

My goal:

  • Accurately simulate a constant power source behavior under AC voltage?
  • But without simulation instability

Questions:

  • Has anyone successfully built a robust CPL model under AC excitation in LTspice?

  • Would a smoother soft-transition function (instead of if()) work better?

  • Are there other tricks to avoid convergence failures near zero crossing?


Re: Making a PWM a continuous voltage source

 

try this
/g/LTspice/files/z_yahoo/Examples/Apps/pwm4_Pulse.zip


Re: Making a PWM a continuous voltage source

 

On Tue, Apr 29, 2025 at 05:59 AM, Christoph wrote:
I tried the statement: PWL REPEAT FOREVER ( | one_period.txt) ENDREPEAT from the undocumentedcommands section of the wiki to no avail.
The "|" (pipe symbol) gives an error.
I do not understand why the "|" character is there in the LTwiki page for "Undocumented LTspice".? I am sure that was a typo.? As far as I know, the pipe character is never used anywhere in LTspice netlists.
?
My best guess (in message 147247 which was a reply in 2023 to a question from you) is that the author of that LTwiki page had intended to write it this way:
... PWL REPEAT FOREVER ( <t1> <v1> ... <tn> <vn> | file=<file spec> ) ENDREPEAT
where the "|" character does not mean to literally type the pipe character there.? In that setting, "|" means "OR", as in, "use either this, or this".? And then somewhere along the way, that line was edited down and the meaning was lost.? His examples, just a few lines lower on that page, show the correct syntax.
?
Unfortunately we can't ask AnalogSpiceman for clarification because he passed on from this world in 2020.
?
Andy
?
?


Re: Making a PWM a continuous voltage source

 

¿ªÔÆÌåÓý

On 29/04/2025 11:58, Christoph via groups.io wrote:
Is it possible to make a PWM signal a continuous voltage source ?

I have these PWL points in a file but  simulating this I have transient response and decay behaviour. I would like to do a FFT on the filter output signal
and the presence of these spoil the FFT picture. Using a sine as a voltage source it behaves like an infinite signal while the PWL from file is always finite, seems so.

I tried the statement: PWL REPEAT FOREVER ( | one_period.txt) ENDREPEAT from the undocumentedcommands  section of the wiki to no avail.
The "|" (pipe symbol) gives an error.
Try removing the pipe. That part of the documentation is confusing. The example showing the pipe doesn't mean you should add it. Using the syntax from the other clearer example:

PWL REPEAT FOREVER ( file=one_period.txt ) ENDREPEAT

See: PWL_Example

--
Regards,
Tony


Making a PWM a continuous voltage source

 

Is it possible to make a PWM signal a continuous voltage source ?

I have these PWL points in a file but simulating this I have transient response and decay behaviour. I would like to do a FFT on the filter output signal
and the presence of these spoil the FFT picture. Using a sine as a voltage source it behaves like an infinite signal while the PWL from file is always finite, seems so.

I tried the statement: PWL REPEAT FOREVER ( | one_period.txt) ENDREPEAT from the undocumentedcommands section of the wiki to no avail.
The "|" (pipe symbol) gives an error.

--
Christoph


Re: LTspice 24.1.7 program exit

 

On Mon, Apr 28, 2025 at 04:41 AM, Mathias Born wrote:
I can't reproduce this. All I get when I run this netlist is an error message about the file "standard.dio" not being found.\
Perhaps you forgot to substitute your computer's "path" to the standard.dio file, in the ".lib" statement.? Obviously, eT edited that line to remove his computer's unique path.
?
I'd be quite interested in any evidence that could substantiate this claim.
?
And with "before", I take it you don't mean LTspiceXVII, ...
I did mean LTspice XVII, and LTspice III and LTspice IV.
... because I had that crashing multiple times per hour on bad days. ...
You must have had incredibly bad days or very unique schematics/netlists (or something unique about your computer), because I rarely ever ever saw LTspice III or IV or XVII crash.? Occasionally (a few times a year) it would hang and I had to manually crash it, but it did not crash itself.? If I recall correctly, that happened ONLY while it was trying to plot a particularly difficult (very 'dense') set of waveforms, but never during a simulation or editing schematics.? Now I use the word "never" which might be incorrect.? But I can truly not remember a time when LTspice III or LTspice IV or LTspice XVII crashed when simulating or preparing to simulate something.? There were ways to make simulations fail, but not to make the program itself fail and fall over.
?
I also note there are group members here who reported they could get theirs to crash, but I don't recall others being able to replicate it.? (Now there may have been exceptions where a new program release did, but it was quickly fixed, causing its memory to fall through the holes in my brain.)
?
Andy
?