PSIM User Manual
PSIM User Manual
User’s Guide
Powersim Inc.
Chapter : -7
PSIM® User’s Guide
Version 9.0
Release 1
January 2010
Disclaimer
Powersim Inc. (“Powersim”) makes no representation or warranty with respect to the adequacy or accuracy of this
documentation or the software which it describes. In no event will Powersim or its direct or indirect suppliers be liable for any
damages whatsoever including, but not limited to, direct, indirect, incidental, or consequential damages of any character
including, without limitation, loss of business profits, data, business information, or any and all other commercial damages or
losses, or for any damages in excess of the list price for the licence to the software and documentation.
Powersim Inc.
email: [email protected]
http://www.powersimtech.com
-6 Chapter :
Contents
1 General Information
1.1 Introduction 1
2.2 Switches 10
2.2.1 Diode, LED, Zener Diode, and DIAC 10
2.2.2 Thyristor and TRIAC 12
2.2.3 GTO and Transistors 13
2.2.4 Bi-Directional Switches 15
2.2.5 Linear Switches 16
2.2.6 Switch Gating Block 17
2.2.7 Single-Phase Switch Modules 19
2.2.8 Three-Phase Switch Modules 19
2.4 Transformers 23
2.4.1 Ideal Transformer 23
2.4.2 Single-Phase Transformers 23
2.4.3 Three-Phase Transformers 25
Chapter : -5i
2.6.1.2 Non-Ideal Operational Amplifier 31
2.6.2 TL431 Shunt Regulator 32
2.6.3 Optocoupler 33
2.6.4 dv/dt Block 34
ii
-4 Chapter :
2.12.1 Solar Cells 94
2.12.2 Wind Turbine 96
Chapter : iii
-3
3.5.1 Zero-Order Hold 120
3.5.2 z-Domain Transfer Function Block 121
3.5.2.1 Integrator 122
3.5.2.2 Differentiator 123
3.5.2.3 Digital Filters 123
3.5.3 Unit Delay 125
3.5.4 Quantization Blocks 126
3.5.5 Circular Buffers 128
3.5.6 Convolution Block 129
3.5.7 Memory Read Block 129
3.5.8 Data Array 130
3.5.9 Stack 130
3.5.10 Multi-Rate Sampling System 131
4 Other Components
4.1 Parameter File 137
iv
-2 Chapter :
4.8.2 Transformation Blocks 154
4.8.2.1 abc-dqo Transformation 155
4.8.2.2 abc-α/β Transformation 156
4.8.2.3 α/β-to-dq Transformation 157
4.8.2.4 Cartesian-Polar Transformation 157
4.8.3 Math Function Blocks 157
4.8.4 Lookup Tables 158
4.8.5 C Block 160
4.8.6 Simplified C Block 161
4.8.7 External DLL Blocks 162
4.8.8 Embedded Software Block 164
5 Analysis Specification
5.1 Simulation Control 165
Chapter : -1v
7 Waveform Processing
7.1 File Menu 193
Index 205
vi
0 Chapter :
1
General Information
1.1 Introduction
PSIM1 is a simulation software specifically designed for power electronics and motor drives. With fast
simulation and friendly user interface, PSIM provides a powerful simulation environment for power electronics,
analog and digital control, magnetics, and motor drive system studies.
PSIM includes the basic package, as well as the following add-on options:
Motor Drive Module
Digital Control Module
SimCoupler Module
Thermal Module
MagCoupler Module
MagCoupler-RT Module
SimCoder2 Module
Renewable Energy Package
The Motor Drive Module has built-in machine models and mechanical load models for motor drive system
studies.
The Digital Control Module provides discrete elements such as zero-order hold, z-domain transfer function
blocks, quantization blocks, digital filters, for digital control system analysis.
The SimCoupler Module provides interface between PSIM and Matlab/Simulink3 for co-simulation.
The Thermal Module provides the capability to calculate semiconductor devices losses.
The MagCoupler Module provides interface between PSIM and the electromagnetic field analysis software
JMAG4 for co-simulation.
The MagCoupler-RT Module links PSIM with JMAG-RT4 data files.
The SimCoder Module provides automatic code generation capability for DSP hardware.
The Renewable Energy Package includes the basic PSIM package, the Motor Drive Module, and Renewable
Energy models such as solar cells and wind turbine for simulation in renewable energy applications.
In addition, PSIM supports links to third-party software through custom DLL blocks. The overall PSIM
environment is shown below.
1. PSIM and SIMVIEW are registered trademarks of, and are copyright by, Powersim Inc., 2001-2010
2. SimCoder is a trademark of Powersim Inc., and is copyright by Powersim Inc., 2008-2010
3. Matlab and Simulink are registered trademarks of the MathWorks, Inc.
4. JMAG and JMAG-RT are copyright by JSOL Corporation, 1997-2010
The PSIM simulation environment consists of the circuit schematic program PSIM, the simulator engine, and
the waveform processing program Simview1. The simulation process is illustrated as follows.
This manual covers both PSIM and all the add-on Modules except SimCoder Module. The use of the SimCoder
Module is described in the separate document SimCoder User Manual.
Chapter 1 of this manual describes the circuit structure, software/hardware requirement, and parameter
specification format. Chapter 2 through 4 describe the power and control circuit components. Chapter 5
describes the specifications of the transient analysis and ac analysis. The use of the PSIM schematic program
and SIMVIEW is discussed in Chapter 6 and 7. Finally, error/warning messages are discussed in Chapter 8.
Power Circuit
Switch
Sensors
Controllers
Control Circuit
The power circuit consists of switching devices, RLC branches, transformers, and coupled inductors. The
control circuit is represented in block diagram. Components in s domain and z domain, logic components (such
Files Description
PSIM.exe PSIM circuit schematic editor
SIMVIEW.exe Waveform display program SIMVIEW
PcdEditor.exe Device database editor
SetSimPath.exe Program to set up the SimCoupler
Module
Images:
Resistor Inductor Capacitor RL RC LC RLC
Attributes:
Parameters Description
Resistance Resistance, in Ohm
Inductance Inductance, in H
Capacitance Capacitance, in F
Initial Current Initial inductor current, in A
Initial Cap. Voltage Initial capacitor voltage, in V
Current Flag Flag for branch current output.
If the flag is zero, there is no current output. If the flag is 1, the current will be
available for display in the runtime graphs (under Simulate -> Runtime
Graphs). It will also be saved to the output file for display in SIMVIEW.
The current is positive when it flows into the dotted terminal of the branch.
Current Flag_A; Current flags for Phase A, B, and C of three-phase branches, respectively.
Current Flag_B;
Current Flag_C
The resistance, inductance, or capacitance of a branch can not be all zero. At least one of the parameters has to
be a non-zero value.
Image:
k m
Attributes:
Parameters Description
Total Resistance Total resistance of the rheostat R (between Node k and m), in Ohm
Tap Position (0 to 1) The tap position Tap. The resistance between Node k and t is: R*Tap.
Current Flag Flag for the current that flows into Node k.
Image:
Attributes:
Parameters Description
Current vs. Inductance Characteristics of the current versus the inductance (i1, L1), (i2, L2), etc.
Current Flag Flag for the current display
The nonlinear B-H curve is represented by piecewise linear approximation. Since the flux density B is
proportional to the flux linkage λ and the magnetizing force H is proportional to the current i, the B-H curve can
be represented by the λ-i curve instead, as shown below.
λ (B)
λ3
λ2 Inductance L = λ / i
λ1
i1 i2 i3 i (H)
The inductance is defined as: L = λ / i, the ratio of λ vs. i at each point. The saturation characteristics are defined
by a series of data points as: (i1, L1), (i2, L2), (i3, L3), etc.
Note that the defined saturation characteristics must be such that the flux linkage λ is monotonically increasing.
That is, L1*i1 < L2*i2 < L3*i3, etc.
Also, similar to the saturation characteristics in the real world, the slope of each linear segment must be
monotonically decreasing as the current increases.
In certain situations, circuits that contain saturable inductors may fail to converge. Connecting a very small
capacitor across the saturable inductor may help the convergence.
Images:
Attributes:
For resistance-type elements:
Parameters Description
Expression f(i) or f(i,x) Expression of v in terms of i and x [v = f(i) or v = f(i,x)]
Expression df/di The derivative of the voltage v versus current i, i.e. df(i)/di
Initial Value io The initial value of the current i
Lower Limit of i The lower limit of the current i
Upper Limit of i The upper limit of the current i
For conductance-type elements:
Parameters Description
Expression f(v) or f(v,x) Expression of i in terms of v and x [i = f(v) or i = f(v,x)]
Expression df/dv Derivative of the current i versus voltage v, i.e. df(v)/dv
Initial Value vo The initial value of the voltage v
Lower Limit of v The lower limit of the voltage v
Upper Limit of v The upper limit of the voltage v
A good initial value and lower/upper limits will help the convergence of the solution.
The nonlinear element (NONI) in the circuit above models a nonlinear diode. The diode current is expressed as
2.2 Switches
There are two basic types of switches in PSIM. One is the switchmode type. It operates either in the cut-off
region (off state) or saturation region (on state). The other is the linear type. It can operates in either cut-off,
linear, or saturation region.
Switches in switchmode include the following:
- Diode and DIAC
- Thyristor and TRIAC
- Self-commutated switches, specifically:
- Gate-Turn-Off switch
- npn bipolar junction transistor (BJT)
- pnp bipolar junction transistor
- Insulated-Gate Bipolar Transistor (IGBT)
- n-channel Metal-Oxide-Semiconductor Field-Effect Transistor (MOSFET) and p-channel
MOSFET
- Bi-directional switch
Switch models are ideal. That is, both turn-on and turn-off transients are neglected.
A switch has an on-resistance of 10μΩ. When there is no R-L-C branch connected in parallel with the switch, a
10-MΩ resistor will be connected across the switch internally. This resistance can be viewed as the off-state
resistance. In certain cases, this resistance may need to be modified. To change the off-state resistance to, for
example, 100 MΩ, connect a 100-MΩ in parallel to the switch. Since PSIM sees that there is already a resistor
in parallel to the switch, the 10-MΩ resistor will not be added.
Snubber circuits are not required for switches.
Linear switches include the following:
- npn and pnp bipolar junction transistor
- n-channel and p-channel MOSFET
Images:
Diode LED
+ +
v v
- -
Parameters Description
Diode Threshold Diode threshold voltage Vd_th, in V. The diode starts to conduct when the positive
Voltage bias voltage is greater than Vd_th.
Diode Resistance Diode on resistance Rd, in Ohm, after it starts to conduct.
Initial Position Flag for the initial diode position. If the flag is 0, the diode is off. If it is 1, the
diode is on.
Current Flag Current flag of the diode.
The i-v characteristics of the diode and LED is shown below:
i-v characteristics
i
Slope = 1/Rd
0 v
Vd_th
Zener:
A zener diode is modeled by a circuit as shown below.
Images:
Zener K
K Circuit Model
VB
A A
Attributes:
Parameters Description
Breakdown Voltage Breakdown voltage VB of the zener diode, in V
Forward Threshold Threshold voltage of the forward conduction (from anode to cathode), in V
Voltage
Forward Resistance On resistance of the forward conduction, in Ohm
Current Flag Flag for zener current output (from anode to cathode)
When the zener diode is positively biased, it behaviors as a regular diode. When it is reverse biased, it will
block the conduction as long as the cathode-anode voltage VKA is less than the breakdown voltage VB. When
VKA exceeds VB, the voltage VKA will be clamped to VB.
Note that when the zener is clamped, since the diode is modelled with an on-resistance of 10μΩ, the cathode-
anode voltage will in fact be equal to: VKA = VB + 10μΩ * IKA. Therefore, depending on the value of IKA, VKA
will be slightly higher than VB. If IKA is very large, VKA can be substantially higher than VB.
Image:
Attributes:
Parameters Description
Breakover Voltage Voltage at which breakover occurs and the DIAC begins to conduct, in V
Breakback Voltage Conduction voltage drop, in V
Current Flag Current flag
Images:
Thyristor TRIAC
A K
Gate
Gate
Attributes:
Parameters Description
Voltage Drop Thyristor conduction voltage drop, in V
Holding Current Minimum conduction current below which the device stops conducting and returns
to the OFF state (for thyristor only)
Latching Current Minimum ON state current required to keep the device in the ON state after the
triggering pulse is removed (for thyristor only)
Initial Position Flag for the initial switch position (for thyristor only)
Current Flag Flag for switch current output
Note that for the TRIAC device, the holding current and latching current are set to zero.
There are two ways to control a thyristor or TRIAC. One is to use a gating block, and the other is to use a switch
controller. The gate node of a thyristor or TRIAC must be connected to either a gating block or a switch
controller.
The following examples illustrate the control of a thyristor switch.
Gating Block
Alpha
Controller
This circuit on the left uses a switching gating block. The switching gating pattern and the frequency are pre-
defined, and remain unchanged throughout the simulation. The circuit on the right uses an alpha switch
controller. The delay angle alpha, in deg., is specified through the dc source in the circuit.
Images:
Parameters Description
Voltage Drop GTO conduction voltage drop, in V
Initial Position Initial switch position flag (0: off; 1: on)
Current Flag Switch current flag (0: no display; 1: display)
Parameters Description
Saturation Voltage The saturation voltage Vce_sat for npn, or Vec_sat for pnp, in V
Initial Position Initial switch position flag (0: off; 1: on)
Parameters Description
On Resistance The on resistance Rds_on of the MOSFET, in Ohm
Diode Threshold Anti-parallel diode threshold voltage, in V
Voltage
Diode Resistance Anti-parallel diode on resistance, in Ohm
Initial Position Initial switch position flag for the transistor only (0: off; 1: on)
Current Flag Switch current flag for the whole module (the transistor plus the diode) (0: no
display; 1: display)
Parameters Description
Saturation Voltage Saturation voltage Vce_sat of the IGBT, in V
Transistor Resistance Transistor on resistance, in Ohm
Diode Threshold Anti-parallel diode threshold voltage, in V
Voltage
Diode Resistance Anti-parallel diode on resistance, in Ohm
Initial Position Initial switch position flag for the transistor only (0: off; 1: on)
Current Flag Switch current flag for the whole module (the transistor plus the diode) (0: no
display; 1: display)
A switch can be controlled by either a gating block or a switch controller. They must be connected to the gate
(base) node of the switch. The following examples illustrate the control of a MOSFET switch.
On-off Controller
The circuit on the left uses a gating block, and the one on the right uses an on-off switch controller. The gating
signal is determined by the comparator output.
Images:
Attributes:
Parameters Description
Initial Position Initial switch position flag (for single switch only).
Initial Position (for Initial switch position for Phase A, or B, or C.
Phase A/B/C)
Switch Position Switch position can be either "On" or "Off" (for push button switch only)
Images:
BJT (npn) BJT (pnp) MOSFET MOSFET
(n-channel) (p-channel)
Parameters Description
Current Gain beta Transistor current gain β, defined as: β=Ic/Ib
Bias Voltage Vr Forward bias voltage, in V, between base and emitter for the npn transistor, or
between emitter and base for the pnp transistor.
Vce,sat [or Vec,sat for Saturation voltage, in V, between collector and emitter for the npn transistor, and
pnp] between emitter and collector for the pnp transistor.
Parameters Description
On Resistance On resistance Rds(on) of the MOSFET, in Ohm
Threshold Voltage Threshold voltage of the gate-to-source voltage, in V, beyond which the MOSFET
Vgs(th) starts to conduct.
Transconductance gm Transconductance gm of the MOSFET.
Diode Threshold Threshold voltage of the anti-parallel diode, in V
Voltage
Diode Resistance On resistance of the anti-parallel diode, in Ohm
A linear BJT device is controlled by the base current Ib. It can operate in one of the three regions: cut-off (off
state), linear, and saturation region (on state).
The properties of a npn BJT in these regions are:
- Cut-off region: Vbe < Vr; Ib = 0; Ic = 0
- Linear region: Vbe = Vr; Ic = β∗Ib; Vce > Vce,sat
- Saturation region: Vbe = Vr; Ic < β∗Ib; Vce = Vce,sat
NPN_1
NPN_1
Image:
Parameters Description
Frequency Operating frequency of the switch or switch module connected to the gating block, in
Hz
No. of Points Number of switching points (for the Gating Block element only)
Switching Points Switching points, in deg. If the frequency is zero, the switching points is in second.
(for the Gating Block element only)
File for Gating Name of the file that stores the gating table (for the Gating Block (file) element only)
Table
The number of switching points is defined as the total number of switching actions in one period. Each turn-on
or turn-off action is counted as one switching point. For example, if a switch is turned on and off once in one
cycle, the number of switching points will be 2.
For the Gating Block (file) element, the file for the gating table must be in the same directory as the schematic
file. The gating table file has the following format:
n
G1
G2
... ...
Gn
where G1, G2, ..., Gn are the switching points.
Example:
Assume that a switch operates at 2000 Hz and has the following gating pattern in one period:
The specification of the Gating Block element for this switch will be:
Frequency 2000.
No. of Points 6
Switching Points 35. 92. 175. 187. 345. 357.
The gating pattern has 6 switching points (3 pulses). The corresponding switching angles are 35o, 92o, 175o,
187o, 345o, and 357o, respectively.
If the Gating Block (file) element is used instead, the specification will be:
Frequency 2000.
File for Gating Table test.tbl
The file “test.tbl” will contain the following:
6
35.
92.
175.
Images:
Diode bridge Thyristor bridge
A+ DC+ DC+ DC+ 1 Ct 3 DC+
1 3 A+
A+
A+
A-
A-
4 2 A- 4 2
A- DC- DC- DC-
DC-
Ct
Attributes:
Parameters Description
Diode Threshold Voltage Threshold voltage of the diode, or forward voltage drop of the thyristor, in V
or Voltage Drop
Diode Resistance On resistance of the diode, in Ohm (for diode bridges only)
Init. Position_i Initial position for Switch i
Current Flag_i Current flag for Switch i
Node Ct at the bottom of the thyristor module is the gating control node for Switch 1. For the thyristor module,
only the gating signal for Switch 1 needs to be specified. The gating signals for other switches will be derived
internally in the program.
Similar to the single thyristor switch, a thyristor bridge can also be controlled by either a gating block or an
alpha controller, as shown in the following examples.
C 3
C
Ct A6 6
Ct
DC-
CSI3 CSI3
DC+
DC+ A 1 3 5
Ct
B A
B
C
DC- C
4 6 2
Ct DC-
Parameters Description
Diode Threshold Voltage Threshold voltage drop of the diode, in V
Diode Resistance On resistance of the diode, in Ohm
Init. Position_i Initial position for Switch i
Current Flag_i Current flag for Switch i
Parameters Description
Voltage Drop Conduction voltage drop of the thyristor, in V
Init. Position_i Initial position for Switch i
Current Flag_i Current flag for Switch i
Parameters Description
On Resistance On resistance of the MOSFET transistor, in Ohm
Diode Threshold Voltage Threshold voltage drop of the diode, in V
Diode Resistance On resistance of the diode, in Ohm
Init. Position_i Initial position for Switch i
Current Flag_i Current flag for Switch i
Parameters Description
Saturation Voltage Saturation voltage Vce_sat of the IGBT transistor, in Ohm
Transistor Resistance On resistance of the IGBT transistor, in Ohm
Diode Threshold Voltage Threshold voltage drop of the anti-parallel diode, in V
Diode Resistance On resistance of the anti-parallel diode, in Ohm
Init. Position_i Initial position for Switch i
Current Flag_i Current flag for Switch i
Parameters Description
Voltage Drop Forward conduction voltage drop of the switch, in V
Resistance Forward on resistance of the switch, in Ohm
Init. Position_i Initial position for Switch i
Current Flag_i Current flag for Switch i
Similar to single-phase modules, only the gating signal for Switch 1 need to be specified for three-phase
modules. Gating signals for other switches will be automatically derived. For the 3-phase half-wave thyristor
bridge, the phase shift between two consecutive switches is 120o. For all other bridges, the phase shift is 60o.
Thyristor bridges can be controlled by an alpha controller. Similarly, voltage/current source inverters can be
controlled by a PWM lookup table controller.
The following examples illustrate the control of three-phase thyristor and voltage source inverter modules.
The thyristor circuit on the left uses an alpha controller. For a three-phase circuit, the zero-crossing of the
Images:
Attributes:
Parameters Description
Lii (self) Self inductance of the inductor i, in H
Lij (mutual) Mutual inductance between Inductor i and j, in H
Initial Current ii Initial current in Inductor i
Current Flag_i Flag for the current printout in Inductor i
In the images, the circle, square, triangle, and plus marks refer to Inductor 1, 2, 3, and 4, respectively.
The following shows a coupled inductor with two branches.
v1 -
i1 +
i2 v2 -
+
Let L11 and L22 be the self-inductances of Branch 1 and 2, and L12 and L21 the mutual inductances, the branch
voltages and currents have the following relationship:
v1 L 11 L 12 d i
= ⋅ ----- 1
v2 L 21 L 22 dt i
2
The mutual inductances between two windings are assumed to be always equal, i.e., L12 = L21.
Example:
Two mutually coupled inductors have the self inductances and mutual inductance as: L11 = 1 mH, L22 = 1.1 mH,
L11 (self) 1m
L12 (mutual) 0.9m
L22 (self) 1.1m
2.4 Transformers
Images:
Np Ns Np Ns
The winding with the larger dot is the primary, and the other winding is the secondary.
Attributes:
Parameters Description
Np (primary) No. of turns of the primary winding
Ns (secondary) No. of turns of the secondary winding
Since the turns ratio is equal to the ratio of the rated voltages, the number of turns can be replaced by the rated
voltage at each side.
Images:
s_4 s_4 p
p_2
2-windinge 5-winding 4-winding
In the images, p refers to primary, s refers to secondary, and t refers to tertiary. The winding with the largest dot
is the primary winding or first primary winding. For the multiple winding transformers, the sequence of the
Attributes:
Parameters Description
Rp (primary); Resistance of the primary/secondary/tertiary winding, in Ohm
Rs (secondary);
Rt (tertiary)
Lp (pri. leakage); Leakage inductance of the primary/secondary/tertiary winding, in H (seen from
Ls (sec. leakage); the primary)
Lt (ter. leakage)
Lm (magnetizing) Magnetizing inductance, in H
Np (primary); No. of turns of the primary/secondary/tertiary winding
Ns (secondary);
Nt (tertiary)
All the resistances and inductances are referred to the primary winding side. If there are multiple primary
windings, they are referred to the first primary winding side.
For the transformers with more than 1 primary winding or more than 3 secondary windings, the attributes are as
follows.
Attributes:
Parameters Description
Rp_i (primary i); Resistance of the ith primary/secondary/tertiary winding, in Ohm
Rs_i (secondary i)
Lp_i (pri. i leakage); Leakage inductance of the ith primary/secondary/tertiary winding, in H (referred
Ls_i (sec. i leakage) to the first primary winding)
Lm (magnetizing) Magnetizing inductance, in H (seen from the first primary winding)
Np_i (primary i); No. of turns of the ith primary/secondary/tertiary winding
Ns_i (secondary i)
All the resistances and inductances are referred to the first primary winding side.
Modeling of a Transformer:
A transformer is modeled as coupled inductors. For example, a single-phase two-winding transformer is
modeled as two coupled inductors. The equivalent circuit can be shown as:
Rp Lp Rs L s Np : Ns
Primary Lm Secondary
Ideal
In the circuit, Rp and Rs are the primary and secondary winding resistances; Lp and Ls are the primary and
secondary winding leakage inductances; and Lm is the magnetizing inductance. All the values are referred to the
primary side.
Rp (primary) 2m
Rs (secondary) 2m
Lp (primary) 1m
Ls (secondary) 1m
Lm (magnetizing) 100m
Np (primary) 220
Ns (secondary) 440
Images:
Y/Y Y/D D/D
6-winding (unconnected)
A a A a A a
b a+
B b B b B a-
b+ Winding 2
C c C c C c b-
c+
N n N c-
Y/Y/D Y/D/D 2-winding (unconnected) Winding 1
n Winding 3
a+ (primary)
a a A+
b A- a- A+
A b A b+ A-
B+
c c B+
B B B- b- B- Winding 4
aa aa C+ c+ C+
C C bb C- c- C-
bb
cc cc
Winding 5
N N
Parameters Description
Rp (primary); Resistance of the primary/secondary/tertiary winding, in Ohm
Rs (secondary);
Rt (tertiary)
Lp (pri. leakage); Leakage inductance of the primary/secondary/tertiary winding, in H
Ls (sec. leakage);
Lt (ter. leakage)
Lm (magnetizing) Magnetizing inductance, in H (seen from the primary side)
Np (primary); No. of turns of the primary/secondary/tertiary winding
Ns (secondary);
Nt (tertiary)
In the images, P refers to primary, S refers to secondary, and T refers to tertiary. All resistances and inductances
are referred to the primary or the first primary winding side.
Three-phase transformers are modeled in the same way as single-phase transformers.
2.5.1 Winding
A winding element provides the interface between the electric circuit and the magnetic equivalent circuit.
Image:
M1
E1
E2
M2
Parameters Description
Number of Turns No. of turns of the winding
Winding Resistance Winding resistance, in Ohm
This element represents a winding on a magnetic core. The two electric nodes (E1 and E2) are connected to an
electric circuit, while the two magnetic nodes (M1 and M2) are connected to other magnetic elements (such as
leakage flux path, air gap, and magnetic core).
Image:
M1 M2
Attributes:
Parameters Description
Inductance Factor AL Inductance factor AL, defined as the inductance per turn squared
Resistance for Losses Resistance R, in Ohm, that represents the losses due to the leakage flux.
Current Flag Display flag of the current that flows through the resistor R
The resistance R represents the losses due to the leakage flux.
Assuming that the mmf (magnetomotive force) applied across the leakage flux path is F, the electric equivalent
circuit of the leakage flux path is as follows:
+ i
AL
F
R
-
The mmf, in the form of a voltage source, applies across the capacitor (the capacitance is AL) and the resistor R.
Let the current flowing through this branch be i, and the rms value be Irms, the relationship between the losses
due to the leakage flux and the resistance R is:
2
P loss = I rms ⋅ R
Image:
M1 M2
Attributes:
Parameters Description
Air Gap Length The length of the air gap, lg, in m
Cross Section Area Cross section of the air gap, Ac, in m2
Resistance for Losses Resistance R, in ohm, that represents the losses due to the air gap fringing effect
Current Flag Display flag of the current that flows through the resistor R
Parameters Description
Inductance Factor AL Inductance factor AL, defined as the inductance per turn squared
Resistance for Losses Resistance R, in ohm, that represents the losses due to the air gap fringing effect
Current Flag Display flag of the current that flows through the resistor R
The resistance R represents the losses due to the air gap fringing effect. Assuming that the mmf (magnetomotive
force) applied across the air gap is F, the electric equivalent circuit of the air gap is as follows:
+ i
AL
F
R
-
The mmf, in the form of a voltage source, applies across the capacitor (the capacitance has the value of the
inductance factor AL) and the resistor R. For the element Air Gap, the inductance factor can be calculated from
the air gap length and the cross section area as:
μo ⋅ Ac
A L = ---------------
-
lg
where Irms is the rms value of the current i flowing through the resistor.
Image:
M1 M2
Attributes:
Parameters Description
Inductance Factor AL Inductance factor AL of the core, defined as the inductance per turn squared
If the length of the core is Llength and the cross section area is Ac, the inductance factor AL is expressed as:
μo ⋅ μr ⋅ Ac
A L = -------------------------
L length
Image:
C1
M1 M2
Attributes:
Parameters Description
Inductance Factor AL Inductance factor AL of the core, defined as the inductance per turn squared
Resistance for Losses Resistance R, in Ohm, that represents the core losses
Coefficient phi_sat Coefficient Φsat for the core B-H curve, in Weber
Coefficient K1 Coefficient K1 for the core B-H curve
Coefficient Kexp1 Coefficient Kexp1 for the core B-H curve
Coefficient K2 Coefficient K2 for the core B-H curve
Coefficient Kexp2 Coefficient Kexp2 for the core B-H curve
Initial Flux phi_o Initial flux Φo of the core, in Weber
Current Flag Display flag of the electric current that flows through the resistor R. If the rms
value of the current is Irms, the core losses can be calculated as: Pcore_loss = Irms2 *
R.
In the element image, the nodes M1 and M2 are the two nodes that connect the core to other magnetic elements
(such as winding, flux leakage path, air gap, etc.). The node marked with a dot is Node M2. Node C1 is a control
output node, which shows the flux (in Weber) flowing through the core, from Node M2 to M1.
Images:
V+ Ro
gnd
where
V+; V- - noninverting and inverting input voltages
Vo - output voltage
Ao - op. amp. dc gain (Ao is set to 100,000.)
Attributes:
Parameters Description
Voltage Vs+ Upper voltage source level of the op. amp.
Voltage Vs- Lower voltage source levels of the op. amp.
The difference between the element Op. Amp. and Op. Amp. (ground) or Op. Amp. (ground/inverted) is that, for
the Op. Amp. element, the reference ground of the op. amp. model is connected to the power ground, whereas
for Op. Amp. (ground) or Op. Amp. (ground/inverted), the reference ground node of the model is accessible and
can be floating.
Note that the image of an op. amp. is similar to that of a comparator. For the op. amp., the inverting input is at
the upper left and the noninverting input is at the lower left. For the comparator, it is the opposite.
Comparator
Attributes:
Parameters Description
Input Resistance Rin Input resistance of the op. amp., in Ohm
DC Gain Ao DC gain of the op. amp.
Unit Gain Frequency Frequency at which the op. amp. gain is 1, in Hz.
Output Resistance Ro Output resistance of the op. amp., in Ohm
Maximum Output Maximum current that the op. amp. output can provide, in A
Current
Voltage Vs+ Upper voltage source level of the op. amp.
Voltage Vs- Lower voltage source levels of the op. amp.
The open-loop gain of the op. amp. is shown below. In the figure, the dc gain Ao and the unit gain frequency are
indicated.
Open-Loop
Gain Av Ao
(dB)
Unit gain frequency
0
f (Hz)
Image:
Cathode
Reference
Anode
The TL431 regulator maintains the reference node voltage to be around 2.495V. In this model, the limited
bandwidth of the TL431 is modelled. That is, the ac frequency response of the TL431 model resembles the
following figure from the datasheet.
2.6.3 Optocoupler
The image and parameters of a optocoupler are shown below.
Image:
id ic
Attributes:
Parameters Description
Current Transfer Ratio The current transfer ratio CTR between the transistor current ic and the diode
current id, that is, CTR = ic/id.
Diode Resistance Diode resistance Rd, in Ohm. Note that the resistance must be greater than 0.
Diode Threshold The forward diode threshold voltage Vd_th, in V
Voltage
Transistor Vce_sat The transistor saturation voltage Vce_sat, in V
Transistor-side Capacitance Cp across the collector and emitter of the transistor, in F
Capacitance
These parameters can either be read directly from the manufacturer datasheet, or can be calculated from the
datasheet information. Take the Motorola optocoupler 4N25 as an example. From the datasheet, we can read the
current transfer ratio and the transistor saturation voltage as:
CTR = 70% = 0.7; Vce_sat = 0.15 V
From the "LED Forward Voltage versus Forward Current" characteristics on the datasheet, one can calculate the
diode resistance Rd and the threshold voltage Vd_th. We assume that the diode forward voltage is approximated
by a straight line. That is,
vd = Vd_th + Rd * id
With TA = 25oC, we can obtain two readings from the curve: id = 10 mA and vd = 1.15 V; id = 40 mA and vd =
1.3 V. Based on these two points, we can calculate Rd and Vd_th as: Rd = 5 Ohm; Vd_th = 1.1 V.
The optocoupler model does not take into account the delay, but it does model the turn-on/turn-off transient
where RL is the load resistor in the switching time test circuit. For 4N25, for example, from the datasheet, we
can obtain: tfall = 1.3 μs, and RL = 100 Ohm. The capacitance is calculated as: Cp = 6 nF.
Image:
The output of the dv/dt block is equal to the derivative of the input voltage versus time. It is calculated as:
V in ( t ) – V in ( t – Δt )
V o = ---------------------------------------------
-
Δt
where Vin(t) and Vin(t-Δt) are the input values at the current and previous time step, and Δt is the simulation time
step.
Device
list
To create a new device file, choose File -> New Device File. To load a device files into the editor, choose File -
> Open Device File. To unload a device file from the editor, choose File -> Close Device File.
Three types of devices can be added to a device files: diode, IGBT, and MOSFET. However, since dual IGBT-
diode modules have a different set of parameters as compared to the regular IGBT devices, they are treated as a
separate type (referred to as the IGBT-DIODE type). The sections that follow describe in more details each type
of devices.
To create a new device, go to the Device menu, and choose either New Diode, New IGBT, New IGBT-Diode,
or New MOSFET.
To make a copy of an existing device in the same database file, highlight the device in the list, and choose
Device -> Save Device As. To make a copy of an existing device and save it in a different database file, first
highlight the device in the list, then highlight the file name in the File Name list, and choose Device -> Save
Device As.
Adding a Device to the Database:
To illustrate how to add a device to a database file, below is the step-by-step procedure to add the Powerex
discrete diode CS240650 (600V, 50A) into the device database file "diode_new.dev".
- Launch PcdEditor.exe. Go to File -> New Device File, and create a file called "diode_new.dev". This file
will be placed in the device sub-folder under the PSIM program folder by default.
- With the file name "diode_new" highlighted in the "File Name" list, Choose Device -> New Diode. A
diode will be added to the database file with Manufacturer as "New" and Part Number as "New".
- Obtain the datasheet of Powerex diode CS240650 from the web site www.pwrx.com. Show the PDF file
of the datasheet on the screen.
- By referring to the information from the datasheet, in the database editor, enter the following information
for this device:
Manufacturer: Powerex
Part Number: CS240650
Package: Discrete
and under Absolute Maximum Ratings:
Vrrm,max (V): 600
IF,max (A): 50
Tj,max (oC): 150
X and Y
axis settings
Data area
Graph area
There are two ways to define the graph. One is to enter the graph data points manually. Another is to use
the Graph Wizard to capture the graph directly from the datasheet image. Defining the graph manually is
preferred if there is only one data point or there are just a few data points. However, if the graph image is
available, it is easier with the Graph Wizard.
- Click on the Add Curve button. Then click on the forward wizard icon to start the Graph
Wizard.
- Display the graph of the datasheet on the screen as follows:
Then press the Print Screen key (the key is labeled as "Prt Scr" on some keyboards) to copy the screen
image to the clipboard.
- Click on the forward wizard icon to paste the screen image into the graph window in the
database editor. Position the graph image properly in the graph window by dragging the left mouse so
that the complete graph is displayed within the window.
If the graph image is either too large or too small, go back to the previous step by clicking on the
backward wizard icon . Then resize the image of the graph in the Adobe Acrobat, and copy the
screen image to the clipboard again.
The graph dialog window should look something like follows.
- In this step, the border of the graph area is defined by first left clicking at the origin of the graph
(usually the lower left corner), then left clicking again at the opposite corner of the origin (usually the
upper right corner). Note that the graph origin does not have to be the lower left corner, and it can be
any one of the four corners.
To locate the origin of the corner more accurately, right mouse click to zoom in, and press the Esc
(escape) key to exit the zoom.
After this, a blue rectangle will appear around the border of the graph, and the dialog window will
appear as follows.
Origin of
the graph
Then click on the forward wizard icon to move on to the next step.
- In this step, the x and y axis settings will be defined. Enter the settings as follows:
X0: 1
Xmax: 1000
Y0: 0.6
Ymax: 2.6
X in log: checked
Leave the checkbox Invert graph unchecked since the diode forward current IF is in the x-axis in this
case. But in other situations, if the current is in y-axis, check the Invert graph checkbox.
Enter the junction temperature as 25 oC. Click on the forward wizard icon to move on to the next
step.
- Left click on top of the graph to capture the data points. In this case, for example, four data points at
the current values of around 1A, 10A, 100A, and 280A are captured. Again, right click to zoom in.
You can capture as many data points as desired.
As data points are captured, red lines will appear that will connect the data points.
Then click on the forward wizard icon to complete the data capture process. The final graph
dialog window should appear as follows.
Psw
Pcond
In the images, beside the diode anode and cathode terminals, there are two
extra nodes. The node with a dot is for the diode conduction losses Pcond, and
the node without a dot is for the diode switching losses Psw.
The style of the package (for example, TO-220, TO-247, etc.) can be
specified in the Style field.
Absolute Maximum Ratings:
Vrrm,max (V): Peak reverse blocking voltage
IF,max (A): Maximum dc current
Tj,max (oC): Maximum junction temperature
Electrical Characteristics:
Vd vs. IF: Forward conduction voltage drop Vd vs. forward current IF
trr vs. IF: Reverse recovery time trr vs. current IF
Attributes:
Parameters Description
Device The specific device selected from the device database
Frequency Frequency, in Hz, under which the losses are calculated
Pcond Calibration The calibration factor Kcond of the conduction losses Pcond
Factor
Psw Calibration Factor The calibration factor Ksw of the switching losses Psw
Number of Parallel Number of identical diode devices in parallel
Devices
The parameter Frequency refers to the frequency under which the losses are calculated. For example, if the
device operates at the switching frequency of 10 kHz, and the parameter Frequency is also set to 10 kHz, the
losses will be the values for one switching period. However, if the parameter Frequency is set to 60 Hz, then the
losses will be the value for a period of 60 Hz.
The parameter Pcond Calibration Factor is the correction factor for the conduction losses. For the example, if
the calculated conduction losses before the correction is Pcond_cal, then
Pcond = Kcond * Pcond_cal
Similarly, the parameter Psw Calibration Factor is the correction factor for the switching losses. For the
example, if the calculated switching losses before the correction is Psw_cal, then
Psw = Ksw * Psw_cal
When several identical diodes are in parallel, one should have just one device in the schematic, and set the
correct number of devices in the parameter input. This is because when several identical devices are in parallel
in the schematic, the device currents may not be exactly equal due to small differences in the simulation. When
Conduction Losses:
The diode conduction losses are calculated as:
Conduction Losses = Vd * IF
where Vd is the diode voltage drop, and IF is the diode forward current. When the diode is conducting
periodically with an on duty cycle of D, the conduction losses are calculated as:
Conduction Losses = Vd * IF * D
Switching Losses:
In calculating the switching losses, the diode turn-on losses are neglected and are not considered.
The diode turn-off losses due to the reverse recovery is calculated as:
Psw_off = Err * f * VR / VR_datasheet
or
Psw_off = 1/4 * Qrr * VR * f
where Err is the reverse recovery energy losses, Qrr is the reverse recovery charge, f is the frequency as defined
in the input parameter Frequency, VR is the actual reverse blocking voltage, and VR_datasheet is the reverse
blocking voltage in the Err characteristics of the datasheet, defined as "Reverse blocking voltage VR (V)" in the
test conditions.
The reverse recovery charge Qrr is defined as:
Qrr = 1/2 * trr * Irr
Whenever Err is given in the device database, the losses will be calculated based on Err. If Err is not given, the
losses will be calculated based on Qrr. If Qrr is not given, the losses will be calculated based on trr and Irr. If
both are not given, the losses will be treated as 0.
The losses Pcond and Psw, in watts, are represented in the form of currents which flow out of these nodes.
Therefore, to measure and display the losses, an ammeter should be connected between the Pcond or Psw node
and the ground. When they are not used, these two nodes cannot be floating, and must be connected to ground.
Pcond_Q
Psw_Q
Pcond_D Q1
Psw_D
Q4
Q1 Q4
In the images, beside the IGBT and diode terminal nodes, there are four extra
nodes from the top to the bottom (or from the left to the right on the top for
the 6-pack package). They are the nodes for transistor conductor losses
Pcond_Q (the node with a circle), for transistor switching losses Psw_Q, for
diode conductor losses Pcond_D (the node with a square), and for diode
Attributes:
Parameters Description
Device The specific device selected from the device database
Frequency Frequency, in Hz, under which the losses are calculated
Pcond_Q Calibration The calibration factor Kcond_Q of the transistor conduction losses Pcond_Q
Factor
Psw_Q Calibration The calibration factor Ksw_Q of the transistor switching losses Psw_Q
Factor
Pcond_D Calibration The calibration factor Kcond_D of the diode conduction losses Pcond_D
Factor
Psw_D Calibration The calibration factor Ksw_D of the diode switching losses Psw_D
Factor
Number of Parallel Number of identical IGBT devices in parallel
Devices
The parameter Frequency refers to the frequency under which the losses are calculated. For example, if the
device operates at the switching frequency of 10 kHz, and the parameter Frequency is also set to 10 kHz, the
losses will be the values for one switching period. However, if the parameter Frequency is set to 60 Hz, then the
losses will be the value for a period of 60 Hz.
The parameter Pcond_Q Calibration Factor is the correction factor for the transistor conduction losses. For the
example, if the calculated conduction losses before the correction is Pcond_Q_cal, then
Pcond_Q = Kcond_Q * Pcond_Q_cal
Similarly, the parameter Psw_Q Calibration Factor is the correction factor for the transistor switching losses.
For the example, if the calculated switching losses before the correction is Psw_Q_cal, then
Psw_Q = Ksw_Q * Psw_Q_cal
Parameters Pcond_D Calibration Factor and Psw_D Calibration Factor work in the same way, except that they
are for the diode losses.
When several identical IGBT devices are in parallel, one should have just one device in the schematic, and set
the correct number of devices in the parameter input. This is because when several identical devices are in
parallel in the schematic, the device currents may not be exactly equal due to small differences in the
simulation. When the number of parallel devices is greater than one, the total current through the group of the
parallel devices will be equally divided among the devices. The total losses are then obtained by multiplying the
losses in each device by the number of parallel devices. The currents flowing out of Nodes Pcond_D, Psw_D,
Pcond_Q, and Psw_Q are the total losses of all the parallel devices combined.
The voltage at the conduction losses node Pcond_Q or the switching losses node Psw_Q represents the calculated
junction temperature Tj_Q of the transistor, and the voltage at the conduction losses node Pcond_D or the
switching losses node Psw_D represents the calculated junction temperature Tj_D of the anti-parallel diode, as
shown below.
Pcond_Q
Psw_Q
Pcond_D
Psw_D
The calculated junction temperatures Tj_Q and Tj_D are used when the database curves are used for loss
calculation. If the calculated junction temperature is between the junction temperatures of two curves,
interpolation will be used. If the calculated junction temperature is lower than the lowest junction temperature
or higher than the highest junction temperature in the curves, the curve corresponding to the lowest or highest
junction temperature will be used. If there is only one curve, that curve is used regardless of the calculated
junction temperature.
Conduction Losses:
The transistor conduction losses is calculated as:
Transistor Conduction Losses = Vce(sat) * Ic
where Vce(sat) is the transistor collector-emitter saturation voltage, and Ic is the collector current. When the
transistor is conducting periodically with an on duty cycle of D, the conduction losses are calculated as:
Transistor Conduction Losses = Vce(sat) * Ic * D
Switching Losses:
The transistor turn-on losses is calculated as:
Transistor Turn-on Losses = Eon * f * Vcc / Vcc_datasheet
where Eon is the transistor turn-on energy losses, f is the frequency as defined in the input parameter Frequency,
Vcc is the actual dc bus voltage, and Vcc_datasheet is the dc bus voltage in the Eon and Eoff characteristics of the
datasheet, defined as "DC bus voltage (V)" in the test conditions.
The transistor turn-off losses is calculated as:
Transistor Turn-off Losses = Eoff * f * Vcc / Vcc_datasheet
where Eoff is the transistor turn-off energy losses.
The loss calculation for the anti-parallel diode or free-wheeling diode is the same as described in the section for
the diode device.
The losses Pcond_Q, Psw_Q, Pcond_D, and Psw_D, in watts, are represented in the form of currents which flow out
of these nodes. Therefore, to measure and display the losses, an ammeter should be connected between the
nodes and the ground. When they are not used, these nodes cannot be floating and must be connected to ground.
Q1 Q4
In the images, beside the MOSFET and diode terminal nodes, there are four
extra nodes from the top to the bottom (or from the left to the right on the top
for the 6-pack package). They are the node for transistor conductor losses
Pcond_Q (the node with a circle), for transistor switching losses Psw_Q, for
diode conductor losses Pcond_D (the node with a square), and for diode
switching losses Psw_D, respectively.
The style of the package (for example, TO-220, TO-262, TO-247, etc.) can be
specified in the Style field.
Absolute Maximum Ratings:
VDS,max (V): Maximum drain-to-source voltage
ID,max (A): Maximum continuous drain current
Tj,max (oC): Maximum junction temperature
Electrical Characteristics - Transistor:
RDS(on) (ohm): Static drain-to-source on-resistance (test conditions: gate-to-source voltage
VGS, in V, and drain current ID, in A)
VGS(th) (V): Gate threshold voltage VGS(th) (test condition: drain current ID, in A)
gfs (S): Forward transconductance gfs. In the linear region of the device, we have
ID
g fs = -------------------------------
- (test conditions: drain-to- source voltage VDS in V, and
V GS – V GS ( th )
drain current ID in A)
tr (ns) and tf (ns): Rise time tr and fall time tf (test conditions: drain-to-source voltage VDS, in V;
drain current ID, in A; and gate resistance Rg, in ohm)
Qg, Qgs, and Qgd: Total gate charge Qg, gate-to-source charge Qgs, and gate-to-drain ("Miller")
charge Qgd, respectively, all in nC (test conditions: drain-to-source voltage
VDS, in V; gate-to-source voltage VDS, in V; and drain current ID, in A)
Ciss, Coss, and Crss: Input capacitance Ciss, output capacitance Coss, and reverse transfer
capacitance Crss, respectively, all in pF (test conditions: drain-to-source
voltage VDS, in V; gate-to-source voltage VDS, in V; and test frequency, in
MHz)
Attributes:
Parameters Description
Device The specific device selected from the device database
Frequency Frequency, in Hz, under which the losses are calculated
VGG+ (upper level) Upper level of the gate source voltage, in V
VGG- (lower level) Lower level of the gate source voltage, in V
Rg_on (turn-on) Gate resistance during turn-on
Rg_off (turn-off) Gate resistance during turn-off. In most cases, the turn-on gate resistance
Rg_on and the turn-off gate resistance Rg_off are identical.
RDS(on) Calibration Factor The calibration factor of the on-state resistance RDS(on)
gfs Calibration Factor The calibration factor of the forward transconductance gfs
Pcond_Q Calibration Factor The calibration factor Kcond_Q of the transistor conduction losses Pcond_Q
Psw_Q Calibration Factor The calibration factor Ksw_Q of the transistor switching losses Psw_Q
Pcond_D Calibration Factor The calibration factor Kcond_D of the diode conduction losses Pcond_D
Psw_D Calibration Factor The calibration factor Ksw_D of the diode switching losses Psw_D
Number of Parallel Number of identical devices in parallel
Devices
The parameter Frequency refers to the frequency under which the losses are calculated. For example, if the
Conduction Losses:
The transistor conduction losses is calculated as:
Transistor Conduction Losses = ID2 * RDS(on)
where ID is the drain current, and RDS(on) is the static on-resistance. When the transistor is conducting
periodically with an on duty cycle of D, the conduction losses are calculated as:
Transistor Conduction Losses = ID2 * RDS(on)* D
Switching Losses:
The transistor turn-on losses is calculated as:
Transistor Turn-on Losses = Eon * f
where Eon is the transistor turn-on energy losses, and f is the frequency as defined in the input parameter
Frequency.
The transistor turn-off losses is calculated as:
Transistor Turn-off Losses = Eoff * f
where Eoff is the transistor turn-off energy losses.
The energy losses Eon and Eoff are calculated using the rise times and the fall times of the voltage and current
waveforms based on the information of the MOSFET gate current, input/output/reverse transfer capacitances,
and gate charges.
The system consists of two induction machines, IM1 and IM2, connected back-to-back. One operates as a
motor, and the other as a generator. From the point of view of the first machine IM1, the mechanical equation
can be written as:
dω
( J 1 + J 2 ) ⋅ ---------m- = T em1 – T em2
dt
where J1 and J2 are the moment of inertia, and Tem1 and Tem2 are the developed torques of the machine IM1 and
IM2, respectively.
From the point of view of the second machine IM2, however, the mechanical equation can be written as:
dω
( J 1 + J 2 ) ⋅ ---------m- = T em2 – T em1
dt
These two equations are equally valid, but will produce opposite mechanical speed.
In order to avoid this ambiguity, in PSIM, the concept "reference direction" is used in the mechanical system so
that the mechanical equation can be uniquely defined.
In a mechanical system, one element is designated as the master unit (this element is considered to operate in
the master mode), and the rest of the elements are in the slave mode. Elements that can be master units are:
Electric machines, mechanical-to-electrical interface blocks, and gear boxes.
The master unit defines the reference direction of the mechanical system. The direction is define as the direction
from the shaft node of the master unit, along the shaft, to the rest of the mechanical system.
Once the reference direction of the mechanical system is defined, the speed and torque reference of the
mechanical system can be defined. For example, if we use the right-hand method, with the thumb pointing in
the reference direction of the mechanical system, by rotating the right hand, the fingers will point to the positive
direction of the speed and the torque.
Moreover, each mechanical element has its own reference direction. The following diagram shows the reference
direction of each mechanical element, as indicated by the arrow:
The reference direction of each element and the reference direction of the overall mechanical system determine
how the element interacts with the mechanical system.
For example, if the reference direction of a machine is along the same direction as the reference direction of the
mechanical system, the developed torque of the machine will contribute to the shaft rotation in the positive
direction. However, if the reference direction of the machine is opposite to that of the mechanical system, the
developed torque will contribute to the shaft rotation in the negative direction.
In the two-machine example above, using the notation of the "reference direction", if we define the machine
IM1 as the master unit, the reference direction of the overall mechanical system will be from left to right, as
shown below. Based on this direction, the machine IM1 will be along the reference direction, and the machine
IM2 will be opposite to the reference direction. This leads to the equivalent circuit of the mechanical system as
shown on the right.
Master Unit
Equivalent Circuit
Reference direction
(J1+J2)*dWm/dt = Tem1 - Tem2
Similarly, if we define the machine IM2 as the master unit, the reference direction of the overall mechanical
system will be from right to left, as shown below. Based on this direction, the machine IM1 will be opposite to
the reference direction, and the machine IM2 will be along the reference direction. This leads to the equivalent
circuit of the mechanical system as shown on the right.
Master Unit
Equivalent Circuit
The following shows another mechanical system with sensors and loads connected in different ways.
In this mechanical system, the machine on the left is the master unit. The reference direction of the mechanical
system is from left to the right along the mechanical shaft. Comparing this direction with the reference direction
of each element, Load 1, Speed Sensor 1, and Torque Sensor 1, will be along the reference direction, and Load
2, Speed Sensor 2, and Torque Sensor 2 will be opposite to the reference direction of the mechanical system.
Therefore, if the speed of the machine is positive, Speed Sensor 1 reading will be positive, and Speed Sensor 2
reading will be negative.
Similarly, the two constant-torque mechanical loads, with the amplitudes of TL1 and TL2, interact with the
machine in different ways. Load 1 is along the reference direction, and the loading torque of Load 1 to the
master machine will be TL1. On the other hand, Load 2 is opposite to the reference direction, and the loading
torque of Load 2 to the machine will be -TL2.
2.8.2 DC Machine
The image and parameters of a dc machine are as follows:
Image:
+
Armature
Shaft Node
Winding
-
+
Field
Winding
-
Attributes:
Parameters Description
Ra (armature) Armature winding resistance, in Ohm
La (armature) Armature winding inductance, in H
Rf (field) Field winding resistance, in Ohm
Lf (field) Field winding inductance, in H
Moment of Inertia Moment of inertia of the machine, in kg*m2
Vt (rated) Rated armature terminal voltage, in V
Ia (rated) Rated armature current, in A
T em = k ⋅ φ ⋅ i a
dω
J ⋅ ---------m- = T em – T L
dt
where vt, vf, ia, and if are the armature and field winding voltage and current, respectively; Ea is the back emf,
ωm is the mechanical speed in rad./sec., Tem is the internal developed torque, and TL is the load torque. The back
emf and the internal torque can also be expressed as:
E a = L af ⋅ i f ⋅ ω m
T em = L af ⋅ i f ⋅ i a
where Laf is the mutual inductance between the armature and the field windings. It can be calculated based on
the rated operating conditions as:
( Vt – Ia ⋅ Ra )
L af = ------------------------------
If ⋅ ωm
Note that the dc machine model assumes magnetic linearity. Saturation is not considered.
Constant-
Torque
Load Speed (in rpm)
Images:
Squirrel-cage Squirrel-cage
Squirrel-cage (unconnected)
(with neutral)
as as as+
as-
bs bs bs+
bs-
cs cs cs+
cs-
ns
Wound-rotor
Wound-rotor (unconnected)
as+
as as-
bs+
bs
bs-
cs+
cs
cs-
ns
cr nr ar- br- cr-
ar br ar+ br+ cr+
Attributes:
Parameters Description
Rs (stator) Stator winding resistance, in Ohm
Ls (stator) Stator winding leakage inductance, in H
Rr (rotor) Rotor winding resistance, in Ohm
Lr (rotor) Rotor winding leakage inductance, in H
v a, s v a, r i a, s i a, r
v abc, s = v b, s v abc, r = v b, r i abc, s = i b, s i abc, r = i b, r
v c, s v c, r i c, s i c, r
For squirrel-cage machines, va,r = vb,r = vc,r= 0. The parameter matrices are defined as:
Rs 0 0 Rr 0 0
Rs = 0 Rs 0 Rr = 0 Rr 0
0 0 Rs 0 0 Rr
M sr M sr M sr M sr
L s + M sr – -------- – -------- L r + M sr – -------- – --------
2 2 2 2
M sr M M sr M sr
Ls = – -------- L s + M sr – -------sr- Lr = – -------- L r + M sr – --------
2 2 2 2
M sr M sr M sr M sr
– -------- – -------- L s + M sr – -------- – -------- L r + M sr
2 2 2 2
2π 2π
cos θ cos ⎛ θ + ------⎞ cos ⎛ θ – ------⎞
⎝ 3⎠ ⎝ 3⎠
2π 2π
M sr = M sr ⋅ cos ⎛ θ – ------⎞ cos θ cos ⎛ θ + ------⎞
⎝ 3⎠ ⎝ 3⎠
2π 2π
cos ⎛ θ + ------⎞ cos ⎛ θ – ------⎞ cos θ
⎝ 3 ⎠ ⎝ 3⎠
where Msr is the mutual inductance between the stator and rotor windings, and θ is the mechanical angle. The
mutual inductance is related to the magnetizing inductance as:
3
L m = --- M sr
2
The mechanical equation is expressed as:
Rs Ls Rr Lr
Lm Rr(1-s)/s
VSI
Induction
Diode Motor
Bridge
Speed Torque
Sensor Sensor
Speed
SPWM Tem
Tload
3-phase currents
Images:
Attributes:
Parameters Description
Rs (stator) Stator winding resistance, in Ohm
Ls (stator) Stator winding leakage inductance, in H
Rr (rotor) Rotor winding resistance, in Ohm
Lr (rotor) Rotor winding leakage inductance, in H
Ns/Nr Turns Ratio Stator and rotor winding turns ratio (for wound-rotor machine only)
No. of Poles Number of poles P of the machine (an even integer)
Moment of Inertia Moment of inertia J of the machine, in kg*m2
Torque Flag Output flag for internal torque Tem
Master/Slave Flag Master/slave flag of the machine (1: master; 0: slave)
Im vs. Lm (Im1,Lm1) ... Characteristics of the magnetizing current Im versus the magnetizing inductance
[(Im1,Lm1) (Im2,Lm2) ...] where Im is in A and Lm is in H.
λ abc, s = M sr ⋅ – 1--- 1 1 2π
– --- ⋅ i abc, s + M sr ⋅ cos ⎛ θ – ------⎞ cos θ
2π
cos ⎛ θ + ------⎞ i abc, r
2 2 ⎝ 3⎠ ⎝ 3⎠
1 1 2π 2π
– --- – ---
2 2
1 cos ⎛ θ + ------⎞ cos ⎛ θ – ------⎞ cos θ
⎝ 3⎠ ⎝ 3⎠
2π 2π
cos θ cos ⎛ θ – ------⎞ cos ⎛ θ + ------⎞ 1 – ---
1 1
– ---
⎝ 3⎠ ⎝ 3⎠ 2 2
2π 2π 1 1
λ abc, s = M sr ⋅ cos ⎛ θ + ------⎞ cos θ cos ⎛ θ – ------⎞ ⋅ i abc, s + M sr ⋅ – --- 1 – --- i abc, r
⎝ 3⎠ ⎝ 3⎠ 2 2
2π 2π 1 1
cos ⎛ θ – ------⎞ cos ⎛ θ + ------⎞ cos θ – --- – ---
2 2
1
⎝ 3⎠ ⎝ 3⎠
In this case, the inductance Msr is no longer constant, but a function of the magnetizing current Im. The
magnetizing current Im and inductance Lm are defined by a series of data points in pair, for example, "(0, 0.041)
(5, 0.035) (20, 0.03)". Between two data points, the inductance Lm is interpolated linearly. When the
magnetizing current is less than the minimum or greater than the maximum, the inductance will be clamped to
the value at the first point or the last point.
Image:
b Shaft Node
n sa sb sc
6-pulse Hall Effect Position Sensor
Parameters Description
R (stator resistance) Stator phase resistance R, in Ohm
L (stator self ind.) Stator phase self inductance L, in H
M (stator mutual ind.) Stator mutual inductance M, in H
The mutual inductance M is a negative value. Depending on the winding
structure, the ratio between M and the stator self inductance L is normally
between -1/3 and -1/2. If M is unknown, a reasonable value of M equal to -0.4*L
can be used as the default value.
Vpk / krpm Peak line-to-line back emf constant, in V/krpm (mechanical speed)
Parameters Description
Resistance (phase-phase) Phase-to-phase (or line-to-line) resistance, in Ohm
Inductance (phase-phase) Phase-to-phase (or line-to-line) inductance, in H
Speed Constant Speed constant Kv, defined as the ratio between the speed and the applied
voltage, in rpm/V
Torque Constant Torque constant Kt, defined as the ratio between the generated torque and the
applied current, in N*m/A
No. of Poles P Number of poles P
Moment of Inertia Moment of inertia J of the machine, in kg*m2
No Load Speed The motor speed at no load with the nominal voltage applied, in rpm
No Load Current The current under no load operation, in A
Torque Flag Output flag for internal developed torque Tem
Master/Slave Flag Master/slave flag of the machine (1: master; 0: slave)
The node assignments of the image are: Nodes a, b, and c are the stator winding terminals for Phase A, B, and C,
respectively. The stator windings are Y connected, and Node n is the neutral point. The shaft node is the
connecting terminal for the mechanical shaft. They are all power nodes and should be connected to the power
E b = k e_b ⋅ ω m
E c = k e_c ⋅ ω m
The coefficients ke_a, ke_b, and ke_c are dependent on the rotor angle θr. In this model, an ideal trapezoidal
waveform profile is assumed, as shown below for Phase A. Also shown is the Phase A hall effect sensor signal
Sa.
ke_a
Sa
Kpk
o
180
o θr
360
-Kpk
α
pk V ⁄ krpm 1
- ⋅ --------------------------------
where Kpk is the peak trapezoidal value, in V/(rad./sec.), which is defined as: K pk = ------------------------ -.
2 1000 ⋅ 2π ⁄ 60
Given the values of Vpk/krpm and Vrms/krpm, the angle α is determined automatically in the program.
The developed torque of the machine is:
T em = ( E a ⋅ i a + E b ⋅ i b + E c ⋅ i c ) ⁄ ω m
The mechanical time constant τmech, therefore, reflects the effect of the friction and windage of the machine.
Note that when the mechanical time constant is set to 0, the friction term is B*ωm is ignored.
To better understand the definition of the mechanical time constant, we can represent the mechanical equation
with the following equivalent circuit:
ωm
1/B Tload
Tem J (or τmech/J)
This circuit shows that the mechanical time constant τmech is equal to the RC time constant of the resistor 1/B
and the capacitor J. Therefore, the mechanical time constant can be measured by the following test:
- Connect the machine to an external mechanical source. With the stator side in open circuit, drive the
machine to a certain speed.
- Remove the mechanical source. The mechanical time constant will be equal to the time that it takes the
machine to decelerate to 36.8% of its initial speed.
Speed
Tem
3-phase currents
Image:
b Shaft Node
c
n
field+ field-
Attributes:
Parameters Description
Rs (stator) Stator winding resistance, in Ohm
Ls (stator) Stator leakage inductance, in H
Ldm (d-axis mag. ind.) d-axis magnetizing inductance, in H
Lqm (q-axis mag. ind.) q-axis magnetizing inductance, in H.
Rf (field) Field winding resistance, in Ohm
Lfl (field leakage ind.) Field winding leakage inductance, in H
Rdr (damping cage) Rotor damping cage d-axis resistance, in Ohm
Ldrl (damping cage) Rotor damping cage d-axis leakage inductance, in H
Rqr (damping cage) Rotor damping cage q-axis resistance, in Ohm
Lqrl (damping cage) Rotor damping cage q-axis leakage inductance, in H
Ns/Nf (effective) Stator-field winding effective turns ratio
Number of Poles P Number of Poles P
Moment of Inertia Moment of inertia J of the machine, in kg*m2
Torque Flag Output flag for internal developed torque Tem
Master/slave Flag Master/slave flag of the machine (1: master; 0: slave)
All the parameters are referred to the stator side.
For more details on the definition and use of the master/slave flag, refer to Section 2.8.1.
The equations of the synchronous machine can be expressed as follows:
d-
V = R ⋅ I + ----
dt λ
where
T T
V = va vb vc vf 0 0 I = i a i b i c i f i dr i qr
T
R = diag R s R s R s R f R dr R qr λ = λ a λ b λ c λ f λ dr λ qr
and
Lo 2π Lo 2π
L s + L o + L 2 cos ( 2θ r ) – ----- + L 2 cos ⎛ 2θ r – ------⎞ – ----- + L 2 cos ⎛ 2θ r + ------⎞
2 ⎝ 3⎠ 2 ⎝ 3⎠
L 2π 2π L
L 11 = – ----o- + L 2 cos ⎛ 2θ r – ------⎞ L s + L o + L 2 cos ⎛ 2θ r + ------⎞ – ----o- + L 2 cos ( 2θ r )
2 ⎝ 3⎠ ⎝ 3⎠ 2
L 2π L 2π
– ----o- + L 2 cos ⎛ 2θ r + ------⎞ – ----o- + L 2 cos ( 2θ r ) L s + L o + L 2 cos ⎛ 2θ r – ------⎞
2 ⎝ 3⎠ 2 ⎝ 3⎠
L f L fdr 0
L 22 = L fdr L dr 0
0 0 L qr
Image:
b Shaft Node
Parameters Description
Rs (stator resistance) Stator winding resistance, in Ohm
Ld (d-axis ind.) Stator d-axis inductance, in H
Lq (q-axis ind.) Stator q-axis inductance, in H.
The d-q coordinate is defined such that the d-axis passes through the center of the
magnet, and the q-axis is in the middle between two magnets. The q-axis is leading
the d-axis.
Vpk / krpm Peak line-to-line back emf constant, in V/krpm (mechanical speed).
The value of Vpk/krpm should be available from the machine data sheet. If this data
is not available, it can be obtained through an experiment by operating the machine
as a generator at 1000 rpm and measuring the peak line-to-line voltage.
No. of Poles P Number of poles P
Moment of Inertia Moment of inertia J of the machine, in kg*m2
Mech. Time Constant Mechanical time constant τmech
Torque Flag Output flag for internal developed torque Tem
Master/slave Flag Master/slave flag of the machine (1: master; 0: slave)
The node assignments of the image are: Nodes a, b, and c are the stator winding terminals for Phase a, b, and c,
respectively. The stator windings are Y connected, and Node n is the neutral point. The shaft node is the
connecting terminal for the mechanical shaft. They are all power nodes and should be connected to the power
circuit.
For more details on the definition and use of the master/slave flag, refer to Section 2.8.1.
The equations of the permanent-magnet synchronous machine are:
va Rs 0 0 ia λa
d
vb = 0 Rs 0 ⋅ ib + ----
- λ
dt b
vc 0 0 Rs ic λc
where va, vb, vc, and ia, ib, and ic, and λa, λb, λc are the stator phase voltages, currents, and flux linkages,
respectively, and Rs is the stator phase resistance. The flux linkages are further defined as:
cos ( θ r )
λa L aa L ab L ac ia 2π
cos ⎛ θ r – ------⎞
λ b = L ba L bb L bc ⋅ i b + λ pm ⋅ ⎝ 3⎠
λc L ca L cb L cc ic 2π
cos ⎛ θ r + ------⎞
⎝ 3⎠
where θr is the rotor electrical angle, and λpm is a coefficient which is defined as:
60 ⋅ V pk ⁄ krpm
λ pm = --------------------------------------
-
3 ⋅ π ⋅ P ⋅ 1000
where P is the number of poles.
The stator self and mutual inductances are rotor position dependent, and are defined as:
L aa = L s + L o + L 2 ⋅ cos ( 2θ r )
2π 2π
sin ( 2θ r ) sin ⎛ 2θ r – ------⎞ sin ⎛ 2θ r + ------⎞ sin ( θ r )
⎝ 3⎠ ⎝ 3⎠
ia 2π
P
T em = – --- ⋅ L 2 ⋅ i a i b i c ⋅ sin ⎛ 2θ r – 2π
P sin ⎛ θ r – ------⎞
------⎞ sin ⎛ 2θ r + 2π
------⎞ sin ( 2θ r ) ⋅ i b – --- ⋅ λ pm ⋅ i a i b i c ⋅ ⎝ 3⎠
2 ⎝ 3⎠ ⎝ 3⎠ 2
ic 2π
2π 2π sin ⎛ θ r + ------⎞
sin ⎛ 2θ r + ------⎞ sin ( 2θ r ) sin ⎛ 2θ r – ------⎞ ⎝ 3⎠
⎝ 3⎠ ⎝ 3⎠
where B is a coefficient, Tload is the load torque, and P is the no. of poles. The coefficient B is calculated from
the moment of inertia J and the mechanical time constant τmech as below:
J
B = ------------
τ mech
b Shaft Node
c
n
Attributes:
Parameters Description
Rs (stator resistance) Stator winding resistance, in Ohm
Ls (stator leakage ind.) Stator d-axis inductance, in H
Vpk / krpm Peak line-to-line back emf constant, in V/krpm (mechanical speed).
This value should be available from the machine data sheet. If not, it can be
obtained through experiment by operating the machine as a generator at 1000 rpm
and measuring the peak line-to-line voltage.
No. of Poles P Number of poles P
Moment of Inertia Moment of inertia J of the machine, in kg*m2
Mech. Time Constant Mechanical time constant τmech, in sec. It is associated with the friction coefficient
B as: B = J / τmech.
Ld Lookup Table File File name of the lookup table for Ldm
Lq Lookup Table File File name of the lookup table for Lqm
dq Flag Flag for the lookup table. When the flag is 0, Ldm and Lqm are function of Id and Iq.
When the flag is 1, Ldm and Lqm are function of the current magnitude Im and the
angle.
Transformation Flag Flag for the transformation convention (see details below)
Torque Flag Output flag for internal developed torque Tem
Master/Slave Flag Master/slave flag of the machine (1: master; 0: slave)
For more details on the definition and use of the master/slave flag, refer to Section 2.8.1.
The relationship between the d-axis and q-axis inductances Ld and Lq and the magnetizing inductances Ldm and
Lqm is as follows:
L d = L s + L dm
L q = L s + L qm
where Ls is the stator leakage inductance. Since Ls is normally very small, Ld can be considered equivalent to
Ldm, and Lq can be considered equivalent to Lqm.
The Transformation Flag defines the transformation convention between the abc frame and the dq frame. When
the Transformation Flag is 0:
2 2
Im = Id + Iq
θ m = atan 2 ( I q, I d )
2π 2π
cos ( θ r ) cos ⎛ θ r – ------⎞ cos ⎛ θ r + ------⎞ ia
Id 2 ⎝ 3⎠ ⎝ 3⎠
= --- ⋅ ⋅ ib
Iq 3 2π 2π
– sin ( θ r ) – sin ⎛ θ r – ------⎞ – sin ⎛ θ r + ------⎞ ic
⎝ 3⎠ ⎝ 3⎠
2 2 2
Im = --- ⋅ I d + I q
3
θ m = atan 2 ( – I d, I q )
Image:
a+
a-
b+
b- Shaft Node
c+
c-
Attributes:
Parameters Description
Resistance Stator phase resistance R, in Ohm
Inductance Lmin Minimum phase inductance Lmin, in H
Inductance Lmax Maximum phase inductance Lmax, in H
Theta_min Duration of the interval θmin where the inductance is at the minimum, in deg.
Theta_max Duration of the interval θmax where the inductance is at the maximum, in deg.
Stator Pole Number Number of stator poles (teeth)
Rotor Pole Number Number of rotor poles (teeth)
Moment of Inertia Moment of inertia J of the machine, in kg*m2
Torque Flag Output flag for internal torque Tem
Master/Slave Flag Master/slave flag of the machine (1: master; 0: slave)
For more details on the definition and use of the master/slave flag, refer to Section 2.8.1.
The node assignments are: Nodes a+, a-, b+, b-, and c+, c- are the stator winding terminals for Phase a, b, and c,
respectively. The shaft node is the connecting terminal for the mechanical shaft. They are all power nodes and
should be connected to the power circuit.
The equation of the switched reluctance machine for one phase is:
d(L ⋅ i)
v = i ⋅ R + -----------------
dt
where v is the phase voltage, i is the phase current, R is the phase resistance, and L is the phase inductance. The
phase inductance L is a function of the rotor angle θ (in electrical deg.), as shown in the following figure. The
inductance profile is half-wave symmetrical. That is, it repeats itself after 180o.
Lmin
θrf θmin
The rotor angle is defined such that, when the stator and the rotor teeth are completely aligned, θ = 0. The value
of the inductance can be in either rising stage, flat-top stage, falling stage, or flat-bottom stage.
If we define the constant k as the rising slope of the inductance from Lmin to Lmax (which is the same as the
falling slope from Lmax to Lmin), and the interval of the rising/falling slope is θrf, we can express the inductance
L as a function of the rotor angle θ (from 0 to 180o) as follows:
max θ
L = L max for 0 ≤ θ ≤ ----------
2
-
θ max⎞ θ θ
L = L max – k ⋅ ⎛ θ – ----------
max max
- - ≤ θ ≤ ----------
for ---------- - + θ rf
⎝ 2 ⎠ 2 2
θ
max θ
max
L = L min - + θ rf ≤ θ ≤ ----------
for ---------- - + θ rf + θ min
2 2
θ max θ max θ max
L = L min + k ⋅ ⎛ θ – ----------
- – θ rf – θ min⎞ for ----------
- + θ rf + θ min ≤ θ ≤ ----------
- + 2θ rf + θ min
⎝ 2 ⎠ 2 2
θ max
L = L max for ----------- + 2θ rf + θ min ≤ θ ≤ 180 o
2
The developed torque of the machine per phase is:
1 2 dL
T em = --- ⋅ i ⋅ ------
2 dθ
Based on the inductance expression, we have the developed torque in each stage as:
Tem = i2*k / 2 [rising stage]
Tem = 0 [flat-top stage]
a+
a-
b+
b- Shaft Node
c+
c-
Attributes:
Parameters Description
Resistance Stator phase resistance R, in Ohm
Stator Pole Number Number of stator poles (teeth)
Rotor Pole Number Number of rotor poles (teeth)
Inductance Table File The file that stores the 2-dimensional table of the inductance versus the rotor
position and the current.
Moment of Inertia Moment of inertia J of the machine, in kg*m2
Torque Flag Output flag for internal torque Tem
Master/Slave Flag Master/slave flag of the machine (1: master; 0: slave)
The inductance table file has the following format:
m, n
θ1, θ2, ..., θm
I1, I2, ..., In
L1,1, L1,2, ..., L1,n
L2,1, L2,2, ..., L2,n
... ... ...
Lm,1, Lm,2, ..., Lm,n
where m is the number of rows and n is the number of columns; θ1 to θm is the row vector for the rotor position
(in deg.), and I1 and In is the column vector for the phase current (in A); and Li,j is the inductance value (in H) at
Row i and Column j. For example, when the rotor position is θ2 and the phase current is I1, the inductance is
L2,1.
Because of the half-wave symmetry, only inductance values from 0 to 180o need to be provided. Note that the
row vector and column vector must be monotonically increasing.
The machine equations are the same as these in the linear switched reluctance machine model.
Image:
Attributes:
Parameter Description
Netlist XML File The XML file that defines the interface between PSIM and JMAG. It has the .xml
extension.
JMAG Input File The JMAG input data file. It has the .jcf extension. Note that the .xml and .jcf files
must be in the same directory.
Parameter Description
dt_of_JMAG Time step used in JMAG.
Ir Rated current. It is used in JMAG
dl_threshold Current threshold. It is used in JMAG
dr_threshold Displacement threshold. It is used in JMAG
MomentofInertia Moment of inertia of the machine, in kg*m2.
MechTimeConstant Mechanical time constant of the machine, in sec.
Back emf Flag Display flag for all FEM coil currents (1: display; 0: no display)
Rotor Angle Flag Display flag for all shaft angles
Speed Flag Display flag for all shaft speeds
Torque Flag Display flag for all developed torques
shaft1 Master Flag Master/slave flag of the machine (1: master; 0: slave)
Please consult JMAG manuals and documents on how to set up the co-simulation on the JMAG side.
Image:
Block with 4 inputs and 4 outputs
Parameter Description
Link Table File The XML file that defines the interface between PSIM and JMAG. It has the .xml
extension.
JMAG Input File The JCF input data file for JMAG. It has the .jcf extension. Note that the .xml file
and the .jcf file must be in the same directory.
JMAG Case Text Comments for the JMAG circuit
IN Nodes Nodes that pass the values from PSIM to JMAG
OUT Nodes Nodes that pass the values from JMAG to PSIM
The number of input and output nodes may vary, depending on the actual number of input/output nodes in a
particular circuit.
The MagCoupler block accepts voltages, currents, and positions as inputs, and it provides voltages, currents,
positions, torques, and force as the outputs. In PSIM, the MagCoupler block is a power circuit element. The
way it interfaces with the rest of the circuit is that both the inputs and outputs are voltage signals (no electric
current flows into the input node). To convert a branch current into a voltage signal, or vice versa, one can use a
current-controlled voltage source, or voltage-controlled current source.
The Link Table File, in XML format, defines the input/output interface and corresponding functions in JMAG.
This file is generated automatically by JMAG. To locate this file, click on the browse button at the right of
the edit field.
The JMAG Input File is the JCF input data file that is read by the JMAG solver. The name is defined in the Link
Table File.
Note that JCF input file .jcf must be in the same directory as the input link table file .xml. If any material
database is used in JMAG, it should also be placed in the directory of the .xml file. Also, the .xml file does not
have to be in the same directory as the schematic file. However, if a .xml file with the same name is present in
the schematic directory, PSIM will read the one in the schematic directory first.
The JMAG Case Text is a text identifying the specific JMAG circuit. It can be any text describing the JMAG
circuit.
The IN Nodes are the nodes through which PSIM passes the values to JMAG. In the MagCoupler block image,
the order of the input nodes is from the top to the bottom. The order can be changed by highlighting the node
and click on the upper or down arrow.
The OUT Nodes are the nodes through which JMAG passes the values back to PSIM. In the MagCoupler block
image, the order of the output nodes is from the top to the bottom. The order can be changed by highlighting the
node and click on the upper or down arrow.
By clicking on the Edit Image button, one can edit and customize the image of the MagCoupler block. Clicking
on the Display File button will display the Link Table File in the Microsoft Internet Explorer environment, and
clicking on the Read File button will read or re-load the Link Table File.
The setup process of calling JMAG in PSIM through the MagCoupler block is as follows.
In JMAG:
- In the JMAG circuit, connect a voltage function to the right of the FEM coil. Under Electrical
Potential in the property window, choose Constant Value, and set Constant Value[V] to 0.
- Connect a current probe to the left of the FEM coil.
- Connect another voltage function to the left of the current probe (the circuit will look like what is
shown above). In the property window, choose Cooperates with an external circuit simulator.
- Highlight the inductor structure window. Go to the menu Conditions -> Create Conditions. From the
Conditions List, highlight Coupled External Circuit Simulator, and click Modify.
- On the Coupled External Circuit Simulator dialog window, there are two lists. The list on the right,
called JMAG, contains all the functions that can be used to interface with PSIM. The list on the left,
called External Circuit Simulator, contains the functions that are selected to interface with PSIM. In
this case, there are two items in the JMAG list, one is the Voltage Function, and the other is the
Current Probe.
- Highlight the Voltage Function, and click on the <- button to move the item from the list on the right to
the list on the left. Repeat the same step to the Current Probe. Now both items should appear in the list
on the left.
- Highlight the Voltage Function, and change the terminal name to VL. Also, change the Current Probe
In PSIM:
- After the rest of the power circuit is created, go to Elements -> Power -> MagCoupler Module, and
select MagCoupler Block. Place the block on the schematic.
- Double click on the MagCoupler block to bring out the property window. click on the browser button
next to the Link Table File edit field to locate and select the file "inductor_jmag.xml". After the
file is read, the property window will display the IN node VL and the OUT node iL.
- Connect the MagCouple block to the rest of the circuit in the schematic.
The setup is now complete and the simulation is ready to run.
Images:
PMSM Step Machine
A B C A+ C+ A- C-
B+ D+ B- D-
M- M+ M- M+
M- M+ M- M+
Attributes:
Parameter Description
Netlist XML File The XML file that defines the interface between PSIM and JMAG-RT. It has the
.xml extension.
JMAG-RT Input File The JMAG-RT data file. It has the .rtt extension. Note that the .xml file and the .rtt
file must be in the same directory.
Parameter Description
shaft1_MomentofInertia Moment of inertia of the machine, in kg*m2
shaft1_MechTimeConstant Mechanical time constant of the machine, in sec.
RU_resistance Resistance of Phase U, in Ohm
RV_resistance Resistance of Phase V, in Ohm
RW_resistance Resistance of Phase W, in Ohm
OffsetAngle Initial rotor angle, in mechanical deg.
coef_inductance Inductance coefficient (used in JMAG-RT)
coef_flux Flux coefficient (used in JMAG-RT)
coef_torque Torque coefficient (used in JMAG-RT)
coef_magnet Magnet coefficient (used in JMAG-RT)
coef_material Material coefficient (used in JMAG-RT)
turns_coil1 Coil 1 turns (used in JMAG-RT)
turns_coil2 Coil 2 turns (used in JMAG-RT)
Current Flag Display flag for 3-phase FEM coil currents (1: display; 0: no display)
Back emf Flag Display flag for 3-phase FEM coil back emf
Parameter Description
RA+ Resistance of Phase A+, in Ohm
RA- Resistance of Phase A-, in Ohm
RB+ Resistance of Phase B+, in Ohm
RB- Resistance of Phase B-, in Ohm
MomentofInertia Moment of inertia of the machine, in kg*m2
MechTimeConstant Mechanical time constant of the machine, in sec.
OffsetAngle Initial rotor angle, in mechanical deg.
turns_coil2 Coil 2 turns (used in JMAG-RT)
coef_inertia1 Inertia 1 coefficient (used in JMAG-RT)
coef_inertia2 Inertia 2 coefficient (used in JMAG-RT)
Current Flag Display flag for 3-phase FEM coil currents (1: display; 0: no display)
Back emf Flag Display flag for 3-phase FEM coil back emf
Rotor Angle Flag Display flag for the rotor angle in mechanical deg.
Speed Flag Display flag for the shaft mechanical speed in rad./sec.
Torque Flag Display flag for the developed torque in N*m
shaft1 Master Flag Master/slave flag of the machine (1: master; 0: slave)
The parameters of a linear solenoid is shown below:
Parameter Description
RA Resistance of the solenoid, in Ohm
Mass Mass of the solenoid, in kg
MechTimeConstant Mechanical time constant of the solenoid, in sec.
SpringConstant Spring constant of the solenoid (used in JMAG-RT)
DispLimitMax Maximum limit of the displacement of the solenoid, in m
DispLimitMin Minimum limit of the displacement of the solenoid, in m
OffsetDisp Initial displacement, in m
turns_coil2 Coil 2 turns (used in JMAG-RT)
coef_mass1 Mass 1 coefficient (used in JMAG-RT)
coef_mass2 Mass 2 coefficient (used in JMAG-RT)
Current Flag Display flag for 3-phase FEM coil currents (1: display; 0: no display)
Back emf Flag Display flag for 3-phase FEM coil back emf
Parameter Description
RU Resistance of Phase U, in Ohm
RV Resistance of Phase V, in Ohm
RW Resistance of Phase W, in Ohm
Mass Mass of the machine, in kg
MechTimeConstant Mechanical time constant of the solenoid, in sec.
OffsetDisp Initial displacement, in m
coef_inductance Inductance coefficient (used in JMAG-RT)
coef_flux Flux coefficient (used in JMAG-RT)
coef_force Torque coefficient (used in JMAG-RT)
coef_magnet Magnet coefficient (used in JMAG-RT)
coef_material Material coefficient (used in JMAG-RT)
turns_coil1 Coil 1 turns (used in JMAG-RT)
turns_coil2 Coil 2 turns (used in JMAG-RT)
coef_mass1 Mass 1 coefficient (used in JMAG-RT)
coef_mass2 Mass 2 coefficient (used in JMAG-RT)
Current Flag Display flag for 3-phase FEM coil currents (1: display; 0: no display)
Back emf Flag Display flag for 3-phase FEM coil back emf
Position Flag Display flag for the solenoid position in m
Velocity Flag Display flag for the solenoid velocity in m/sec.
Force Flag Display flag for the developed force in N
mass1 Master Flag Master/slave flag of the solenoid (1: master; 0: slave)
In all the parameter definitions above, except the flags (current flag, back emf flag, rotor angle/position flag,
speed/velocity flag, torque/force flag, and master flag), all other parameters are read from the .rtt file defined in
the XML file. These values can be changed, and for these parameters noted with "used in JMAG-RT", the
changed values will be sent back to JMAG-RT for calculation.
Several MagCoupler-RT examples are provided under the "examples\MagCoupler-RT" folder.
Image:
Attributes:
Parameters Description
Constant Torque Torque constant Tconst, in N*m
Moment of Inertia Moment of inertia of the load, in kg*m2
If the reference direction of a mechanical system enters the dotted terminal, the load is along the reference
direction, and the loading torque to the master machine is Tconst. Otherwise the loading torque will be -Tconst.
See Section 2.6.1 for more detailed explanation on the reference direction.
A constant-torque load is expressed as:
T L = T const
Image:
Attributes:
Parameters Description
Maximum Torque Maximum torque Tmax of the load, in N*m
Base Speed Base speed nbase of the load, in rpm
Moment of Inertia Moment of inertia of the load, in kg*m2
The torque-speed curve of a constant-power load is shown below:
Torque
(N*m)
When the mechanical speed is less than the base speed nbase, the load torque is:
T L = T max
When the mechanical speed is above the base speed, the load torque is:
P
T L = ----------
ωm
Image:
Attributes:
Parameters Description
Constant Speed (rpm) Speed constant, in rpm
Moment of Inertia Moment of inertia of the load, in kg*m2
A constant-speed mechanical load defines the speed of a mechanical system, and the speed will remain
constant, as defined by the speed constant.
Image:
Attributes:
Parameters Description
Tc Constant torque term
k1 (coefficient) Coefficient for the linear term
Image:
Attributes:
Parameters Description
Speed Flag Flag for speed dependency
Flag = 0: The load is frictional and is always against the rotational direction;
Flag = 1: The load is independent of the rotational direction.
Moment of Inertia Moment of inertia of the load, in kg*m2
The value of the mechanical load is defined by the voltage value at the control node (1V corresponds to 1 N*m).
This node is a control circuit node.
Image:
Shaft 1
Shaft 2
Attribute:
Parameter Description
Gear Ratio The gear ratio a
Shaft 1 Master/Slave Flag Master/slave flag for Shaft 1
Shaft 2 Master/Slave Flag Master/slave flag for Shaft 2
The shaft with the bigger dot is Shaft 1.
Image:
This block is used in situations where both mechanical systems have a device in the master mode, and they must
be connected together to form one system. Based on the connection convention in PSIM, a mechanical system
can have only one master device. In this case, the mechanical coupling block can be inserted in between, and
the mechanical system on each side of the coupling block can have its own device in the master mode.
Image:
Attribute:
Parameter Description
Master/Slave Flag Flag for the master/slave mode (1: master, 0: slave)
Similar to electric machines, the mechanical-electrical interface block can be used to define the reference
direction of a mechanical system through the master/slave flag. When the interface block is set to the master
mode, the reference direction is along the mechanical shaft, away from the mechanical node, and towards the
rest of the mechanical elements.
Let’s assume that a drive system consists of a motor (with a developed torque of Tem and a moment of inertia of
J1) and a mechanical load (with a load torque of Tload and a moment of inertia of J2). The equation that
describes the mechanical system is:
dω m
( J 1 + J 2 ) ⋅ ---------- = T em – T load
dt
where ωm is the shaft mechanical speed. In PSIM, this equation is modelled by an equivalent circuit as shown
below.
ωm speed node
Tem J1 J2 Tload
Wm
Mechanical
speed
Images:
Parameter Description
Gain Gain of the sensor
The output of the speed sensor is in rpm.
The output of the speed/torque sensor depends on how the sensor is connected in a mechanical system.
For the speed sensor, if the sensor is along the reference direction of the mechanical system (refer to Section
2.8.1 for more details on the definition and use of the reference direction), a positive mechanical speed would
give a positive sensor output. Otherwise, if the sensor is opposite to the reference direction of the mechanical
system, a positive mechanical speed would give a negative sensor output.
For example, in the mechanical system below, Speed Sensor 1 is along the reference direction, and Speed
Sensor 2 is opposite to the reference direction of the mechanical system. If the actual mechanical speed is
positive, the output of Speed Sensor 1 will be positive, and the output of Speed Sensor 2 will be negative.
Reference direction of the mechanical system
The torque sensor measures the torque difference between the dotted side of the sensor and the undotted side.
To understand the physical meaning of the torque sensor measurement, we use the diagram below as an
illustration.
The figure on the left shows a torque sensor connected with a 10-N*m mechanical load, and the reference
direction of the mechanical system is from left to right. Based on the reference direction, if we use the right-
hand method, by pointing the thumb in the reference direction and rotating the right hand, the direction of the
fingers will show the direction of the positive speed and torque. The physical interpretation of the system is
shown on the right.
10 Wm Load
10
Torque sensor
In this case, the direction of the positive speed and torque is in the clockwise direction. The dotted side of the
sensor is on the left, and the load is in such a way that it tries to slow down the shaft (the load torque is in the
counter-clockwise direction).
The physical meaning of the torque sensor is that, if the dotted side of the sensor is fixed, the sensor will
measure the torque tension on the undotted side of the sensor, and a positive sensor output would mean that the
torque is opposite to the direction of the speed reference. Therefore, for the example above, the positive speed
reference is in the clockwise direction, and the load torque is in the counter-clockwise direction. This will give
a torque sensor reading of 10 N*m.
Similarly, if the undotted side of the sensor is fixed, the sensor will measure the torque tension on the dotted
side of the sensor, in the positive direction of the speed reference. For example, in the system below, the torque
sensor is flipped with the dotted side on the right. If the undotted side is fixed, the load torque is applied to the
dotted side of the sensor, in the opposite direction of the speed reference. The torque sensor output will be -10
N*m instead.
10 Wm Load
10
Torque sensor
To understand how the torque sensor is modeled in the equivalent circuit of the mechanical system, we use the
following system as an example.
Load 1 Load 2
Sensor 1 Sensor 2
The system consists of one machine, 2 torque sensors, and 2 mechanical loads. The torques and moment of
inertia for the machine and the loads are as labelled in the diagram. The reference direction of this mechanical
system is from left to right. The equation for this system can be written as:
dω
( J + J L1 + J L2 ) ⋅ ---------m- = T em – T L1 – T L2
dt
The equivalent electrical circuit of the equation is shown below:
Sensor 1 Sensor 2
ωm
The node voltage in the circuit represents the mechanical speed ωm. The current probe on the left represents the
reading of the Torque Sensor 1. Similarly, the current probe on the right represents the reading of the Torque
Sensor 2. Note that the second current probe is from right to left since Sensor 2 is opposite to the reference
direction of the mechanical system.
The equivalent circuit also illustrates how mechanical power is transferred. The multiplication of the current to
the voltage, which is the same as the torque times the mechanical speed, represents the mechanical power. If the
power is positive, it is transferred in the direction of the speed ωm.
Attribute:
Parameter Description
Initial Position (deg.) Initial shaft position, in deg.
No. of Bits of Resolution Number of Bits of resolution N
The encoder output resolution is determined by the number of bits N. The encoder has two outputs: one is the
number of counts (the range is from 0 to 2N-1), and the other is the position, in mechanical deg. (the range is
from 0 to 360o).
An example of a PMSM drive system using the absolute encoder is given in the sample file "Absolute Encoder
PMSM Drive.sch".
Image:
Attribute:
Parameter Description
Initial Position (deg.) Initial shaft position, in deg.
No. of Lines Number of lines that are in the code pattern of the code disk of the encoder
The two quadrature outputs are A and A (A is the inverse of A), and B and B. They are offset by 90o. In
addition, the encoder provides separate index signal output Z and Z that provide one count per revolution.
An example of an induction motor drive system using the incremental encoder is given in the sample file
"Incremental Encoder INDM Drive.sch".
2.11.6.3 Resolver
A resolver is essentially a rotary transformer with one rotor winding and two stator windings. These two stator
windings, referring to as the COS winding and SIN winding, are located 90o apart.
As the shaft rotates, the output voltages of the COS and SIN windings vary as the cosine and sine functions of
the shaft angle.
cos+
sin+
cos-
sin-
Attribute:
Parameter Description
Initial Position (deg.) Initial shaft position, in deg.
No. of Poles Number of poles of the resolver
The resolver has four outputs: cos+, cos- (the inverse of cos+), sin+, and sin- (the inverse of sin+). The peak
amplitude of all the outputs is 1.
An example of a PMSM drive system using the resolver is given in the sample file "Resolver PMSM
Drive.sch".
Image:
Attribute:
Parameter Description
Initial Position (deg.) Initial shaft position, in deg.
No. of Poles Number of poles of the sensor
The hall effect sensor provides three logic signal outputs A, B, and C, which are spaced 120 electrical deg.
apart.
The hall effect sensor is the same as the built-in hall effect sensor in the brushless dc machine.
Examples of BDCM motor drive systems using the hall effect sensor are given in the "examples" sub-folder of
the PSIM directory.
Images:
Physical Model Functional Model
Pmax Pmax
Light Intensity
Ambient Temperature
Parameter Description
Standard Light Intensity S0 Standard light intensity S0, in W/m2. The value is normally 1000 W/m2 in
standard test condition, and is 200 W/m2 in low light intensity test
condition.
Ref. Temperature Tref The reference temperature Tref, in oC.
Series Resistance Rs The series resistance Rs, in Ohm.
Shunt Resistance Rsh The shunt resistance Rsh, in Ohm.
Short Circuit Current Ish0 Short circuit current Ish0, in A.
Diode Reverse Current Id0 Diode reverse current Id0, in A.
Band Energy Eg Band energy of the solar cell, in eV.
Temperature Coefficient Ct Temperature coefficient Ct, in A/K
Coefficient ks Coefficient ks that defines how light intensity affects the solar cell
temperature.
Coefficient A Coefficient A used in the model.
Parameter Description
Open Circuit Voltage Voc Voltage measured when the solar cell terminals are open circuit, in V
Short Circuit Current Isc Current measured when the solar cell terminals are short circuit, in A
Maximum Power Voltage Vm Solar cell terminal voltage when the output power is at the maximum, in V.
Maximum Power Current Im Solar cell terminal current when the output power is at the maximum, in A.
6.00
5.00
Current
4.00
3.00
Maximum Power Point
2.00
1.00
Power
300.00
250.00
Power 200.00
150.00
100.00
50.00
0.0
1. Voltage
V
S. Heier and R. Waddington, Grid Integration of Wind Energy Conversion Systems, Wiley, 2006
Images:
Wind Turbine
Wind Speed
Pitch Angle
Attributes:
Parameter Description
Nominal Output Power The maximum output power of the wind turbine, in W, at 0o pitch angle. This
power is considered as the maximum power operating point of the turbine,
and it should not exceed the rated power of the generator.
Base Wind Speed The base wind speed that would produce the nominal output power, in m/s
Base Rotational Speed The base rotational speed of the turbine that would produce the nominal
output power, in rpm
Initial Rotational Speed The initial rotational speed of the turbine, in rpm
Moment of Inertia Moment of inertia of the wind turbine blade, in kg*m2
Torque Flag Flag to display the internal torque of the wind turbine (0: no display; 1:
display)
Master/Slave Flag Master/slave flag for the connected mechanical system (0: slave; 1: master)
In the image, the node with the letter "w" is for the wind speed input in m/s, and the node with the letter "p" is
for the blade pitch angle input in deg. Both nodes are control circuit nodes.
The power generated by a wind turbine can be expressed as:
1 3
P = --- ⋅ A ⋅ v wind ⋅ ρ ⋅ C p
2
where A is the area of the rotor blade, vwind is the wind speed, ρ is the air density, and Cp is the power
coefficient. The power coefficient Cp is a function of the tip speed ratio λ and the blade pitch angle β. It can be
expressed as [Heier1]:
x –c6
Cp = c1 ⋅ ( c2 – c3 β – c4 β – c5 ) ⋅ e + c7
Cp 0.20 β=10ο
0.10
0.0
The figure shows that the power coefficient Cp reaches the maximum of 0.49 when the tip speed
ratio λ is 8.18. We choose the values of Cp and λ at the maximum as the nominal values, i.e., Cp_nom
= 0.49, λnom = 8.18. One way to control the wind turbine, therefore, is to maintain the tip speed
ratio at or close to the nominal value so that the power that the wind turbine generates is at the
maximum.
Two types of transfer function blocks are provided: one with zero initial values (the element is called s-domain
Transfer Function in the PSIM library) and the other with initial values as input parameters (called s-domain
Transfer Function (initial value) in the PSIM library).
Images:
Attributes:
Parameters Description
Order n Order n of the transfer function
Gain Gain k of the transfer function
Coeff. Bn...Bo Coefficients of the numerator (from Bn to Bo)
Coeff. An...Ao Coefficients of the denominator (from An to Ao)
Initial Values xn..x1 Initial values of the state variables xn to x1 (for the element s-domain Transfer
Function (initial value) only)
Let Y(s) = G(s)*U(s) where Y(s) is the output and U(s) is the input, we can convert the s-domain expression into
the differential equation form as follows:
x1 0 0 0 ... 0 –A0 ⁄ An x1 B0 – A0 ⋅ Bn ⁄ An
x2 1 0 0 ... 0 –A1 ⁄ Anx2 B1 – A1 ⋅ Bn ⁄ An
d- k
---- = 0 ... 0 – A 2 ⁄ A n ⋅ + ----- ⋅ B2 – A2 ⋅ Bn ⁄ An ⋅u
dt x 3 0 1 x3 A
n
... ... ... ... ... ... ... ... ...
xn 0 0 0 ... 1 – A n – 1 ⁄ A n xn Bn – 1 – An – 1 ⋅ Bn ⁄ An
The initial values of the state variables xn to x1 can be specified as the inputs in the element s-domain Transfer
Function (initial value).
Example:
The following is a second-order transfer function:
Order n 2
Gain 1.5
Coeff. Bn...Bo 0. 0. 400.e3
Coeff. An...Ao 1. 1200. 400.e3
Image:
Attribute:
Parameter Description
Gain Gain k of the transfer function
3.1.2 Integrator
There are three types of integrators: regular integrator, external resettable integrator, and internal resettable
integrator.
Images:
Regular Integrator External Resettable Integrator Internal Resettable Integrator
Attributes:
Parameters Description
Time Constant Time constant T of the integrator, in sec.
Initial Output Value Initial value of the output
Parameters Description
Time Constant Time constant T of the integrator, in sec.
Initial Output Value Initial value of the output
Reset Flag Reset flag (0: edge reset; 1: level reset)
Parameters Description
Time Constant Time constant T of the integrator, in sec.
Initial Output Value Initial value of the output
Lower Output Limit Lower limit of the output
Upper Output Limit Upper limit of the output
The transfer function of an integrator is:
1
G ( s ) = ------
sT
The Bode plot of the amplitude |G| and the phase angle Φ of the integrator is shown as below:
|G|
1/T
0 ω (rad/sec)
-20dB/dec
Φ
0 ω
-90o
The output of the external resettable integrator can be reset by an external control signal (at the bottom of the
block). For the edge reset (reset flag = 0), the integrator output is reset to zero at the rising edge of the control
signal. For the level reset (reset flag = 1), the integrator output is reset to zero as long as the control signal is
high (1).
The output of the internal resettable integrator is reset to 0 when the output reaches either the lower limit or the
upper limit. It works in the same way as the external resettable integrator with the edge reset, except that in this
case users do not need to set up the external reset circuit.
To avoid over saturation, a limiter should be placed at the integrator output.
Example:
The following circuit illustrates the use of the resettable integrator. The input of the integrator is a dc quantity.
The control input of the integrator is a pulse waveform which resets the integrator output at the end of each
cycle. The reset flag is set to 0.
Vd
vo
vctrl
Image:
Attribute:
Parameter Description
Time Constant Time constant T of the differentiator, in sec.
Since sudden changes of the input will generate spikes at the output, it is recommended that a low-pass filter be
placed at the input of the differentiator.
Image:
Attributes:
Parameters Description
Gain Gain k of the PI controller
Time Constant Time constant T of the PI controller
The transfer function of a PI controller is defined as:
1 + sT
G ( s ) = k ⋅ ---------------
sT
The Bode plot of the amplitude |G| and the phase angle Φ of the PI controller is shown as below:
|G| -20dB/dec
0 ω (rad/sec)
1/T
Φ
0 ω
-90o
Image:
Attributes:
Parameters Description
Gain Gain k of the controller
Pole Frequency Frequency of the pole fc, in Hz
where ω c = 2πf c .
The Bode plot of the amplitude |G| and the phase angle Φ of the single-pole controller is shown as below:
|G|
-20dB/dec
0 ωc ω (rad/sec)
Φ
0 ω
-90o
Image:
Attributes:
Parameters Description
Gain Gain k of the PI controller
Time Constant Time constant T of the PI portion of the controller
Pole Frequency Frequency of the pole fc, in Hz
|G| -20dB/dec
0 ω (rad/sec)
1/T 1/Tc -20dB/dec
Φ
0 ω
-90o
Image:
Attributes:
Parameters Description
Gain Gain k of the PI controller
Frequency fz1 Frequency fz1 of the first zero, in Hz
Frequency fz2 Frequency fz2 of the second zero, in Hz
Frequency fp1 Frequency fp1 of the first pole, in Hz
Frequency fp2 Frequency fp2 of the first pole, in Hz
1 1 1 1
where T z1 = ------------ , T z2 = ------------ , T p1 = ------------- , and T p2 = ------------- .
2πf z1 2πf z2 2πf p1 2πf p2
The Bode plot of the amplitude |G| and the phase angle Φ of the Type-3 controller is shown as below:
0 ω (rad/sec)
1/Tz1 1/Tz2 1/Tp1 1/Tp2
90o
Φ
0 ω
-90o
Images:
2nd-order low-pass 2nd-order high-pass 2nd-order band-pass 2nd-order band-stop 1st-order low-pass
Parameters Description
Gain Gain k
Damping Ratio Damping ratio ξ
ω
Cut-off Frequency Cut-off frequency fc ( f c = -----c- ) for low-pass and high-pass filters, in Hz
2π
ωo
Center Frequency Center frequency fo ( f o = ------ ) for band-pass and band-stop filter, in Hz
2π
Passing Band; B
Frequency width fb ( f b = ------ ) of the passing/stopping band for band-pass/band-
2π
Stopping Band stop filters, in Hz
Parameters Description
Gain Gain k
ω
Cut-off Frequency Cut-off frequency fc ( f c = -----c- ) of the low-pass filter, in Hz
2π
The transfer function of these filters are listed below.
For second-order low-pass filter:
2
ωc
G ( s ) = k ⋅ --------------------------------------
2
-
2
s + 2ξω c s + ω c
For second-order high-pass filter:
2
s
G ( s ) = k ⋅ --------------------------------------
2
-
2
s + 2ξω c s + ω c
For second-order band-pass filter:
B⋅s
G ( s ) = k ⋅ ---------------------------------
2
-
2
s + B ⋅ s + ωo
For second-order band-stop filter:
2 2
s + ωo
G ( s ) = k ⋅ ---------------------------------
2
-
2
s + B ⋅ s + ωo
For first-order low-pass filter:
ωc
G ( s ) = k ⋅ --------------
s + ωc
3.2.1 Summer
The input of a one-input summer or two-input summer can be either a scalar or a vector. The input of a three-
input summer can only be a scalar.
Images:
1-input 2-input 2-input 3-input
Input 1
Input 1 Input 1
Input 2
Attribute:
Parameter Description
Gain_i Gain ki for the ith input
For the three-input summer, the input with a dot is the first input.
If the inputs are scalar, the output of a summer with n inputs is defined as:
V o = k 1 V 1 + k 2 V 2 + ... + k n V n
If the input is a vector, the output of a two-input summer will also be a vector, which is defined as:
V1 = [a1 a2 ... an]
V2 = [b1 b2 ... bn]
Vo = V1 + V2 = [a1+b1 a2+b2 ... an+bn]
The output of a one-input summer, however, will still be a scalar which is equal to the summation of the input
vector elements, that is, Vo = a1 + a2 + ... an.
Images:
Multiplier Divider
Numerator
Denominator
For the divider, the dotted node is for the numerator input.
The input of a multiplier can be either a vector or a scalar. If the two inputs are vectors, their dimensions must
be equal. Let the two inputs be:
V1 = [a1 a2 ... an]
V2 = [b1 b2 ... bn]
The output, which is a scalar, will be:
Vo = V1 * V2T = a1*b1 + a2*b2 + an*bn
Image:
Images:
Exponential Power LOG LOG10
Parameters Description
Coefficient k1 Coefficient k1
Coefficient k2 Coefficient k2
For example, if k1 = 1, k2 = 2.718281828, and Vin = 2.5, then Vo = e2.5 where e is the base of the natural
logarithm.
The output of a power function block is defined as:
k2
V o = k 1 ⋅ V in
The function block LOG gives the natural logarithm (base e) of the input, and the block LOG10 gives the
common logarithm (base 10) of the input.
--1-
T 2
V rms =
T ∫0 vin ( t )dt
where T = 1/fb. The output is only updated at the beginning of each period.
Image:
Attribute:
Parameter Description
Base frequency Base frequency fb, in Hz
Images:
Absolute Sign
Images:
In the arctangent and arctangent 2 blocks, the input node marked with x is the real part, and the other input node
marked with y is the imaginary part.
The output of the arctangent and arctangent 2 blocks is the inverse tangent of the ratio between the imaginary
y
part y and the real part x, i.e. θ = tg ⎛⎝ --⎞⎠ . The output of the arctangent block is in degree, and the range is from
–1
x
o. On the other hand, the output of the arctangent 2 block is in radian, and the range is from -π to +π.
0 to 360
The arctangent 2 block behaves in the same way as the function atan2(y,x) in the C language.
∑ ⎜ v in ( n ) – v in ⎛⎝ n + ----⎞⎠ ⋅ e
N
v o = ---- ⋅ ⎟
N ⎝ 2 ⎠
n=0
Image:
Amplitude
Phase Angle
Parameters Description
No. of Sampling Points No. of sampling points N
Fundamental Frequency Fundamental frequency fb, in Hz.
The dotted node of the block refers to the output of the amplitude. Note that the phase angle output has been
internally adjusted such that a sine function Vm*sin(ωt) will give a phase angle output of 0.
Note that the FFT block only works if the input signal contains dc, the fundamental component, and harmonics
of the fundamental components (with the frequencies at multiple integer times of the fundamental frequency). If
the input signal contains another component that is not multiple integer of the fundamental frequency, the FFT
block will not give the correct result.
Also, the FFT block only measures the fundamental component, not any other harmonics. For example, if the
input signal contains 60 Hz (fundamental) and 180 Hz, if the parameter "Fundamental Frequency" is set to 180,
the FFT block output will be incorrect.
Example:
In the circuit below, the voltage vin contains a fundamental component v1 (100 V at 60 Hz), a 5th harmonic
voltage v5 (25 V at 300 Hz), and a 7th harmonic v7 (25 V at 420 Hz). After one cycle, the FFT block output
reaches the steady state with the amplitude of 100 V and the phase angle of 0o.
v1
vin vamp v1
vin
v5 Angle
v7 vamp
Angle
Image:
Attributes:
Parameters Description
Number of Inputs Number of inputs
Block Function Type Function type of the block. It can be either Maximum or Minimum.
The number of inputs can be changed through the drop-down menu.
3.3.1 Comparator
The output of a comparator is high when the positive input is higher than the negative input. When the positive
input is lower, the output is zero. If the two input are equal, the output is undefined and it will keep the previous
value.
Image:
Note that the comparator image is similar to that of the op. amp. For the comparator, the noninverting input is at
the upper left and the inverting input is at the lower left. For the op. amp., however, it is the opposite.
3.3.2 Limiters
Four types of limiters are provided to limit the amplitude of a signal: lower/upper limiter, lower limiter, upper
limiter, and range limiter.
Images:
Lower/upper Limiter Lower Limiter Upper Limiter Range Limiter
Attributes:
Parameters Description
Lower Limit Lower limit of the limiter
Upper Limit Upper limit of the limiter
For a lower/upper limiter, or lower limiter, or upper limiter, the output of the limiter is clamped to the upper or
lower limit whenever the input exceeds the limiter range. If the input is within the limit, the output is equal to
the input.
For a range limiter, let the range of the upper limit and the lower limit be Vrange. When the input is within the
limit, the output is equal to the input. When the output exceeds the upper limit, the output is subtracted by the
range Vrange until it is within the range. When the output is below the lower limit, it is added by range Vrange
until it is within the range.
Image:
Parameter Description
dv/dt Limit Limit of the rate of change (dv/dt) of the input
Images:
Attributes:
Parameters Description
Rising Angle theta Rising angle θ, in deg.
Peak Value Peak value Vpk of the waveform
Attribute:
Parameter Description
Pulse Width (deg.) Pulse width θ in half cycle, in deg.
The waveforms of these two blocks are shown below. Note that the input vin is in deg., and can be in the range
of -360o to 360o. Both waveforms are half-wave and quarter-wave symmetrical.
Vpk 1
o vin θ vin
180
0 0 o o
o
360 180 360
-Vpk -1
θ
Image:
Input
Control
The difference between this block and the zero-order hold block (ZOH) in Digital Control Module is that this
block is treated as a continuous element and sampling moments can be controlled externally; whereas the zero-
Example:
In this example, a sinusoidal input is sampled. The control signal is a square wave voltage source with an
amplitude of 1.
vin
vo
vctrl
Image:
Attributes:
Parameters Description
No. of Digits No. of digits N after the decimal point
Truncation Flag Truncation flag (1: truncation; 0: round-off)
Let the input of the round-off block be Vin. The input is first scaled based on the following expression:
N
V in, new = V in ⋅ 10
If the truncation flag is 1, the output will be equal to Vin,new truncated, and then divided by 10N. Otherwise, the
output will be equal to Vin,new rounded off to the nearest integer, and then divided by 10N.
Examples:
If Vin = 34.5678, N = 0, truncation flag = 0, then we have the output Vout = 35. Similarly, if Vin = 34.5678, N = 0,
truncation flag = 1, then Vout = 34.
If Vin = 34.5678, N = 1, truncation flag = 1, then Vout = 34.5. If Vin = 34.5678, N = -1, truncation flag = 1, then
Vout = 30.
Attribute:
Parameter Description
Delay Time Delay time, in sec. (for the Time Delay block only)
A time delay block delays the input signal by a specified amount of time interval. It, for example. can be used to
model the propagation delay of a logic element.
A unit time delay block delays the input signal by just one simulation time step. If the simulation time step is
changed, the delay time will be changed accordingly.
Note that the difference between the unit time delay block and the unit delay block in Digital Control Module is
that this block is a continuous element and the delay time is one simulation time step; whereas the unit delay
block is a discrete element and the delay time is equal to the sampling period.
For a discrete system, the unit delay block should be used.
Example:
In this circuit, the first time delay block has a delay time of 1 ms, and the second block has a delay time of 4 ms.
This example illustrates that the input of the time delay block can be either an analog or a digital signal.
1 ms
vin1
vo1
vin2
vo2
4 ms
vin2
vo2
3.3.8 Multiplexer
The output of a multiplexer is equal to a selected input depending on the control signal. Three multiplexers are
provided: multiplexers with 2 inputs; 4 inputs; and 8 inputs.
Images:
2-input 4-input 8-input
d0
d0 d0
d1
Y Y
d1 d2 Y
d3
s0 d7
s1 s0
s2 s1 s0
In the images, d0..d7 are the data inputs; and s0..s2 are the control signals. The truth tables of the multiplexers
Example:
The following circuit selects the maximum value out of two inputs. When Va is greater than Vb, the comparator
output will be 1, and Vo = Va. Otherwise Vo = Vb.
V 2
V rms – V 12
THD = -----h = --------------------------
-
V1 V1
where V1 is the fundamental component (rms), Vh is the harmonic rms value, and Vrms is the overall rms value
of the waveform. The THD block is modelled as shown below.
Image:
Vrms Vh
THD vin(t) THD
vin(t)
v1(t) V1
v1(t)
A second-order band-pass filter is used to extract the fundamental component. The center frequency and the
passing band of the band-pass filter need to be specified.
Parameters Description
Fundamental Frequency Fundamental frequency of the input, in Hz
Passing Band Passing band of the band-pass filter, in Hz
Example:
In the single-phase thyristor circuit below, a THD block is used to measure the THD of the input current. The
delay angle of the thyristor bridge is chosen as 30o. For the THD block, the fundamental frequency is set at 60
Hz and the passing band of the filter is set at 20 Hz. The simulation results are shown on the right.
vs
alpha=30 deg.
is THD
is1
One of the THD block output is the input current fundamental component is1. By comparing the phase
difference between the input voltage vs and the current is1, one can calculate the input displacement power
factor. This, together with the THD value, can be used to calculate the input power factor.
Images:
AND OR NOT XOR
Image:
Parameter Description
Trigger Flag Trigger flag (0: edge-triggered; 1: level-triggered)
An edge-triggered flip-flop only changes the states at the rising edge of the set/reset input. The truth table of an
edge-triggered flip-flop is:
S R Q Qn
0 0 no change
0 ↑ 0 1
↑ 0 1 0
↑ ↑ not used
A level-triggered flip-flop, on the other hand, changes the states based on the input level. The truth table of a
level-triggered set-reset flip-flop is:
S R Q Qn
0 0 no change
0 1 0 1
1 0 1 0
1 1 not used
Images:
A J-K flip-flop is positive edge triggered, and the truth table is:
S R J K Clock Q Qn
0 1 x x x 1 0
1 0 x x x 0 1
0 0 x x x 0 0
1 1 0 0 ↑ no change
1 1 0 1 ↑ 0 1
1 1 1 0 ↑ 1 0
1 1 1 1 ↑ Toggle
x: Do not care
Image:
Images:
Monostable Controlled Monostable
Attribute:
Parameter Description
Pulse Width On-time pulse width, in sec.
The input node at the bottom of the controlled monostable block is for the pulse width input.
Image:
Image:
Preset Enable
Preset Value
Clock Output
Up/Down
Reset
Attribute:
Parameter Description
No. of Bits Number of bits N
When the Up/Down input is 0, the counter decrements, and when the Up/Down input is 1, the counter
increments.
The Reset input resets the counter to 0 when it is high (1). The Preset Enable input sets the counter to the preset
value when it is high.
The truth table of the counter is:
Up/Down Preset Enable Reset Clock Action
x 0 0 x No count
1 0 0 ↑ Count up
0 0 0 ↑ Count down
x 1 0 x Preset
x x 1 x Reset
x: Do not care
Images:
Vin Vo Vin Vo
Clock
Let N be the number of bits. The output of the A/D converter is calculated as:
N
2
V o = --------- ⋅ V in
V ref
Image:
Attribute:
Parameter Description
Sampling Frequency Sampling frequency of the zero-order hold, in Hz
Like all other discrete elements, the zero-order hold has a free-running timer which determines the moment of
sampling. The sampling moment is synchronized with the origin of the simulation time. For example, if the
zero-order hold has a sampling frequency of 1000 Hz, the input will be sampled at 0, 1 msec., 2 msec., 3 msec.,
and so on.
Example:
In the following circuit, the zero-order hold sampling frequency is 1000 Hz. The input and output waveforms
are shown on the left.
Note that in above circuit, a continuous-domain integrator is also connected to the input sine source. This makes
it a mixed continuous-discrete circuit, and a simulation time step selected for the continuous circuit will be
used. With this time step, the familiar staircase-like waveform can be observed at the zero-order hold output.
Without the integrator, the circuit becomes a discrete circuit. Since only the calculation at the discrete sampling
points is needed, the simulation time step will be equal to the sampling period, and only the results at the
sampling points are available. The waveforms, as shown below, appear continuous. In fact the waveforms are
discrete, and the connection between two sampling points makes it look like continuous.
If a0 = 1, the expression Y(z) = H(z) * U(z) can be expressed in difference equation as:
y ( n ) = b 0 ⋅ u ( n ) + b 1 ⋅ u ( n – 1 ) + ... + b N ⋅ u ( n – N ) –
[ a 1 ⋅ y ( n – 1 ) + a 2 ⋅ y ( n – 2 ) + ... + a N ⋅ y ( n – N ) ]
Image:
Attributes:
Parameters Description
Order N Order N of the transfer function
Coeff. b0...bN Coefficients of the numerator (from b0 to bN)
Coeff. a0...aN Coefficients of the denominator (from a0 to aN)
Sampling Frequency Sampling frequency, in Hz
Example:
The following is a second-order transfer function:
3
400.e
H ( z ) = ---------------------------------------------------
2
-
3
z + 1200 ⋅ z + 400.e
Assuming a sampling frequency of 3 kHz, the specification will be:
Order N 2
Coeff. b0...bN 0. 0. 400.e3
Coeff. a0...aN 1. 1200. 400.e3
Sampling Frequency 3000.
Images:
Regular Integrator External Resettable Integrator Internal Resettable Integrator
Attribute:
Parameters Description
Algorithm Flag Flag for integration algorithm
0: trapezoidal rule
1: backward Euler
2: forward Euler
Initial Output Value Initial output value
Reset Flag Reset flag (0: edge reset; 1: level reset) (for external resettable integrator only)
Lower Output Limit Lower limit of the output (for internal resettable integrator only)
Upper Output Limit Upper limit of the output (for internal resettable integrator only)
Sampling Frequency Sampling frequency, in Hz
The output of an external resettable integrator can be reset by an external control signal (at the bottom of the
block). With the edge reset (reset flag = 0), the integrator output is reset to zero at the rising edge of the control
signal. With the level reset (reset flag = 1), the integrator output is reset to zero as long as the control signal is
high (1).
The output of an internal resettable integrator is reset to 0 whenever the output reaches either the lower limit or
the upper limit. The integrator works in the same way as the external resettable integrator with the edge reset,
except that users do not need to set up the external reset circuit in this case.
If we define u(t) as the input, y(t) as the output, T as the sampling period, and H(z) as the discrete transfer
function, the input-output relationship of an integrator can be expressed under different integration algorithms
as follows.
With trapezoidal rule:
T z+1
H ( z ) = --- ⋅ -----------
2 z–1
T
y ( n ) = y ( n – 1 ) + --- ⋅ ( u ( n ) + u ( n – 1 ) )
2
With backward Euler:
z
H ( z ) = T ⋅ -----------
z–1
y(n) = y( n – 1) + T ⋅ u(n)
3.5.2.2 Differentiator
The transfer function of a discrete differentiator is:
1 z–1
H ( z ) = --- ⋅ -----------
T z
where T is the sampling period. The input-output relationship can be expressed in difference equation as:
1
y ( n ) = --- ⋅ ( u ( n ) – u ( n – 1 ) )
T
Image:
Attribute:
Parameter Description
Sampling Frequency Sampling frequency, in Hz
Images:
Attributes:
For elements that read the coefficients directly:
Parameters Description
Order N Order N of the transfer function
Coeff. b0...bN Coefficients of the numerator (from b0 to bN)
Coeff. a0...aN Coefficients of the denominator (from a0 to aN)
Sampling Frequency Sampling frequency, in Hz
For elements that read the coefficients from a text file:
Parameters Description
File for Coefficients Name of the file storing the filter coefficients
Sampling Frequency Sampling frequency, in Hz
The transfer function of the general digital filter is expressed in polynomial form as:
If a0 = 1, the output y and input u can be expressed in difference equation form as:
y ( n ) = b 0 ⋅ u ( n ) + b 1 ⋅ u ( n – 1 ) + ... + b N ⋅ u ( n – N ) –
[ a 1 ⋅ y ( n – 1 ) + a 2 ⋅ y ( n – 2 ) + ... + a N ⋅ y ( n – N ) ]
If the denominator coefficients a0..aN are not zero, this type of filter is called infinite impulse response (IIR)
filter.
The transfer function of the FIR filter is expressed in polynomial form as:
–1 –( N – 1 ) –N
H ( z ) = b0 + b1 ⋅ z + ... + b N – 1 ⋅ z + bN ⋅ z
If a0 = 1, the output y and input u can be expressed in difference equation form as:
y ( n ) = b 0 ⋅ u ( n ) + b 1 ⋅ u ( n – 1 ) + ... + b N ⋅ u ( n – N )
The coefficient file for block Digital Filter (file) and FIR Filter (file) has the following format:
For FIR Filter (file):
N
b0
b1
... ... ...
bN
For Digital Filter (file), the format can be either one of the following:
N or N
b0 b0, a0
b1 b1, a1
... ... ... ... ... ...
bN bN, aN
a0
a1
... ... ...
aN
Example:
To design a 2nd-order low-pass Butterworth digital filter with the cut-off frequency fc = 1 kHz, assuming the
sampling frequency fs = 10 kHz, using MATLAB, we have:
Nyquist frequency fn = fs / 2 = 5 kHz
Normalized cut-off frequency fc* = fc/fn = 1/5 = 0.2
[B,A] = butter (2, fc*)
which will give:
B = [0.0201 0.0402 0.0201 ] = [b0 b1 b2]
A=[ 1 -1.561 0.6414 ] = [a0 a1 a2]
Order N 2
Coeff. b0...bN 0.0201 0.0402 0.0201
Coeff. a0...aN 1. -1.561 0.6414
Sampling Frequency 10000.
If the coefficients are stored in a file, the file content will be:
2
0.0201
0.0402
0.0201
1.
-1.561
0.6414
Or the file can also have the content as follows:
2
0.0201, 1
0.0402, -1.561
0.0201, 0.6414
Image:
Attribute:
Parameter Description
Initial Output Value Initial value of the output of the block
Sampling Frequency Sampling frequency, in Hz
The difference between the unit delay block and the time delay block is that the unit delay block is a discrete
element and it delays the sampled points by one sampling period, whereas the time delay block is a continuous
element and it delays the whole waveform by the delay time specified.
Image:
Quantization Block Quantization Block (with offset)
Attributes:
Parameters Description
No. of Bits Number of bits N
Vin_min Lower limit of the input value Vin,min
Vin_max Upper limit of the input value Vin,max
Vo_min Lower limit of the output value Vo,min
Vo_max Output value Vo,max that corresponds to the input value Vin,max
Sampling Frequency Sampling frequency, in Hz
To understand how the quantization blocks work, we will look at a special case where N = 3, Vin,min = 0, and
Vin,max = 1. The input will be divided into 23 (or 8) stages. Depending on the input level, the output will be one
of the 3-bit discrete numbers 000, 001, 010, 011, 100, 101, 110, and 111. The output will have 23 (or 8) levels,
and 23-1 (or 7) steps. If the binary number 000 corresponds to the decimal number 0, and the binary number 111
corresponds to the decimal number 0.875, and Vo,min = 0, and Vo,max = 1, we can plot the waveforms of the
input, output, and the quantization error Vin-Vo of the two quantization blocks as below.
The waveforms on the left are from the quantization block without the offset, and the waveforms on the right
are from the quantization block with the offset.
(110) (110)
(101) (101)
(100) (100)
(011) (011)
(010) (010)
(001) (001)
(000) (000)
As shown from the waveforms on the left, the quantization error of the quantization block is from 0 to 1 LSB
(least significant bit), or 1/23 (or 0.125).
For the quantization block with offset, a value of 0.5*LSB is added to the input before performing the
quantization. This reduces the quantization error to -0.5 LSB to +0.5 LSB (except when the input is close to the
maximum value), as shown from the waveforms on the right.
The figure below shows the input-output relationship of a general quantization block with offset.
Vo,max N
2 Binary numbers
N
Actual output limit 2 -1
ΔVo
Vo
Vo,min
0
Vin,min Vin,max
Vin ΔVin
The number of bits determines the quantization resolution. The input range, Vin,max - Vin,min, is divided into 2N
stages, with the width of each stage as:
V o = V o, min + ( k – 1 ) ⋅ ΔV o
Example:
For a quantization block with the offset, let N = 3, Vin,min = 0, Vin,max = 1, Vo,min = 0, and Vo,min = 1. We have
ΔVin = ΔVo = 1/8. If Vin = 0.25, it is in the 3rd stage (k = 3), and it corresponds to Vo = 0 + (3 - 1) * 1/8 = 0.25. If
Vin = 0.6, it is in the 6th stage (k = 6), and it corresponds to Vo = 0 + (6 - 1) * 1/8 = 0.625.
Images:
Circular Buffer (single output) Circular Buffer (vector output)
Attributes:
Parameters Description
Buffer Length The length of the buffer
Sampling Frequency Sampling frequency, in Hz
A circular buffer stores data in a buffer. When the pointer reaches the end of the buffer, it will start again from
the beginning.
The circular buffer with single output is a type of first-in-first-out memory storage device, and the output is
equal to the value being pushed out.
The output of the circular buffer with vector output is a vector array with the length equal to the buffer length.
To access each memory location, use the memory read block.
Example:
If a circular buffer has a buffer length of 4 and a sampling frequency of 10 Hz, we have the buffer storage at
different time as follows:
Image:
where
ci = Σ[ ak+1 * bj-k], k=0, ..., m+n-1; j=0, ..., m+n-1; i=1, ..., m+n-1
Example:
If A = [1 2 3] and B = [4 5], we have m = 3; n = 2; and the convolution of A and B is: C = [4 13 22 15].
Image:
Attribute:
Parameter Description
Memory Index Offset Offset from the starting memory location
A memory read block allows one to access the memory location of elements such as convolution block, vector
array, and circular buffer. The index offset defines the offset from the starting memory location.
Image:
Attributes:
Parameters Description
Array Length The length of the data array N (for the element Array only)
Values Values of the array (for the element Array only)
File for Coefficients Name of the file storing the array (for the element Array (file) only)
If the array is read from a file, the file will have the following format:
N
a1
... ... ...
aN
where N is the length of the array, and a1..aN are the array values.
Example:
To define an array A = [2 4 6 8], we will have: Array Length = 4; Values = 2 4 6 8. If the array is to be read from
a file, the file will be:
4
2.
4.
6.
8.
3.5.9 Stack
A stack is a first-in-last-out register.
Image:
Vin
push Vo
pop
Attribute:
Parameter Description
Stack Depth The stack depth
Vo
Images:
In PSIM In SimuLink
SimCoupler Model Block
In Link Node Out Link Node
In PSIM, the In Link nodes receive values from Simulink, and the Out Link nodes send the values to Simulink.
They are all control elements and can be used in the control circuit only. In Simulink, the SimCoupler model
block is connected to the rest of the system through input/output ports.
Power
in PSIM
File: pmsm_psim.sch
Control
in SimuLink
File: pmsm_simulink.mdl
The following are the steps to set up SimCoupler for PSIM-Matlab/Simulink co-simulation for the example
above.
In PSIM:
- After the rest of the power circuit is created, connect three Out Link nodes to the low-pass filters of
Phase A, B, and C currents, and rename them as “Ia”, “Ib”, and “Ic”; and connect one Out Link node to
the speed sensor output and rename it as “Wrpm”.
- Connect three In Link nodes to the positive inputs of the comparators, and rename them as “Va”, “Vb”,
and “Vc”.
- Go to the Simulate menu, and select Arrange SLINK Nodes. A dialog window will appear. Arrange
the order of the In Link nodes (SLINK In) and Out Link nodes (SLINK Out) to be the same as how the
input/output ports would appear in the SimCoupler model block in Simulink (the order of the ports is
from the top to the bottom). In this example, the order will be “Va”, “Vb”, and “Vc” for the In Link
nodes, and “Ia”, “Ib”, “Ic”, and “Wrpm” for the Out Link nodes.
- Save the schematic file. In this example, we assume that the file is saved to
“C:\PSIM\pmsm_psim.sch”.
In Simulink:
- Start Matlab.
- Launch Simulink. Open an existing file or create a new file. After the rest of the system is created, go
to the menu "S-function SimCoupler" in the Simulink Library Browser, select the SimCoupler block,
and place it on the schematic.
- In the PMSM example file, double click on the SimCoupler block, and click on the Browser button to
locate and select the PSIM schematic file “C:\PSIM\pmsm_psim.sch”. Then click on Apply. The
number of input and output ports of the SimCoupler model block will automatically match those
defined in the PSIM netlist. In this case, there will be 3 input ports and 4 output ports.
- Go to the Simulation menu and select Simulation Parameters. Under Solver Options, set the Type
to “Fixed-step”. Set Fixed step size to be the same as or close to PSIM’s time step. In this case, the
time step is set to 0.1ms. More discussion on the selection of the solver option and the time step is
given in the next section.
- The setup is now complete. Go to Simulink and start the simulation.
The SimCoupler Module supports Matlab/Simulink Release 13 and higher.
Please also note that when the SimCoupler model block is used in a feedback system in Simulink, the
SimCoupler model block may be part of an algebraic loop (please refer to Matlab Help for more information on
algebraic loops). Some versions of Matlab/Simulink can not solve a system containing algebraic loops, and
other can solve the system but with degraded performance. To break an algebraic loop, place a memory block at
each output of the SimCoupler model block. The memory block introduces one integration time step delay.
There are different ways of setting up Simulink to perform co-simulation. The recommend approach is to set the
Solve Type to Fixed-step and define the Fixed step size to be the same or close to PSIM’s time step. The figure
below shows this option.
It is recommended that Simulink use the same time step as PSIM, although we have found that, even if the
Simulink time step is slightly larger than PSIM time step, satisfactory results are obtained. In this case, for
example, the time step is set to 20 us, 10 times larger than the PSIM time step.
If the Simulink Solver type is instead set to Variable-step, the simulation results will not be correct. The figure
below shows this option.
When the Simulink Solver type is set to Variable-step, in order to obtain correct results, a zero-order-hold must
be placed at the input of the SimCoupler model block. Moreover, the zero-order-hold sample time must be the
same or close to PSIM time step. The figure below shows the configuration.
Therefore, Simulink must be set up to have the Solver Type as Fixed-step with the time step the same or close
to the PSIM time step, or if the Solver Type is Variable-step, a zero-order-hold must be used with the sample
time the same or close to PSIM time step
Image:
The parameter file is a text file created by the user. The format is shown below:
<name> = <value> % Add comment here
(global) <name> = <value> % Definition "(global)" is used in SimCoder only
<name> <value> // Add comment here
LIMIT <name> <lower limit> <upper limit>
% Comment
// Comment
The field <value> can be either a numerical number (e.g. “R1 = 12.3”) or a mathematical expression (e.g. “R3 =
R1 + R2/2.”). The name and the value can be separated by either an equation sign (e.g. “R1 = 12.3”) or a space
(e.g. “R1 12.3”). Text from the character % or // to the end of the line is treated as comments (e.g. “% R3 is the
load resistance”).
The definition "(global)" is used in SimCoder only for automatic code generation. Please refer to the SimCoder
User Manual on how it is used. For PSIM simulation, this definition is ignored. That is, a parameter definition
"(global) Kp = 1.2" is treated the same as "Kp = 1.2".
For example, a parameter file may look like the following:
R1=12.3 %R1 is defined as 12.3
R2 23.4Ohm %Equation sign can be replaced by space
% Comment starts with either % or //
R3=R1+R2/2. //Math expression is allowed
L1=3m //power-of-ten suffix is allowed. L1=0.003
C1=100uF
LIMIT R3 5. 25. %R3 is limited between 5. and 25.
When PSIM saves the schematic that contains the parameter file element, it will save the information of both
the relative path and absolute path of the parameter file, as well as a copy of the content of the parameter file.
When PSIM loads a schematic with the parameter file element, it will search and load the parameter file in the
following order: relative path (relative to the schematic file), absolute path, and the local path (the local folder
where the schematic file is). If PSIM still can not find the parameter file, it will create the parameter file in the
local schematic folder from the copy that it saved in the schematic file.
4.2.1 Time
The Time element is a special case of the piecewise linear voltage source. It is treated as a grounded voltage
source, and the value is equal to the simulation time, in sec.
Image:
4.2.2 Constant
The constant element allows users to define a constant. It behaviors as a grounded voltage source.
Image:
Attribute:
Parameter Description
Value Value of the constant
4.2.3 DC Source
A dc source has a constant amplitude. The reference of the grounded dc voltage sources is the ground.
Images:
DC DC (battery) Grounded DC (circle) Grounded DC (T) Current
Attribute:
Parameter Description
Amplitude Amplitude of the source
θ t
1/f
Images:
Voltage Current
Attributes:
Parameters Description
Peak Amplitude Peak amplitude Vm
Frequency Frequency f, in Hz
Phase Angle Initial phase angle θ, in deg.
DC Offset DC offset Voffset
Tstart Starting time, in sec. Before this time, the source is 0.
To facilitate the setup of three-phase circuits, a symmetrical three-phase Y-connected sinusoidal voltage source
is provided. The dotted phase of the source refers to Phase A.
Image:
3-phase Voltage
a
Attributes:
Parameters Description
V (line-line-rms) Line-to-line rms voltage amplitude
Frequency Frequency f, in Hz
Init. Angle (phase A) Initial angle for Phase A
Images:
Voltage Current
Attributes:
Parameters Description
Vpeak-peak Peak-to-peak amplitude Vpp
Frequency Frequency, in Hz
Duty Cycle Duty cycle D of the high-potential interval
DC Offset DC offset Voffset
Phase Delay Phase delay θ of the waveform, in deg.
Vpp
D*T Voffset
0 t
T
θ (T=1/f)
When the phase delay θ is positive, the waveform is shifted to the right along the time axis.
Images:
Voltage Current
Attributes:
Parameters Description
Vpeak-peak Peak-to-peak amplitude Vpp
Frequency Frequency, in Hz
Duty Cycle Duty cycle D of the rising slope interval
DC Offset DC offset Voffset
D*T Vpp
0 t
Voffset
T
θ
(T=1/f)
When the phase delay θ is positive, the waveform is shifted to the right along the time axis.
A sawtooth-wave voltage source is a special case of the triangular source with the duty cycle of 1 and dc offset
and phase delay of 0, and with one node grounded. It is defined as below:
Image:
Sawtooth-wave
Attributes:
Parameters Description
Vpeak Peak amplitude
Frequency Frequency, in Hz
Images:
Voltage Current
Attributes:
For the Step type source:
Parameters Description
Vstep Value Vstep after the step change
Tstep Time Tstep at which the step change occurs
Parameters Description
Vstep1 Value Vstep1 before the step change
Vstep2 Value Vstep2 after the step change
Tstep Time Tstep at which the step change occurs
T_transition Transition time Ttransition from Vstep1 to Vstep2
Vstep1
Ttransition
0 Tstep t 0 Tstep t
Images:
Voltage Current
Attributes:
For the sources that define the values and times separately:
Parameters Description
Frequency Frequency of the waveform, in Hz
No. of Points n No. of points
Values V1...Vn Values at each point
Time T1...Tn Time at each point, in sec.
For the sources that define the values and times in pair:
Parameters Description
Frequency Frequency of the waveform, in Hz
Times, Values (t1,v1) ... Time and value at each point
The time and value pair must be enclosed by left and right brackets. The time and value can be separated by
either a comma, such as (1.2m,5.5), or a space, such as (1.2m 5.5), or both, such as (1.2m, 5.5).
Example:
The following is a non-periodic piecewise linear source. It has 3 segments which can be defined by four points
3
2
1
The specification for the piecewise linear voltage source will be:
Frequency 0.
No. of Points n 4
Values V1...Vn 1. 1. 3. 3.
Times T1...Tn 0. 0.1 0.2 0.3
The specification for the piecewise linear (in pair) voltage source will be:
Frequency 0.
Times, Values (t1,v1)... (0., 1) (0.1, 1) (0.2, 3) (0.3, 3)
where Vm is the peak-to-peak amplitude of the source, n is a random number in the range of 0 to 1, and Voffset is
the dc offset.
Images:
Voltage Current
Attributes:
Parameters Description
Peak-Peak Amplitude Peak-to-peak amplitude of the source
DC Offset DC offset
Image:
Parameters Description
Expression The mathematical expression of the source
Tstart Start time of the source
In the expression, “T” or “t” represents time. For example, to implement a sinusoidal source, the expression will
be: sin(2*3.14159*60*t+2.09).
Images:
vin1 vin2
Current-controlled Variable-gain
Voltage-controlled Current-controlled voltage-controlled
(flowing through)
vin1 vin2
Attribute:
Parameter Description
Gain Gain of the source
For voltage-controlled sources, the controlling voltage is from the positive node (+) to the negative node (-).
For current-controlled sources (with an arrow pointing from one node to another), the control nodes are
connected across a RLC branch, and the direction of the controlling current is indicated by the arrow.
For current-controlled sources (with a wire connecting the two nodes), the controlling current flows from one
control node to another, as indicated by the arrow. A 10-uOhm resistor is used to sense the controlling current.
The output of a controlled source, except variable-gain controlled sources, is equal to the gain multiplied by the
controlling voltage or current. For the variable-gain controlled sources, the output is equal to the following:
v o = ( k ⋅ v in2 ) ⋅ v in1
i o = ( k ⋅ v in2 ) ⋅ v in1
Example:
The circuits below illustrates the use of current controlled voltage sources. In the circuit on the left, the voltage
source is controlled by the inductor current is. With a gain of 1, the waveform of the voltage vis is equal to that
of is. In this way, a current quantity can be converted to a voltage quantity.
The circuit on the right is equivalent to that on the left, except that a different current controlled source is used
instead.
Vis Vis
is is
In the nonlinear power source, the term sign(vin) is 1 if vin is positive, and it is -1 if vin is negative.
Note that these nonlinear sources can be used in the power circuit only.
Images:
vin1 vin2
vin1 vin2
Parameter Description
Gain Gain k of the source
For the nonlinear power source:
Parameters Description
Gain Gain k of the source
Coefficient k1 Coefficient k1
Coefficient k2 Coefficient k2
For the nonlinear (division) source, Input 1 is on the side of the division sign.
Images:
Voltage Sensor Current Sensor
Attribute:
Parameter Description
Gain Gain of the sensor
a a
b b
c c
Attributes:
Parameters Description
Operating Frequency Operating frequency or fundamental frequency of the ac meter, in Hz
Cut-off Frequency Cut-off frequency of the low-pass/high-pass filter, in Hz
kWh Meter Start Time Time from which the kilowatt hour meter starts, in sec. (for W/kWh meters only)
kWh Meter Stop Time Time at which the kilowatt hour meter stops, in sec. (for W/kWh meters only)
VA Display Flag Display flag for apparent power (0: no display; 1: display) (for VA-Power Factor
meters only)
PF Display Flag Display flag for power factor (0: no display; 1: display) (for VA-Power Factor
meters only)
DPF Display Flag Display flag for displacement power factor (0: no display; 1: display) (for VA-
Power Factor meters only)
In the images for the single-phase/3-phase wattmeter / kWh meter, the node with the letter "W" is for the real
power output, in watt, and the node with the letter "kWh" is for the kilowatt hour output, in kilowatt-hour.
A low-pass filter is used in the dc meter and wattmeter models to filter out high-frequency components,
whereas a high-pass filter is used in the ac meter models to filter out the dc component. The cut-off frequency
determines the transient response of the filter.
Except the voltage and current probes, the readings of all the meters are meaningful only when the readings
reach the steady state.
The single-phase and 3-phase VAR meter measure the reactive power (VAR) at the fundamental frequency; and
the VA-Power Factor meters measure the apparent power (VA), the total power factor (PF), and the
displacement power factor (DPF). The kilowatt hour meter reading gives the integration of the real power over
a time interval defined by the start time and the stop time.
For a single-phase circuit, the real power P, reactive power Q, apparent power S, total power factor PF, and the
displacement power factor DPF are defined as follows.
Assume both the voltage and current contains harmonics, i.e.
v(t) = 2V 1 sin ( ω 1 t + φ 1 ) + 2V 2 sin ( ω 2 t + φ 2 ) + ...
where ω1 is the fundamental frequency and all others are harmonic frequencies. We have the rms values of the
Note that the reactive power is for the fundamental component only.
The apparent power S is defined as:
S = V rms ⋅ I rms
The total power factor PF and the displacement power factor DPF are then defined as follow:
P
PF = ---
S
DPF = cos ( φ 1 – θ 1 )
For the three-phase circuit, the definitions are similar. Note that the 3-phase VA-Power Factor meter is for the 3-
phase 3-wire circuit, and the summation of the three phase voltages or currents must be equal to zero, that is:
va + vb + vc = 0
ia + ib + ic = 0
To use the single-phase or three-phase wattmeter/VAR meters, insert the meters into the circuit.
Example:
This example shows how single-phase and three-phase meters are used. The circuit on the left shows the use of
the wattmeter and VAR meter, and the circuit on the right shows the use of the three-phase wattmeter and VAR
meter.
A B A B C D
Interface for current scope, and
Interface for 2-channel scope 1-channel and 4-channel voltage scopes
The 1-channel and 4-channel voltage scope and the current scope have the same interface. For the 4-channel
scope, the channel can be selected through the drop-down channel selection, and the settings apply that the
channel selected.
The scope is designed to operate in a similar way as the actual oscilloscope in the lab. It has 3 main sections:
Timebase section, Channel section, and Trigger section.
In the Timebase section, the scale of time (x axis) is defined.
In the Channel section, the scale of the Y axis, as well as the offset and the color of the waveform, are defined.
The channel display mode can be either DC, AC, or Gnd (for ground). When the display mode is in DC, the
entire waveform is displayed. If the display mode is in AC, only the ac portion of the waveform is displayed.
When the display mode is Gnd, the waveform will show 0.
In the Trigger section, the trigger conditions are defined. The trigger can be set to either ON or OFF. When the
trigger is off, the waveform is free-running, and the display of the waveform in the scope may vary from one
frame to another. If the trigger is on, the waveform display will only start when the trigger conditions are met.
This will lead to a steady waveform display.
There are three trigger modes: rising-edge triggering, falling-edge triggering, and one-shot triggering (if the
once checkbox is checked, the one-shot triggering is selected). The one-shot triggering will trigger only once,
and it is useful, for example, in situations where a transient needs to be captured.
The trigger level sets the level at which the triggering occurs. For example, if Channel A is selected with the
rising-edge triggering and the trigger level of 0V, whenever the Channel A input crosses over 0 from negative to
positive, triggering will occur and the waveform display will start from that instant.
On the scope, if the Auto scale checkbox is checked, the scale of all the channels will be automatically adjusted
so that the waveforms are within the display of the scope.
Note that voltage scopes have connecting terminals which can be connected to either power circuit nodes or
control circuit nodes. The scopes will display the node-to-ground voltages at these nodes.
The current scope, on the other hand, has no connecting terminals. It is associated with any element that has the
parameter of the current flag, and it is enabled by right clicking on top of the element, and selecting the branch
current under the Current Scopes, as shown below. After the branch current is selected, a check mark will
appear in front of the branch current name.
Image:
Attribute:
Parameter Description
Initial Value Initial value of the node voltage
Image:
Example:
The circuit below implements the step change of a load. In the circuit, the on-off switch controller is used to
control the bi-directional switch. The step voltage source, which is connected to the controller input, changes
from 0 to 1 at the time of 12 ms. The closure of the switch results in the short-circuit of the resistor across the
switch and the increase of the current.
On-off
Controller
Image:
Enable/Disable
Attributes:
Parameters Description
Frequency Operating frequency of the controlled switch/switch module, in Hz
Pulse Width On-time pulse width of the switch gating, in deg.
Example:
The figure below shows a thyristor circuit using delay angle control. In the circuit, the zero-crossing of vs,
which corresponds to the moment that the thyristor would start conducting naturally, is used to provide the
synchronization. The delay angle is set at 30o. The gating signal is delayed from the rising edge of the
synchronization signal by 30o.
vs iRL1
vsync
Image:
Enable/Disable
Attributes:
Parameters Description
Frequency Switching frequency, in Hz
Update Angle Update angle, in deg., based on which the gatings are internally updated. If the
angle is 360o, the gatings are updated at every cycle. If it is 60o, the gatings are
updated at every 60o.
File Name Name of the file storing the PWM gating pattern
A lookup table, which is stored in a file, contains the gating patterns. It has the following format:
n, m1, m2, ..., mn
k1
G1,1, G1,2, ..., G1,k1
... ... ...
Example:
This example shows a three-phase voltage source inverter (file: “vsi3pwm.sch”). The PWM for the converter
uses the selected harmonic elimination. The gating patterns are described above and are pre-stored in File
“vsi3pwm.tbl”. The gating pattern is selected based on the modulation index. The waveforms of the line-to-line
voltage and the three-phase load currents are shown below.
Image:
LOAD I
V
P
k=1
Example:
The following circuit illustrates how a control circuit signal can be passed to the power circuit. As seen from the
power circuit, the CTOP block behaviors as a grounded voltage source.
Images:
abc to dqo dqo to abc
θ θ
2π 2π
cos θ cos ⎛ θ – ------⎞ cos ⎛ θ + ------⎞
⎝ 3⎠ ⎝ 3⎠
vd va
2--- 2π 2π
vq = ⋅ sin θ sin ⎛ θ – ------⎞ sin ⎛ θ + ------⎞ ⋅ v b
3 ⎝ 3⎠ ⎝ 3⎠
vo vc
1 1 1
--- --- ---
2 2 2
cos θ sin θ 1
va 2π 2π vd
cos ⎛ θ – ------⎞ sin ⎛ θ – ------⎞ 1
vb = ⎝ 3⎠ ⎝ 3⎠ ⋅ vq
vc 2π 2π vo
cos ⎛ θ + ------⎞ sin ⎛ θ + ------⎞ 1
⎝ 3⎠ ⎝ 3⎠
Example:
In this example, three symmetrical ac waveforms are transformed into dqo quantities. The angle θ is defined as
θ = ωt where ω = 2π*60. Since the angle θ changes linearly with time, a piecewise linear voltage which has a
ramp waveform is used to represent θ. The simulation waveforms show the three-phase ac (top), the angle θ
(middle), and the dqo output. In this example, the “q” component is constant, and both the “d” and the “o”
components are zero.
Images:
abc to αβ ab to αβ ac to αβ αβ to abc
In the images, the letter "al" refers to α, and the letter "be" refers to β.
The transformation equations are:
From abc to αβ:
1 1 va
1 – --- – ---
vα 2 2 2
= --- ⋅ ⋅ vb
vβ 3 3 3
0 ------- – ------- vc
2 2
From ab to αβ:
3
--- 0
vα 2 v
= ⋅ a
vβ vb
------2- 2
2
From ac to αβ:
3
--- 0
vα 2 va
= ⋅
vβ 2 vc
– ------- – 2
2
From αβ to abc:
1 0
va
2 –1 - ------3- ⋅ v α
vb = --- ⋅ --2 2
3 vβ
vc 1 3
– --- – -------
2 2
Images:
αβ to dq dq to αβ
θ θ
In the images, the letter "al" refers to α, and the letter "be" refers to β.
The transformation equations are:
From αβ to dq:
vd cos θ sin θ ⋅ v α
=
vq – sin θ cos θ vβ
From dq to αβ:
vα cos θ – sin θ ⋅ v d
=
vβ sin θ cos θ vq
Images:
In the images, the letter "r" refers to the amplitude, and the letter "a" refers to the phase angle θ. The angle is in
rad.
The transformation equations are:
From Cartesian to polar:
2 2
r = x +y
y
θ = atan ⎛ --⎞
⎝ x⎠
From polar to Cartesian:
x = r ⋅ cos θ
y = r ⋅ sin θ
Images:
1-input 2-input 3-input 5-input 10-input
Attributes:
Parameters Description
Expression Expression of the output versus inputs where n is the number of inputs
f(x1,x2,...,xn)
Expression df/dxi Expression of the derivative of the function f versus the ith input
Images:
1-dimensional 2-dimensional
Index j
Index i
Attribute:
Parameter Description
File Name Name of the file storing the lookup table
For the 2-dimensional lookup table block, the node at the left is for the row index input, and the node at the top
is for the column index input.
The one-dimensional lookup table has one input and one output. Two data arrays, corresponding to the input
and the output, are stored in the lookup table in a file. The format of the table is as follows.
Vin(1), Vo(1)
Vin(2), Vo(2)
...
Vin(n), Vo(n)
Examples:
The following shows a one-dimensional lookup table:
1., 10.
2., 30.
3., 20.
4., 60.
5., 50.
( 1.5 – 1 ) ⋅ ( 30 – 10 )
If the input is 0.99, the output will be 10. If the input is 1.5, the output will be 10 + ------------------------------------------------ =20.
2–1
The following shows a 2-dimensional lookup table with integer inputs:
3, 4
1., -2., 4., 1.
2., 3., 5., 8.
Column
2.3 3 3.4
1.1 -2 4
Row 2 2.091 3.826 4.818
2.2 3 5
4.8.5 C Block
The C block allows users to enter C code directly without compiling the code, unlike in the case of external
DLL blocks where users need to compile the code into a DLL using a compiler. The code of the C block will be
interpreted and executed at runtime by a built-in C interpreter in PSIM.
This block makes it very easy to support custom C codes, and to define and modify the functionality of the
block.
The interface of the C block dialog window is shown below.
In the Number of Input/Output Ports section, the number of input and output ports of the ports is defined. After
the number of ports is changed, the image of the block in the schematic will change accordingly.
In the Function Type section, there are four choices:
Variable/Function Definitions: For includes statements and global variable definition.
OpenSimUser Fcn: The function that is called only once at the beginning of the simulation for
initialization.
RunSimUser Fcn: The function that is called at each simulation step.
CloseSimUser Fcn: The function that is called only once at the end of the simulation for
termination.
When one of the choices is selected, the area underneath shows the corresponding code. The complete code
consists the combined code of all the four parts.
Function
selection
Area for
custom code
Click on the Check Code button to check if the code has any compiling errors. Click on the Edit Image button
to customize the image of the C block.
For example, assume that a C block has 2 inputs and 3 outputs. After numbers of input/output ports are defined,
the C block will have an image in PSIM as follows:
2-input / 3-output
in[0] out[0]
out[1]
in[1] out[2]
input output
Area for
custom code
In the Number of Input/Output Ports section, the number of input and output ports of the ports is defined. After
the number of ports is changed, the image of the block in the schematic will change accordingly.
Variables that can be used in the code include:
t: Time passed from PSIM
delt: Time step passed from PSIM
x1, x2, ... : Inputs 1, 2, etc.
y1, y2, ... : Outputs 1, 2, etc.
Unlike the C block, the simplified C block can be used for automatic code generation.
1 1 1 1
2 2
3 3
6 6
input output
Attribute:
Parameter Description
File Name Name of the DLL file
The node with a dot is for the first input (in[0]). The sequence of the input/output nodes is from the top to the
bottom.
The images and parameters of a general DLL block are shown below.
1
1
input 2 output
2 3
Attribute:
Parameter Description
DLL File Name of the DLL file
Input Data File Name of the input data file that DLL reads (optional)
Number of Input Number of input nodes (optional)
Nodes
Number of Output Number of output nodes (optional)
Nodes
IN Nodes List of input nodes (optional)
OUT Nodes List of output nodes (optional)
Parameter 1 Parameter to be passed from PSIM into DLL (optional)
Parameter 2 Parameter to be passed from PSIM into DLL (optional)
Edit Image (button) Click this button to edit and customize the image of the DLL block.
Display File (button) Click this button to display the content of the Input Data File (optional).
Read File (button) If the Input Data File is modified, click this button to reload the data file
(optional).
The node with a dot is for the first input (in[0]). The sequence of the input/output nodes is from the top to the
bottom.
By default, users define the number of inputs and outputs. But the number of inputs and outputs, the node
names, as well as the number of parameters and the parameter names can all be defined inside the DLL routine.
Attribute:
Parameter Description
DLL File Name of the DLL file that defines the functionality and the interface of the block
Number of Nodes Total number of input and output nodes
The Embedded Software Block has similar functionality as the general external DLL block. However, unlike
the general DLL block whose connection nodes are predefined as either inputs or outputs, the Embedded
Software Block allows the node types to be programmed as needed.
Also, additional information, such as the exact instant at which the state of a variable changes, can be calculated
and passed to and from PSIM.
The Embedded Software Block is a control circuit element, and can be used in the control circuit only.
For more information on how to use the Embedded Software Block, please refer to the document "Help
Embedded Software Block.pdf".
5.2 AC Analysis
The frequency response of a circuit or a control loop can be obtained with the ac analysis. A key feature of the
ac analysis in PSIM is that, a circuit can be in its original switchmode form, and no average model is required.
Nevertheless, with the average model, the time it takes to perform the ac analysis will be shorter.
The following are the steps to set up the ac analysis:
- Identify a sinusoidal voltage source as the excitation source for the ac sweep.
- Place ac sweep probes at the desired output location. To measure the loop response of a closed control
loop, use the node-to-node probe.
- Place the AC Sweep block on the schematic, and define the parameters of the ac sweep.
- Run the simulation.
Below are the images of the ac sweep probes and the AC Sweep block.
Images:
Attributes:
Parameters Description
Start Frequency Start frequency of the ac sweep, in Hz
End Frequency End frequency of the ac sweep, in Hz
No. of Points Number of data points
Flag for Points Flag to define how the data points is generated.
Flag = 0: Points are distributed linearly in LOG10 scale
Flag = 1: Points are distributed linearly in linear scale
Source Name Name of the excitation source
Start Amplitude Excitation source amplitude at the start frequency
End Amplitude Excitation source amplitude at the end frequency
Freq. for extra Points Frequencies of additional data points. If the frequency-domain characteristics
change rapidly at a certain frequency range, one can add extra points in this region
to obtain better data resolution.
The principle of the ac analysis is that a small ac excitation signal is injected into the system as the perturbation,
and the signal at the same frequency is extracted at the output. To obtain accurate ac analysis results, the
Image:
Attributes:
Parameters Description
Start Value Starting value of the parameter
End Value End value of the parameter
Increment Step Increment step
Parameter to be Swept Parameter to be swept
For example, let the resistance of a resistor be “Ro”. To sweep the resistance from 2 Ohm to 10 Ohm, with a
step of 2 Ohm, the specification will be:
Start Value 2
End Value 10
Increment Step 2
Parameter to be Swept Ro
The image and parameters of the parameter sweep element are shown below.
Parameter sweep will produce two plots: One is the outputs versus time, and the other is the outputs at the last
simulation point versus the swept parameter.
For example, a circuit has two outputs V1 and V2, and the resistance Ro is swept. The total simulation time is
0.1 sec. After the simulation, there will be two plots in Simview. One is V1 and V2 versus time. The other is V1
and V2 versus Ro. The V1 and V2 values used in the second plot are the values at the last simulation point at
0.1 sec.
PSIM’s schematic program provides interactive and user-friendly interface for circuit schematic entry and
editing. The following figure shows a boost power factor correction circuit in the PSIM environment.
In PSIM, all the elements are stored under the Elements menu. The elements are divided into four groups:
Power (for power circuit element), Control (for control elements), Other (for switch controllers, sensors,
probes, interface elements, and elements that are common to both power and control), and Sources (for voltage
and current sources).
Also, the most recent elements are listed in the pull-down button on the
toolbar, and can be selected.
In addition, one can select elements from the Element Toolbar.
Place Once an element is selected from the menu, the image of the element will appear on the
screen and move with the mouse. Click the left button of the mouse to place the element.
Select Element To select an existing element on the schematic, click on the element. A rectangle will
appear around the element.
To select a block of a circuit, keep the left button of a mouse pressed and drag the mouse
until the rectangle covers the selected area.
Rotate Before the element is placed, right click to rotate the element. After an element is
selected, select Edit -> Rotate to rotate the element.
Wire To connect a wire between two nodes, select Edit -> Wire. The image of a pen will
appear on the screen. To draw a wire, keep the left button of the mouse pressed and drag
the mouse. A wire always starts from and end at a grid intersection.
For easy inspection, a floating node is displayed as a circle, and a junction node is
displayed as a solid dot.
Label If two or more nodes are connected to the same label, they are connected. It is equivalent
as though they were connected by wire. Using labels will reduce the cross-wiring and
improve the schematic layout.
The text of a label can be moved. To select the text, left click on the label, then press the
Tab key.
Assign To assign the parameters of an element, double click on the element. A dialog box will
appear. Specify the values and hit the <Return> key or click on OK.
Move To move an element or a circuit block, select the element/circuit block and drag the mouse
while keeping the left button pressed.
Move Schematic To move the whole schematic, right click and drag the mouse.
The diamonds on the four sides represent the connection nodes and the positions of the subcircuit.
They correspond to the connection nodes of the subcircuit block on the right. There are no diamonds at
the four corners since connections to the corners are not permitted.
When a diamond is selected, it is colored red. By default, the left diamond at the top is selected and
marked with red color. Click on the desired diamond to select and to specify the port name.
In this example, in the main circuit “chop.sch”, there are four linking nodes, two on the left side and
two on the right side of the subcircuit block. The relative position of the nodes are that the upper two
nodes are 1 division below the top and the lower two nodes are 1 division above the bottom.
To specify the upper left linking node, click on the top diamond of the left side, and type “in+”. The
text “in+” will be within that diamond box and a port labelled with “in+” will appear on the screen.
Connect the port to the upper left node. The same procedure is repeated for the linking nodes “in-”,
“out+”, and “out-”.
- After the four nodes are placed, the node assignment and the subcircuit appear in PSIM as shown
below.
File: sub.sch
File: main.sch
In the window, the diamonds marked red are the connection nodes of the subcircuit block, in exactly
the same positions as appearing in the main circuit.
- Use the drawing tool to create/edit the image for the subcircuit block. If the drawing tool is not already
displayed, go to the View menu and check Drawing Tools. Click on Zoom In and Zoom Out icons on
the toolbar to adjust the size of the image working area.
After the image is created, the pop-out window will appear as follows.
- Place the cursor inside the input field of the dialog window for the gain, and change the gain either by
pressing on the upper/down arrow keys on the keyboard, or by entering a new value and then clicking
on Apply. Watch how the waveforms change as the gain is changed.
Other parameters, such as current reference, dc input voltage, inductance, capacitance, and load
resistance, can be changed in the similar way.
- Branch currents can also be displayed in the free-run mode. To display the inductor current, for
example, right click on top of the inductor, and a menu will appear. Choose Current Scopes and the
branch current name.
- An image of the current scope (similar to the voltage scope image, but without connection terminals)
will appear. Double click on the scope to expand and view the inductor waveform.
Below is how the window would look like with both the voltage scope and the current scope.
Other branch currents, such as capacitor current, load current, diode current, or MOSFET switch
current, can be displayed in the similar way.
Current scope
Voltage scope
On Editing:
Display grid Check this option to display the grid in the PSIM schematic.
Zoom factor: The zoom factor defined here is used when the schematic is zoomed in or out.
Enable rubber band: When checked, an element or a portion of a circuit remains connected with the rest of
the circuit when moved.
On Text Font:
Default text font: Set the default font for the text placed in the schematic.
Default graph font: Set the text font for the runtime graphs.
On Simulation:
Simulation result format: Simulation results can be saved in either binary format (default) or text format. The
binary format will result in a smaller result file, and will be faster to load.Set the default
font for the text placed in the schematic.
Output buffer size: When checked, the simulation data will be written to the result file in segment. For
example, if the buffer size is set to 20 MB, the simulation data will be first saved to the
buffer, and when it reaches 20 MB, the whole 20-MB data will be written to the result file.
Please note that the runtime graph only plots the data in the buffer. Therefore, when the
old data are saved to the file and the new data fills in the buffer, the runtime graph will
only show the waveform of the new data, and the old waveform will be lost.
To retain all the waveforms in the runtime graph, one can either increase the buffer size,
or un-check this option.
When this option is un-checked, however, PSIM will allocate all the required memory for
the buffer at the very beginning. If the simulation time step is small and the total time is
long, and if there are many output curves, a very large memory may be required, which
will take some time to allocate, and may even fail if the computer does not have sufficient
amount of memory.
Disable simulation warning messages: When this option is checked, warning messages generated in the
simulation are suppressed.
On Software Updates:
Check for software updates: When this option is checked, if you have the valid software annual maintenance,
PSIM will automatically check for new updates on the Powersim server. If a new update
is available, you will be prompted to install the update.
On Automatic Backup:
Automatic backup: When this option is checked, PSIM will create a backup of the file currently being edited
in the time interval specified. In case of a program crash, the backup file will preserve the
previous work. The backup file is deleted automatically when the file is closed normally
from the PSIM environment.
On Time-Out:
Idle time: When this option is checked, PSIM will be timed out after the program is idle for the
specified amount of time. Note that this applies to the PSIM network version only.
When PSIM is timed out, the license will be released and other users will be able to check
it out. When PSIM is back from the idle state, it will try to log back in the License
Manager if a license is still available. If there is no license available, an error message will
be posted.
This feature will prevent users from holding up licenses unintentionally.
Predefined
icon images
Icon
editing area
- In the section Add Shortcut Key, select the option Elements. Then find and highlight the element
"Resistor".
- Move the cursor into the input field of Press new shortcut key, and press the key "r" on the keyboard.
Then click on Assign.
- The key "r" will be assigned to the resistor, and the definition will appear in the Current Shortcut
Standard image
Secondary image
To share the secondary images that one creates with other people, one just has to send to them the secondary
image library file (with the .lib2 extension).
In this case, the inductance and capacitance values will be defined through the interface, and need to appear in
the property window of the new LC filter element. Therefore, the parameter value for the inductance needs to be
defined as a variable, in this case, L, and the value for the capacitance as C.
Then from Subcircuit -> Edit Default Variable List, add the variables L and C as the default variables. This
step is necessary as the new element obtains the parameter information from the default variable list. The
default variable list window should appears as follows.
Here Variable Label is the text that describes the parameter, Variable Name is the variable that is used as the
parameter value in the subcircuit, and Variable Value is the default value of the parameter. For example, for the
inductance L, the Variable Label is Inductance, the Variable Name is L, and the Variable Value is 1m.
After the file is created, place it in the "lib" sub-folder in the PSIM directory.
SIMVIEW is PSIM’s waveform display and post-processing program. The following shows simulation
waveforms in the SIMVIEW environment.
SIMVIEW reads data in either ASCII text format or SIMVIEW binary format. The following shows a sample
text data file:
Time Isa Isc Isb Tem_IM
5.000000000E-006 0.000000000E+000 0.000000000E+000 0.000000000E+000 7.145888260E-048
1.000000000E-005 0.000000000E+000 0.000000000E+000 0.000000000E+000 1.082981714E-046
1.500000000E-005 0.000000000E+000 0.000000000E+000 0.000000000E+000 5.408644357E-046
2.000000000E-005 1.139566166E-001 -2.279132474E-001 1.139566166E-001 1.613605209E-017
2.500000000E-005 5.072914178E-001 -1.014582858E+000 5.072914178E-001 3.598226665E-015
... ... ... ...
If the Auto-Grid box is checked, the number of axis divisions will be automatically determined. The data range
and grid division, however, can be manually set.
By default, the first column of the data, which is usually Time, is used as the X axis. However, any other
column of the data can be used as the X axis. For example, the following figure shows a sine waveform as the X
Edit Box
All the data variables available for display are in the Variables Available box, and the variables currently being
displayed are in the Variables for Display box. After a variable is highlighted in the Variables Available box, it
can be added to the Variables for Display box by clicking on “Add ->”. Similarly, a variable can be removed
from display by highlighting the variable and clicking on “<- Remove”.
In the Edit Box, an mathematical expression can be specified.
A mathematical expression can contain brackets and is not case sensitive. The following math functions are
allowed:
+ addition
- subtraction
* multiplication
/ division
^ to the power of [Example: 2^3 = 2*2*2]
SQRT square-root function
Once Measure is selected, an individual curve can be selected by clicking on the pull-down menu
on the Measure toolbar. The functions, Max, Min, Next Max, Next Min, Avg, and rms, can
be used to evaluate the curve. Note that these functions are only enabled in the Measure mode.
Memory
Expression
Result
One key feature of the calculator is that it provides 9 memory spaces. By double clicking on a number in the
Measure dialog window in Simview, the value will be automatically transferred to the calculator and stored in
one of the memory spaces, starting from the top. In this way, data can be directly transferred to this calculator
for calculation without the need to record them on a piece of paper.
Q0 Q0 Q1
Q1
clock
clock
1V
1V
In the circuit on the left, the initial values of both Q0 and Q1 are assumed to be zero. At the clock rising edge, Q0
will change to 1. Without delay, the position of Q1, which should remain at 0, will toggle to 1 at the same time.
To prevent this, a time delay element with the delay period of one time step needs to be inserted between Q0 and
the input (J) of the second flip-flop.
It should be noted that, in PSIM, the power circuit and the control circuit are solved separately. There is one
time step delay between the power and the control circuit solutions.
W-1 Warning!!! The program failed to converge after 10 iterations when determining switch positions.
The computation continues with the following switch positions: ... ...
This warning occurs when the program fails to converge when determining switching positions. Since
the computation continues based on the switch positions at the end of the 10th iteration, results could be
inaccurate. One should be cautious when analyzing the results.
There are many factors that cause this problem. The following measures can be taken to isolate and
solve the problem:
- Check the circuit and make sure the circuit is correct.
- Check the switch gating signals.
- Connect small resistors/inductors in series with switches and voltage sources.
W-2 Warning!!! The program did not reach the steady state after 60 cycles when performing the ac
sweep.
This warning occurs when the program fails to reach the steady state after 60 cycles when performing
the ac sweep. The cause of the problem could be that the system is poorly damped at that particular
frequency or the signal amplitude is too small.
You may try the following to isolate and solve the problem:
- Run the time-domain simulation with the excitation source at that frequency and see if time-
domain waveforms are oscillatory.
- Increase the excitation voltage amplitude for larger signal level, or
- Reduce the time step for better accuracy and resolution.
8.3 Debugging
Some of the approaches in debugging a circuit is discussed in the following.
Symptom:
Simulation results show sudden changes (discontinuity) of inductor currents and capacitor voltages.
Solution:
This may be caused by the interruption of inductor current path and short-circuit of capacitor (or
capacitor-voltage source) loops. Check the switch gating signals. If necessary, include overlap or dead
time pulses to avoid open-circuit or shooting-through.
If an initial current is assigned to an inductor, initial switch positions should be set such that a path is
provided for the current flow. Otherwise, the inductor current will be forced to start from zero.
Symptom:
Simulation waveforms look incorrect or inaccurate, or the waveform resolution is poor.
Solution:
This may be caused by two reasons. One is the time step. Since PSIM uses the fixed time step during the
entire simulation, one should make sure that the time step is sufficiently small. As a rule of thumb, the
time step should be several tens times smaller than the switching period.
Another reason is the problem of waveform display. One should make sure that the print step is not too
big. To display all the data points, set the print step to 1.
Index 205
flag J
load 165 JMAG 1, 76
master/slave 57, 59, 61, 63, 67, 69, 71, 73, 75, 87, 88 JMAG-RT 1, 81, 82
save 165
flip-flop L
D 117 label 172, 174, 190, 199
J-K 116 leakage flux 23, 26, 27, 65
S-R 115 LED 10
format library
ASCII text 193 adding new DLL element 191
binary 184, 193 adding new subcircuit element 189
free run 165, 181 edit 174, 187, 188, 189, 190, 191
functional model 94, 95 library browser 133, 171, 174
light intensity 94
G limiter
gate gradient (dv/dt) 110
AND 115 lower 110
logic 3, 115, 201 lower/upper 110
NAND 115 range 110
NOR 115 upper 110
NOT 115 LOG 5, 107, 196
OR 115 LOG10 5, 107, 166, 196
XOR 115 logic gate 115
gating block 12, 14, 17, 18, 19 lookup table
gear box 54, 85, 87, 88 2-D 158
loss calculation 35
H diode 44
hardware target IGBT 47, 48
general 165 MOSFET 51
PE-Expert3 165
PE-Pro/F28335 165 M
TI F28335 165 machine
brushless dc 62, 64, 93
I dc 56, 57
image induction 54, 58, 61, 89
secondary 188 nonlinear induction 58
inductor 7, 78, 191, 203 nonlinear permanent magnet synchronous 70
coupled 22, 24 nonlinear switched reluctance 74
saturable 8 permanent magnet synchronous 68, 70
initial value 9, 99, 100, 101, 150 squirrel-cage induction 58, 59, 60, 61
integrator switched reluctance 73
s-domain synchronous (external excitation) 66
external resettable 100 wound-rotor induction 58, 59, 61
internal resettable 100 MagCoupler 77
z-domain MagCoupler block 76, 77, 78, 79, 80
external resettable 122 MagCoupler Module 1, 76, 80, 81, 85
internal resettable 122 MagCoupler-DL block 76
interface MagCoupler-RT Module 1, 81, 85
between power and control circuits 154 magnetic elements 26, 27, 29, 187
interface block 89 math function block 158
control-power 154, 201 Matlab/Simulink 1, 132, 133, 180, 187
mechanical-electrical 54, 85, 88 maximum power 94, 95
maximum/minimum function block 109
mechanical coupling block 85, 88
206 Index
mechanical load ac sweep (loop) 166
constant-power 85 current 79, 91, 146, 175, 181
constant-speed 86 voltage 146, 181
constant-torque 85 propagation delay 113, 201
externally-controlled 87 proportional-integral controller 102, 168
general-type 86 Pulse 118
mechanical load model 1, 54, 85, 89
memory read block 128, 129 Q
message quantization block 1, 126
error 2, 161, 184, 202
warning 2, 167, 180, 184, 202 R
meter reference direction
3-phase VAR 148 of mechanical system 55, 85, 88, 90, 91
VA-power factor 146 renewable energy 1, 94
VAR 146, 148 resistor 4, 7, 8, 27, 28, 29, 137, 144, 146, 150, 169, 176,
monostable 117 186, 187, 203
Motor Drive Module 1, 54, 85 resolver 91, 92, 93
MPPT 95 rheostat 8
multiplexer 113 root-mean-square function block 107
multiplier 3, 106 round-off block 112
multi-rate sampling system 131 rubber band 183
runtime graph 7, 180, 181, 184
N
node S
link 159, 161 sampling/hold block 111
SLINK 229 scope
nonlinear element 10, 11 current 148, 149, 150, 165, 174, 181, 182
conductance-type 10 voltage 148, 165, 181
conductance-type with additional input 10 sensor
resistance-type 10 current 146
resistance-type with additional input 10 hall effect 62, 63, 64, 65, 66, 93
position 54, 63, 64, 65, 66, 76, 81, 85, 91, 92, 93
O speed 89, 90, 91, 133
operational amplifier torque 89, 90, 91
ideal 40 voltage 146, 154, 201
non-ideal 41, 42 shunt regulator 32
sign function block 5, 108, 196
P SimCoder 1, 2, 137, 165, 176, 180, 184
password 173 SimCoupler Module 1, 3, 132, 133, 180, 187
disable 183 simulation control 165, 180, 181
enter 183 solar cell 94, 95
PE-Pro/F28335 165 source 138
physical model 94, 95 constant 138
pitch angle 96 current-controlled current 144
port current-controlled voltage 78, 144, 145
bi-directional 175, 176 dc 13, 15, 138
input signal 108, 175 math function 143
output signal 175 nonlinear voltage-controlled 145, 146
subcircuit 177, 178 piecewise linear 138
power coefficient 96, 97 random 143
power function block 107 sawtooth 141
print step 165, 202, 203 sinusoidal 139
probe 146 square wave 112
ac sweep 167 square-wave 140
Index 207
step 141 alpha/beta-dq 157
triangular 140, 141 Cartesian-Polar 157
voltage-controlled current 78, 144 transformer 2, 23
voltage-controlled voltage 78, 144 ideal 23
square waveform block 111 single-phase 23
square-root function block 107 three-phase 25
stack 130, 131 transistor
subcircuit 173, 175, 176, 178, 180 BJT (npn) 10, 14
connecting 178 BJT (pnp) 10, 13
creating GTO 10, 13
in the main circuit 176 IGBT 10
in the subcircuit 177 MOSFET (n-channel) 10
image 179 MOSFET (p-channel) 10, 13
summer 106 trapezoidal waveform block 111
sweep trigonometric function 108
ac 166, 167, 203
parameter 168, 169 U
switch unit delay block 113, 125
bi-directional 10, 15, 16, 151
DIAC 10, 12 V
linear 10, 16, 17 variable
self-commutated 10, 13 default 175, 176, 178, 179, 190
thyristor 10, 12, 13, 151 passing 178
transistor 10, 13, 45, 47, 50, 51, 52 runtime 174, 181
TRIAC 10, 12 voltmeter
switch controller 2, 12, 17, 151 ac 146
alpha 13, 19, 21, 151 dc 146
on-off 14, 15, 151
PWM lookup table 21, 22, 152 W
switch module wattmeter 146, 147, 148
single-phase 19 3-phase 148
three-phase 19 wind turbine 96
wire 172, 174, 177, 185, 203
T
THD block 114, 115 Z
Thermal Module 1, 35, 43, 48 zero-order hold 1, 111, 112, 120, 131, 162
TI F28335 165
time 138, 162
idle 184
print 165
total 165, 180, 183
time delay block 112, 113, 125, 201
time step 34, 76, 77, 133, 134, 162, 165, 166, 180, 183,
201
tip speed ratio 96, 97
TL431 32
toolbar 172, 174, 183, 185, 186, 198
transconductance 16, 50, 51, 53
transfer function block
s-domain 99
z-domain 121
transformation 154
abc-alpha/beta 156
abc-dqo 155
208 Index