![Page 1: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/1.jpg)
The World Leader in High Performance Signal Processing Solutions
Model-Based Design For Motor Control Development
Paul Crook – Analog Devices
![Page 2: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/2.jpg)
2
Topics
Developing motor control applications using model-based design and automatic code generation
Hardware platform Model-Based Design overview Modeling of motor control systems Simulation and automatic code generation Running generic C-code on embedded platformWhen to use MBD and when to use “traditional” design
methods
![Page 3: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/3.jpg)
3
ADI Demo Platforms
Motor Drive hardware 3 phase PM motor PC with MATLAB®, Simulink®, and IAR Embedded Workbench
![Page 4: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/4.jpg)
4
HW Platform
100V-250V AC input with PFC, 5A Isolated current, position, voltage and diagnostic feedback 3-phase, 0.55kW, permanent magnet synchronous motor
![Page 5: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/5.jpg)
5
ADSP-CM40x Embedded Target
Key PointsARM CORTEX M4F240MHzTwo 16-bit ADCs
380ns conversion time
SINC filter384kB SRAM2MB Flash20 DMA channelsPeripherals for
motor controlCommunication
interfaces
![Page 6: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/6.jpg)
6
MODEL-BASED DESIGN
![Page 7: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/7.jpg)
7
Why Model-Based Design?
• Requirements Development• System Simulation• Automatic Code Generation• Continuous Verification
![Page 8: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/8.jpg)
8
The Traditional Design Process
Requirements Phase
Design Phase
Realization Phase
Testing Phase
![Page 9: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/9.jpg)
9
Traditional Design of a Multi-Domain System
Integration, Test & Certification
Research & Requirements
Software
Requirements
Design
Realization
Testing
Hardware
Requirements
Design
Realization
Testing
Mechanical
Requirements
Design
Realization
Testing
![Page 10: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/10.jpg)
10
The Cost of a Traditional Design Process
Source: ROI for IV&V, NASA
![Page 11: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/11.jpg)
11
Model-Based Design
• Automate regression testing
• Detect design errors
• Parameter tuning
• Support certification and standards
• Generate efficient code
• Explore and optimize implementation tradeoffs
• Model multi-domain systems
• Explore and optimize system behavior in floating point and fixed point
• Collaborate across teams and continents
INTEGRATION
IMPLEMENTATION
DESIGN
TE
ST
& V
ER
IFIC
AT
ION
RESEARCH REQUIREMENTS
ARM
C, C++
Environment Models
Physical Components
Algorithms
![Page 12: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/12.jpg)
12
Model-Based Design for Embedded System Development
Designwith
Simulation
ExecutableSpecifications
ContinuousTest and
Verification
AutomaticCode Generation
Models
Designwith
Simulation
ExecutableSpecifications
ContinuousTest and
Verification
AutomaticCode Generation
ModelsTest with Design- Detects errors earlier
Simulation- Reduces “real” prototypes- Iterative “what-if” analysis
Automatic code generation- Minimizes coding errors
Executable models- Unambiguous- “One Truth”
![Page 13: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/13.jpg)
13
Steps in MBD approach
1. Plant modeling- Motor, load, power electronics etc.
2. Interface modeling- Sensors, device drivers
3. Controller modeling- Field oriented control of 3 phase PM motor
4. Analysis and synthesis- The models created in step 1-3 are used to identify dynamic
characteristics of the plant model.- Tuning and configuration of system
5. Validation and test- Offline simulation and/or real-time simulation- Time response of the dynamic system is investigated
6. Deployment to embedded target- Automatic code generation- Test and verification
![Page 14: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/14.jpg)
14
Steps in MBD approach
Simulation of Controller and Plant model Off-line development of algorithms without access to HW Code generation and deployment to embedded controller Comparison between simulation and actual implementation
PC
Target
Controller Model
Motor/inverterModel
System Model
TestSignals Verify
CodeGeneration
Motor Drive System
System
Embedded Controller
Motor/inverter
HW
![Page 15: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/15.jpg)
15
Model complexity
What is a good model?Represent the states of interestSupports automatic code generationExecute fastUse existing (trusted) librariesReusable across platforms
Too little Too much
?
Right balance
5
![Page 16: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/16.jpg)
16
Model complexity
Understanding strengths and weaknesses of tools is critical when defining model scope
Strength
Weakness
- Solving differential equation- Time domain modeling- Visualization- Target specific setup- Managing system resources- Time scheduling
- Register setup and control- Managing System resources- Time scheduling- Real time control systems- Debugging and test- Visualization
![Page 17: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/17.jpg)
17
Interfacing to Embedded Target
SW architectureGeneric C-code needs to be tied to embedded platformUtilizing strength of multiple environmentsGraphical environment for application code development“Classic” C-code for target specific control
Control Algorithm
Embedded Platform
HW interface layerPl
atfor
m
inde
pend
ent
Platf
orm
de
pend
ent
![Page 18: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/18.jpg)
18
Interfacing Embedded Target
Two platforms – one implementationCommon control algorithm for Simulation and Embedded systemPlatform specific device drivers or behavioral models
Debug algorithm using simulation and test on embedded platform
![Page 19: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/19.jpg)
19
Drive system feedback and control
Feedback
![Page 20: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/20.jpg)
20
Motor Control Application Program
Power Inverter and Motor
Sensors, interfaces and Device Drivers
MC Algorithm
MC ‘C’ codeDevice driversApplication code
CC & LinkMC ApplicationFirmware
Device Driver
Aut
oco
de
![Page 21: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/21.jpg)
21
AC Motor Algorithm (Field Oriented Control)
Shaft position sensor measures rotor magnet (flux) position – velocity is calculated. Two/three motor currents measured (two is enough). Clarke-Park transfer calculate Torque (Iq) and Flux (Id) components of current. Speed loop generates Iq reference; Id reference set to zero for PMSM. Current loops and Field alignment generates a,b,c voltage commands.
![Page 22: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/22.jpg)
22
Field oriented control
![Page 23: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/23.jpg)
23
Simulation
0 1000 2000 3000 4000 5000-250
-200
-150
-100
-50
0
Frequency [kHz]
Mag
nitu
de
[dB
]
0 1000 2000 3000 4000 5000-3000
-2000
-1000
0
Frequency [kHz]
Pha
se [
Deg
rees
]
Simulink scopes Code debugging
Data analysis in MATLAB
![Page 24: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/24.jpg)
24
Generating C-code
![Page 25: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/25.jpg)
25
Building and Linking – IAR EWB
![Page 26: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/26.jpg)
26
Building and Linking
Workbench
Matlab/Simulink
Motor Control- FOC functions
ARM Library- M3/M4 support
Executable
C-code
Device drivers- SW enablement package
Application code- State machines
Scheduling- IRQs/RTOS
C-code C-code
Device Drivers- Functional model
System resources- Allocation & setup
Legacy code- Existing code
CM40x
![Page 27: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/27.jpg)
27
Running target
MATLAB GUI + embedded engineStreaming data back to MATLAB
0 20 40 60 80 100 120 140 160 180 200-1000
-500
0
500
1000
Dut
y-cy
cle
Captured runtime data
0 20 40 60 80 100 120 140 160 180 2002.5
3
3.5
4x 10
4
Pha
se c
urr
en
t
0 20 40 60 80 100 120 140 160 180 2000
2
4
6
8R
oto
r a
ng
le
Sample number
![Page 28: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/28.jpg)
28
Sampling domains
10 kHz
1 kHz
![Page 29: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/29.jpg)
29
Summary
Model-Based DesignSystem modeling and simulationAutomatic code generation
Modeling of motor control systemsElectronics/mechanicalInterfacesControl algorithm
Interfacing generic C-code to embedded targetUse of different environmentsDevice drivers
Debugging and testOff-lineIn real-time
![Page 30: Model-Based Design For Motor Control Development](https://reader035.vdocument.in/reader035/viewer/2022070321/558ca280d8b42ab3318b4605/html5/thumbnails/30.jpg)
30
Questions