How to measure duty

Hello,

I’m creating a converter circuit in Qspice and would like to obtain the duty ratio (Duty) from the waveform.

Since there doesn’t seem to be a direct way to measure the Duty, I tried to get the on-time instead using the following command, but it didn’t return the on-time shown in the waveform.

I used “last” because I want to know the Duty after the circuit reaches steady state.

Could you please tell me the correct command to use?

meas ton trig V(xx)=0.9 rise=last targ V(xx)=0.9 fall=last

I have a direct PWM waveform measurement symbol. The symbol can be download from my Symbol library in following path.

Symbols-KSKelvin (Github) : / probes and measure / Measure-PWM.qsym

This is a demo schematic.
example.Measure-PWM.qsch (7.8 KB)

2 Likes

Thank you very much.

I was able to make it work, but the correct waveform didn’t appear when the cshunt option was enabled.

Is it possible to look inside the model?

Is it implemented as a block in the analog circuit?

I don’t encrypt my work; you can always view how I implement my subcircuit in the netlist. To do so, go to View > Netlist, and you can study how it is implemented.
Well, I didn’t think about having “cshunt”…, PWM measurement highly depends on circuit timing, and “cshunt” will mess things up!

1 Like

Well, actually, the best approach is always to use a C++ block for this type of processing.
I have uploaded a pulse analyzer that can provide you with frequency, duty cycle, and pulse count. This is definitely better than using a subcircuit with native devices and should be more reliable.

Symbols-KSKelvin (Github) :
/ KSKelvinDLL / PulseAnalyzerKSK.qsym
/ KSKelvinDLL / pulseanalyzerksk.cpp

2 Likes

In addition, if you prefer .meas, I have this page in my command guideline as your reference.

.meas - (.tran) Pulse Period OnTime Freq Duty.qsch (2.1 KB)

1 Like

Thank you for your useful tips.
I continue learning about Qspice.

I updated the method in Measure-PWM.qsym and it will work with cshunt included.

1 Like