Tutorial: Introduction to Modeling with Spice
Learn how to design a Band Pass Filter with components from the Spice block library and simulate the model with the Spice solver.
Files for This Tutorial
SpiceBandPassFilter.scm
Overview of the Band Pass Filter
Band pass filters are widely used in wireless transmitters and receivers to pass and block frequencies within a certain range. The main purpose of the filter is to refine a noisy signal into an ideal signal within a set of frequencies.
The model that you build for this tutorial includes a low-pass filter (passive) and amplifier. Your goal is to remove the high-frequency signal and keep only frequencies in the pass band. You will set the cut frequency (fc) to 50hz and amplify the signal by 10x.
Design the Low Pass Filter
Construct the low-pass filter portion of your band-pass filter model. Include a resistor and capacitor.
- From Twin Activate, select .
-
Select
. Navigate to your working directory. For File name, enter
SpiceBandPassFilter.Your model is saved as SpiceBandPassFilter.scm in the specified directory.
- In the Palette Browser, from Resistor block into the current diagram and double-click the block. , drag one
- For Resistance, enter 256000 Ohm, then click OK.
- On the model, select the Resistor block to change its orientation.
-
On the ribbon, select the left arrow on the Orient
tool:
The resister rotates to the left:
- In the Palette Browser, from Capacitor block into the current diagram, then double-click the block. , drag one
- For Device capacitance, enter 1.2e-8, then click OK.
- In the Palette Browser, from Ground block into the current diagram. , drag one
-
Connect the components as follows:
The low-pass filter of the electrical schematic of the BandPassFilter model is complete.
Design the Non-Inverting Unity Amplifier
Create a non-inverting unity amplifier with a Voltage Controlled Voltage Source (VCVS).
-
In the Palette Browser, from VCVS block into the current
diagram and double-click the block.
, drag one
- In the block dialog, for Gain, enter 10.0, then click OK.
-
Connect the amplifier to the low-pass filter.
Your model should look something like this:
Next define the source for the excitation by combining the three sinusoidal signals at different frequencies.
-
Add the following blocks to your model from the Palette Browser:
- From SineWaveGenerator blocks into the diagram. , drag three
- From Sum block into the
diagram.Note: Choose the Sum block that has ports on the left side.
, drag one
-
Double-click the Sum block and define these parameters:
- For Number of inputs, enter 3.
- For each input port, select the '+' operator.
- Keep the default values for all other parameters.
-
Connect the blocks you just added to the model. Note that the converter is
automatically added between the Sum block and the Resistor.
-
Define each of the SineWaveGenerator blocks as follows:
For this block Enter this value for Frequency (rad/s) SineWaveGenerator 1 62.8 rad/s (=10Hz) SineWaveGenerator 2 62.8 e3 rad/s (=10Hz) SineWaveGenerator 3 62.8 e6 rad/s (=1MHz) Keep the defaults for any remaining parameters. - In the Palette Browser, from Scope block into the current diagram and double-click the block. , drag one
- For Number of inputs, enter 2.
-
Connect the Scope block to the model. Note that the converters from the model
to the Scope are automatically added to the model.
- Save your model.
Simulating the Diagram
-
On the ribbon, select Setup.
- On the dialog that appears, select the Simulation Time tab.
-
For Final Time, enter .25 seconds. This simulation run
time should be sufficient to capture the lowest frequency (10Hz) of the model
two times.
Your model is complete, and you are ready to simulate it!
-
On the ribbon, select Run.
The Scope block in the model should generate a plot that looks something like this:
The plot shows that the low-pass filter removed the high-frequency signal and passed only the frequencies that were less than 50 Hz. The signal in the pass band was amplified by 10.
- Experiment with the diagram by modifying the block parameters and evaluating their effect on the simulation results.