Quarter-Wave Bandpass Filter Design - simple#
This tutorial tells you how to design a simple quarter-wave bandpass stub filter with simpleEMS. This filter passes the frequencies in one band and stops the others.
Note
You must have simpleEMS and openEMS on your computer. See Installation.
Make a file with the name quarterwave_bandpass_filter.py.
Import the modules#
Import QuarterWaveFilterParams, BandPassQuarterWaveFilter, and
setup_simulation from simpleEMS.
from simpleEMS import QuarterWaveFilterParams, BandPassQuarterWaveFilter
from simpleEMS import setup_simulation
QuarterWaveFilterParams holds the parameters of the filter and of the
simulation.
BandPassQuarterWaveFilter makes the filter.
setup_simulation makes the CSXCAD geometry and the FDTD solver. It also sets
the frequency range of the simulation.
Set the parameters#
params = QuarterWaveFilterParams(
substrate_eps_r=3.3,
substrate_tand=0.001,
substrate_thickness_mm=1.6,
min_freq=0.5e9,
max_freq=3e9,
centre_freq=1.5e9,
bandwidth_freq=1e9,
filter_type="bandpass",
filter_response="butterworth",
filter_order=3,
)
QuarterWaveFilterParams holds the centre frequency, the bandwidth, the type
of response, the order of the filter, and the properties of the substrate.
Set up the simulation#
sim = setup_simulation(params)
setup_simulation prepares the FDTD solver and the CSXCAD geometry. It returns
a SimSetup with the CSX, FDTD, and freqs attributes.
Build the filter#
filter = BandPassQuarterWaveFilter(params, sim)
filter.print_and_save_params(params)
ports = filter.build_band_pass_quarter_wave_filter()
filter.create_mesh()
filter.write_and_show_structure(sim)
These commands build the substrate, the ground plane, the series lines, the stubs, the ports, and the mesh. Then they show the structure in AppCSXCAD. Close the AppCSXCAD window to continue. The filter is now ready for the simulation.
The bandpass filter has a short circuit at the end of each stub. The bandstop
filter does not. create_shunt_line_short() makes this short circuit.
Run the simulation#
filter.run_simulation(sim)
This command runs the openEMS solver. Wait until the solver stops.
Show the results#
sim_data = filter.compute_sim_data(sim, ports)
filter.plot_s_param(sim_data.freqs, sim_data.s11, sim_data.s21)
filter.show_plots()
These commands show the S11 and the S21 curves. Use them to examine the passband of the filter.
Export the results#
You can write the model to the Gerber format for a PCB manufacturer. You can also write the results to the Touchstone format for other EDA tools.
filter.export_gerber(sim)
filter.export_touchstone(
freqs=sim_data.freqs,
s11=sim_data.s11,
s21=sim_data.s21,
)
Complete script#
The complete script is below. It designs the filter, runs the simulation, and shows the results.
#!/usr/bin/env python3
"""Quarter-wave bandpass stub filter design example at 2.45 GHz."""
# IMPORTS
from simpleEMS import QuarterWaveFilterParams, BandPassQuarterWaveFilter
from simpleEMS import setup_simulation
# IMPORTS
# PARAMS
params = QuarterWaveFilterParams(
substrate_eps_r=3.3,
substrate_tand=0.001,
substrate_thickness_mm=1.6,
min_freq=0.5e9,
max_freq=3e9,
centre_freq=1.5e9,
bandwidth_freq=1e9,
filter_type="bandpass",
filter_response="butterworth",
filter_order=3,
)
# PARAMS
# SETUP
sim = setup_simulation(params)
# SETUP
# BUILD
filter = BandPassQuarterWaveFilter(params, sim)
filter.print_and_save_params(params)
ports = filter.build_band_pass_quarter_wave_filter()
filter.create_mesh()
filter.write_and_show_structure(sim)
# BUILD
# SIMULATE
filter.run_simulation(sim)
# SIMULATE
# PPROCESS
sim_data = filter.compute_sim_data(sim, ports)
filter.plot_s_param(sim_data.freqs, sim_data.s11, sim_data.s21)
filter.show_plots()
# PPROCESS
# EXPORT
filter.export_gerber(sim)
filter.export_touchstone(
freqs=sim_data.freqs,
s11=sim_data.s11,
s21=sim_data.s21,
)
# EXPORT