首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写program、代做Matlab编程语言
项目预算:
开发周期:
发布时间:
要求地区:
School of Engineering 1 of 13
Control of an Electric Drive in Simulink
Introduction
Simulink is a dynamic simulation environment of Matlab, in which complex
physical systems can be modelled through differential equations and their
behaviour can be analysed. An electric drive can also be modelled in Simulink
through the equations governing its operation. However, as the electric drive
consists of different subsystems, such as an electric motor, a power electronic
converter, a mechanical load, each of these subsystems can be modelled
separately before combining them into a single model to emulate the behaviour
of a complete electric drive.
Fig. 1 shows the basic structure of an electric drive. The type of the motor
determines the configuration of the power converter, the number of sensors,
and the control algorithm. For example, if the motor is a dc machine, then the
power converter would be a half-bridge (two-quadrant drive) or a full H-bridge
(four-quadrant drive), there will be one current sensor and one dc-link voltage
sensor. The position/speed of the rotor is acquired through a shaft-mounted
position sensor.
Fig. 1 A typical electric drive
Using the blocks and tools offered by Simulink, the physical behaviour of the
blocks shown in Fig. 1 can be emulated. The scheme of Fig. 1 in terms of Simulink
blocks is shown in Fig. 2. The highlighted areas represent different subsystems
of Fig. 1. The area labelled ‘Display’ shows a scope on which different quantities
can be plotted as a function of time to visualize the time evolution of different
variables. The subsystems are briefly described below.
Motor Load Power
Converter
Control
algorithm
User set
points
Sensors
Conversion
to digital
domainControl of an Electric Drive in Simulink
School of Engineering 2 of 13
Fig. 2 Simulink block diagram of a dc motor drive
The motor
In Fig. 2, a dc motor is shown as the actuator, but it can also be any other
electrical machine, such as a three-phase permanent magnet synchronous
motor. The details of the ‘Motor’ subsystem are shown in Fig. 3. As observed,
they are the electrical and mechanical state equations of a separately excited
constant flux dc motor. The applied armature voltage is the electrical actuation
signal and the torque produced by the machine acts as the mechanical actuation
signal. The load torque is shown as a separate input, which can be either a
constant, a step function or any other load torque profile depending on the
application being analysed. The outputs of the dc motor block are the armature
current and the rotor mechanical position. The user can choose to have the
mechanical speed as another output.
The parameters of the dc motor can be set/changed by double clicking on the
block and just inputting the new values in the dialog box. Fig. 4 shows the dialog Control of an Electric Drive in Simulink
School of Engineering 3 of 13
box for the dc motor parameters. Since all the parameters shown in Fig. 4 are in
their standard SI units, the inputs (voltage and load torque) and the outputs of
(current and angle) of the motor block should also be interpreted in their
standard SI units.
Fig. 3 Simulink block implementation of the state equations of a constant flux dc motor
Fig. 4 Parameter dialog box for a constant flux dc motor Control of an Electric Drive in Simulink
School of Engineering 4 of 13
The power converter
For a dc motor drive, the power electronic converter can consist of a half-bridge
or a full H-bridge depending on whether the motor is required to rotate in one
direction only (half-bridge) or in both directions (full-bridge). To preserve
generality of the implemented drive system, a full H-bridge is simulated to give
maximum flexibility to the user. The power converter block also includes a pulse
width modulation (PWM) scheme that converts the duty cycles for the two legs
of the H-bridge (da and db) into pulses of varying widths. The dc-link voltage is
defined as a constant input decided by the user. The modulator block’s
parameter dialog box is shown in Fig. 5, which requires the user to input the
switching frequency in Hz. The details of the modulator block are shown in Fig. 6.
Fig. 5 Parameter dialog box for the modulator
Fig. 6 H-bridge modulation scheme Control of an Electric Drive in Simulink
School of Engineering 5 of 13
Sensors and ADCs
In electric drives, voltage, current and position sensors are used to measure the
dc-link voltage, the load currents and the shaft position respectively. Since these
quantities are in the analog domain while the control, in modern electric drives,
is in digital domain, an analog to digital conversion is necessary. Analog to digital
converters (ADCs) do this conversion and provide the controller with
measurements at a fixed sampling frequency (decided by the drive designer).
The sensors measuring the voltage and current also introduce noise on the
measurements, which is normally a zero-mean, constant variance white noise.
In addition to the white noise on the analog signal, the noise due to the
quantization effect of the ADCs impacts the measurement in the digital domain
further. All these effects are simulated inside the ‘Sensing subsystem’ of Fig. 2
as detailed in Fig. 7.
For the shaft position measurement, incremental or absolute position sensors
are normally used in electric drives. The resolution of the position signal
available to the controller depends on the number of pulses per revolution of
the incremental encoder or the bit resolution of the absolute encoder. The fixed
resolution of the position sensors introduces a quantization noise on the
position signal. This quantization noise is emulated in the simulation for an
incremental encoder.
Fig. 7 Sensor subsystem structure Control of an Electric Drive in Simulink
School of Engineering 6 of 13
It can be noticed from Fig. 7 that there is only one input current ia but two other
currents ib and ic are included to allow the user to simulate a three-phase
system. For a three-phase machine, the currents ib and ic must also be added as
inputs to the block rather than constants as shown in Fig. 7.
Fig. 8 shows the parameter dialog box for the sensing subsystem. The range of
the current and voltage measurement must be set such that this range is not
exceeded at any time. The resolution of the ADCs is usually 12-bit in commercial
electric drives but can also be 14 to 16-bit in case of high-end drives. The pulseper-revolution
(ppr) value for incremental encoders starts from as low as 12ppr
for very low-cost encoders and can be in excess of 10,000ppr for devices used
for precision applications.
Fig. 8 Sensor subsystem parameters
Control algorithm
The control algorithm for the electric drives is normally executed on a digital
signal processor (DSP) at a fixed control execution frequency, usually at the
switching frequency of the power converter. The control routines are normally
written in a high-level language such as C. The block labelled ‘Control’ in Fig. 2
emulates the behaviour of a DSP that samples the input data at a fixed frequency
and outputs the duty cycles for the power converter after one execution cycle.
The details of the block are shown in Fig. 9. Control of an Electric Drive in Simulink
School of Engineering 7 of 13
This block consists of a Matlab s-function. S-functions (system-functions)
provide a powerful mechanism for extending the capabilities of the Simulink
environment. An S-function is a computer language description of a Simulink
block written in MATLAB, C, C++, or Fortran. The block labelled ‘simple_control’
is like any other Simulink block but its behaviour can be fully controlled by the
user by modifying the program that describes it.
Fig. 9 Details of the block labelled ‘Control’ in Fig. 2
In electric drives, the control algorithm is executed on a DSP that can be
programmed in C, BASIC and assembly languages with C being the most
commonly used language. The s-function feature of Simulink is therefore used
to program the functionality of the block ‘simple_control’ in C.
The program describing an s-function block must follow a certain structure and
must contain some pre-defined functions and definitions. To program the
s-function block properly, it is recommended to start with an example code such
as ‘sfuntmpl_doc.c’ or ‘sfuntmpl_basic.c’ available from Matlab and modify
according to the requirements of the application. The available templates are
for a level 2 s-function.
The number of inputs, outputs and parameters of the s-function block are
defined inside the C program and they must match the inputs and outputs in Control of an Electric Drive in Simulink
School of Engineering 8 of 13
Simulink. The parameters passed by Simulink to the s-function are listed in the
dialog box of the s-function as shown in Fig. 10. In Fig. 10, the only parameter
that Simulink passes to the s-function is Ts, the sampling time. Inside the C
program describing the s-function, this parameter Ts is used to define the
execution sample time of the s-function block i.e. the block is executed every Ts
seconds.
Since the execution time of the s-function must match the switching period of
the power converter and the sampling frequency of the current, voltage and
position measurements, the parameter Ts is defined as a global constant for the
simulation. To change this parameter, go to: File->Model Properties->Model
Properties, click on the tab Callbacks and then click InitFcn.
Fig. 10 Parameter dialog box for the s-function shown in Fig. 9
Some screenshots from the C code for the s-function ‘simple_control’ are shown
below with a brief explanation of the functions, variables and parameters.
S_FUNCTION_NAME: this constant defines the name of the s-function and it
must correspond to the name of the file (without the extension .c) which is also
used as the s-function name in the block (see Fig. 10). Control of an Electric Drive in Simulink
School of Engineering 9 of 13
The header files, such as aux_funcs.h and Constants.h are user-defined .h files
that contain definitions of functions and constants used in the code. The two
header files are included as an example, others can be defined and included as
necessary.
Fig. 11 Code lines defining the type of the s-function, inputs, outputs and parameters
U(element): this function macro gets a pointer to the vector of inputs from
Simulink and allows to get the inputs to local variables.
NUM_INPUTS, NUM_OUTPUTS, NUM_PARAMS: these must correspond to the
inputs, outputs and parameters of the s-function block in Simulink. If these
constants do not match the s-function block’s conditions, Matlab will generate
an error and will not compile the code for execution.
The parameters passed by Simulink to the function can be accessed as elements
of the parameter array starting from 0. For example, the first parameters will be
read in as: (mxGetPr(ssGetSFcnParam(S,0))[0]). The second parameter can be
read in as: (mxGetPr(ssGetSFcnParam(S,0))[1]).
The global variables should be defined outside of any functions so that they’re
accessible to all the functions. In Fig. 11, TS, TS_INV and thm_prev are global
variables. Variables that must hold their values between executions can be
declared as global, although it is not strictly necessary.
In Fig. 12, the sizes of the inputs, outputs, sample times, and other arrays are
defined. It is important to set the number of sample times to 1 through the Control of an Electric Drive in Simulink
School of Engineering 10 of 13
function ssSetNumSampleTimes(S, 1); as the s-function is intended to be a
single-execution-rate block in our application of an electric drive. The sample
time of the s-function is then set by calling ssSetSampleTime(S, 0, Ts); as shown
in Fig. 13. The figure also shows the initialization conditions that the user can
set, for example, assigning initial values to the global variables.
Fig. 12 Definition of the s-function code array sizes
Fig. 13 s-function sample time and initialization conditions Control of an Electric Drive in Simulink
School of Engineering 11 of 13
The outputs for the model are calculated through the function mdlOutputs
shown in Fig. 14. First, the inputs from the Simulink environment are read into
the local variables and arrays. The calculations necessary for the control of an
electric drive are performed on these local variables before passing the outputs
to Simulink. This is the function where almost all of the code related to the
drive’s control should reside.
Fig. 14 Some code lines for mdlOutputs function
To complete the process of building a Simulink block from a C program, the code
must be compiled into a Matlab executable file. The command used for this is
mex (that stands for Matlab executable). This command must be called in the
Matlab command window by ensuring that the folder in which the code files are
located is selected as the ‘current folder’ in Matlab (see Fig. 15). All the .c and .h
files that contain the functions used inside the main file ‘simple_control.c’
should be within the current folder and all .c source files must be included as Control of an Electric Drive in Simulink
School of Engineering 12 of 13
input arguments of the mex command as shown in Fig. 15, where aux_funcs.c is
the second .c source file that must be compiled along with simple_control.c.
Every time anything is changed in the code (e.g. changing a parameter in a .h file
or adding/deleting a line in any .c file of the project), the mex command should
be repeated before expecting a change in the behaviour of the s-function block.
This process is similar to compiling and building the project files in a DSP code.
Fig. 15 Instructions for compiling the C code into a mex file
A C compiler will be needed to compile the code into a mex file. There are
several compilers available from Mathworks, any of these can be used for
compiling the code.
Once successfully mexed, the current folder will have a mexw file with the name
of the s-function e.g. simple_control.mexw64. This file will be accessed by
Simulink during simulation as the contents of the S-function block shown in
Fig. 9. Control of an Electric Drive in Simulink
School of Engineering 13 of 13
The task
Your task is to understand the model and the basic project you are provided.
Simulate it with different conditions to enhance your understanding and be
familiar to the model and the C code. Then, starting from the basic project as
described above, develop the model and C code for the following objectives:
1) Armature current control of the dc motor
2) DC motor’s speed control
3) Apply different load torque profiles to test your speed control
4) DC motor’s position control (optional)
5) A model to simulate a three-phase PMSM drive (advanced)
6) Simulate vector control of a three-phase PMSM (advanced)
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做 program、代写 c++设计程...
2024-12-23
comp2012j 代写、代做 java 设...
2024-12-23
代做 data 编程、代写 python/...
2024-12-23
代做en.553.413-613 applied s...
2024-12-23
代做steady-state analvsis代做...
2024-12-23
代写photo essay of a deciduo...
2024-12-23
代写gpa analyzer调试c/c++语言
2024-12-23
代做comp 330 (fall 2024): as...
2024-12-23
代写pstat 160a fall 2024 - a...
2024-12-23
代做pstat 160a: stochastic p...
2024-12-23
代做7ssgn110 environmental d...
2024-12-23
代做compsci 4039 programming...
2024-12-23
代做lab exercise 8: dictiona...
2024-12-23
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!