Electronic – How to get FROM and TO times of trig on measure statement of LTSPICE

circuit-designltspicemeasurementpower electronicsspice

I need to measure the voltage on two signals which have a difference of phase, so in order to do the measure that I need I have to get V1 (t) and V2 (t + delay_between_signals). One way to that is by finding when the reference value occurs and finding the second by adding the time of occurrence + delay_between_signals.

To acquire the time when the reference value occurs I use:

.meas tran tving trig V (vin) = 0 rise = 1 targ V (vin) = 1.5 rise = 1

But it gives me only the time between 0V and 1.5V. I know that is the result that the command is supposed to give, but on the error log it shows the time where the measure starts from and the time where measure ends. Is there a way to get these values?

Or even better, is there a way to get the time (and use it a variable, of course) where the measure occurs on the .measure spice directive?

As requested, here is the original circuit, the graph and the directives used:
The circuit
The waveform
The directives

It is hard to see but there is a difference of phase between the V(vout) and V(vin) waves. Since I want to measure the gain, V(vout) must measured not in the same time as V(vin), but in t + delay_between_signals.

Best Answer

If you need to measure the Y-axis at a specific time point then, for your case, you would use this:

.meas tving find V(vin) at <time_value>

Similarly fot the delayed voltage. Don't forget that the measurement is directly related to the resolution of the data points. By default, it's 300 points, which can give inaccurate readings. To disable waveform compression, use .opt plotwinsize=0. Often times it is enough compared to reducing the timestep.

If, OTOH, you need to calculate the delay between the two, you would use:

.meas a find time when V(x)=0 rise=1
.meas b find time when V(y)=0 rise=1
.meas delay param b-a