0% found this document useful (0 votes)
210 views

MBDT General Presentation

Uploaded by

Vu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views

MBDT General Presentation

Uploaded by

Vu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 150

MODEL-BASED DESIGN TOOLBOX

ENABLING FAST PROTOTYPING AND DESIGN

ON-TARGET RAPID PROTOTYPING FOR


MODEL-BASED DESIGN AND
MOTOR CONTROL APPLICATION DEVELOPMENT

EXTERNAL USE
Agenda
• Overview:
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo:
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER

• Model-Based Design:
− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control:


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo:


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control:


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo:
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A:

1 EXTERNAL USE
Introduction: Model-Based Design (MBD)
• Model-Based Design is becoming more common during the normal course of software development to
explain and implement the desired behavior of a complex system. The challenge is to take advantage of
this approach and get an executable that can be simulated and implemented directly from the model to help
you get the product to market in less time and with higher quality. This is especially true for electric motor
controls development in this age of hybrid/electric vehicles and the industrial motor control application
space.

• Many companies model their controller algorithm and the target motor or plant so they can use a simulation
environment to accelerate their algorithm development.

• The final stage of this type of development is the integration of the control algorithm software with target
MCU hardware. This is often done using hand code or a mix of hand code and model-generated code.
Model-Based Design Toolbox allows this stage of the development to generate 100% of the code from the
model.

2 EXTERNAL USE
Introduction: Model-Based Design Toolbox
• The Model-Based Design Toolbox includes an embedded target supporting NXP MCUs, Simulink™ plug-in
libraries which provide engineers with an integrated environment and tool chain for configuring and
generating the necessary software, including initialization routines, device drivers, and a real-time scheduler
to execute algorithms specifically for controlling motors.
• The toolbox also includes an extensive Math and Motor Control Function Library developed by NXP’s
renowned Motor Control Center of Excellence. The library provides dozens of blocks optimized for fast
execution on NXP MCUs with bit-accurate results compared to Simulink™ simulation using single-precision
math.
• The toolbox provides built-in support for Software and Processor-in-the-Loop (SIL and PIL), which enables
direct comparison and plotting of numerical results.

MathWorks products required for MBD Toolbox:


− MATLAB (32-Bit or 64-Bit)*
− Simulink
− MATLAB Coder
− Simulink Coder
− Embedded Coder
*Earlier released products only support 32-bit
3 EXTERNAL USE
Reduce Development Time with Model-Based Design
Use software-based model Fewer defects found in
System vs. paper-based method, this phase of testing, Functional
Requirements and start testing at very where finding defects is Testing
earliest stage. expensive.

Convert model to SIL


and now can test
Modeling/ ANSI-generated
Simulation software. Can also
use MC library with
SIL testing.

With AMMCLIB HIL Testing


library and MBD
Toolbox, test Rapid Prototype
Model using target
Now that more testing
MCU and compiler
on target has occurred
through PIL
earlier in the process,
testing.
HIL testing time is
reduced.
With MBD Toolbox, auto-
Target MCU
generate code for direct
interface of peripherals for Implementation Reduce Time
target hardware without any
manual hand code. Time
from This. . .
Using NXP’s Model-Based Design Toolbox you can reduce development time from this.

4 EXTERNAL USE
Objectives

• Exposure to NXP’s hardware/software enablement

e.g.:MTRCKTSBNZVM128 Model-Based Design Toolbox


with Simulink ™

Model-Based Design
Driver configuration
Assignment to pins
Initialization setup

BLDC Motor Control Dev Kit

Signal Visualization
and Data Acquisition Tool

5 EXTERNAL USE
Agenda
• Overview: 20 minutes
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo: 50 minutes


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MBD Toolbox and use FreeMASTER

• Model-Based Design: 10 minutes


− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control: 30 minutes


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo: 80 minutes


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control: 20 minutes


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo: 80 minutes
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A: 10 minutes

6 EXTERNAL USE
MBD Toolbox: Library Contents
Simulink
Libraries
MBD Toolbox
Peripheral block
library

MBD Toolbox
Library for
S12ZVM

7 EXTERNAL USE
Model-Based Design Toolbox: Toolbox Contents

On-Chip Peripherals Configuration/Modes Utilities


• General • FreeMASTER Interface
• Compilers Supported
− ADC conversion - Data acquisition
− CodeWarrior
− Digital I/O - Calibration
− Wind River DIAB - Customize GUI
− PIT timer
− Green Hills • Profiler Function
− ISR
− Cosmic - Exec. time measurement
• Communication Interface - Available in PIL
− CAN driver − IAR
- Available in standalone
− SPI driver − GCC
− I2C − RAM/FLASH targets
− UART • Simulation Modes
• Motor Control Interface
− Cross triggering unit
− Normal Embedded MCU Support
− Accelerator
− PWM
− Software in the Loop (SIL) • MPC5643L
− eTimer block(s) • MPC567xK
− Processor in the Loop (PIL)
− Sine wave generation • MPC574xP
− ADC Command List • MCU Option • S12ZVM
− GDU (Gate Drive Unit) − Multiple packages • KV10Z
− PTU (Programable Trigger Unit) • 56F82xx
− Multiple Crystal frequencies
• KV31/30/40/50
− TIM Hall Sensor Port
• S32K
− FTM (Flex Timer Module)
− PDB (Programmable Delay Block)

8 EXTERNAL USE NOTE: Peripheral Blocks and compiler support is dependent on MCU use.
Automotive Math and Motor Control Library Set - Architecture
General Motor Advanced Motor
Control Library Control Library

General Digital
General Function
Filters Library
Library

9 EXTERNAL USE Mathematical


Library
Automotive Math and Motor Control Library Set – Content

MLIB GFLIB GDFLIB GMCLIB AMCLIB

• Absolute Value, Negative Value • Trigonometric Functions • Finite Impulse Filter • Clark Transformation • BEMF Observer DQ
• MLIB_Abs, MLIB_AbsSat • GFLIB_Sin, GFLIB_Cos, • GDFLIB_FilterFIR • GMCLIB_Clark • AMCLIB_BemfObsrvDQ
• MLIB_Neg, MLIB_NegSat GFLIB_SinCos, GFLIB_Tan • Moving Average Filter • GMCLIB_ClarkInv • Tracking Observer
• Add/Subtract Functions • GFLIB_Asin, GFLIB_Acos, • GDFLIB_FilterMA • Park Transformation • AMCLIB_TrackObsrv
• MLIB_Add, MLIB_AddSat GFLIB_Atan, GFLIB_AtanYX • 1st Order Infinite Impulse • GMCLIB_Park
• MLIB_Sub, MLIB_SubSat • GFLIB_AtanYXShifted • GMCLIB_ParkInv
Filter
• Multiply/Divide/Add-multiply • Limitation Functions • Duty Cycle Calculation
• GDFLIB_FilterIIR1init
• GFLIB_Limit, GFLIB_VectorLimit • GMCLIB_SvmStd
Functions • GDFLIB_FilterIIR1
• GFLIB_LowerLimit, • Elimination of DC Ripples
• MLIB_Mul, MLIB_MulSat
GFLIB_UpperLimit
• 2nd Order Infinite Impulse
• MLIB_Div, MLIB_DivSat • GMCLIB_ElimDcBusRip
• PI Controller Functions Filter
• MLIB_Mac, MLIB_MacSat
• GDFLIB_FilterIIR2init • Decoupling of PMSM Motors
• MLIB_Mnac, MLIB_Msu • GFLIB_ControllerPIr,
• GDFLIB_FilterIIR2 • GMCLIB_DecouplingPMSM
• MLIB_VMac GFLIB_ControllerPIrAW
• GFLIB_ControllerPIp,
• Shifting
GFLIB_ControllerPIpAW
• MLIB_ShL, MLIB_ShLSat
• MLIB_ShR • Interpolation
• MLIB_ShBi, MLIB_ShBiSat • GFLIB_Lut1D, GFLIB_Lut2D
• Normalisation, Round Functions • Hysteresis Function
• MLIB_Norm, MLIB_Round • GFLIB_Hyst
• Conversion Functions • Signal Integration Function
• GFLIB_IntegratorTR
• MLIB_ConvertPU, MLIB_Convert
• Sign Function Delivery Content
• GFLIB_Sign
• Signal Ramp Function  Matlab/Simulink Bit Accurate Models
• GFLIB_Ramp  User Manuals
• Square Root Function  Header files
• GFLIB_Sqrt
 Compiled Library File
 License File (to be accepted at install time)

10 CONFIDENTIAL AND PROPRIETARY


AMMCLib Application Example for MPC5643L
PMSM Field Oriented Control

11 CONFIDENTIAL AND PROPRIETARY


Auto Math and Motor Control Library Set – Supported Devices
GreenHills CodeWarrior WindRiver Cosmic IAR GCC S32DS PPC
Multi Diab
Target Platform
Version Version Version Version Version Version Version
2015.1.4 10.6.4 5.9.4.8 4.3.4 8.11 4.9.3 1.2
MPC560xP
MPC560xB
MPC564xL Available Available Available Not supported1 N/A2 N/A2 Available
MPC567xF
MPC567xK
MPC574xC
MPC574xG
MPC574xP
MPC574xR Available N/A2 Available Not supported1 N/A2 N/A2 Available
MPC577xC
MPC577xK
MPC577xM
S12ZVM N/A2 Available N/A2 Available N/A2 N/A2 N/A2

S32K14x Available Not supported1 N/A2 Not supported1 Available Available N/A2

KEAx Available Available N/A2 Not supported1 N/A2 N/A2 N/A2

1) Not supported: The compiler contains the support of selected device, however the AMMCLib does not support this compiler.
2) N/A: The compiler (or the compiler version) does not support selected device.

12 EXTERNAL USE
MBD Toolbox: RAppID Bootloader Utility
The RAppID Bootloader works with the built-in Boot Assist Module (BAM) included in Freescale Qorivva MCUs or can be
resident in FLASH. The Bootloader provides a streamlined method for programming code into FLASH or RAM on either
target EVBs or custom boards. Once programming is complete, the application code automatically starts.
Modes of Operation
The Bootloader has two modes of operation: for use as a stand-alone PC desktop GUI utility, or for integration with different user required
tools chains through a command line interface (i.e. Eclipse Plug-in, MATLAB/Simulink, …)
MCUs Supported
MPC5534, MPC5601/2D, MPC5602/3/4BC, MPC5605/6/7B, MPC564xB/C, MPC567xF, MPC567xK, MPC564xA, MPC5605/6/7BK,
MPC564xL, MPC5604/3P, MPC574xP, MPC5746R, MPC5746C, MPC5748G, MPC5777C, MPC5775K, S12ZVC, S12ZVL, S12ZVM,
S12VR, KEAZN16/32/64, KEAZ64/128, S32K144, 56F82xx, KV10Z, and KV3x/KV4x/KV5x.

Graphical User Interface Command Line

Status given in two stages:


Bootloader download, then
application programming

13 EXTERNAL USE
What is FreeMASTER?

• Runtime configuration & tuning tool for embedded software


applications
• Graphical Control Panel
• Data Capture tool, interface to custom processing in Matlab, Excel
etc.

What do we do with FreeMASTER? MCU Memory Access

• Connect: to target MCU over UART, CAN,


BDM, JTAG Communication DLL Library

• Monitor: read & show variables in run-time


• Control: set variables, send commands
• Share: enable Excel, Matlab or a script engine
to add hardware to the control loop

Connect over UART, Direct memory access Share any connection


USB, CAN or JTAG j-link, CMSIS-DAP or P&E over the internet

14 EXTERNAL USE
FreeMASTER Topology and Platforms Support

PC Side Embedded Side


User code
Supported platforms:

USB, JTAG, LIN, CAN, BDM ...

USB, JTAG, LIN, CAN, BDM ...


• S08
• DSC

FreeMASTER

FreeMASTER
• ARM Cortex-M (Kinetis/S32)
• S12/S12X/S12Z(MagniV),
• MPC56xx, MPC57xx
• ColdFire V1/V2

UART/SCI UART/SCI

15 EXTERNAL USE
MBD Toolbox: Summary of Customer Application Support

SYSTEM APPLICATION
User Application
Software Application SW
API

Target Platform
GDFLIB Algorithm

GMCLIB
Motor Control
Digital filtering
Libraries
Documentation

GFLIB API
General functions
Drivers
MC library set
On-Chip
Drivers Peripherals
Efficient
Reflecting the chip features PINS

System Infrastructure External Hardware


FreeMaster Boot Loader External
Support Support Connections

16 EXTERNAL USE
Agenda
• Overview:
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo:
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER

• Model-Based Design:
− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control:


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo:


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control:


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo:
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A:

17 EXTERNAL USE
Hands-On Demo: Motor Kit
MTRCKTSBNZVM128
Features:
• MC9S12ZVML/C12MKH
• BDM interface
• On-board OSBDM
• Hall Sensor
• Resolver interface
• SINCOS interface
• LIN/CAN BLDC Motor
• USB-to-SCI serial port
Control Dev Kit
• Phase and DC-bus current sensing circuits
• FAULT indicator
• Over-voltage and over-current FAULT indicator with Motor and Drive Features:
potentiometer adjustments
• Input voltage 12–24 V DC
• 2 User LEDs
• Output current 5–10 Amps
• 2 push buttons
• 3-phase MOSFET inverter using 6 N-
• 1 switch
channel Power MOSFETs
• 4 MHz oscillator
• 4 pole-pair BLDC motor with Hall
• 1 Potentiometer
sensors (9450 RPM rated speed at
24 V)

18 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Load in Flash Bootloader using CodeWarrior Flash Programmer


Use the Flash programmer in CW IDE to program the Flash Bootloader.

19 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Run Simple Model Simulation


1. Open Model “Simple_ADC.slx and save it as S12ZVM_Simple_ADC.slx”
2. You will see a model that changes the output state of a relational operator based on an input value as
compared to a data value.
3. Run simulation and open the scope. You should see the following on the scope:

20 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


1. Save Model as “S12ZVM_Simple_ADC.slx”
2. Select system target file “mcd_s12zvm.tlc” to configure model for the MCU
3. Open Simulink Library
4. Go to Motor Control Toolbox for MC9S12ZVMx -> MC9S12ZVMx ->
MCD_MC9S12ZVMx_Config_Information Block
5. Drag the block into the model
6. Open block and go to PIL and Download Config
7. Check Enable Download Code after Build and BAM Restart Request
8. Enter the COM port number that you are using from PC
9. Enable Freemaster to run on SCI 1 at 115200 Baud
10. Delete Sine Wave block and both Scopes
11. Also delete line that was going to second input of scope
12. Go back to library under Motor Control Blocks and drag in an ADC Config block, ADC Command
Sequence List block and a ADC Read block which will connect to the ADC_Value line
21 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


13. Open “Configuration Parameters” and go to PIL/BAM Setup tab.
14. Enter the COM port number that you are using from PC

22 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


15. Open “Configuration Parameters” and go to FreeMASTER Config tab.
16. Enable Freemaster to run on SCI 1 at 115200 Baud

23 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


17. Open “ADC Config block” and set Conversion Mode to Trigger.
18. Also select Data Bus register access,12-bit resolution and right justification

24 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


19. Open “ADC Command List” and set input channel to 20.

25 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


20. Go back to library under Peripheral Interface Blocks, drag in two Digital Output blocks and connect one to
output of the comparator and the other to Toggle subsystem.
21. Open Digital Output blocks and select pins

26 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


22. Go back to model and delete Function Call block
23. Go back to library under Utility Blocks, drag in a TIM Output block and connect to Trigger of Toggle
subsystem.
24. Open TIM output block and set the timeout to 100 ms.

27 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model
Convert Simple Model and Run
• This is what the model should look like after step 24

28 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Convert Simple Model and Run


25. Go to Code -> C/C++ Code pull down menu and then select Build Model.
26. Wait for model to generate code and then a prompt from the RAppID Bootloader Utility will appear. Reset the
MCU and then select “OK”.
27. Once the download is complete you should observe an LED blinking.
28. Turn the Potentiometer on the Motor Kit from right to left. You should observe the LED turn ON and OFF
when turning the POT from one stop to the other. Conversion of the model is complete!

29 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Using FreeMASTER with Hands-On Demo


29. Start FreeMASTER and open project TestLedA2D.pmp. Just press OK if a message comes up that the map
file has been updated.
30. Go to Project Options Pull Down and select “Options”. Verify that COM settings are the same as what were
set in your model.
31. Once the COM settings are correct, press the STOP button and start turning the Potentiometer back and
forth. You should see the following (next slide):

Note: You should be able to change the threshold value to something other than 2000. Try
changing it and see if the LED_State changes state.

30 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Using FreeMASTER with Hands-On Demo


• This is what you should see after step 31

31 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Using FreeMASTER with Hands-On Demo


32. You will notice that there is dither in the A2D reading as you change the Potentiometer. This is because the
system tick time in the model is too slow. To change this, go to the model and select the Simulation pull
down menu. Then select Configuration parameters. Change the Fixed-step size from “auto” to “.001”

32 EXTERNAL USE
Hands-On Demo: Read A/D and Toggle LED Simple Model

Using FreeMASTER with Hands-On Demo


33. Disconnect FreeMASTER by pressing the STOP button. Then rebuild the model and have the bootloader
download the software to the MCU. Re-Connect FreeMASTER and turn the Pot. You should see the
following:

33 EXTERNAL USE
Agenda
• Overview:
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo:
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER

• Model-Based Design:
− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control:


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo:


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control:


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo:
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A:

34 EXTERNAL USE
Model-Based Design Steps: Step 1 (Simulation)
Simulation in PC environment
PWM A
Torque IQ PI IQ Va
Control + loop Filter cmd cmd

ADC - Reverse
Park
Transform
PWM
Modulation
PWM B

ID PI ID Vb
+ loop Filter cmd cmd PWM C
Zero -
Gate
IA Driver
A/D Va
ID
Conversion Forward Forward IB
Park Clark
Transform Transform
Vb
IC
IQ

Motor Position
Analog
Analog Device Model
Sensor Model Controller Model

Electric Motor Model Idealized simulation of the controller and the motor to refine the
PC Environment
control technique. Done on host PC without regard for embedded
controller. Can optionally add analog device models for fault
detection and signal control.
35 EXTERNAL USE
Model-Based Design Steps: Step 2 – Software in the Loop (SIL)
(SIL) Generated code executes as atomic unit on PC
PWM A
Torque IQ PI IQ Va
Control + loop Filter cmd cmd

ADC - Reverse
Park
PWM
Modulation
PWM B

Transform

ID PI ID Vb
+ loop Filter cmd cmd PWM C
Zero -
Gate
IA
Driver
A/D Va
ID
Conversion Forward Forward IB
Park Clark
Transform Transform
Vb
IC
IQ

Motor Position
Analog
Analog Device Model
Sensor Model Controller Model

PC Environment Electric Motor Model Still done on host PC without regard for embedded controller. Instead
using generated C code that is compiled using a PC-based compiler.
Run same test vectors as in simulation for C Code Coverage analysis
and verify functionality.
36 EXTERNAL USE
Model-Based Design Steps: Step 3 – Processor in the Loop (PIL)
(PIL) Executes generated code on the target MCU
PWM A
Torque IQ PI IQ Va
Control + loop Filter cmd cmd

ADC - Reverse
Park
Transform
PWM
Modulation
PWM B

ID PI ID Vb
+ loop Filter cmd cmd PWM C
Zero -
Gate
IA Driver
A/D Va
ID
Conversion Forward Forward IB
Park Clark
Transform Transform
Vb
IC
IQ

Motor Position
Analog
Analog Device Model
Sensor Model Controller Model

Electric Motor Model Execute the model on the target MCU and perform numeric
PC Environment + MCU
equivalence testing. Co-execution with MCU and Model-Based Design
working together while collecting execution metrics on the embedded
controller of control algorithm. Validate performance on MCU.
37 EXTERNAL USE
Model-Based Design Steps: Step 3 (PIL)

Verification and Validation at Code Level


• This step allows:
− Translation validation through systematic testing
− To demonstrate that the execution semantics of the model are being preserved during
code generation, compilation, and linking with the target MCU and compiler

• Numerical Equivalence Testing:


− Equivalence Test Vector Generation
− Equivalence Test Execution
− Signal Comparison

38 EXTERNAL USE
Example IEC 61508 and ISO 26262 Workflow for Model-Based Design
with MathWorks Products*
Model advisor, modeling PIL testing using MBD Toolbox PIL Mode Support**
standards checking
Simulation (model testing), Real-Time Workshop Embedded
model coverage, RMI Coder traceability report or
model vs. code coverage
comparison

Simulink / Stateflow / Simulink Fixed Point Real-Time Workshop Embedded Coder


*Workflow from The MathworksTM ** NXP MBD Toolbox is part of Mathworks
Presentation Material Model-Based Workflow outlined in The MathworksTM
39 EXTERNAL USE Design for IEC 61508 and ISO 26262 Material Model-Based Design for IEC 61508 and
ISO 26262 as well as part of certification
qualification tool suite.
Model-Based Design Steps: Step 4 (Target MCU)*

Torque
Control +
IQ
loop
PI
Filter
IQ
cmd
Va
cmd
PWM A
* I/O peripheral driver blocks
ADC - Reverse
Park
Transform
PWM
Modulation
PWM B
can be included in the model,
ID PI ID Vb

Zero
+
-
loop Filter cmd cmd PWM C
providing the analog driver
Gate

A/D Va
IA Driver
interfaces needed to directly
ID
Conversion Forward
Park
Transform
Forward
Clark
Transform
IB
interface to devices external
Vb
IQ
IC
from the MCU.
Motor Position
Output
Input Drivers*
Drivers* Controller Model
Execute on Target MCU on ECM/EVB

MCU with
Embedded Control Electric Motor Generate production code to run on embedded MCU with real motor
Module (ECM)
while collecting execution metrics on the embedded controller of control
algorithm. Validate performance on MCU and use FreeMASTER to tune
control parameters and perform data logging.
40 EXTERNAL USE
Model-Based Design Approach
Idea incubation ANSI C code Experiments Final Product
PWM A
PWM A Torque IQ PI IQ Va
Torque
+
IQ PI IQ Va
PWM A Control + loop Filter cmd cmd PWM A
Control loop Filter cmd cmd Torque IQ PI IQ Va Torque IQ PI IQ Va
- + - Reverse PWM B Control + loop Filter cmd cmd
Reverse Control loop Filter cmd cmd PWM
PWM PWM B Park
Park
Modulation - Reverse Transform
Modulation - Reverse PWM B
Transform PWM PWM B PWM
Park Park
Modulation ID PI ID Vb Modulation
Vb Transform Transform
+
ID PI ID
PWM C
+ loop Filter cmd cmd PWM C
loop Filter cmd cmd Vb Vb
ID PI ID ID PI ID
Zero - + cmd PWM C Zero - + loop Filter cmd cmd PWM C
loop Filter cmd
Zero - Zero -
IA
IA Va
Va IA
IA ID
ID Va Va
Forward Forward IB
Forward Forward IB ID ID
Park Clark
Park Clark Forward Forward Forward Forward
IB Transform Transform IB
Transform Transform Park Clark Vb Park Clark
Vb IC

To SIL
IC Transform Transform IQ Transform Transform

To PIL To MCU
IQ Vb Vb
IC IC
IQ IQ

Motor Position
Motor Position
Motor Position Motor Position

Controller Model Controller Model Controller Model Real Controller

Electric Motor Model Electric Motor Model Electric Motor Model Real Electric Motor

PC Environment MCU with Embedded


PC Environment PC Environment + MCU Control Module (ECM)

Step 1 – System Requirements: Step 2 – Modeling/Simulation: Step 3 – Rapid Prototype: Step 4 – Target MCU Implementation
MBD Simulation Only MBD Simulation with ANSI C Code MBD Simulation with ANSI C Code ANSI C Code Running on Target HW
using SIL using PIL & MCU
• Software requirements • Control algorithm design • Controller code generation • Validation/verification phase
• Control system requirements • Code generation preparation • Determine execution time on MCU • Controller code generation
• Overall application control strategy • Control system design • Verify algorithm on MCU • Determine execution time on MCU
• Overall application control strategy • See memory/stack usage on MCU • Start testing implementation on target ECM
design • Start testing implementation approach • Code generate control algorithm
• Start testing implementation approach • Target testing controls algorithm on MCU • Test system in target environment Utilize
calibration tools for data logging and
parameter tuning

• Modeling style guidelines applied • Testing of functional components of • Refine model for code generation • Execute code on target MCU
• Algorithm functional partitioning algorithm • Function/File partitioning • Functional testing in target environment
• Interfaces are defined here • Test harness to validate all requirements • Data typing to target environment done here • Ensure execution on target is correct as well
• Test coverage of model here • Scaling for fixed point simulation and code gen as code generation on target is performing
• Creates functional baseline of model Testing of functional components of algorithm as desired.
• Test harness to validate all requirements
• Test coverage of model here
41 EXTERNAL USE • Creates functional baseline of model
• Equivalence testing
Demo: SIL/PIL Step 2 & 3 of MBD
1. Open Model “FOC_Sensorless_SIL_PIL.slx
2. You will see a motor simulation of an FOC control algorithm
3. Will Run model and view the results.

42 EXTERNAL USE
Demo: SIL/PIL Step 2 & 3 of MBD

4. You can switch between SIL and PIL thru using the tools menu.

43 EXTERNAL USE
Demo: SIL/PIL Step 2 & 3 of MBD
5. Open “Configuration Parameters” in the reference model.
6. Go to PIL/BAM Setup tab.
7. Enter the COM port number that you are using from PC.

44 EXTERNAL USE
Demo: SIL/PIL Step 2 & 3 of MBD
8. - Will Run model and view the results.

45 EXTERNAL USE
Demo: SIL/PIL Step 2 & 3 of MBD
9. Let us try improving the execution time by changing the compiler options
10. Change the optimization level from 0 to 2.

46 EXTERNAL USE
Demo: SIL/PIL Step 2 & 3 of MBD
11. Run model and view the results.

47 EXTERNAL USE
Agenda
• Overview:
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo:
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER

• Model-Based Design:
− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control:


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo:


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control:


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo:
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A:

48 EXTERNAL USE
Motor Kit: MTRCKTSBNZVM128 BLDC Motor Control Kit

• The kit includes a 4 pole-pair count motor, which means that every single mechanical revolution equals four
electrical revolutions. State changes in Hall sensors is every 60 degrees electrical.

49 EXTERNAL USE
Motor Kit: XS12ZVMx12EVB Power indicator
LEDs OSBDM
User Switches

CAN option
Hall
interface

LIN interface

I/O Port access Motor


(for example PWM connector
/ TIM / ECLK)

USB-to-SCI
interface
GDU / 3-phase
bridge access
Reset
BDM interface
12 V
supply
User LEDs

Potentiometer Resolver ADC inputs Current Sense


interface Resistors
50 EXTERNAL USE
Motor Kit: System Diagram

Vb+

A
Phase A

Phase B
S12ZVM
Analog Phase C
Gate
Drive Current BLDC
Unit Feedback Motor
Pot
Switches Hall Sensors
Vb-
PWM

TIM
PMF GPIO ADC
S12ZVM Hall Sensor Port

SCI Digital DO

RAppID BL Utility LEDs

51 EXTERNAL USE
Motor Kit: S12ZVM for BLDC Motor Control

Discrete Solution
VREG 3+
MCU
(8pin) 20+ Gate
or
Driver
2+
DSC (48pin)
LIN phy (48pin)
(8pin)
Op-amps

4 cm
~1 ½ in.

S12ZVM Solution:
• ~ 50 fewer solder joints
• - 4 to 6 cm2 PCB space
64 pin
52 EXTERNAL USE
10 Billion Electric Motors Shipped Globally in 2013
2.5 Billion in Automobiles, 30 Per Car Average
Convertible roof Circular pump for stationary
Motor for Heating fan
Sliding roof heating system • source: IMS Research, 2013
stationary heating system
Idle position
Cooling fan for air adjustment system
conditioning system
Tailgate closing
Heating and air
conditioning system Rear windscreen
wiper
Wipers
Ergonomic backrest, Fuel pump
headrest adjustment
Belt system
Circular pump for heating Seat control
and cooling water circuit
Headrest adjustment
Engine cooling fan
Backrest adjustment
Starter
Rear seat adjustment
Alternator,
generator Active suspension
Mirror
Steering wheel, adjustment
adjustment
Window winder

Scavenging pump, Door closing


high-pressure pump
Headlight range Central locking
adjustment unit system
Headlight cleaning EPS
ABS Arial
pump drive drive
Headlight tilting

Motor Control

53 EXTERNAL USE
Motor Kit: S12ZVM Family
Digital 5 V Analog
BLDC/PMSM/SR motor control Components Components

MCU Core High-Voltage


and Memories Components

Key Features:
• S12Z CPU @ 50 MHz bus speed
Pierce Temp 2 x 12-Bit
• 6 ch. Gate Drive Unit (GDU) with 50-150 nC total Gate Charge CAN/LIN-PHY
Osc. Sense LADC
drive capability, incl charge pump for High-Side, Bootstrap diodes SCI 1 SCI 0
RCosc.
PLL
Bootstrap
+/-1.3% Diodes
for charging external bootstrap capacitors
3x Phase
SPI MSCAN S12Z 50MHz Bus
• Embedded Vreg with switchable 5V/20 mA sensor supply Comparators
G BDM KWU Win 16-256 KB GDU 6ch
• LIN PHY, LIN2.1 / 2.2 / J2602 compliant P BDC Wdog Flash (ECC) MOS-FET-Predriver
I TIM 16b
• Dual 12-bit list-based ADC (LADC), synch with PWM through O 128B-1kB 2-32kB Charge Pump
4ch
Programmable Trigger Unit (PTU) 6ch PMF 2ch
EEPROM RAM
VSUP
(ECC) (ECC) VREG
(PWM) PTU sense
• 2x Op-amp for current sensing
Current Sense
EVDD
(2 x Op-Amp)

Target applications:
• Sensorless BLDC or PMSM motor control Options:
• Package: 64-LQFP-EP, 48 LQFP-EP, 80-LQFP-EP
• Switched Reluctance Motor
• Memory: 16 kB / 32 kB / 64 kB / 128 kB / 256 kB Flash
• Bidirectional DC motors (H-Bridge) • Spec-Options:
• Various pumps (oil, fuel, water, vacuum) • L with LIN phy
• Cooling fan, HVAC blower, Turbocharger • C with CAN-PHY (256 kB only)
• C with 2nd Vreg for external CAN phy (128/64 kB)
• “ “ with High Voltage PWM-communication interface
54 EXTERNAL USE • Temperature: V / M / W (up to 150 °C Ta per AEC-Q100
Grade 0)
Digital 5V Analog
Components Components

Motor Kit: S12ZVML (LIN Version) — Details MCU Core


and Memories
High-Voltage
Components

2x UARTs LIN Physical S12Z CPU On-chip RC 2 x 12-bit list based ADC
One linked to LIN Phy, 2nd Layer 16-bit, 32-bit MAC, OSC Simultaneous measurement
as independant Test Intf. LIN2.2 and SAE linear addressing factory- 5+4 ch. external. Plus 8 ch. int
J2602 compliant Harvard architech trimmed to +/- (temp sence, GDU phase, Ref
+/- 8 kV ESD compatible within 1.3%, meets voltages) with DMA
SPI
As alternative test Interf or capability S12 MagniV family LIN -needs
for peripherals (sensors)

Pierce Temp 2 x 12-Bit


LIN-PHY 3x Phase Comparators
MSCAN 2.0A/B Osc. Sense LADC
RCosc. for BEMF zero crossing
CAN Controller SCI 1 SCI 0 PLL
+/-1.3% detection in sensorless BLDC
Up to 18 Wake-up pins 3x Phase
SPI MSCAN S12Z 50MHz Bus Comparators 6-ch. GDU
Combined with Analog
G BDM KWU Win 32-128 KB GDU 6ch Low side and high side FET
Input pins
P BDC Wdog Flash (ECC) MOS-FET-Predriver pre-drivers for each phase with
I TIM 16b 100-150 nC total gate Charge
4 ch. 16-bit Timer O 4ch 512B 4-8kB Charge Pump
Hall Inputs, software timing EEPROM RAM Charge Pump
6ch PMF 2ch VSUP
(ECC) (ECC) VREG
(PWM) PTU sense To support reverse battery
6-ch. PMF Current Sense protection and boostrap assist
15-bit PWM for motor EVDD 70mA total supply
(2 x Op-Amp) for 100% duty-cycle
control with dead time,
fault mgmt Vsup sense
PTU Flash (32/64/128 EEPROM Monitoring supply voltage
External Supply Enables kB) 4 byte
5 V / 20 mA switchable for Voltage Regulator
synchronization 512 B erasable. 10 eraseable, 100
local (same PCB), over 5V/70 mA for whole system
between PMF K p/e cycles. Can K program /
current protected. and ADC erase cycles 2x Op-Amp for current
be used for Data
Eg. supplying Hallsensors measurement / sensing
AEC-Q100 Grade 0 Packaging Option
Qual‘ed up to 150 °C Ta 64LQFP-EP
55 EXTERNAL USE
Motor Kit: S12ZVM Family Feature Set Summary
Connectivity CAN LIN CAN LIN CAN LIN PWM

Product Name VMC256 VML128 VMC128 VML64 VMC64 VML32 VML31 VML31 VM32 VM16

80LQFP- 64LQFP- 64LQFP- 64LQFP- 64LQFP- 64LQFP- 64LQFP- 48LQFP- 64LQFP- 48LQFP- 64LQFP- 48LQFP-
Package
EP EP EP EP EP EP EP EP EP EP EP EP
EEPROM (bytes) 1K 512 512 512 512 512 128 128 128 128 128 128
PHY CAN LIN 0 LIN 0 LIN LIN LIN HV HV HV HV
Separate VREG 1+1 0 1 0 1 0 0 0 0 0 0 0
GDU (HS / LS) 3/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3 3/3
Bootstrap Diodes 0 0 0 0 0 0 3 3 3 3 3 3
Op Amp 2 2 2 2 2 2 2 1 2 1 2 1
ADC (ext. channels) 8+8 4+5 4+5 4+5 4+5 4+5 4+5 1+3 4+5 1+3 4+5 1+3
MSCAN 1 1 1 1 1 1 0 0 0 0 0 0
SCI 2 2 2 2 2 2 2 1 2 1 2 1
SPI 1 1 1 1 1 1 1 0 1 0 1 0
TIM (IC/OC
4 4 4 4 4 4 4 3 4 3 4 3
channels)
PWM channels 6+4 6 6 6 6 6 6 6 6 6 6 6
Internal timers RTI+API RTI+API RTI+API RTI+API RTI+API RTI+API RTI+API RTI+API RTI+API RTI+API RTI+API RTI+API
External FET
Nominal Total Gate 100-150 100-150 100-150 100-150 100-150 100-150 50-80 50-80 50-80 50-80 50-80 50-80
Charge (nC)
12 mm x 10 mm x 10 mm x 10 mm x 10 mm x 10 mm x 10 mm x 10 7 mm x 7 10 mm x 7 mm x 7 10 mm x 7 mm x 7
Package Size
12 mm 10 mm 10 mm 10 mm 10 mm 10 mm mm mm 10 mm mm 10 mm mm

Samples availability H2 2015 Now Now Now Now Now Now Q2 2015 Now Q2 2015 Now Q2 2015

Production release H2 2016 Q1 2014 Q1 2014 Q1 2014 Q1 2014 Q1 2014 Q1 2016 Q3 2016 Q1 2016 Q3 2016 Q1 2016 Q3 2016
56 EXTERNAL USE
Motor Kit: S12ZVM Ecosystem — The Complete Solution

Customer Application Software

CAN/LIN Stack
FreeMASTER:

NVM Drivers
MC ToolBox: MCAT

LIN Drivers
MC Dev Kit
-Graphical User
Rapid prototyping with Tuning Reference
Interface
Matlab Simulink Tool Software
-Instrumentation

Math and Motor Control Libraries:


- Standard optimized math functions and motor control algorithms
- Includes Matlab Simulink Models Autosar OS

Compiler and Debugger Graphical Init Tool

Hardware (Evaluation board, target application)

Freescale Freescale enablement Third-party


production Software Software production Software

57 EXTERNAL USE
Motor Control: Motion Force Generation

• Current flowing in a magnetic field results in a force on the conductor


• Direction of generated force is governed by “Right Hand Rule” (Lorentz Force Law)

current
I B
Direction of force
causing wire motion

Right Hand Rule


F  I .B.l. sin 
58 EXTERNAL USE
Electromagnetic Force Creates Torque

Uniform Magnetic Field bo

F1= I.Bo.l.sin
r

Current flowing
α away from you

F2 = I.Bo.l.sin
Current flowing
towards you

Maximum torque occurs


when  = ± 90°

Single Coil Rotor T = 2I.Bo.l.r sin (clockwise)


l = length of wire

59 EXTERNAL USE
Motor Types

• DC Motors
− Two or more permanent magnets in stator
− Rotor windings connected to mechanical commutator

• BLDC Motors
− PM in rotor, 3-phase conductors in stator
− Trapezoidal back-EMF

• Permanent Magnet Synchronous Motors


− Similarto BLDC in construction
− Sinusoidal back-EMF

60 EXTERNAL USE
BLDC Motor = Trapezoidal Back-EMF

► BLDC Motor Commutation


- one phase is un-powered at any given time A B C

A B C

0V

C B

61 EXTERNAL USE
PM Machines – Trapezoidal vs. Sinusoidal

• The characteristic “Trapezoidal” or “Sinusoidal” is linked with the shape of the Back-EMF of the Permanent
Magnet motor.
− “Sinusoidal” means Synchronous (PMSM) motors
− “Trapezoidal” means Brushless DC (BLDC) motors

• BLDC motor control (6-step control)


− Only 2 of the 3 stator phases are excited at any time
− 1 unexcited phase used as sensor (sensorless control)

• Synchronous motor (Field-oriented control)


− All 3 phases are persistently excited at any time

62 EXTERNAL USE
Trapezoidal vs. Sinusoidal PM Machine
• Sinusoidal” or “Sinewave” machine means Synchronous (PMSM)
• Trapezoidal means brushless DC (BLDC) motors
• Differences in flux distribution
• Six-Step control vs. Field-Oriented Control
• Both requires position information
• BLDC motor control
− 2 of the 3 stator phases are excited at any time
− 1 unexcited phase used as sensor (BLDC Sensorless)
• Synchronous motor
− All 3 phases persistently excited at any time
− Sensorless algorithm becomes complicated

63 EXTERNAL USE
Trapezoidal Control: Brushless DC Motor

A BLDC motor consists of a rotor with permanent magnets and a stator with phase windings. A BLDC motor
needs electronic commutation for the control of current through its three phase windings.

Stator Permanent
Magnets

N
Rotor
S S Phase
Windings

Phase
N
Stator
Windings

64 EXTERNAL USE
Trapezoidal Control: BLDC Commutation Method

• Stator Field is generated between 60° to 120° to


GND
+Vp (PWM) rotor field to get maximal torque and energy
efficiency
Lb
Running • Six Flux Vectors defined to create rotation
Direction
Motor
Torque
Lc
60°-120°

(PWM) LaStator Flux


+Vp (PWM)
GND +Vp
GND(PWM)
(PWM)

65 EXTERNAL USE
Trapezoidal Control: Commutation Method

Trapezoidal control is one type of commutation method used to turn a motor where only two phase windings
will conduct current at any one time. With direction also to consider, that leaves six possible patterns.

Circuit Representation
of BLDC Stator Windings

Phase A Phase C

Phase B

66 EXTERNAL USE
Trapezoidal Control: Commutation Control

By adding switches, the current flow can be controlled by a MCU to perform trapezoidal
control.

Vb+
Vb+

OFF
ON At Ct OFF
ON
Vb-
N.C.
Vb+ Vb-
N.C.
Vb+
ON Ab
OFF Cb ON
OFF
Vb- Phase A Phase C
Vb-

Vb+

Phase B
ON Bt
OFF
Vb-
N.C.
Vb+
ON Bb
OFF
Vb-
67 EXTERNAL USE
Trapezoidal Control: Turning the Motor CW

With the switches, the stator can be used to turn the motor to the desired direction and location by creating a
magnetic field that affects the magnets on the rotor.

At
Cb Bb
Phase Phase Phase
CW
A B C
Bt o Ct
0/180○ Vb- NC Vb+ N
30○ Vb- Vb+ NC
Ab S S Ab
60○ NC Vb+ Vb-
90○ Vb+ NC Vb-
Ct
N Bt
120○ Vb+ Vb- NC
150○ NC Vb- Vb+
Bb Cb
Vb+ Vb- NC At
Top
Switch On Off Off
Bottom
Switch Off On Off
68 EXTERNAL USE
Trapezoidal Control: Turning the Motor CCW
With the switches, the stator can be used to turn the motor to the desired direction and location by creating a
magnetic field that affects the magnets on the rotor.

At
Cb Bb
Phase Phase Phase
CCW
A B C
Bt o Ct
0/180○ Vb+ NC Vb- N
30○ Vb+ Vb- NC
Ab S S Ab
60○ NC Vb- Vb+
90○ Vb- NC Vb+
Ct
N Bt
120○ Vb- Vb+ NC
150○ NC Vb+ Vb-
Bb Cb
Vb+ Vb- NC At
Top
Switch On Off Off
Bottom
Switch Off On Off
69 EXTERNAL USE
Trapezoidal Control: Motor Position
In order to commutate correctly for trapezoidal control, motor position information is required for proper motor
rotation. The motor position information enables the MOSFETs or IGBTs in the inverter to properly be
switched ON and OFF to ensure proper direction of current flow through the phase windings. Therefore, Hall
sensors are used as position sensors for trapezoidal control. Each Hall sensor is placed 120 degrees apart
and delivers a “high” state when facing a “north pole” and a “low” state when facing a “south pole”.

Hall A
A
o
N

S S

Hall B N
Hall C

70 EXTERNAL USE
Trapezoidal Control: Motor Position CW
With three Hall sensors, it is possible to have eight states with two invalid states. That leaves six valid states
that can be used to determine which two phase coils to drive the current through and in which direction. The
six states are generated due to rotation of the motor.

Hall A Hall B Hall C State CW Hall A


1 0 0 4 0/180○ A
1 1 0 6 30○ o
60○
N
0 1 0 2
0 1 1 3 90○
S S
0 0 1 1 120○
1 0 1 5 150○ Hall B N
0 0 0 Invalid n/a Hall C
1 1 1 Invalid n/a

71 EXTERNAL USE
Trapezoidal Control: Motor Position CCW

With three Hall sensors, it is possible to have eight states with two invalid states. That leaves six valid states
that can be used to determine which two phase coils to drive the current through and in which direction. The
six states are generated due to rotation of the motor.

Hall A Hall B Hall C State CCW Hall A


1 0 0 4 0/180○ A
1 0 1 5 30○ o
0 1 60○
N
0 1
0 1 1 3 90○
S S
0 1 0 2 120○
1 1 0 6 150○ Hall B N
0 0 0 Invalid n/a Hall C
1 1 1 Invalid n/a

72 EXTERNAL USE
Trapezoidal Control: Bringing It All Together
With the commutation table and the motor position table, a full trapezoidal control algorithm can be
developed.

Motor Position Table Input Commutation Table Output


Hall A Hall B Hall C State CW CW Phase A Phase B Phase C
1 0 0 4 0/180○ 0/180○ Vb+ NC Vb-
1 1 0 6 30○ 30○ Vb+ Vb- NC
0 1 0 2 60○ 60○ NC Vb- Vb+
0 1 1 3 90○ 90○ Vb- NC Vb+
0 0 1 1 120○ 120○ Vb- Vb+ NC
1 0 1 5 150○ 150○ NC Vb+ Vb-
0 0 0 Invalid n/a Vb+ Vb- NC
Top
1 1 1 Invalid n/a Switch On Off Off
Bottom
Switch Off On Off

73 EXTERNAL USE
Trapezoidal Control: Bringing It All Together
With the commutation table and the motor position table, a full trapezoidal control algorithm can be developed.

Trapezoidal Control Algorithm Clockwise Rotation


Hall A Hall B Hall C State CW Phase A Phase B Phase C
1 0 0 4 0/180○ Vb+ NC Vb-
1 1 0 6 30○ Vb+ Vb- NC
0 1 0 2 60○ NC Vb- Vb+
0 1 1 3 90○ Vb- NC Vb+
0 0 1 1 120○ Vb- Vb+ NC
1 0 1 5 150○ NC Vb+ Vb-
0 0 0 Invalid n/a Vb+ Vb- NC
1 1 1 Invalid n/a Top
On Off Off
Switch
Bottom
Switch Off On Off

74 EXTERNAL USE
Trapezoidal Control: Bringing It All Together

With the commutation table and the motor position table, a full trapezoidal control algorithm can be
developed.

Trapezoidal Control Algorithm Counter Clockwise Rotation


Hall A Hall B Hall C State CW Phase A Phase B Phase C
1 0 0 4 0/180○ Vb- NC Vb+
1 0 1 5 30○ Vb- Vb+ NC
0 0 1 1 60○ NC Vb+ Vb-
0 1 1 3 90○ Vb+ NC Vb-
0 1 0 2 120○ Vb+ Vb- NC
1 1 0 6 150○ NC Vb- Vb+
0 0 0 Invalid n/a Vb+ Vb- NC
1 1 1 Invalid n/a Top
On Off Off
Switch
Bottom
Switch Off On Off

75 EXTERNAL USE
Sensor-based Commutation
Rotor Electrical Position (Degrees)
0 60 120 180 240 300 360
DC BUS voltage
Hall a Commutation
events
Hall b Bt Ct
At

Hall c Ab Bb Cb

1 2 3 4 5 6
PWM At
B
PWM Bt
A C

PWM Ct

One phase powered by


complementary PWM
PWM Ab signal,
second phase grounded:
PWM Bb
• Low MOSFET switching
losses
PWM Cb • Low EMC noise

76 EXTERNAL USE
Trapezoidal Work-Shop Control Block diagram
MC9S12ZVM Board 3-phase Inverter

Power line 3-phase


BLDC
Motor

Hall A
Hall B
TIM GPIO GDU
Hall C

TIM Hall Sensor


Trigger States

Measure Hall Time & Commutation PMF


Position Recognition Control Comm.
Sequence

Duty
Cycle

On-Chip BDM 1/T


Debugging
ActualSpeed
- Limitations

FreeMaster Required Speed + Speed


SCI 1
Serial Port PI Controller
S12ZVM
77 EXTERNAL USE
Agenda
• Overview:
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo:
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER

• Model-Based Design:
− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control:


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo:


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control:


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo:
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A:

78 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit

Summary Trapezoidal Motor Control on MPC5643L steps:


1. Open TrapCtrl.mdl
2. Save model as MPC564xL_TrapCtrl.mdl
3. Configure MPC5643L configuration block
4. Configure Input port blocks to read motor hall position state
5. Configure output blocks to monitor motor position with LEDs
6. Configure eTimer Blocks to detect change in motor position sensors
7. Configure eTimer Capture to measure Hall sensor pulse width for RPM calculation
8. Configure ADC block for monitoring potentiometer input for RPM Request
9. Configure Digital Input for use in controlling RPM Request
10. Configure DSPI blocks to interface to Freescale 3PP driver
11. Connect and configure Flex PWM blocks for output to switches
12. Configure PIT Timer and ADC blocks to read phase voltages.

79 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit

80 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit
Configure Hall Sensor Input Block using Digital I/O steps:
Remove termination blocks and pull 3 output blocks to replace them and then set them to the
correct MCU pins. Set input blocks to correct pins.

81 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit

Commutation Change event Commutation Change event

82 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit

Measure the pulse width of a hall sensor so that motor speed can be calculated

83 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit

MotorSpeed Block with ADC and Digital outputs steps:

84 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit
3PhaseDutyCycleOut Block with Flex PWM Blocks steps:
Pull Simple PWM phase block from library, connect to phase A and configure.

85 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit
PMF Block steps:

86 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit

PMF Block steps:

87 EXTERNAL USE
Hands-on Demo: Implement Trapezoidal Motor Control on Motor Kit

3PhaseDutyCycleOut Block with Flex PWM Blocks steps:


Copy phase C block, paste twice and connect to phase A & B.

88 EXTERNAL USE
Hands-on Demo: FreeMASTER to Monitor and Tune Parameters

Using FreeMASTER with Hands-on Demo


1. Start FreeMASTER and open project S12ZVM_TrapCtrl.pmp. Press OK if a message comes up that the
map file has been updated.
2. Go to Project Options pull-down and select “Options”. Verify that COM settings are the same as what
were set in your model.
3. Once the COM settings are correct, press the STOP button.
4. Change MotorSpeedReqFreemaster Variable to 1000 RPM.

89 EXTERNAL USE
Agenda
• Overview:
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo:
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER

• Model-Based Design:
− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control:


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo:


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control:


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo:
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A:

90 EXTERNAL USE
Motor Control: Why FOC over Trapezoidal

• FOC inherently better at aligning rotor and stator flux which results in a more efficient way of
generating motor torque.

• Since FOC continuously pulls the rotor to a new position torque ripple is reduced making it
ideal for application like electric steering where low speeds are required.

• FOC uses sinusoidal commutation therefore reducing EMC noise that trapezoidal control can
create.

• Finally, FOC can enable a motor to go above its rated speed at the expense of torque. This
is called Field Weakening where the stator windings are energized at an angle where the
rotor’s magnetic field weaker therefore increasing the magnetic field vector.

91 EXTERNAL USE
Motor Control: Creation of Rotating Magnetic Field
• The space-vectors can be defined for all motor quantities

j120 j 240
B is  iAe  iB e
j0
 iC e
3ph currents
A B C
1

A
0

is
-1
p 2p

92 EXTERNAL USE
Motor Control: Transformation to 2-ph Stationary Frame
Is_a_comp Forward Clark Is_beta 3ph currents / MMF
Is_b_comp Transformation
Is_c_comp Is_alpha
a,b,c->alpha,beta A B C
1

b 3ph quantities

-1
p 2p


 b
1.5
is
Stationary
2ph quantities
0

-1.5
p 2p

93 EXTERNAL USE
Motor Control: Transformation to 2-ph Synchronous Frame
• Position and amplitude of the stator flux/current vector is fully controlled by two DC values
 b
1

b Stationary
2ph quantities
0

-1
p 2p

 d q
1
is
Rotating
2ph quantities
0

alpha Forward Park d -1

beta Transformation –
q p 2p
, b > d, q

94 EXTERNAL USE
Motor Control: FOC Transformation Summary

Phase A  d d  Phase A

Control
3-Phase Stationary Rotating

Action
Phase B Phase B
Phase C
to
2-Phase
b to
Rotating
q q to b SVM
Stationary Phase C

3-Phase 2-Phase 3-Phase


System System System
From measurement ?
AC DC AC

Stationary Reference Frame Rotating Reference Frame Stationary Reference Frame

95 EXTERNAL USE
Motor Control: FOC Transformation Summary

Control Action

PWM A
Torque IQ PI IQ Va
IQ +
Control loop Controller cmd cmd
- Space
Inverse PWM B
Vector
Park PWM
Modulation
Transform
(SVM)
ID PI ID Vb
+ loop Controller cmd cmd PWM C
Zero -

IA
Va
ID

Park Clark IB
A/D
Transform Transform
Vb
IC
IQ

Motor Position
I/O

96 EXTERNAL USE
Motor Control: Field Oriented Control in Steps
1. Measure obtain state variables quantities
(e.g. phase currents, voltages, rotor position, rotor speed …).

2. Transform quantities from 3-phase system to 2-phase system (Forward Clark Transform) to simplify the
math - lower number of equations

3. Transform quantities from stationary to rotating reference frame -


“rectify” AC quantities, thus in fact transform the AC machine to DC machine

4. Calculate control action (when math is simplified and machine is “DC”)

5. Transform the control action (from rotating) to stationary reference frame

6. Transform the control action (from 2-phase) to 3-phase system

7. Apply 3-phase control action to el. motor

97 EXTERNAL USE
Motor Control: Commutation Control Methods

• All three inverter legs (6 transistors) are managed at any time – transistors are either switched on or off

• PWM pairs are set to complementary mode Vb+


o Top transistor – ON
On At
o Bottom transistor – OFF
3
o Or vice versa
Off Ab
o Deadtime is inserted to protect inverter against short
Vb-
circuit Deadtime
ON

OFF

ON

OFF

PWM period

32 1 2 3
98 EXTERNAL USE
Motor Control: Commutation Control Methods
• All three inverter legs (6 transistors) are managed at any time – transistors are either switched on or off

• PWM pairs are set to complementary mode Vb+


o Top transistor – ON
Off At
o Bottom transistor – OFF
2
o Or vice versa
Off Ab
o Deadtime is inserted to protect inverter against short
Vb-
circuit Deadtime
ON

OFF

ON

OFF

PWM period

32 1 2 3
99 EXTERNAL USE
Motor Control: Commutation Control Methods
• All three inverter legs (6 transistors) are managed at any time – transistors are either switched on or off

• PWM pairs are set to complementary mode Vb+


o Top transistor – ON
Off At
o Bottom transistor – OFF
1
o Or vice versa
On Ab
o Deadtime is inserted to protect inverter against short
Vb-
circuit Deadtime
ON

• All PMSM phases are always supplied creating sinusoidal


voltages. OFF

ON

OFF

PWM period

32 1 2 3
100 EXTERNAL USE
Motor Control: Current Sensing with Shunt Resistors

DC Bus
+U/2
• Shunt resistors voltage drop measured
PWM At PWM Bt PWM Ct
• SW calculation of all 3 phase currents
Phase A Phase B Phase C
needed
PWM Ab PWM Bb PWM Cb

• Adding all 3 phase currents equals zero


uI_S_B Shunt
allowing that only two phase currents uI_S_A uI_S_C
resistors
needed to be sampled by the MCU. - U/2
Ground
iSB
• Dual-sampling required

iSA n iSC

3-ph PM Synchronous Motor

101 EXTERNAL USE


ADC to PWM Synchronization - Why Needed?

• ADC sampling helps to filter the measured current - antialiasing

PWM Period Asynchronous


Sampling
Average Current Inductor Current

Sampled Current

Synchronized
Sampling

PWM 0

ADC trigger Signal


A/D
calc.

Data Processing and New PWM Parameters Calculation


102 EXTERNAL USE
Motor Control: Incremental Encoders

Scanning Principle

• The current position is calculated by


incrementing/decrementing the pulse edges.

• The direction of counting is determined by phase shift of


two quadrature pulses.

• The reference pulse is used to denote start point.


Source: Heidenhain
Incremental Encoder Pulses
• Rotary encoders output the position values over the
binary TTL square-waves or serial data interfaces
(EnDat, SSI, PROFIBUS-DP)

There are 4 phases within one pulse cycle. You need


for example (360/0.5)/4=180 pulses per rotation if
0.5deg resolution is wanted.

103 EXTERNAL USE


Motor Control: Resolvers
• Rotor is put directly on the drive’s shaft Sensor Components
• Stator is fixed on drive’s shield Auxiliary
Rotor Stator
transformer
• Simple assembly and maintenance
• No bearings — “unlimited” durability
• Resist well against distortion, vibration, deviation of
operating temperature and dust
• Worldwide consumption millions of pieces at present
time Sensor Principle
Sinusoidal Voltage
• Widely used in precious positioning applications 1
0.5
Usin 0

• The number of generated sine and cosine cycles per -0.5


-10 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01

one mechanical revolution depends on the number of 


1
Co-sinusoidal Voltage

 0.5
resolver pole-pairs (usually 1-3 cycles) 0
-0.5
-1
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01
Uref
1 Reference Voltage
Ucos
Rotor shaft 0.5
0
-0.5
-1
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01

104 EXTERNAL USE


Motor Control: Autonomous Motor Control Loop Implementation
NO CPU involvement & interrupt during motor control cycle
TIM
Timer
Commutation Event
PWM signals
Fault Inputs
GDU
Gate Drive
Unit

trigger ADC0 DCBus Volt.


PMF reload PTU Analog BackEMF
Pulse Width Digital DCBus Curr.
Modulation Converter Phase
Programm Mux
With Fault DC link &
-able
Phase
Trigger ADC1 DCBus Volt. Dividers
Unit trigger Analog BackEMF
Digital DCBus Curr.
glb_ldok Converter
Conversion Conversion +
Command Result -
Current Sense
OpAmps
RAM / NVM Trigger
List(s)
Command
List (s)
Result
List (s)
(<=32) (<=64) (<=64)

105 EXTERNAL USE


Motor Control: Pulse Width Modulator Module (PMF)

• 6 PWM channels, 3 independent counters Complementary Mode


with / without dead time insertion
− Up to 6 independent channels or 3 complementary pairs
• Based on core clock (max. 100 MHz)
• Complementary operation:
− Dead time insertion
− Top and Bottom pulse width correction
− Double switching
− Separate top and bottom polarity control
• Edge- or center-aligned PWM signals Double-Switching Mode
for single shunt system
• Integral reload rates from 1 to 16
• 6-step BLDC commutation support, with optional link to
TIM Output Compare
• Individual software-controlled PWM outputs (+ easy
masking feature per output)
• Programmable fault protection

106 EXTERNAL USE


Motor Control: 2 x 12 bit Analog Digital Converter
Command and Result List
DMA integrated RAM / NVM RAM Double buffered
Command Result Value List Flexible conversion sequence and
Automatic Trigger Sys Clock Sequence List (RVL) oversampling
(CSL)
Can be triggered by PTU, for Command 1 Result 1
Fully autonomous motor control
accurate synch with PWM Command 2 Result 2
PRSCLR ... ... cycle which unloads CPU
Up to 32 triggers per control ... ...
cycle per ADC ADC Command 64 Result 64
clock
Trigger Interrupt
Restart DMA
From PTU
LoadOK
Seq_abort Trigger Control Unit Abort
RVL
SAR & C-DAC DMA
ANx_8 Analog +
. Mux Takes commands from
. Sample & Hold
From External
ANx_2
. SRAM /NVM and stores
or OpAmp - results back into SRAM
ANx_1
ANx_0
.
.
.

External & OpAmp Inputs


Internal ADC channels
9 external channels ( 5 to ADC0
and 4 to ADC1) Monitoring Internal Signals Sample Time Conversion Time
OpAmp output shared with ADC DC link, phase voltages, Vsup Selectable: 480 ns to 2.88 µs 1.8 µs @ max. ADC clock for 12 bit
external channel
Vreg & ADC temp sensors

107 EXTERNAL USE


Bandgap voltage
Motor Control: Programmable Trigger Unit (PTU)
Completely avoids CPU involvement to trigger ADC during the control cycle
• One 16-bit counter as time base
• Two independent trigger generators (TG) RAM
• Up to 32 trigger events per trigger generator Trigger Value Lists

• Trigger Value List stored in system memory Trigger1 Trigger1


Trigger 2 Trigger 2
• Double buffered list, so that CPU can load new ... ...
values in the background ... ...
Trigger 32 Trigger 32
• Software generated “Reload” & trigger event
• Synchronized with PMF and ADC to guarantee
coherent update of all control loop modules PTU X PTUT0
Trigger Generator ADC0
(TG) 0
X PTURE
Trigger Generator ADC1
(TG) 1
X PTUT1

PWM Reload
Time base Event
Control
Counter
Async Com-
mutation Event
Bus Clock
108 EXTERNAL USE
Motor Control: Autonomous PMSM Application Timing
Two shunts current sensing
PMFMOD
VAL0

Hardware Events
PWM counter 100 us

SW Serviced
0

PMF PMF phA out


A_top
A_bot
B_top
PMF phB out
B_bot

PMF half cycle reload deadtime PMF half cycle reload


every fourth opportunity every fourth opportunity
PWM Reload

Autonomous Hardware Events


Trig. 1 Trig. 0 Trig. 1
Trig. 0
PTU PTU counter
PTU triggers Delay in
order for
DMA to load
ADC0

Preset
Phase current A ADC list
sampling
DMA0
UDCBus
sampling
ADC0 conversion

Phase current B
ADC1 sampling
DMA1 Temp sampling
EOC EOC
ADC1 conversion interrupt interrupt

SW
FOC
CPU ISR service
routine
FOC calculations application
Calculations
Free for application use

109 EXTERNAL USE


Motor Control: Rotor Position Sensor Elimination

• FOC requires accurate position and velocity signals


• Conventional motion control systems uses resolvers or encoders
• Sensor, wirings, connectors increase the cost of the system and decrease the reliability
• Application Sensorless PM Motor Control In
− Lower overall drive cost by eliminating mechanical position sensor
• cost sensitive application
• increase system performance for the same price
− Increase position resolution in collaboration of estimator and low cost position sensor
• increase system performance
• back-up sensor
− Independent position sensing together with mechanical
• safety critical application
• increase system redundancy
• A sensorless motor strategy is good for applications that don’t have the motor to stop and does not change
direction (ex. Fuel pumps).

110 EXTERNAL USE


Motor Control: What is Back EMF and how to use it
• An electric motor acts like a generator and can generate a secondary force that opposes the original
electromotive force (EMF) called back EMF. There is a direct correlation between the back EMF and position
of a motor.
• Since there is a direct correlation between motor position and back EMF voltage amplitude we can use it to
get motor position needed for FOC.
• In sensor-less trapezoidal the back EMF zero crossings are detected by measuring the phase voltage of the
coil that is not energized, but in FOC that is not the case.
• All coils are energized thru the full commutation cycle. Therefore a back EMF observer is used to estimate
the back EMF using a simplified model of a PMSM motor, phase current feedback, and command voltage
information.
• To measure the back EMF a certain amount of motor speed is required so that enough back EMF voltage is
generated for measurement. Therefore a minimum speed is required for sensorless FOC algorithms to
operated.

111 EXTERNAL USE


Motor Control: Simplified Sensorless PM Control

• Force Mode – Use the requested speed and position as the estimated speed and position for the back-EMF
observer and FOC control. FOC always uses phase currents from the shunt resisters. Speed control uses
requested speed and position to close the loop on speed.

• Tracking Mode – The back-EMF observer closes the loop and uses it own estimated position and speed
vs. the requested position and speed for feedback. Speed control uses requested speed and position to
close the loop on speed.

• Sensorless Mode – Speed control uses back-EMF observer speed and position to close the loop on speed.

• Basically each mode transition happens at a different requested speed value to eventually have the motor
spin fast enough to generated enough back-EMF to accurately estimate the motor position and speed.

112 EXTERNAL USE


Agenda
• Overview:
− Introduction and Objectives
− Model-Based Design Toolbox: Library blocks, FreeMASTER, and Bootloader

• Hands-On Demo:
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Convert simple model to run on Motor Kit with MCD Toolbox and use FreeMASTER

• Model-Based Design:
− Model-Based Design Steps: Simulation, SIL, PIL and ISO 26262
− SIL/PIL Hands-On Demo Step 2 & 3 of MBD

• Trapezoidal Motor Control:


− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor

• Trapezoidal Motor Control Hands-on Demo:


− Implement Trapezoidal Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor and tune parameters

• FOC Motor Control:


− FOC Sensor-less control and how to use it to turn a motor
• FOC Motor Control Hands-On Demo:
− Implement FOC Sensor-less Motor Control on Motor Kit
− Run software from the model and use FreeMASTER to monitor
• Summary and Q&A:

113 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

Summary FOC Sensor-less Motor Control on S12ZVM steps:


1. Open FOC_Sensorless.slx
2. Save model as S12ZVM_FOC_Sensorless.slx
3. Configure S12ZVM thru model configuration parameters
4. Configure the Gate Driver Unit with the GDU Configuration Block
5. Configure ADC blocks to read phase currents
6. Set up PTU triggers to synchronize current readings with PWM
7. Setup ADC interrupt to start FOC Fast Loop
8. Configure Digital Input for Toggling LED
9. Connect and configure PMF PWM blocks for output to switches thru GDU

114 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

115 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

FastLoopInput Block

116 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
FastLoopAlgorithm Block

117 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

FastLoopAlgorithm FOC Block

118 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

FastLoopAlgorithm PosObserver Block

119 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
COM Port Setup:

120 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

121 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
Gate Drive Unit configuration steps:

122 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
Gate Drive Unit configuration steps (the settings = 720 nsec):

123 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
Gate Drive Unit configuration steps:

124 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
Gate Drive Unit configuration steps:

125 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
Gate Drive Unit configuration steps:

126 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
Gate Drive Unit configuration steps:

127 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

128 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

PTU Unit configuration steps:

129 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

PTU Unit configuration steps:

130 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

PTU Unit configuration steps:

131 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

132 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

ADC Unit configuration steps:

133 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

ADC Unit configuration steps: Copy ADC0_Config

134 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

ADC Command List Block steps:

135 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

ADC Command List Block steps: Copy ADC0_Command_List

136 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

137 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
ADC ISR Block steps:

138 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

FastLoopInput

139 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

ADC Command List Block steps:

140 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

141 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

3PhaseDutyCycleOut Block with Flex PWM Blocks steps:


Pull Simple PWM phase block from library, connect to phase A and configure.

142 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

PMF Block steps:

143 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control
PMF Block steps:

144 EXTERNAL USE


Demo: FreeMASTER to Monitor and Tune Parameters

Using FreeMASTER with Hands-On Demo


1. Start FreeMASTER and open project S12ZVM_FOC_Sensorless.pmp. Press OK if a message comes up
that the map file has been updated.
2. Go to Project Options pull-down and select “Options”. Verify that COM settings are the same as what were
set in your model.
3. Once the COM settings are correct, press the STOP button.
4. Change MotorSpeedReqFreemaster Variable to 1000 RPM.

145 EXTERNAL USE


Demo: FreeMASTER to Monitor and Tune Parameters

146 EXTERNAL USE


Demo: FreeMASTER to Monitor and Tune Parameters

147 EXTERNAL USE


Demo: Implement FOC Sensor-Less Motor Control

148 EXTERNAL USE

You might also like