3.1 Schematic capture and simulation with Xscheme and NGSpice
This section demonstrates the usage of Xschem and NGSpice opensource tools.
1. Run Xscheme
- Open a Ubuntu 22.04 terminal and run the following commands (assuming that you already installed the tools):
$ source $HOME/unic-cass/env.sh
$ xschem
- The window pops up successfully as follows.
Source
Schematic capture - Create instances
Draw a RLC circuit in Xscheme:
- Create a new instance by selecting
Tools
»Insert Symbol
(Shift + i)
- Create a resistor by
xscheme_library/devices
»res.sym
»OK
» Click on the schematic windows
- Create an inductor (
ind.sym
)
- Create a capacitor (
capa.sym
)
- Create an arithmetic source (
vsource_arith.sym
)
3. Schematic capture - Change the paramters
Change the capacitance to 50nF and the inductance to 10mH
- Click on the
capacitor
and pressq
; change the value ofC1
to50nF
then pressOK
- Click on the
inductor
and pressq
; change the value ofL1
to10mH
then pressOK
Set the voltage source
- Click on the
voltage source
and pressq
; change the value ofE1
to" '3*cos(time*time*time*1e11)' "
then pressOK
(note the single and doulbe quotes)
Final view
4. Schematic capture - Wiring
To connect the wire, press w
then use the left-mouse click to create multiple wire segments
-
- Put the cursor to the red point, then press
w
- Put the cursor to the red point, then press
-
- Move the cursor here and left-mouse click, then press
w
again
- Move the cursor here and left-mouse click, then press
-
- Move the cursor here and left-mouse click, then press
w
again
- Move the cursor here and left-mouse click, then press
-
- Move the cursor here and left-mouse click on the red point to finish wiring
-
- Put the cursor to the red point, then press
w
- Put the cursor to the red point, then press
-
- Move the cursor to the red point, then left-mouse click
5. Schematic capture - Create lab pins
To view the waveform and name the net, insert a lab_pin
symbol, and change its name
- Create a
lab_pin
byxscheme_library/devices
»lab_pin.sym
»OK
» Click on the net for thelab_pin
- Select the
lab_pin
symbol and then pressq
to rename it intoA
- Similary create the lab pin
B
,C
, and0
(ground)
Note
-
You can copy the lab pin
A
by selecting it and pressc
, then move it to the correct net -
Rotate can be done by pressing
Shift+r
6. Schematic capture - Set up a simulation
To set up the simulation, insert a code symbol and enter the simulation commands
- Create a code symbol by
xscheme_library/devices
»code.sym
»OK
» Click on the schematic to place it
- Select the code symbol and press
q
; change thename
intoSTIMULI
andvalue
to:
".tran 10n 2000u uic
.save all"
Note
- The double quote is required
7. Simulate the design using NGSpice
-
Xscheme uses NGSpice as the default simulator
-
To create the design’s netlist, click
Netlist
button to generate the spice file
- To view the netlist, select
Simulation
»Edit netlist
- To simulate, click
Simulate
button to run the simulation
8. Plot the waveform in NGSpice
- Plot the waveform in NGSpice by enter
plot a b c
in NGSpice terminal