开云体育


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

开云体育

Don't even think abut trying to do that. It would make your version of LTspice unique, even if you could do it. Instead, make your own library files for such devices, i.e. My MOSFETS etc.

On 2025-05-08 00:24, Per wrote:
think about adding them into the "Pick one of These" file.
?
--
Best wishes John Woodgate RAYLEIGH Essex OOO-Own Opinions Only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

Yes/Nope.... They are the LTSpice provided "Pick one of These".? I have not yet ventured into other models as provided by manufacturers. I'm not even sure I want to and if I did I would go mad and think about adding them into the "Pick one of These" file.
?
For the moment I will give you kind people a rest.


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

On Wed, May 7, 2025 at 02:42 PM, Per wrote:
Oh. The transistor models are just the normal 3 Pin nmos devices.
?
MN
M1
That is not quite what I meant.
?
When you open the model for each MOSFET, and look at its contents, does it look like this?
.model MyNMosfet NMOS(...)
Or does it look like this?
.subckt MyNMosfet d g s
R1 ...
C2 ...
M3 ...
.model ...
.ends MyNMosfet
?
If you are using only the MOSFETs that come with LTspice's "Pick New MOSFET"? menu, then they are the first kind.? But maybe you were using some models that you downloaded from a manufacturer or from somewhere on the Internet, and they could be either kind.
?
Unfortunately, your bimos.asc hierarchical schematic can not accept both kinds of MOSFET models.? That is not your fault.
?
Andy
?


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

Curly braces are needed here in order to avoid an ambiguity. Because you might also have
?
.model MOS ...
?
?
?
On Wed, May 7, 2025 at 08:38 PM, Per wrote:

The help states curly braces are no longer required but it seems that they are.
?
My subcircuit reads,
?
.subckt bimos D1 D2 G S
D1 N001 G RB496KA
D2 G N001 RB496KA
M1 D1 N001 S S {MOS}
M2 D2 N001 S S {MOS}
.ends bimos
?
?
?
?


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

Oh. The transistor models are just the normal 3 Pin nmos devices.
?
MN
M1
?
With Value set to {MOS} and using a name from the list you get when you "Pick New Mosfet"
?
Overall the idea (need) is to reuse the subcircuit but choosing different devices without fixing the subcircuit and this time, famous last words, it seems like it is going to work.
?
Again thanks for the help.


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

Face Palm... Sorry. I finaly twigged it having found the help. Doh.
?
For anyone else text is passed by enclosing in inverted thingies.
?
In a subcircuit pop up on the .PARAMS box write something like MOS="Si7336ADP"
?
Presumably also applies to a raw .params statement on a schematic.
?
The model in the subcircuit should have the parameter you want to pass, in the above case MOS set to {MOS}
?
The help states curly braces are no longer required but it seems that they are.
?
My subcircuit reads,
?
.subckt bimos D1 D2 G S
D1 N001 G RB496KA
D2 G N001 RB496KA
M1 D1 N001 S S {MOS}
M2 D2 N001 S S {MOS}
.ends bimos
?
?
?
?


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

Per, what kind of transistor models are you using, and trying to pass into a subcircuit?
?
Are they .MODEL models?? Or are they defined by a block of netlist lines surrounded by .SUBCKT ... .ENDS?
?
Andy
?


Re: Passing a Mosfet Value as a parameter to a hierarchical subcircuit

 

OK I'm still flummoxed...
?
"Not quite. LTspice also knows string parameters, which were introduced extactly for the purpose discussed here."
?
Mathias. Can you give an example?


Re: Calculate average value of a waveform under specific conditions using .meas command

 

On Wed, May 7, 2025 at 07:14 PM, Andy I wrote:
But this is for a thesis project, so I assume it is somewhat research related, and he might want to know things to a greater level of detail.? Such as, what is the average voltage over the short time interval when the inductor current is increasing, versus when it is decreasing, or when it is zero.? I don't know the reasons why, but I think it makes sense that he might need to know to that level of detail.
Hello Andy and Tony,
?
What you have mentioned is correct. Accuracy and precision are needed. And I checked the derivative option too. Due to ringing during DCM the derivative makes the situation horrible, here is a screenshot for your reference. And if you take a closer look, the derivative is maximum around zero crossing just at the start of the inductor current ramp up, when the inductor current is at its peak, the derivative is at an in-between(ish) value (neither maximum, nor minimum). Similarly, during the inductor current ramp down phase the derivative is again at its valley somewhere in between the entire ramp down duration.

You guys really pushed the envelope and thought out of the box to help me solve my problem. I learned a lot from this discussion. I genuinely am grateful to the both of you. However, to solve this particular problem, I'm afraid I can only rely on manually moving the cursor to find specific points then use these points to syntax my .meas statements to keep measurements as honest as possible.

Again thanks to both of you in making me learn new stuff about LTspice.

With Regards,
Ankit


Re: Dual Active bridge

 

On Wed, May 7, 2025 at 10:50 AM, John Woodgate wrote:

... Using CTRL-left click, I see 5.9124 A, but that includes the inrush current at t=0+. Is there any way to change the 'Interval start', other than changing the sim time to omit the inrush current? ...

Yes.? LTspice calculates the Average and RMS values over the displayed plot only.? Right-click on the X-axis and change the Left: value to something after the waveforms have stabilized.? Then use Ctrl-Left-Click on the name at the top of the plot.? As long as the displayed interval contains many many cycles, it should be a "good enough" average even if it is not an exact integral number of cycles.
?
Andy
?
?


Re: Dual Active bridge

 

On Wed, May 7, 2025 at 07:32 AM, Andy I wrote:
It would be interesting to see why LTspice 24 simulates badly whereas LTspice XVII does not.
Switching to the Alternate solver in LTspice 24.1.8 allows the simulation to run successfully without stalls.
?
I also changed the simulation command to ".tran 0 5m 2m" eliminate the uic and skip past the initial transient. I also commented out the erroneous measure statements.
?
Alternatively, I also noticed that some of the transient currents can be limited substantially by adding a 10m series resistance to the input source, the inductors, and the input and output capacitors. I also added a 1 ohm series resistance to the gate drive sources. With these changes the circuit simulates in 24.1.8 using the Normal solver.?
?


Re: Dual Active bridge

 

On Wed, May 7, 2025 at 10:36 AM, John Woodgate wrote:

...? Do you get a very long series of entries in the expanded netlist about relaxing tolerances to seek convergence?? That occurs even with the 1 ohm in series with V9, in the sim which runs OK to 100 ms. ...

No.? But I get hundreds of "Heightened Def Com" warnings, without the 1 ohm series resistor.? With it, those warnings disappear.
?
Andy
?


Re: Dual Active bridge

 

开云体育

Yes, my 8A/16A figures were what I saw without expanding the waveform. Using CTRL-left click, I see 5.9124 A, but that includes the inrush current at t=0+. Is there any way to change the 'Interval start', other than changing the sim time to omit the inrush current? Doing that, I get 5.8583 A, so we are in violent agreement on that point.

On 2025-05-07 15:10, Andy I via groups.io wrote:
After adding Rser=1 ohm to V9:
?
The average current from V9 is 5.858 Amps, compared to the 8 Amps you said yours had.? Our simulations should not have differed by more than 2 Amps!? Something is wrong.? (Unless you eyeballed your "8 Amps" without measuring it.)? The current waveform there does look kind of sinusoidal with about 8 Amps peak amplitude, varying from -1 A to about +16.5 A.? But it is a highly distorted sinewave and that makes a big difference; the average is not in the middle.? LTspice says the average is 5.858 A DC, in my simulation.
?
The average power from V9 simulates as 507 W, which is nowhere near the roughly 800 W that you estimated.? Again, was that by ayeballing, or measuring it?
?
At the load, I measure 132 V DC as you did, plus some ripple.? Average power there is 385 W, so the converter loses 122 W to heat (76% efficiency).? That is not so bad, but again most of it is in M4, M5, M6, and M7, which can be reduced by building some dead-band into their gate waveforms.
?
Simulating with a discrete 1 ohm resistor instead of Rser=1, I have 640 W sourced by V9 and 108 W dissipated by the 1 ohm resistor.? Between the two, that is 532 W supplied by V9+1ohm to the rest of the circuit.? It is not quite the same as the 507 W when Rser was internal, but I don't know why (it should not have differed, right?).? Will check into that later.
?
In any event, with LTspice XVII, the power losses of the circuit are reasonable, and can be reduced further.? If LTspice 24 tells you a different story, that needs to be understood.? If LTspiceXVII says 122 W is lost and LTspice24 says 400 W is lost, that is a big problem.
?
Andy
?
--
Best wishes John Woodgate RAYLEIGH Essex OOO-Own Opinions Only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


Re: Dual Active bridge

 

开云体育

I entirely agree. I may be doing something wrong, but I can't see what. Do you get a very long series of entries in the expanded netlist about relaxing tolerances to seek convergence?? That occurs even with the 1 ohm in series with V9, in the sim which runs OK to 100 ms. V9 current near 100ms is an 8 A peak sine wave with the positive peak clipped, sitting on 8A DC.

On 2025-05-07 14:32, Andy I via groups.io wrote:
?
It would be interesting to see why LTspice 24 simulates badly whereas LTspice XVII does not.
?
--
Best wishes John Woodgate RAYLEIGH Essex OOO-Own Opinions Only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


Re: Dual Active bridge

 

After adding Rser=1 ohm to V9:
?
The average current from V9 is 5.858 Amps, compared to the 8 Amps you said yours had.? Our simulations should not have differed by more than 2 Amps!? Something is wrong.? (Unless you eyeballed your "8 Amps" without measuring it.)? The current waveform there does look kind of sinusoidal with about 8 Amps peak amplitude, varying from -1 A to about +16.5 A.? But it is a highly distorted sinewave and that makes a big difference; the average is not in the middle.? LTspice says the average is 5.858 A DC, in my simulation.
?
The average power from V9 simulates as 507 W, which is nowhere near the roughly 800 W that you estimated.? Again, was that by ayeballing, or measuring it?
?
At the load, I measure 132 V DC as you did, plus some ripple.? Average power there is 385 W, so the converter loses 122 W to heat (76% efficiency).? That is not so bad, but again most of it is in M4, M5, M6, and M7, which can be reduced by building some dead-band into their gate waveforms.
?
Simulating with a discrete 1 ohm resistor instead of Rser=1, I have 640 W sourced by V9 and 108 W dissipated by the 1 ohm resistor.? Between the two, that is 532 W supplied by V9+1ohm to the rest of the circuit.? It is not quite the same as the 507 W when Rser was internal, but I don't know why (it should not have differed, right?).? Will check into that later.
?
In any event, with LTspice XVII, the power losses of the circuit are reasonable, and can be reduced further.? If LTspice 24 tells you a different story, that needs to be understood.? If LTspiceXVII says 122 W is lost and LTspice24 says 400 W is lost, that is a big problem.
?
Andy
?


Re: Calculate average value of a waveform under specific conditions using .meas command

 

On Wed, May 7, 2025 at 03:10 AM, Tony Casey wrote:
I don't see why you have to specify small time intervals if your simulation has achieved steady state - each cycle will be essentially the same, so a full display of only 2 cycles will be ample - search by derivative will always find the transition. Don't make things more complicated than they need to be.
That is true, IF Ankit wants to know only the long-term average of the voltage waveform.? But this is for a thesis project, so I assume it is somewhat research related, and he might want to know things to a greater level of detail.? Such as, what is the average voltage over the short time interval when the inductor current is increasing, versus when it is decreasing, or when it is zero.? I don't know the reasons why, but I think it makes sense that he might need to know to that level of detail.
?
Andy
?
?


Re: Calculate average value of a waveform under specific conditions using .meas command

 

I question whether taking the derivatives of the waveform is good or bad.? Since there is ringing, it might manifest itself as large spikes in the derivative, which could mess up those .MEAS calculations.
?
We can just about see the ringing in the uploaded photo (screenplot from LTspice, green waveform).? It is barely there, but depending on the ringing frequency, their di/dt could be quite large.
?
Andy
?
?


Re: Dual Active bridge

 

On Wed, May 7, 2025 at 05:04 AM, John Woodgate wrote:

Without UIC, it runs under version 24.1.8. The input voltage is 100 V, the input current is 8 A DC plus 8A peak roughly sinusoidal (so the current goes from 0 to 16 A). The output voltage is 132 V DC and the output current is 3 A.

Wow!? Which schematic was that?? What makes our simulations so utterly different?
?
I used dd.asc with UIC removed.? The input current from V9 is hardly sinusoidal.? If you had sinusoidal current, then something must be wrong.
?
My simulation's input voltage is 100 V (of course), but the average input current is 6.159 A, not 8 A DC.? Its waveform peaks at around +105 A (that's not a typo!) and at -23 A (yes, power going back into the voltage source).? Those peaks are quite narrow.? It is definitely not "roughly sinuoidal".
?
The RMS current from V9 is 12.6 A, which includes both the DC portion and the AC component which represents instantaneous power going both ways.
?

So I think the input power is quite a lot bigger than the output power, which is not what is wanted.

The important thing is, do the numbers make sense?? Do they add up?
?
In my simulation, they do.? Using Alt-Left-Click on V9, LTspice plots the instantaneous power (V*I) waveform of V9.? Then using Ctrl-Left-Click on the waveform label at the top of the plot, it says the Average Power is -597.32 W.? That is the power dissipated by V9, meaning that V9 sources +597.32 W to the circuit.
?
Doing the same thing with the load (R1), LTspice shows 458.39 W dissipated by the load.
?
The difference is 597-32 - 458.39 = 138.93 W that V9 sources but does not reach the load.? That is not so bad.? It's not ideal, of course, but nothing is perfect.? I think a lot of power is lost due to short-circuit current through the FETs.
?
Doing the same thing to each of the MOSFETs on the right side (M4, M5, M6, M7) shows that each of them dissipates (loses as heat) approx. 32.4 W, adding up to 129.6 W lost in those four FETs.? That compares favorably with the 138.93 W total power that did not make it from V9 into R1.? It shows that the four FETs on the right side caused most of the power loss.? You can improve that.
?

But I have 1 ohm in series with V9 to limit the inrush current.

Ah, of course!? That is what makes your simulation so much different than mine.
?

Without the 1 ohm, it still stalls after a few hundred microseconds, with no error message.

If it stalls, then it is still simulating, right?? If it is still simulating, then there won't be an error message (yet).? It would be great if LTspice always times out after a while, but when should it time out?? Apparently it thinks it is still making positive progress.??From what you wrote earlier, I think LTspice 24 was heading towards a "timestep too small" error, but not reaching it.? That rarely happens.? Usually when it is heading towards a "timestep too small" situation, it positively reaches it, and aborts.? Apparently it saves itself before that happens.? Hmm.
?
LTspice XVII does not stall at any point, with or without Rser-1 ohm.
?
It would be interesting to see why LTspice 24 simulates badly whereas LTspice XVII does not.
?
Andy
?
?


Re: Dual Active bridge

 

Set Lp = 2,3mH Ls=5,1mH Llkg=76uH . Imagn=magnetizing current =8% of primary peak current, Llkg = 3% of Lp (values chosen for 30KHz).
Imagn/Ipeak may be a little bit higher, i.e. 15%
A small gap between the upper and lower Bridge MOS will prevent from cross-conducting current spikes. At present, currents are overlapping.?
Also check the phase angles between the primary and secondary side bridge drive pulses to achieve?output voltage, as desired.
-----
Udo


Re: Dual Active bridge

 

开云体育

Without UIC, it runs under version 24.1.8. The input voltage is 100 V, the input current is 8 A DC plus 8A peak roughly sinusoidal (so the current goes from 0 to 16 A). The output voltage is 132 V DC and the output current is 3 A. So I think the input power is quite a lot bigger than the output power, which is not what is wanted. But I have 1 ohm in series with V9 to limit the inrush current. Without the 1 ohm, it still stalls after a few hundred microseconds, with no error message.

On 2025-05-07 01:18, Andy I via groups.io wrote:
On Tue, May 6, 2025 at 05:33 PM, <arhamishtiaq42@...> wrote:
so do you think my primary side current is fine?
That is a somewhat difficult question for me to answer.? Maybe others can speak to this better than I can.
?
But I think the answer is "yes", I think it is normal.
?
Because the waveforms are not sinusoidal and the voltage and current waveforms are so very different from each other, you can not use Vrms*Irms to estimate power.? You must multiply V(time) by I(time) at every moment in time, then average the product over time.? And when you do that, you find that the power into the primary = 593 W, even though its Vrms * Irms = 95.6 * 12.9 = 1233 VA.
?
(I am still wondering where you got 40 A from.? My simulations did not come close.)
?
I think the only way for the primary current to be around 500 W / 100 V = 5 A, is if the transformer's primary current was also a square wave and in-phase with the voltage there.
?
The energy source (V9) provides 597 W, the transformer passes 593 W, and the load (R1) dissipates 458 W.? These are from simulating your third schematic, dd.asc, without UIC, and waiting until after the initial transients die out.
?
Andy
?
?
--
Best wishes John Woodgate RAYLEIGH Essex OOO-Own Opinions Only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.