Design a Filter
This tutorial walks through a complete filter design workflow using mcltspice tools. You will create a circuit from a template, simulate it, measure the bandwidth, and adjust component values to hit a target specification.
Design a 1st-order RC lowpass filter with a -3dB cutoff at 10 kHz.
Workflow
Section titled “Workflow”-
Create the circuit
Use
create_from_templateto generate an RC lowpass filter netlist:{"template_name": "rc_lowpass","params": {"r": "1k","c": "15n"}}The theoretical cutoff is
f_c = 1 / (2 * pi * R * C) = 1 / (2 * pi * 1000 * 15e-9) = 10,610 Hz. Close to 10 kHz. -
Simulate
Run AC analysis with
simulate_netliston the generated.cirfile. The template includes an.ac dec 100 1 1megdirective by default. -
Measure bandwidth
Use
measure_bandwidthon the.rawfile with signalV(out):{"raw_file_path": "/tmp/rc_lowpass.raw","signal_name": "V(out)"}This returns the -3dB frequency, which should be near 10.6 kHz.
-
Iterate if needed
If the cutoff is off-target, use
tune_circuitto get suggestions:{"template": "rc_lowpass","params": {"r": "1k", "c": "15n"},"targets": {"bandwidth_hz": "~10000"},"signal": "V(out)"}The tool will measure the actual bandwidth and suggest adjusted component values.
-
Visualize
Generate a Bode plot with
plot_waveform:{"raw_file": "/tmp/rc_lowpass.raw","signal": "V(out)","plot_type": "bode"}This creates an SVG showing magnitude and phase vs. frequency.
Key takeaway
Section titled “Key takeaway”The RC lowpass cutoff frequency is f_c = 1 / (2 * pi * R * C). To lower the cutoff, increase R or C. To raise it, decrease them. The tune_circuit tool does this math for you and suggests standard component values from E12/E24 series.