Simulation of DC Circuits with SPICE like netlist.
As the circuits increase in size manual solution becomes time consuming and numerical
simulation is the most convenient method for circuit analysis.
The circuit below has 22 resistors, 6 current sources, 5 voltage sources
and 22 nodes. Modified nodal analysis would give a matrix equation with
a 27x27 matrix.
One of the most used method for simulating this type of circuit is
by using a SPICE netlist.
SPICE netlists consist of a set of statements specifying the nodes
between which the component is connected, the type of component and
the numerical value of the component relevant parameters.
In the applet below, DC circuits with up to 40 resistors, 10 current sources,
10 voltage sources and 40 nodes can be simulated.
Each resistor is entered as:-
R1 1 2 3
The first letter R denotes a resistor. The first 2 numbers refer to the node numbers between which the resistor is
connected and the third number is the numerical value of the resistance of
the resistor in ohms. For resistors the ordering of the nodes is not significant.
Statement can be R1 1 2 3 or R1 2 1 3.
For current sources, the statement is :-
I1 2 3 4
I specifies a current source, 2 an 3 are the node numbers between which
the current source is connected and 4 is the current in amps supplied by
the current source. For current sources the ordering of the nodes IS
significant. In this case the current supplied by the source is flowing from
node 2 to node 3. If the current was flowing from node 3 to node 2 then the
ststement would be I1 3 2 4.
For voltage sources, the statement is :-
V1 3 4 5
V specifies a Voltage source, 3 an 4 are the node numbers between which
the voltage source is connected and 5 is the voltage in volts supplied by
the voltage source. For voltage sources the ordering of the nodes IS
significant. In this case the positive terminal of the source is connected
to node 3 and the negative terminal to node 4.
The applet below is intended for illustrative purposes and contains only the
minimum coding to simulate circuits. No error checking is carried out.
The first step is to enter the number of nodes Nd (excluding 0) and the number of voltage
sources Nv. If the number of nodes is 22 then ALL nodes from 0 to 22 must have
a minimum of 2 components connected to them.
To enter a resistor the row and col scrollbars must be adjusted to the desired resistor. The labelling of the resistors is not significant. Any resistor on the
be used to represent a circuit resistor provided the node numbers and
component value is correctly set.
When it is located, it is displayed as pink text. Nd1 and Nd2 are then used to
set the node numbers and c1, c2 and c3 used to set the component value shown
by the blue text at the top. When row, col, Nd1, Nd2, c1, c2 and c3 are correctly set
then the right arrow of the Lock scrollbar must be clicked. The component
text is shown in cyan and updated.
At this point the left arrow of the Lock scrollbar must be clicked to return the
text to pink.
The other components are then set in the same way. Unused components
MUST be left with both node numbers and component value equal to zero. When all components are
entered the right arrow of the soln scrollbar must be clicked. If the
circuit was entered correctly, then the node voltages and voltage source
currents are displayed.
The image below shows the applet used to simulate the above circuit. The node
voltages are shown in yellow green and the voltage source currents in
pink magenta on the right. All voltages are in volts and currents in amps. The labelling of the components is not significant.
R0 to R21 are used to enter the resistors R1 to R22. I40 to I45 are used
to represent current sources I1 to I6 and V50 to V54 used for V1 to V5.
The image below shows how the change in node voltages can be seen when any
component value is changed. Eg to change R1 to 5.5ohms set row = 1, col = 0,
Nd1 = 2, Nd2 = 6, c1, c2 and c3 to 0.55, 0.0 and 1.0 respectively. soln can be left to 1. When the right arrow of the Lock scrollbar is clicked, the value of R1 and the solution is immediately updated. For more
changes Lock and soln can be left at 1 and c1, c2, c3 used to change
the component value.
The image below emphasises the nonsignificance of the resistor labels. R24
instead of R21 is
used to represent circuit resistor R22 with the correct solution obtained.
This is true for the resistors and current sources but not for the voltage sources.
If there are 5 voltage sources, then the first 5 components V50 to V54 MUST be
used to represent them.
Simpler circuits can be simulated. The image below shows the
circuit above being simulated.
Return to main page
Return to page index
Copyright © 2010 Cuthbert A. Nyack.