Skip to content

Commit fe10cdf

Browse files
Enhance Laplace Transform Basics documentation with detailed examples and applications
1 parent 1e735b9 commit fe10cdf

1 file changed

Lines changed: 246 additions & 18 deletions

File tree

src/docs/articles/laplace-basics.md

Lines changed: 246 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,57 @@ The transfer function describes how a linear block changes a signal. It can say
1212

1313
If you want the exact syntax supported by SpiceSharpParser, see [LAPLACE Transfer Sources](laplace.md). This page focuses on the intuition.
1414

15+
## Running Example: Sensor To ADC
16+
17+
Imagine a sensor connected to an ADC input:
18+
19+
```text
20+
sensor voltage -> amplifier and filter -> ADC input
21+
```
22+
23+
The real circuit might include an op-amp, resistors, capacitors, sensor capacitance, board parasitics, and an ADC input network. Early in a design, you may not want every detail. You may only need answers like:
24+
25+
| Question | Why it matters |
26+
|----------|----------------|
27+
| What is the low-frequency gain? | The ADC code must match the sensor value. |
28+
| Where does high-frequency noise get reduced? | Noise above the useful signal band should not dominate the ADC input. |
29+
| How fast does the ADC input settle? | The ADC should sample after the signal has settled enough. |
30+
| Does the front end ring or overshoot? | Overshoot can create false readings or clipping. |
31+
| How much phase shift is added? | Phase matters in control loops and sampled systems. |
32+
33+
A simple first model might be:
34+
35+
```text
36+
H(s) = gain * wc / (s + wc)
37+
```
38+
39+
For example, use `gain = 2` and `fc = 10 kHz`, where `wc = 2*pi*fc`.
40+
41+
That one expression says:
42+
43+
- At DC and low frequency, the ADC input is about twice the sensor voltage.
44+
- Around `10 kHz`, the gain starts rolling off.
45+
- High-frequency noise is reduced.
46+
- In the time domain, sudden changes become smoother and slower.
47+
48+
This is the main trick: the same transfer function explains the frequency response and the time response of the same linear block.
49+
50+
## What You Can Use This For
51+
52+
Laplace-domain transfer functions are useful when you know the behavior you want, but do not need a detailed component-level model yet.
53+
54+
| Application | What the transfer function captures |
55+
|-------------|-------------------------------------|
56+
| ADC anti-alias or input filtering | Pass the signal band, reduce high-frequency noise. |
57+
| Sensor front-end bandwidth | Model a sensor or conditioning circuit that cannot respond instantly. |
58+
| Amplifier bandwidth | Keep the desired gain at low frequency, then roll off at high frequency. |
59+
| AC coupling | Block DC while passing changing signals. |
60+
| Control-loop blocks | Model plant, compensator, lead, lag, or finite bandwidth terms. |
61+
| LC or mechanical resonance | Model peaking, ringing, and damping. |
62+
| Phase shaping | Add phase lead or lag without building the full circuit yet. |
63+
64+
Use this style for linear, small-signal behavior. If the important behavior is clipping, saturation, slew rate, switching, startup sequencing, or device physics, use a more detailed circuit or behavioral model instead.
65+
1566
## Time Domain And Frequency Domain
1667

1768
The time domain is the waveform you would see on an oscilloscope:
@@ -20,29 +71,71 @@ The time domain is the waveform you would see on an oscilloscope:
2071
voltage versus time
2172
```
2273

23-
It answers questions like:
74+
In SPICE, transient analysis (`.TRAN`) is the usual time-domain view. It answers questions like:
75+
76+
| Time-domain question | Example in the sensor-to-ADC story |
77+
|----------------------|-------------------------------------|
78+
| How fast does the output rise? | The sensor voltage steps and the ADC input follows with a rounded edge. |
79+
| How long does it take to settle? | The ADC input must be close enough before sampling. |
80+
| Does it overshoot? | A resonant input network may go above the final value. |
81+
| Does it ring? | A lightly damped system may oscillate before settling. |
82+
| Is the signal smoothed? | A low-pass filter removes fast changes and noise. |
2483

25-
| Question | Example |
26-
|----------|---------|
27-
| How fast does the output rise? | Step response |
28-
| Does it overshoot? | Damped resonance |
29-
| Does it settle? | Filter or control loop response |
84+
A low-pass transfer function makes sharp changes slower. That is not a bug. It is the time-domain price paid for reducing high-frequency content.
85+
86+
A second-order transfer function can ring. In the frequency domain that same behavior appears as a gain bump near the natural frequency.
3087

3188
The frequency domain is the same circuit viewed by sine waves at different frequencies:
3289

3390
```text
3491
gain and phase versus frequency
3592
```
3693

37-
It answers questions like:
94+
In SPICE, AC analysis (`.AC`) is the usual frequency-domain view. It answers questions like:
95+
96+
| Frequency-domain question | Example in the sensor-to-ADC story |
97+
|---------------------------|-------------------------------------|
98+
| Which frequencies pass through? | Low-frequency sensor changes pass to the ADC. |
99+
| Which frequencies are reduced? | High-frequency noise is attenuated. |
100+
| What is the bandwidth? | The useful flat region ends near the cutoff frequency. |
101+
| How much phase shift is added? | The ADC input lags the sensor signal near the cutoff. |
102+
| Is there resonance? | A gain peak warns that the time response may overshoot or ring. |
103+
104+
These two views are not separate realities. They are two ways to inspect the same linear system.
105+
106+
## Three SPICE Views
107+
108+
The same `H(s)` is interpreted differently by different analyses.
109+
110+
| SPICE view | What it asks | How to think about `s` |
111+
|------------|--------------|-------------------------|
112+
| `.OP` | What is the DC operating point? | Set `s = 0`. |
113+
| `.AC` | What is gain and phase versus frequency? | Set `s = j*omega`. |
114+
| `.TRAN` | What waveform happens over time? | The simulator uses the equivalent dynamic behavior. |
115+
116+
For the sensor-to-ADC low-pass:
117+
118+
```text
119+
H(s) = gain * wc / (s + wc)
120+
```
121+
122+
In `.OP`, set `s = 0`:
123+
124+
```text
125+
H(0) = gain * wc / wc = gain
126+
```
127+
128+
So the DC sensor value is multiplied by `gain`.
129+
130+
In `.AC`, the simulator evaluates:
131+
132+
```text
133+
H(j*omega)
134+
```
38135

39-
| Question | Example |
40-
|----------|---------|
41-
| Which frequencies pass through? | Low-pass filter |
42-
| Which frequencies are blocked? | High-pass coupling |
43-
| How much delay or phase shift is added? | Op-amp bandwidth |
136+
At low frequency, `omega` is small and the gain is close to `gain`. At high frequency, `omega` is large and the gain gets smaller.
44137

45-
SPICE `.AC` analysis is frequency-domain analysis. It tries many frequencies and reports the output magnitude and phase.
138+
In `.TRAN`, a sudden input step does not appear instantly at the output. The output moves toward the final value with a rounded response.
46139

47140
## What `s` Means
48141

@@ -52,7 +145,7 @@ A Laplace transfer function is written with a variable named `s`:
52145
H(s)
53146
```
54147

55-
Think of `s` as a placeholder that lets one expression describe both DC and AC behavior.
148+
Think of `s` as a special placeholder for dynamic behavior. It is not a node, not a parameter you define with `.PARAM`, and not a voltage.
56149

57150
For operating point analysis:
58151

@@ -72,6 +165,44 @@ omega = 2 * pi * f
72165
- The magnitude of `H(j*omega)` is the gain at that frequency.
73166
- The angle of `H(j*omega)` is the phase shift at that frequency.
74167

168+
## Units Sanity Check
169+
170+
Units make Laplace formulas feel less arbitrary.
171+
172+
| Symbol | Unit | Meaning |
173+
|--------|------|---------|
174+
| `f` | Hz | Cycles per second. |
175+
| `omega`, `w`, `wc`, `wp`, `wz`, `wn` | rad/s | Angular frequency. |
176+
| `tau` | seconds | Time constant. |
177+
| `s` | 1/seconds | Laplace variable. |
178+
| `gain` | usually unitless | Voltage gain for an `E` source. |
179+
| `gm` | siemens | Transconductance for a `G` source. |
180+
181+
The terms added together in a transfer function must have compatible units.
182+
183+
In this low-pass:
184+
185+
```text
186+
H(s) = 1 / (1 + s*tau)
187+
```
188+
189+
`s` has units of `1/seconds`, and `tau` has units of `seconds`, so `s*tau` is unitless. That is why it can be added to `1`.
190+
191+
In this equivalent low-pass:
192+
193+
```text
194+
H(s) = wc / (s + wc)
195+
```
196+
197+
`s` and `wc` both have units of `1/seconds`, so they can be added. The ratio is unitless.
198+
199+
To move between hertz and angular frequency:
200+
201+
```text
202+
omega = 2 * pi * f
203+
f = omega / (2 * pi)
204+
```
205+
75206
## Gain And Phase
76207

77208
Gain says how much bigger or smaller the output is than the input.
@@ -100,6 +231,30 @@ Phase says how much the output sine wave is shifted relative to the input sine w
100231

101232
For many first-order filters, the phase shift is most noticeable around the cutoff frequency.
102233

234+
In the sensor-to-ADC example, phase lag means the ADC input sine wave reaches its peak later than the sensor sine wave. This can matter a lot in feedback systems and sampled control loops.
235+
236+
## Bode Plot Intuition
237+
238+
A Bode plot is just a frequency-domain plot:
239+
240+
- Magnitude tells you gain versus frequency.
241+
- Phase tells you shift versus frequency.
242+
243+
You can understand the common shapes without drawing the plot.
244+
245+
| Shape | What it means |
246+
|-------|---------------|
247+
| Flat magnitude | The block behaves almost like a simple gain. |
248+
| Magnitude rolls down | High frequencies are being reduced. |
249+
| Magnitude rises | Low frequencies are blocked or a zero is adding gain. |
250+
| Phase moves negative | The output lags the input. |
251+
| Phase moves positive | The output leads the input. |
252+
| Magnitude has a bump | The system may overshoot or ring in time. |
253+
254+
For a low-pass filter, the magnitude is flat at low frequency and slopes down after the cutoff. The phase starts changing before the cutoff, is most active near the cutoff, and then approaches its high-frequency limit.
255+
256+
For a resonant system, the magnitude may show a bump. In time-domain language, that bump is the same energy storage behavior that can create overshoot and ringing.
257+
103258
## Time Constants And Cutoff Frequency
104259

105260
A first-order RC low-pass has this transfer function:
@@ -128,9 +283,11 @@ At the cutoff frequency:
128283

129284
The time-domain meaning of `tau` is also useful: after one time constant, a first-order step response has moved about 63 percent of the way toward its final value.
130285

286+
Smaller `tau` means faster response and higher cutoff frequency. Larger `tau` means slower response and lower cutoff frequency.
287+
131288
## Poles And Zeros
132289

133-
Poles and zeros are the frequencies where a transfer function changes behavior.
290+
Poles and zeros are places where a transfer function changes behavior.
134291

135292
A pole usually makes gain start falling and phase start lagging:
136293

@@ -163,9 +320,10 @@ Use this quick checklist:
163320

164321
1. Set `s = 0` to find the DC gain.
165322
2. Look for terms like `s + wc` or `1 + s*tau`; these are poles.
166-
3. Look for `s` in the numerator; that often means DC is blocked.
167-
4. Compare the numerator degree with the denominator degree; in SpiceSharpParser, the numerator degree must not be greater.
168-
5. Convert `wc` to hertz with `fc = wc/(2*pi)`.
323+
3. Look for `s` in the numerator; that often means DC is blocked or phase lead is added.
324+
4. Look for a frequency such as `wc`, `wp`, `wz`, or `wn`; that is where behavior changes.
325+
5. Compare the numerator degree with the denominator degree; in SpiceSharpParser, the numerator degree must not be greater.
326+
6. Convert angular frequency to hertz with `fc = wc/(2*pi)`.
169327

170328
Examples:
171329

@@ -177,6 +335,35 @@ Examples:
177335
| `10*wc/(s+wc)` | Gain of 10 with one-pole bandwidth |
178336
| `(1+s/wz)/(1+s/wp)` | Lead or lag block, depending on pole/zero placement |
179337

338+
## Choose Your Transfer Function
339+
340+
Start with the behavior you need, then choose a simple transfer function.
341+
342+
| Goal | Try this transfer | Time-domain intuition | Frequency-domain intuition |
343+
|------|-------------------|-----------------------|----------------------------|
344+
| Smooth noise or limit bandwidth | `wc/(s+wc)` | Edges become rounded. | Flat, then rolls off. |
345+
| Add gain and bandwidth limit | `gain*wp/(s+wp)` | Output follows with finite speed. | Gain is `gain` at low frequency, then rolls off. |
346+
| Block DC | `s/(s+wc)` | A step causes a temporary response that returns toward zero. | Low frequencies are reduced, high frequencies pass. |
347+
| Model peaking or ringing | `wn*wn/(s*s + 2*zeta*wn*s + wn*wn)` | May overshoot or ring before settling. | May show a bump near `fn`. |
348+
| Shape phase in a loop | `(1+s/wz)/(1+s/wp)` | Can improve or slow loop response. | Adds lead or lag between zero and pole. |
349+
350+
For the running sensor-to-ADC example, the first or second row is usually the starting point.
351+
352+
## What Changes As Frequency Increases?
353+
354+
This table is a quick way to read common blocks.
355+
356+
| Block | Low frequency | Near cutoff or natural frequency | High frequency |
357+
|-------|---------------|----------------------------------|----------------|
358+
| Low-pass | Passes signal with normal gain. | Gain drops and phase lags. | Signal is reduced. |
359+
| High-pass | DC and slow changes are reduced. | Gain rises and phase changes. | Signal passes. |
360+
| Finite-bandwidth amplifier | Acts like a normal gain block. | Gain starts falling. | Amplifier cannot keep up. |
361+
| Damped resonance | Often near normal gain. | May peak and shift phase quickly. | Usually rolls off. |
362+
| Lead block | Starts at lower gain. | Adds positive phase over a band. | Ends at higher gain. |
363+
| Lag block | Starts at higher gain. | Adds negative phase over a band. | Ends at lower gain. |
364+
365+
When you see a strong frequency-domain change, expect a related time-domain effect. Rolloff means smoothing and slower edges. Peaking means possible overshoot. Heavy phase shift means delay-like behavior for sine waves.
366+
180367
## Common Physical Blocks
181368

182369
### RC Low-Pass
@@ -189,6 +376,8 @@ H(s) = 1 / (1 + s*R*C)
189376

190377
Use it for simple bandwidth limits, anti-alias filters, smoothing, and sensor front ends.
191378

379+
In the time domain, it slows edges and smooths noise. In the frequency domain, it passes low frequencies and reduces high frequencies.
380+
192381
### AC Coupling High-Pass
193382

194383
A series capacitor with a resistor to ground blocks DC:
@@ -199,6 +388,8 @@ H(s) = s / (s + wc)
199388

200389
Use it when you want changes or AC content, but not the DC level.
201390

391+
In the time domain, a step appears as a temporary pulse-like response. In the frequency domain, low frequencies are reduced and high frequencies pass.
392+
202393
### Finite Op-Amp Bandwidth
203394

204395
An ideal gain block has the same gain forever, but a real amplifier loses gain at high frequency. A simple closed-loop approximation is:
@@ -233,6 +424,17 @@ where:
233424

234425
Smaller `zeta` gives more peaking and ringing. Larger `zeta` gives a flatter, more damped response.
235426

427+
## Common Misconceptions
428+
429+
| Misconception | Better way to think about it |
430+
|---------------|------------------------------|
431+
| `s` is a normal variable I can set with `.PARAM`. | `s` is reserved for Laplace behavior inside the transfer expression. |
432+
| `.AC 1` means the input is always 1 V in every simulation. | `AC 1` sets the small-signal AC magnitude; it is mainly a convenient way to read gain directly. |
433+
| A Laplace source is a perfect replacement for a real op-amp. | It is a linear approximation of selected behavior, such as gain and bandwidth. |
434+
| A good `.AC` plot guarantees every transient behavior is good. | Nonlinear effects, clipping, slew rate, and startup behavior may still matter. |
435+
| Higher cutoff is always better. | Higher cutoff is faster, but it also lets more high-frequency noise through. |
436+
| More poles and zeros always make a better model. | Use the simplest model that answers the design question. |
437+
236438
## Good Uses Of LAPLACE Sources
237439

238440
`LAPLACE` sources are best for linear, small-signal behavior:
@@ -254,6 +456,32 @@ They are not a good fit for behavior that is strongly nonlinear:
254456

255457
For those, use detailed circuit models, behavioral expressions, or device models that directly represent the nonlinear behavior.
256458

459+
## Small Exercises
460+
461+
These are quick checks for reading transfer functions.
462+
463+
| Question | Answer |
464+
|----------|--------|
465+
| What is the DC gain of `10*wc/(s+wc)`? | Set `s = 0`, so the gain is `10`. |
466+
| Does `s/(s+wc)` pass DC? | No. At `s = 0`, the numerator is `0`. |
467+
| If `fc` increases in `wc/(s+wc)`, does the block get faster or slower? | Faster. Higher cutoff means shorter time constant. |
468+
| What does `AC 1` help with in `.AC` analysis? | The output magnitude is directly the transfer gain from that source. |
469+
| What does lower `zeta` usually mean in a second-order block? | More peaking and more ringing. |
470+
| Why avoid a pure integrator such as `1/s` here? | Its DC gain is singular, so it is outside the supported finite-DC-gain subset. |
471+
472+
## Intuition Checklist
473+
474+
When you see a transfer function, ask:
475+
476+
1. What is the DC gain when `s = 0`?
477+
2. Does it pass or block low frequencies?
478+
3. Where does the gain start changing?
479+
4. Does the output lead or lag the input?
480+
5. Would a step be smooth, fast, slow, or ringing?
481+
6. Is this linear approximation enough, or do nonlinear details matter?
482+
483+
For the sensor-to-ADC example, this checklist says: the DC gain is `gain`, low-frequency sensor signals pass, high-frequency noise is reduced above `fc`, phase lag appears near the cutoff, and time-domain edges become smoother.
484+
257485
## SpiceSharpParser Subset
258486

259487
SpiceSharpParser intentionally supports a practical subset:

0 commit comments

Comments
 (0)