Transient and the RC time constant
Run a transient analysis of an RC circuit, read the time constant off the curve, and work out when a following gate actually switches.
- Lesson
- E1.3
- Time
- 25 min
- Runs on
- ngspice
- Check
- 5 questions
A power-on reset holds a chip in reset while its supply and clocks come up. One design charged a 10 nF capacitor through 100 kΩ, so R·C = 1 ms, chosen "so reset lasts 1 ms". The buffer after it switched at half the 1.8 V supply, so reset ended after 0.69 ms, before a slow oscillator had started.
- v(vdd)
- v(por)
- Time 693.6 µsv(vdd) = 1.8 V · v(por) = 900 mV
v(por) crosses 0.9 V at 0.694 ms. The buffer flips and the chip leaves reset, 0.31 ms early.
- Time 1 msv(vdd) = 1.8 V · v(por) = 1.137 V
At 1 ms, where the design expected reset to end, v(por) is already 1.137 V, well past the threshold.
Read the plot as a table
| Time | v(vdd) | v(por) |
|---|---|---|
| 0 s | 0 V | 0 V |
| 500 µs | 1.8 V | 707.7 mV |
| 693.6 µs | 1.8 V | 900 mV |
| 1 ms | 1.8 V | 1.137 V |
| 1.5 ms | 1.8 V | 1.398 V |
| 2 ms | 1.8 V | 1.556 V |
| 2.5 ms | 1.8 V | 1.652 V |
| 3 ms | 1.8 V | 1.71 V |
Measured on ngspice 42 (500 of the run's 3014 time points).
R·C says how fast a capacitor charges; the threshold of the next gate says when anything happens.
The curve a capacitor follows
- The step arrives
At t = 0 the source jumps to 1 V. The capacitor holds 0 V, so all of the 1 V sits across R1 and 1 mA flows into C1.
i = 1 mA
- The charge slows down
Each bit of charge raises vout, which leaves less voltage across R1 and so less current. At one time constant the current has fallen to 0.37 mA.
i = 0.37 mA
- Settled
After about five time constants vout is within 1 % of 1 V and the current is almost zero. The capacitor now acts as an open circuit.
Read the circuit as text
- V1 voltage source (step 0 → 1 V): + →
in, − →0 - R1 resistor (1 kΩ): pin 1 →
in, pin 2 →n1 - C1 capacitor (1 nF): pin 1 →
n1, pin 2 →0 - out port: terminal →
n1
Node 0 is ground. The source, R1 and C1 are the netlist lines of the lab below.
A capacitor stores charge, and its current is i = C·dv/dt, so a fast change of voltage needs a large current. A resistor in series limits that current, so the capacitor voltage cannot jump; it moves along a curve.
Watch the curve first: the plot below is the transient run of the lab netlist, where the input steps from 0 to 1 V and vout follows. The lower panel is the current of the source, i(v1). Step through it and read the values at each stop.
That current is negative. SPICE counts a voltage source's current as positive when it flows into the + terminal, so a source that delivers charge reads below zero. The schematic shows the real direction: 1 mA out of the + terminal, which SPICE prints as −1 mA.
- v(in)
- v(out)
- i(v1)
- Time 1 nsv(in) = 1 V · v(out) = 499.9 µV · i(v1) = -999.5 µA
The input reaches 1 V after its 1 ns edge. vout is still almost 0 V: the capacitor has no charge yet. All of the 1 V is across R1, so 1 mA flows and
i(v1)reads −1 mA. - Time 693.7 nsv(in) = 1 V · v(out) = 500 mV · i(v1) = -500 µA
vout crosses 0.5 V at 693.7 ns. That is ln 2 · τ = 0.693 τ, plus half of the 1 ns edge. Half the step is left across R1, so the current is half too: −0.5 mA.
More context
A gate that switches at half the supply switches here, well before one time constant.
- Time 1 µsv(in) = 1 V · v(out) = 631.9 mV · i(v1) = -368.1 µA
One time constant: vout = 631.9 mV. The formula gives 1 − e−1 = 632.1 mV; the edge started the charge 0.5 ns late. The current has fallen to e−1 of its start, −0.37 mA.
- Time 2.303 µsv(in) = 1 V · v(out) = 900 mV · i(v1) = -100 µA
vout reaches 90 % at 2.303 µs, which is ln 10 · τ. The current is down to a tenth: −0.1 mA.
- Time 5 µsv(in) = 1 V · v(out) = 993.3 mV · i(v1) = -6.741 µA
Five time constants: vout = 993.3 mV, within 0.7 % of its final value. The current is almost zero (−6.7 µA).
Read the plot as a table
| Time | v(in) | v(out) | i(v1) |
|---|---|---|---|
| 0 s | 0 V | 0 V | 0 A |
| 1 ns | 1 V | 499.9 µV | -999.5 µA |
| 693.7 ns | 1 V | 500 mV | -500 µA |
| 1 µs | 1 V | 631.9 mV | -368.1 µA |
| 2 µs | 1 V | 864.6 mV | -135.4 µA |
| 2.303 µs | 1 V | 900 mV | -100 µA |
| 4 µs | 1 V | 981.7 mV | -18.33 µA |
| 5 µs | 1 V | 993.3 mV | -6.741 µA |
| 6 µs | 1 V | 997.5 mV | -2.48 µA |
| 8 µs | 1 V | 999.7 mV | -335.6 nA |
| 10 µs | 1 V | 1 V | -45.42 nA |
Every point is from a run of the lab netlist on ngspice 42 (500 of its 1016 time points).
Now give it a name. Charged through a resistor from a step of V, the capacitor follows v(t) = V·(1 − e−t/τ). The time constant τ = R1C1 sets the scale of the time axis, and here τ = 1 kΩ × 1 nF = 1 µs. Double either part and every time on the plot doubles with it.
Milestones in time constants
Solve v(t) = V·(1 − e−t/τ) for the time at which the output reaches a fraction f of the step: t = τ · ln(1/(1 − f)). Five fractions come up again and again.
| Fraction of the step | Time | Formula | Measured on the lab |
|---|---|---|---|
| 50 % | 0.693 τ | ln 2 · τ | t50 = 6.936531e-07 |
| 63.2 % | 1 τ | 1 − e−1 = 0.632 | v_tau = 6.319360e-01 |
| 10 % to 90 % | 2.197 τ | ln 9 · τ | t10_90 = 2.197212e-06 |
| 99 % (settled within 1 %) | 4.605 τ | ln 100 · τ | t99 = 4.605639e-06 |
| 99.3 % | 5 τ | 1 − e−5 = 0.9933 | v_5tau = 9.932589e-01 |
τ = 1 µs. The measured times and values include half of the 1 ns input edge.
The 63.2 % point defines τ, but no gate cares about 63.2 %. A gate switches at its switching threshold VM: the input voltage at which its output flips. For a CMOS buffer VM is often about half the supply. The time to reach it is t = τ · ln(V/(V − VM)), which is 0.693 τ at half the supply.
So the reset of the hook ended at 0.69 ms, with τ = 100 kΩ × 10 nF = 1 ms. To hold reset for 1 ms, size the RC for the threshold instead: τ = 1 ms / ln 2 = 1.44 ms.
Sized for τ = 1 ms
VDD vdd 0 PULSE(0 1.8 0 1u 1u 1 2)
R1 vdd por 100k
C1 por 0 10n
.control
tran 1u 5m
meas tran t_reset WHEN v(por)=0.9 RISE=1
.endc
t_reset = 6.936472e-04: the buffer leaves reset after 0.69 ms.
Sized for the 0.9 V threshold
VDD vdd 0 PULSE(0 1.8 0 1u 1u 1 2)
R1 vdd por 144.27k
C1 por 0 10n
.control
tran 1u 5m
meas tran t_reset WHEN v(por)=0.9 RISE=1
.endc
t_reset = 1.000503e-03: τ = 1.44 ms puts the half-supply crossing at 1 ms.
Both measured on ngspice 42. The extra 0.5 µs is half of the supply's 1 µs ramp.
How a transient run steps through time
A transient analysis integrates the circuit through time, and you start one with tran tstep tstop. The solver picks its own internal steps: short ones where voltages change fast, long ones where they settle. tstep is the print interval, and by default it also caps the step. The cap is the smaller of tstep and (tstop − tstart)/50, unless you give a fourth number, tmax.
Before the first step, the solver finds the operating point: the DC state with every source at its time-zero value and every capacitor open. The lab's pulse starts at 0 V, so the capacitor starts empty. The keyword uic (use initial conditions) skips that solve. The run then starts from .ic values, or from 0 V on every node.
PULSE(v1 v2 delay rise fall width period)
A trapezoid that repeats every period. The lab uses 0 to 1 V, no delay, 1 ns edges, 20 µs high, 40 µs period.
SIN(offset amplitude freq)
A sine wave around an offset, for E1.6 and the amplifiers later.
PWL(t1 v1 t2 v2 ...)
Straight lines between listed points: a supply ramp, a glitch, any shape you can tabulate.
An edge never has zero rise time. If you write 0 for the rise of a PULSE, ngspice uses tstep instead. With tran 10n 10u that is a 10 ns edge, so the 50 % crossing moves from 693.7 ns to 698.2 ns. With tran 1n 10u it comes back to 693.6 ns.
Asked in interviews
What is an RC time constant?
τ = RC, the time an RC takes to reach 63.2 % of a step, or 1 − 1/e. Every time on the charging curve scales with it: double R or C and every time doubles.
How long does an RC take to reach half the supply?
ln 2 · τ, about 0.69 τ. A gate that switches at half the supply therefore switches well before one time constant. Size a delay for the switching threshold VM: t = τ·ln(V/(V − VM)).
How many time constants to settle within 1 %?
ln 100 ≈ 4.6 τ for 1 %. Five τ gives 99.3 %, seven τ gives 99.9 %. Settling to the resolution of an ADC takes more: about (N + 1)·ln 2 · τ for half an LSB of N bits.
What does uic do in a SPICE transient?
It skips the operating-point solve. Capacitors and nodes start from .ic values or IC= on the element, or from 0 V. Without uic, the run starts from the DC solution, so a capacitor on a DC source starts fully charged.
Try it
Run the netlist and read the five meas lines, then open Plots to see the same curve as the figure. FIND ... AT reads a value at a time, WHEN finds the time a value is crossed, and TRIG ... TARG measures the time between two crossings.
Now change C1 out 0 1n to 2n and predict every number before you run. τ doubles to 2 µs, so t50 should double and v_tau should drop to the value at τ/2. Then set the pulse rise to 0 and see t50 move by about half of tstep.
Run the netlist to draw its plots here.
v_tau = 6.319360e-01 t50 = 6.936531e-07 t10_90 = 2.197212e-06 targ= 2.303078e-06 trig= 1.058659e-07 v_5tau = 9.932589e-01 t99 = 4.605639e-06Check yourself
Remember
- A capacitor charged through a resistor follows v(t) = V·(1 − e−t/τ), with τ = RC; every time on the curve scales with τ.
- The output reaches 50 % at 0.693 τ, 63.2 % at τ, 90 % at 2.303 τ and 99.3 % at 5 τ; settling within 1 % takes 4.6 τ.
- A following gate switches at its switching threshold VM, at t = τ · ln(V/(V − VM)); size a delay for that threshold, not for τ.
tran tstep tstopstarts from the operating point unlessuicis given; a PULSE edge written as 0 becomeststeplong.