You are on page 1of 4

SimulinkR-SPICE-Interface

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

The Simulink-SPICE-Interface was developed by BAUSCH-GALL GmbH and it is available for


MATLAB/Simulink Release 14.

BAUSCH-GALL GmbH, Wohlfartstrasse 21 b,


D-80939 Muenchen, Germany
Telephone: +49/89/3232625, Telefax: +49/89/3231063
email: info@Bausch-Gall.de
web: www.Bausch-Gall.de

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

Fig. 1: DC Motor with Control Loop

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

Fig. 2: System Block Diagram of Simulink-SPICE-Model

2
START START
START
Device Level OpAmp Device Level OpAmp
VS IS PSI Ideal OpAmp
without DC feedback with DC feedback

PSI MR MR

[VS] [IS] IS PSI PSI


VI [VI]
VS W
STATOR [IR] IR MF MF
(SPICE) FLUX
OPPOSING E.M.F.

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

Fig. 3: Simulink block diagram


1 MR

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

Fig. 4: Subsystem MECHANICS Fig. 5: Subsystem SPICE

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

Fig. 6: for PI Controller with A741-Model

3
VCC
27

Q10 Q11 Q12 Q14


QPL QPL QPL QPL

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

Fig. 7: Device-Level Model of Operational Amplifier A741

File gsmcir3.cir from Chapter 4.5 of SIMULINK-SPICE-Interface Users Manual


.TRAN 0.005 10 0 0.005
* TSTEP TSTOP TSTART TMAX (only TMAX important here)
*
* stator
* current IS returned to SIMULINK
* VS set from within SIMULINK
VS 1 0 SLSP
RS 1 2 500
LS 2 0 10
*
* rotor
* current IR returned to SIMULINK
* voltage at node 3 is returned to SIMULINK
ER 3 0 9 0 -20
RR 3 4 0.5
LR 4 5 0.1
* VI set from within SIMULINK
VI 5 0 SLSP
*
* PI controller
* VD set from within SIMULINK
VD 6 0 SLSP
R1 6 7 10K
R2 7 8 50K
R3 12 0 10K
R4 7 9 10MEG
C 8 9 3.3U
VCC 10 0 15
VEE 0 11 15
XOPA 12 7 9 10 11 UA741
*
.SUBCKT UA741 2 1 24 27 26
* subcircuit for device-level model of ua741 opamp
* from [3], pages A1.6 and A1.39
R1 10 26 1K
.
.
COMP 22 8 30PF
Q1 3 2 4 QNL
.
.
Q23 26 20 25 QPL
.MODEL QNL NPN(BF=80 RB=100 CCS=2PF TF=0.3NS TR=6NS CJE=3PF
+ CJC=2PF VAF=50)
.MODEL QPL PNP(BF=10 RB=20 TF=1NS TR=20NS CJE=6PF CJC=4PF VAF=50)
.ENDS UA741
.END

Fig. 8: SPICE circuit file

You might also like