Spice3f5

Measurements with .meas

Rise time, delay, averages and the -3dB frequency of RC circuits.

Every kind of .meas measurement on two RC low pass circuits: rise time and delay (TRIG/TARG), values at a time (FIND), crossings (WHEN), slope (DERIV), averages and RMS values, a measurement of other measurements (PARAM), and the -3dB frequency of an ac response. The comments give the expected values.

0200m400m600m800m1020µ40µ60µ80µ100µtime (s)v(1)v(2)
Transient response
  • v(1)
  • v(2)
-30-20-1001101001k10kfrequency (Hz)vdb(11)
AC response of the second circuit (dB)
  • vdb(11)

Output

f3db: vdb(11)=-3.0103 AT 159.155
atf3db: v(11)=(-3.0103dB,-44.9977deg) AT 159.155
risetime=2.19669e-06 FROM 1.10594e-06 TO 3.30263e-06
delay=6.9318e-07 FROM 1.0005e-06 TO 1.69368e-06
v2: v(2)=0.631995 AT 2e-06
tfall: v(2)=0.5 AT 5.16947e-05
slope: d(v(2))/d(time)=368218 AT 2e-06
vavg: AVG(v(1))=0.50001 FROM 0 TO 0.0001
vrms: RMS(v(1))=0.707111 FROM 0 TO 0.0001
vpp: PP(v(2))=1 FROM 0 TO 0.0001
ratio: risetime/delay=3.16901
risetime = 2.196693e-06
delay = 6.931798e-07
ratio = 3.169009e+00
f3db = 1.591550e+02

The circuit: examples/meas_demo.cir

meas_demo.cir - .meas on an RC low pass: tau = 1us, corner 159Hz

* Transient: a 1V pulse into r1/c1 (tau = 1us)
vin 1 0 pulse(0 1 1u 1n 1n 50u 100u)
r1 1 2 1k
c1 2 0 1n

* AC: r2/c2 (corner 1/(2*pi*1k*1u) = 159.15Hz)
va 10 0 dc 0 ac 1
r2 10 11 1k
c2 11 0 1u

.tran 0.05u 100u
.ac dec 100 1 10k

* Rise time 10%-90%: tau*ln(9) = 2.197us
.meas tran risetime TRIG v(2) VAL=0.1 RISE=1 TARG v(2) VAL=0.9 RISE=1
* 50% delay, input to output: tau*ln(2) = 0.693us
.meas tran delay TRIG v(1)=0.5 RISE=1 TARG v(2)=0.5 RISE=1
* Output 1us after the edge: 1-exp(-1) = 0.632
.meas tran v2 FIND v(2) AT=2u
* When the output falls through 0.5
.meas tran tfall WHEN v(2)=0.5 FALL=1
* Slope 1us after the edge: exp(-1)/tau = 3.68e5 V/s
.meas tran slope DERIV v(2) AT 2u
* Averages over one period of the 50% duty input: 0.5, 0.707
.meas tran vavg AVG v(1) FROM 0 TO 100u
.meas tran vrms RMS v(1) FROM 0 TO 100u
.meas tran vpp PP v(2)
* Measurements of measurements: ln(9)/ln(2) = 3.17
.meas tran ratio PARAM risetime/delay

* -3dB point, and the response there: (-3.01dB,-45deg)
.meas ac f3db WHEN vdb(11)=-3.0103
.meas ac atf3db FIND v(11) AT f3db

.control
run
* The results are vectors in each plot
setplot tran1
print risetime delay ratio
setplot ac1
print f3db
.endc
.end

Run it with spice meas_demo.cir, or open it with File › Load netlist in the Qt window. The plots and output above were made by util/mkexamples.py, which runs the deck in batch mode. All examples