0
\$\begingroup\$

I have been using .meas for quite a lot now, but then I want to tabulate the value of each node at the end of each phase. I am trying to simulate a circuit with a square pulse as its CLOCK. This circuit has two phases(phase 1 when CLOCK is HIGH and phase 2 when CLOCK is LOW). I used .step para (figure is attached) for getting different CLK frequency. But then now how can I use .meas to get the value of each node at the end of a phase? the time at which a phase ends is varying with CLK frequency.
The output looks a bit messy, the thing is for each clock frequency we are measuring the output at the end of that CLOCK cycle. Now for each frequency I need to measure the output at time = time period of that frequency(This is varying!!!) enter image description here

PS: I did not add the circuit since I did not what to increase complexity, I guess the answer is independent of the circuit enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ What do you mean with "at the end of a phase"? Can you show a plot of this source with an annotation or some arrows, something, that will show where exactly, in time, you need the measurement? \$\endgroup\$ Sep 8, 2021 at 14:20
  • \$\begingroup\$ By phase I meant : when clock is high and when clock is low. Its a square pulse. But then the clock's time period is varying. So how can I write a .meas function for this scenario ? @aconcernedcitizen \$\endgroup\$ Sep 8, 2021 at 16:34

1 Answer 1

2
\$\begingroup\$

One way to do it would be this:

test

The PULSE() source is set up to have its period and all the rest of the timings dependent on a .param that is .stepped. First, a temporal helper is measured and stored as the variable T, denoting the time when the measurement needs to happen; in this case it accounts for the initial delay, the rising time, and the ON time. Then the actual measurement happens and the error log displays the values under the v(out) column. Is this what you wanted?


I'm re-reading and it looks like you need to measure the frequency, or at least the time when the period is off, which means you can't use a .step to change the frequency? If so then modify the .meas scripts to first detect the period (trise1, trise2), the falling edge (tfall), and then measure V(out) at the end of tfall:

.meas trise1 when v(out)=0.5 rise=1
.meas tfall when v(out)=0.5 fall=1
.meas trise2 when v(out)=0.5 rise=2
.meas T param trise2-trise1
.meas x find v(out) at tfall-10m*T

For the above test circuit, the error log will output this:

Measurement: trise1
  step  v(out)=0.5
     1  0.000130963
     2  6.54814e-005
     3  4.36542e-005

Measurement: tfall
  step  v(out)=0.5
     1  0.00040691
     2  0.000203455
     3  0.000135637

Measurement: trise2
  step  v(out)=0.5
     1  0.00113096
     2  0.000565481
     3  0.000376988

Measurement: t
  step  trise2-trise1
     1  0.001
     2  0.0005
     3  0.000333333

Measurement: x
  step  v(out)  at
     1  1.618   0.00039691
     2  1.618   0.000198455
     3  1.618   0.000132303

A few things to note: that tfall-10m*T is an attempt to have the measurement on the ON value, since tfall is measured when V(out)=0.5. And it might see that trise1, trise2 are not needed since all you need is tfall, but think of the case when you are measuring both rising times further away into the simulation, i.e. with rise=100, or so (e.g. to reach steady-state). This would mean that tfall will also use fall=100, and then the period would be smaller than the measured tfall, so then tfall-10m*T might fail. Not lastly, don't try to use tf instead of tfall because it will silently fail (that line will be skipped). I don't know why this happens. Also, the "by-the-book" syntax should be .meas x find y when z ..., so what you see, .meas x when z ... is a shortcut that means .meas x find time when z ... (time is implicitly used).

The condition for measurement doesn't have to be rise=... or fall=..., the keyword WHEN works for other signals in the circuit, too. Since you say you have two phases, you might want to measure one based on the other, so something like this can be used:

.meas t1 find v(phase1) when v(phase2)=0.5 ...
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.