Professional Documents
Culture Documents
Simulink1 is widely used for the time-domain simulation of control, mechanical, hydraulic and other
dynamical systems described by block diagrams. Today, many larger systems contain electrical or
electronic subsystems with semiconductor devices. For the simulation of such subsystems, special-
ized software tools are used. One such program is SPICE2 , a general purpose circuit simulator devel-
oped at the University of California at Berkeley which has become a standard in industry, research
and education.
The Simulink-SPICE-Interface was developed for the simultaneous simulation of mixed systems con-
taining Simulink-type and SPICE-type subsystems. The interface works within the familiar MAT-
LAB3 /Simulink environment and is based on a Simulink feature to create new blocks written in C
(C MEX S-Functions). The source code of SPICE Version 3F5 was implemented in such a way.
The interface block SLSP reads in the circuit file, initializes the simulation, performs the numerical
integration in the time-domain and manages the communication between SPICE and Simulink.
To simulate a mixed system, the user first defines the subsystems to be modeled in Simulink (i.e.
mechanical, hydraulical, etc.) and the electrical/electronic subsystems to be modeled in SPICE. After
selection of the state variables for data exchange between the Simulink- and SPICE-submodels, the
Simulink block diagram is edited and the SPICE circuit file is written. After selection of an appro-
priate integration algorithm and step size, the simulation may be started. Results can be viewed and
printed within the MATLAB environment as usual.
The Simulink-SPICE-Interface combines the time-proven tools Simulink and SPICE for a straight-
forward and efficient simulation of complex mixed systems which contain electrical or electronic
subsystems.
Typical applications:
mechanical/hydraulical/electrical/electronic mixed systems (i.e. automotive)
aerospace/avionics
environmental technology
power system design
biological/medical/biomedical systems
d:/slsp/dbl/slspdbl.tex HG 03-NOV-04
1
The MathWorks, Inc.
2
Simulation Program with Integrated Circuit Emphasis, U.C.Berkeley, CA, U.S.A.
3
The MathWorks, Inc.
1
Example
In this application, the Interface is used for the simulation of the speed control system of a dc motor
(Fig. 1). The system block diagram of the overall Simulink-SPICE-Model is shown in Fig. 2 where
the shaded areas are modeled in SPICE. The Simulink block diagram is shown in Fig. 3. The time-
domain response of the angular velocity (t) is presented in Fig. 6. All other state variables are
available for plotting within the MATLAB environment. The operational amplifier in the PI controller
is modeled at the transistor level (Fig. 7). The SPICE circuit file was created by using the schematic
editor SpiceNet from intusoft.
IR
Speed
Pot. Tachometer
Controller
Rotor
Inertia JM
RR
VD VR G
LR
ML
LS
RS IS
VS
Stator
IR
R2 C
8
50k 3.3
R1
6 7 RR LR
9 3 IR 4 5
10k
C4 20 0.5 0.1
C1 R
VD V (9) ER (VR ) VI
0.01 0.5
0
S
PI controller Rotor C3
0.1
1
JM
50
0
2 IS LS C2
0.5
ML
50
RS LS
1 IS 2 0
7
220 500 10
VS
0
1 0
Stator
2
START START
START
Device Level OpAmp Device Level OpAmp
VS IS PSI Ideal OpAmp
without DC feedback with DC feedback
PSI MR MR
ROTOR
T (SPICE) ML W W
ML
MECHANICS
IR
ML
[VS] VS VR [VR]
VI
W
VR [VR] [VD] VD
[VI] VI IS [IS] WS
PICONTROLLER
(SPICE)
SENSOR WS
[VD] VD IR [IR]
VD WS
SPICE
1
1
PSI
1
C2
VR
2 VS
IR
SLSP 1
3 1/JM
1
3 2 Mux Demux 2
ML
s
W gsmcir3.cir
VI IS
3 SLSP
1 3
MF
C3
VD IR
2
60
50
40
angular velocity in rad/s
30
20
10
0
S
10
0 1 2 3 4 5 6 7 8 9 10
T in s
3
VCC
27
3 6 17 22
Q22
Non-Inverting Input QNL
2 Q1 Q2 1
QNL QNL
Q15 Q20 23
Inverting Input 4 5 QNL QNL
21 R10
50
Output
Q4
QPL R5 COMP
Q3 39K 30PF
QPL 24
R9
Q16
25
QNL
7 8
Q21 25
20 QPL
Q7 Q18 R6
QNL QNL 40K
Q23
9 14 QPL
Q19
QNL
18
Q5 Q6 Q8 15 Q9 Q13 13 Q17
QNL QNL QNL QNL QNL QNL
10 11 12
R1 R2 R3 R4 R8 R11
R7
1K 50K 1K 3K 50 50K
50K
VEE
26