Plexim PLECS RT Box User manual

dx
www.plexim.com
Request a PLECS and PLECS Coder trial license
Get the latest RT Box Target Support Package
Check the PLECS and RT Box documentation
RT Box
DEMO MODEL
Sensorless Vector Control for Permanent Magnet
Synchronous Machine
Cascaded speed and current control with an observer based position
and speed estimation
Last updated in RT Box TSP 2.1.5

Sensorless Vector Control for Permanent Magnet Synchronous Machine
1 Overview
This RT Box demo model features a drive system with a permanent magnet synchronous machine
(PMSM). The following sections describe in detail the implementation of the power stage and controls
using the PLECS Electrical and Control domains. This demo model has the following features:
• The drive outputs a nominal torque of 0.11 Nm and is fed by a 24 V DC voltage source.
• Explanation how to convert data sheet parameters of a PMSM to use in the PLECS PMSM model.
• The implementation of a rotor position and speed observer for sensorless field oriented control strat-
egy.
• A closed-loop cascaded controller with inner d- and q- axis current controller and outer speed con-
troller.
• The model is split into two distinct subsystems called “Plant” and “Controller”. This allows the same
model to be used in an offline simulation in PLECS and for real-time simulations on the PLECS RT
Box. These subsystems can then be independently built on the PLECS RT Box either for Hardware-
in-the-loop (HIL) testing of an external controller, or for rapid control prototyping (RCP). The two
RT Boxes are connected for a complete closed-loop simulation.
The following sections provide a detailed description of the model and instructions on how to simulate
it.
The execution time represents the actual time it takes to execute one calculation step of the PLECS
model on the RT Box hardware. The chosen discretization step sizes and average execution times for
each subsystem in this demo model are shown in Fig. 1.
0.0 2.5
Time ( s)
RT Box 1
RT Box 2/3
80%
72%
Plant
0 50
Time ( s)
3%
3%
Controller
Execution Time
Disc. Time-Step
Figure 1: performance overview for the execution on two RT Boxes
1.1 Requirements
To run this demo model, the following items are needed (available at www.plexim.com):
• Two PLECS RT Boxes and one PLECS and PLECS Coder license
• The RT Box Target Support Library
• Follow the step-by-step instructions on configuring PLECS and the RT Box in the Quick Start guide
of the RT Box User Manual.
• Three 37 pin Sub-D cables to connect the boxes front-to-front.
Note that this demo model is targeted at two RT Boxes application, with one running the Plant and
the other running the Controller. In this way, the execution time of each real-time target is minimized.
Besides, the setup can easily transition to a HIL or RCP test later on.
However, if the user has only one RT Box available, please check the corresponding models targeted
for one RT Box application. In this case, two 37 pin Sub-D cables are still needed to connect in front
Analog Out interface with Analog In interface, and Digital Out interface with Digital In interface.
• For RT Box 2 and 3, by default the multi-tasking feature is enabled in this demo. “Controller” part
is circled with a Task frame block, and runs in one core. The rest of the circuit on the schematic be-
longs to the “Base task”, and runs in another core. In this way the computational effort is split onto
different cores. Please check the default setting under Scheduling tab of the Coder options... win-
dow.
www.plexim.com 1

Sensorless Vector Control for Permanent Magnet Synchronous Machine
• For RT Box 1 multi-tasking is disabled since there is only one CPU core available for calculating the
model, which includes both Plant and the Controller.
2 Model
The top level schematic of the demo model is depicted in Fig 2. The model is split into two subsys-
tems: “Plant” and “Controller”. Both subsystems are enabled for code generation by right-clicking
on the component and selecting Enable code generation check box from the Subsystem + Execu-
tion settings... menu. This allows the model to be simulated and the controls to be verified offline in
PLECS before a real time simulation on the RT Box target.
The inherit delays of the closed-loop control are modelled in a simplified way in the offline simulation
using a Delay block (z−1) with sample time Ts_control.
Controller
Is
En
Vdc
PWM
Enc./A,B,I
z-1
z-1
Plant
Is
sw
Vdc
En
θ/A,B,I
z-1
Figure 2: Top level schematic of the demo model sensorless speed controlled PMSM
2.1 Plant
The power circuit includes an PMSM and a three-phase full bridge voltage source inverter (VSI). The
DC voltage source Viwith Vdc = 24 V supplies the VSI, which is represented by three Mosfest Half
Bridge power modules.
sw1
sw2
sw3
sw4
sw5
sw6
sw1
sw2
sw3
sw4
sw5
sw6
Is
Analog
Out
sw
PWM
Capture
Vi
V
Vdc
Analog
Out
PMSM
Probe
RotorPosition
*
*
En
Digital
In
θ
Incr.
Encoder
1
Tunable
is
vdc
vdc
Load
1
Figure 3: Power circuit of the PMSM drive system
The six switching signals are fed into the subsystem by a PWM Capture block from the PLECS RT
Box component library. The measurements of the DC voltage and the AC current output by Analog
Output blocks. The rotor angular position is converted by the Incremental Encoder block into digital
orthogonal pulses, which can be measured outside of “Plant” subsystem.
www.plexim.com 2

Sensorless Vector Control for Permanent Magnet Synchronous Machine
The rotor inertia absorbs energy when the motor is accelerating and thus provides a load when start-
ing up or changing speed. For this purpose the value from data sheet of Tab. 1 was used in the PMSM
block, as internal mechanical load. For closed loop startup, the load cannot be higher than 40 %, other-
wise the observer will not be able to track the speed in time and the control will become unstable. To
demonstrate a load step, a load profile alternates between 20 % and 40 % of the nominal motor torque.
The load is not applied until the controller is switched on.
Machine Parameters
The machine parameters are listed in Tab. 1 which were taken from the data sheet. The following pa-
rameters must be converted in order to use them in the PLECS model:
• Line to line quantities must be converted in line to neutral quantities such as stator resistance R
and stator inductance Ld and Lq. The conversion factor is √3.
• The permanent magnet flux linkage can be calculate from line to neutral back EMF voltage eln.
Which is the peak voltage induced by the permanent magnets in each phase per unit rotational
speed. The relation can be expressed as follows:
eln =p ω (1)
In Tab. 1, the back EMF voltage eln was measured at a speed of 1000 revolution per minute (rpm).
However, the PLECS model parameters are in radiants per second (rad/s) which requires a conversion.
Note The machine model is chosen as Rotor reference frame. This configuration allows the gener-
ation of code for this model, however, it does not allow the simulation of the machine in generator mode
together with dead-times on the inverter half-bridges.
Table 1: Specifications of applied PMSM BLWS232D-36V-4000
Number of pole pairs 2
Rated Power (W) 40
Rated Torque (Nm) 0.1
Rated Speed (rpm) 4000
Line to Line Resistance (Ω) 2.4
Line to Line Inductance (mH) 4.39
Rotor Inertia (Nms2) 0.0000074852
Back EMF Voltage (V/krpm) 4.5
2.2 Controls
In the controller subsystem, the DC-link voltage and the stator currents are measured by Analog In
blocks. The mechanical angular speed of the rotor is obtained from the Quadrature Encoder Counter
block, which converts the orthogonal digital pulses.
The initial mechanical speed reference value is set at 2000 rpm. In order to guarantee a robust start-
up process of the observer, it is always started at a speed of 2000 rpm and regulated to the desired
speed after the start-up. The speed of 500 rpm cannot be undercut in connection with the attached
www.plexim.com 3

Sensorless Vector Control for Permanent Magnet Synchronous Machine
load in order to guarantee stable operation of the observer. Otherwise the observer will not be able to
track the speed in time and the control will become unstable.
For the startup scenario a Finite State Machine is used. The system is first started with a current
ramp in current control mode in order to align the position of the machine. After the current ramp
and a short settling time, the speed control is started. If the drive system is operated with encoder,
this startup scenario is omitted. The observer is already set to an initial speed of 500 rpm for a better
transient response during startup. For robust system behavior, an abrupt speed change is limited with
a rate limiter.
CLrst
Is
Analog
In
abc
dq
dq
abc
Current
Control
Idq*
Vs*
Idq
ωe
0
Id*
En
Digital
Out
2000
ωm*[rpm]
ω
Control
Iq
ωe
ωe*
Vdc
Analog
In
1
Enable
θ
Obs.
Enc.
ωe
PWM
PWM
Out
Enc.
c
ω
2
s
Enc.
Count
1
Observer
Enable
StartupScenario
OSrst
CLrst
mode
ObsEn
enable
mode
1
2
3
mode
C
U(I)
θ,ω
Observer
iγδ
ωe
θ
uγδ*
1
mode
Rate
2000
1
2
3
mode
w_start
ωmstart
OSrst
max
2
*
*
*
/
NOT
ObsEn
Figure 4: Controller model of the sensorless rotor-field oriented control
Rotor-field oriented control is applied to the drive system and the basic structure is shown in Fig 4,
where the stator current is regulated in the dq-frame. The speed and rotor position can be calculated
by either using the Observer subsystem or Encoder Counter target block. This selection is made by
the “Selector” block, where the observer can be enabled or disabled. A higher-level controller is imple-
mented for speed control, whereby a speed reference in rpm can be set. The complete controller can be
enabled or reset via “Enable”. In this case, the model continues to run in open loop with a fixed mod-
ulation index. In further investigations where the “Plant” RT box is replaced by real hardware, this
Digital Out is needed for enabling and disabling.
The voltages are the control variables and are represented in the dq-frame which can be derived from
Eq. 2 while Lsd =Lsq. The currents are controlled with a PI controller, which is explained in the fol-
lowing.
ud
uq
=
Rs−ωLsq
ωLsd Rs
·
id
iq
+
Lsd 0
0Lsq
·
d
dt id
d
dt iq
+
0
ω f
(2)
PI current controller
The d and q axis currents which are controlled by a PI controller are included in subsystem “Current
Control”, which is shown in Fig 5. The proportional and integral gains are designed following the “Op-
timum Magnitude” method, which is described in more detail in the “Boost Converter” demo model of
www.plexim.com 4

Sensorless Vector Control for Permanent Magnet Synchronous Machine
Idq*
Vs*
Idq
ωe
+
−
Ls
+
−
+
+
*
*
+
+
Phi
CLrst
CLrst
d-axis
e
u
Kp
Ki
Kbc
PI(s)
q-axis
e
u
Kp
Ki
Kbc
PI(s)
C
C
C
C
C
C
Figure 5: PI controller in dq-frame
the RT Box Target Support Package. For the PI controller a PLECS library block was used, further
descriptions can be found under help button. As the parameter source is set to external, the control
parameters Kp and Ki can be manipulated during a real time simulation on the RT Box. Additionally
the integrators can be reset via the “CLrst” signal.
Rotor position and speed observer
The “Observer” subsystem shown in Fig. 6 was developed according to [1] and is explained conceptu-
ally in the following. The observer can be utilized by any type of synchronous motor such as a surface
PMSM (non-salient Ld=Lq), interior PMSM (with saliency Ld< Lq) and synchronous reluctance
motor.
In the observer model the estimated rotating γ-δframe is used, which differs from the d-q reference
frame by the position error θe.
The position error θeis obtained from the extended electromotive force (EMF), which is estimated by
the observer. The position error θeis used to estimate rotor position and speed. Fig. 7 shows the con-
ceptional block diagram of the least-order observer for estimating the eγwhere gis the observer gain,
which is set to g= 600. The δ-axis component of eδis estimated in the same way as eγ. Comparing
Fig. 6 with Fig. 7, the blue dotted frame outlines how the observer is embedded in the overall model.
The sign block evaluates the reference speed and gives a negative “sign” to position error θe, if the ref-
iγδ
ωe
θ
uγδ*
+
−
+
−
df/dt
+
+
Ls
Rs
1/s
K
*
*
+
+
+
−
θerror
eγ
θe
eδ
ω
θe
ω0
Observer
Gain
rst
Observer
Gain1
rst
rst
sign
OSrst
OSrst
OSrst
Figure 6: Subsystem of rotor position and speed observer
erence speed is negative. This is necessary during start-up of the drive to ensure correct tracking of
the observer. All integrators of the observer can be reset by the “OSrst” signal.
www.plexim.com 5

Sensorless Vector Control for Permanent Magnet Synchronous Machine
Figure 7: Equivalent block diagram of least-order observer
Algorithm
The machine model used for the sensorless control algorithm is given in γ−δcoordinates including the
extended EMF [1]:
uγ
uδ
=
Rs−ωLsq
ωLsd Rs
·
iγ
iδ
+
Lsd 0
0Lsq
·
d
dt iγ
d
dt iδ
+
eδ
eγ
(3)
where
eδ
eγ
=Eex
−sin θe
cos θe
+ (ˆω−ω)Ls
−iδ
iγ
.(4)
Assuming the error between estimated speed ˆωand actual speed ωis sufficiently small, Eq. 4 can be
simplified and the second therm is eliminated, resulting in Eq. 5.
ˆeδ
ˆeγ
=Eex
−sin ˆ
θe
cos ˆ
θe
(5)
By transforming Eq. 5 position error ˆ
θecan be estimated in two ways, both schemes are implemented
in the configurable subsystem “θeerror”:
Scheme A:
ˆ
θe= tan−1−ˆeγ
ˆeδ(6)
Scheme B:
ˆ
θe≈−ˆeγ
ˆ
Eex (7)
A PI compensator Ge(s)is used to compensate the estimated speed ˆωand estimated position ˆ
θ, so that
the position error ˆ
θebecomes zero. During acceleration the estimated position error can be reduced
using a 3. order instead of a 2. order compensator. Both are implemented in a configurable subsystem.
Ge(s) = K1−K2
s+K3
s2(8)
www.plexim.com 6

Sensorless Vector Control for Permanent Magnet Synchronous Machine
The coefficients are designed with a natural frequency of ωn= 70 rad/s and a damping factor of ζn=
1.5for the 2. order compensator according to the following rule: K1= 2ζnωn, K2=ζnω2
n. The 3. order
compensator is designed according to the following rule: s3+K1s2+K2s+K3= (s+ωn)(s2+2ζnωns+ω2
n).
The cutoff frequency of the low-pass filter for the speed estimator is selected as 1000 rad/s.
Speed Controls
To control the drive speed a outer speed control loop is provided. The time constants of the outer con-
trol loop is dictated by mechanical time constants, which is larger on comparison to the inner current
control loop. The proportional-integral speed controller can be described as follows
T∗
e
∆ωm
=Kp1 + 1
τis(9)
Te∗defines the reference torque and ∆ωmis defined as ∆ωm=ω∗
m−ωm. The controller is represented
in terms of a proportional gain Kpand integral time constant τi. According to [2] page 117 ff. for the
closed loop transfer function of the speed controller the bandwidth is effectively defined by the band-
width frequency ωsp
B, while the proportional gain is given as
Kp=ωsp
BJ(10)
The inertia J of the total mechanical load must be taken into account additionally for designing the
control parameters. For this purpose, the total combined inertia must be estimated.
According to [2] ωsp
B= 100 rad/s is a typical value for the effective speed control bandwidth in high-
performance drives. In this demo model, however, a lower value of ωsp
B= 70 rad/s was assumed due to
the additional delay of the observer. The value ωsp
B, together with the inertia J, fully defines the pro-
portional gain of the controller.
For a damping factor of ζ= 1 and the already defined Kp, the integral time constant τiis determined
as follows:
τi=4
ωsp
B
.(11)
The manipulated variable of the speed controller is the reference torque T∗
e, which in turn is the set-
point of the inner current controller loop. Therefore a conversion from mechanical torque Teto iqcur-
rent has to be done regarding Eq. 12. The values for flux linkage Ψmof the permanent magnets and
number of rotor permanent magnet pole pairs pare needed additionally.
Te=3
2Ψmiqp(12)
To perform this conversion the gain block with the coefficient Kis used.
i∗
q=T∗
e
K(13)
3 Simulation
This model can run both in offline mode on a computer or in real-time mode on the PLECS RT Box.
For the real-time operation, two RT Boxes (referred to as “Plant” and “Controller”) need to be set up as
demonstrated in Fig. 8 using three DB37 cables.
Please follow the instructions below to run a real-time model on two RT Boxes:
www.plexim.com 7

Sensorless Vector Control for Permanent Magnet Synchronous Machine
Analog In
Analog Out
Digital In
Digital Out
Analog In
Analog Out
Digital In
Digital Out
Controller Plant
Analog Signals
PWM Signals
Encoder Signals
Figure 8: Hardware configuration for the real-time operation of the demo model
• From the System tab of the Coder options... window, select the “Plant” and Build it onto the
“Plant” RT Box. Then, select “Controller" and Build it onto the “Controller” RT Box. If this se-
quence is not followed, the control will become unstable and the controller must be reseted via “En-
able” to force a restart.
• Once the models are uploaded, from the External Mode tab of the Coder options... window, Con-
nect to both RT Boxes and Activate autotriggering.
3.1 Transient Scenarios
The load profile alternates between 0.04 Nm and 0.06 Nm with a nominal torque of 0.1 Nm, which is
shown in Fig 9. The required torque can be compensated through the current controller in approx.
0.05 s. The drop in speed, which is approx. 200 rpm, can be compensated from the speed controller
within 0.5 s.
Step change of speed reference
The stator current, rotational angle and speed are shown in the scope of the “Controller” subsystem.
To observe a transient behavior of the system, e.g. a step change of the speed reference from 1000 rpm
to 2000 rpm, please further follow the scenario below:
• Make sure that the External Mode and Activate autotriggering of both RT Boxes are enabled.
• Switch the Trigger channel parameter to [Observer] in the External Mode tab of the “Con-
troller” subsystem’s Coder options... window.
• Setup the Trigger level parameter to be 1500 and Trigger delay [steps] to be −4000.
• Open the controller subsystem and change the Constant block “ω∗
m” from the default value of 1000 to
2000.
The step change will be captured by the scope in the “Controller” subsystem, as shown in Fig. 10. A
comparison between the measured angle and speed from the encoder and the estimated angle and
speed from the observer is shown. Nevertheless, the measured and estimated speed match each other
very well. When the speed reference changes rapidly, the position estimation error and the speed esti-
mation error are caused. However, this error is very small and has very little effect on the motor con-
trol. At speeds below 1000 rpm, a larger speed ripple becomes visible. In general, the observer works
better for higher speeds, but this effect is additionally amplified in lower speed ranges by a blanking
time.
www.plexim.com 8

Sensorless Vector Control for Permanent Magnet Synchronous Machine
StatorCurrents
RotationalSpeed(ωr)
ElectricalTorque(Te)
Current(A)
-2
0
2
Speed(rpm)
0
1000
2000
Time(s)
0.7 0.8 0.9 1.0 1.1 1.2 1.3
Torque(Nm)
0.00
0.05
0.10
ia
ib
ic
Speed
PMSM:Electricaltorque
Figure 9: Transient response of the speed controller for a load torque step from 0.01 Nm to 0.02 Nm
(offline simulation results).
Note The literature reference [1] does not describe a specific startup procedure for this sensorless con-
trol algorithm. However, the system start-up procedure is especially delicate when using sensorless
control schemes. This demo model uses a simple open-loop start-up procedure to ramp up the controls
and system operation but does not go into further details. This means depending on the exact timing of
events in a real-time simulation the control may fail to start up properly. In such a case the controller
needs to be restarted.
3.2 Conclusions
This model demonstrates a PMSM drive system which can run in both offline simulation and real-time
operation for Hardware-in-the-loop testing and rapid control prototyping. Rotor-field oriented control
is applied to the drive system where the stator current is regulated in the dq-frame. A higher-level
controller is implemented for speed control, whereby an observer is used to track the electrical angular
velocity and rotor position.
www.plexim.com 9

Sensorless Vector Control for Permanent Magnet Synchronous Machine
PhaseCurrents
Rotationalangle
RotationalShaftSpeed
Current(A)
-2
0
2
Angle(rad)
0
2
4
6
1.30 1.35 1.40 1.45 1.50 1.55 1.60
Speed(rpm)
1000
1500
2000
ia
ib
ic
Encoder
Observer
Encoder
Observer
Figure 10: Transient response of speed controller for a change in speed reference from 1000 RPM to
2000 RPM (offline simulation results).
References
[1] S. Morimoto, K. Kawamoto, M. Sanada and Y. Takeda, “Sensorless control strategy for salient-
pole PMSM based on extended EMF in rotating reference frame”, IEEE Trans. Ind. Appl., vol. 38,
no. 4, pp. 1054-1061, Jul./Aug. 2002.
[2] R. De Doncker, D. Pulle and A. Veltman, “Advanced electrical drives”, Springer, 2011.
www.plexim.com 10

Revision History:
RT Box TSP 2.1.5 First release
How to Contact Plexim:
+41 44 533 51 00 Phone%
+41 44 533 51 01 Fax
Plexim GmbH Mail)
Technoparkstrasse 1
8005 Zurich
Switzerland
http://www.plexim.com Web
RT Box Demo Model
© 2002–2021 by Plexim GmbH
The software PLECS described in this document is furnished under a license agreement. The software
may be used or copied only under the terms of the license agreement. No part of this manual may be
photocopied or reproduced in any form without prior written consent from Plexim GmbH.
PLECS is a registered trademark of Plexim GmbH. MATLAB, Simulink and Simulink Coder are regis-
tered trademarks of The MathWorks, Inc. Other product or brand names are trademarks or registered
trademarks of their respective holders.
Other manuals for PLECS RT Box
7
This manual suits for next models
3
Table of contents
Other Plexim Media Converter manuals

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim RT Box TSP 2.0.5 User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual
Popular Media Converter manuals by other brands

ZyXEL Communications
ZyXEL Communications Ethernet-to-Fiber Media Converter... datasheet

Pinacl
Pinacl 2233 user manual

SMARTIX
SMARTIX DH16 quick start guide

Samson
Samson 611 Mounting and operating instructions

Midimuso
Midimuso CV-12 Assembly instructions

Menards
Menards MASTERFORCE 260-9519 Operator's manual