0% found this document useful (0 votes)
96 views85 pages

FTF Ind F0010

Uploaded by

Pasha Zubkov
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)
96 views85 pages

FTF Ind F0010

Uploaded by

Pasha Zubkov
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/ 85

Hands-On Workshop: Motor Control, Part 3:

Development in MATLAB™/Simulink™
Using the Motor Control Toolbox
FTF-IND-F0010

John H Floros | MCD Toolbox Manager


APR.2014

TM

External Use
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 1
Introduction: WHAT DO WE DO?

• The CodeWarrior and Engineering Tools


group’s objective is to develop software
enablement tools to assist our customers
with rapid prototyping and accelerate
algorithm development on their target
Freescale MCU
• This includes software tools that
automatically generate peripheral
initialization code through GUI
configuration, to generating peripheral
driver code from a Model Based Design
environment like Simulink™

TM

External Use 2
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 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. Motor Control Development Toolbox allows this stage of the
development to generate 100% of the code from the model.

TM

External Use 3
Introduction: Motor Control Development Toolbox
• The Motor Control Development Toolbox includes an embedded target supporting Freescale
MCUs and 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 Freescale’s renowned Motor Control Center of Excellence. The library provides dozens of
blocks optimized for fast execution on Freescale 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 MC Toolbox:


− MATLAB (32-Bit or 64-Bit)*
− Simulink
− MATLAB Coder
− Simulink Coder
− Embedded Coder
*Earlier released products only support 32-bit

TM

External Use 4
Introduction: Reduce Development Time With MBD
and MC Toolbox
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 MC library HIL Testing


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

TM

External Use 5
Introduction: Reduce Development Time With MBD
and MC Toolbox

System Functional
Requirements Testing

Modeling/
Simulation

HIL Testing

Rapid Prototype

To This!
Target MCU
Implementation

Time
TM

External Use 6
Objectives
After this Hands-on Workshop, you will be able to:
Use the Motor Control Development Toolbox to auto-
generate and build software for the MCU directly from the
MATLAB™/Simulink™ environment.
Configure the MCU peripherals required to implement
three phase motor control using the MCU and the low-
voltage Three Phase Motor Control Kit.
Implement Trapezoidal Motor Control from a model based
design environment and auto generate the code to run the
brushless DC Motor provided with the Motor Kit.
Know how Motor Control Development Toolbox can help
with your motor control development projects and
Freescale MCUs.

TM

External Use 7
Objectives

• Freescale’s hardware/software enablement


TWR-ELEV TWR-KV10Z32 TWR-MC-LV3PH

TOWER System 3-Phase Motor Control Kit


Modular, expandable and cost-
effective development platform

Motor Control Development Toolbox


with Simulink ™

Model-based design driver configuration, Real-time Debugging Tool


Assignment to pins, & initialization setup Data acquisition and calibration

TM

External Use 8
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks,
FreeMASTER, and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

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

NOTE: Peripheral Block and compiler availability is dependant on which MCU is use.
TM

External Use 10
MCD Toolbox: Math and Motor Control Library Contents
GFLIB GDFLIB GMCLIB
• Trigonometric Functions • Finite Impulse Filter • Clark Transformation
− GFLIB_Sin − GMCLIB_Clark
− GDFLIB_FilterFIR
− GFLIB_Cos − GMCLIB_ClarkInv
− GFLIB_Tan • Moving Average Filter
− GFLIB_Asin • Park Transformation
− GFLIB_Acos − GDFLIB_FilterMA − GMCLIB_Park
− GFLIB_Atan • 1st Order Infinite Impulse Filter − GMCLIB_ParkInv
− GFLIB_AtanXY
• Limitation Functions − GDFLIB_FilterIIR1init • Duty Cycle Calculation
− GFLIB_Limit − GDFLIB_FilterIIR1 − GMCLIB_SvmStd
− GFLIB_LowerLimit • Elimination of DC Ripples
− GFLIB_UpperLimit • 2nd Order Infinite Impulse Filter
− GFLIB_VectorLimit − GMCLIB_ElimDcBusRip
− GDFLIB_FilterIIR2init
• PI Controller Functions • Decoupling of PMSM Motors
− GFLIB_ControllerPIr − GDFLIB_FilterIIR2 − GMCLIB_DecouplingPMSM
− GFLIB_ControllerPIrAW
− GFLIB_ControllerPIp
− GFLIB_ControllerPIpAW
• Linear Interpolation
− GFLIB_Lut1D
• Hysteresis Function
− GFLIB_Hyst
• Signal Integration Function
− GFLIB_IntegratorTR
• Sign Function
− GFLIB_Sign
• Signal Ramp Function
− GFLIB_Ramp

TM

External Use 11
MCD Toolbox: RAppID Bootloader Utility
The RAppID Bootloader works with the built-in Boot Assist Module (BAM) included in the Freescale
Qorivva and also supports MagniV, Kinetis, and DSCs family of parts. 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, MPC564xL, MPC5604/3P, MPC574xP, S12ZVM, KV10 and 56F82xx.
Graphical User Interface Command
Line

Status given in two stages:


Bootloader download, then
application programming

TM

External Use 12
FreeMASTER – Run Time Debugging Tool

• User-friendly tool for real-time debug


monitor and data visualization
− Completely non-intrusive monitoring of
variables on a running system
− Display multiple variables changing
over time on an oscilloscope-like
display, or view the data in text form
− Communicates with an on-target driver
via USB, BDM, CAN, UART
• Establish a Data Trace on Target
− Set up buffer (up to 64KB), sampling rate
and trigger
USB
− Near 10-µs resolution BDM
CAN
UART
JTAG
http://www.freescale.com/freemaster Ethernet

TM

External Use 13
MCD Toolbox: Summary of 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

TM

External Use 14
Motor Control Development
Toolbox
Any Questions?

TM

External Use 15
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 16
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 ID
Va

Conversion Forward
Park
Forward
Clark
IB

Transform Transform
Vb
IC
IQ

Motor Position
Analog
Analog Device Model
Sensor Model Controller Model

Idealized simulation of the controller and


the motor to refine the control technique.
Done on host PC without regard for
Electric Motor Model embedded controller. Can optionally add
PC Environment analog device models for fault detection
and signal control.
TM

External Use 17
Model Based Design Steps: Step 2 (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
Transform
PWM
Modulation
PWM B

ID PI ID Vb
+ loop Filter cmd cmd PWM C
Zero -
Gate
IA Driver
A/D ID
Va

Conversion Forward
Park
Forward
Clark
IB

Transform Transform
Vb
IC
IQ

Motor Position
Analog
Analog Device Model
Sensor Model Controller 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
Electric Motor Model vectors as in simulation for C Code
PC Environment
Coverage analysis and verify functionality.
TM

External Use 18
Model Based Design Steps: Step 3 (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 ID
Va

Conversion Forward
Park
Forward
Clark
IB

Transform Transform
Vb
IC
IQ

Motor Position
Analog
Analog Device Model
Sensor Model Controller Model

Execute the model on the target MCU and


perform numeric equivalence testing. Co-
execution with MCU and Model Based Design
working together while collecting execution
Electric Motor Model metrics on the embedded controller of the
PC Environment + MCU
control algorithm. Validate performance on
the MCU.
TM

External Use 19
Model Based Design Steps: Step 3 (PIL)

Verification and Validation at Code Level


• This step allows:
− Translationvalidation 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

TM

External Use 20
Example IEC 61508 and ISO 26262 Workflow for
Model-Based Design with MathWorks Products*
Model advisor, modeling PIL testing using embedded IDE links
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
TM Presentation Material Model-Based
External Use 21 Design for IEC 61508 and ISO 26262
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 Generate production code to run on embedded MCU with real
Embedded Control
Module (ECM)
Electric Motor motor 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.
TM

External Use 22
Model Based Design Steps: Summary

PWM A PWM A PWM A


Torque IQ PI IQ Va Torque IQ PI IQ Va Torque IQ PI IQ Va
Control + loop Filter cmd cmd Control + loop Filter cmd cmd Control + loop Filter cmd cmd PWM A
Torque IQ PI IQ Va
- Reverse PWM B
- Reverse PWM B
- Reverse PWM B Control + loop Filter cmd cmd
PWM PWM PWM
Park Park Park
Transform
Modulation
Transform
Modulation
Transform
Modulation - Reverse PWM B
PWM
Park
ID PI ID Vb ID PI ID Vb ID PI ID Vb Modulation
Transform

Zero
+
-
loop Filter cmd cmd PWM C
Zero
+
-
loop Filter cmd cmd PWM C
Zero
+
-
loop Filter cmd cmd PWM C

Gate Zero
+
-
ID
loop
PI
Filter
ID
cmd
Vb
cmd PWM C

Gate
Driver
IA IA IA
Va Va Va

Driver
IA
ID ID ID Va
Forward Forward IB Forward Forward IB Forward Forward IB ID
Park Clark Park Clark Park Clark
Forward Forward IB
Transform Transform Transform Transform Transform Transform
Vb Vb Vb Park Clark
IC IC IC Transform Transform
IQ IQ IQ Vb
IC
IQ

Motor Position Motor Position Motor Position


Motor Position

Controller Model Controller Model Controller Model Controller Model

Electric Motor Model Electric Motor Model Electric Motor Model Electric Motor

MCU with
PC Environment
PC Environment PC Environment Embedded Control
+ MCU
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 using SIL MBD Simulation with ANSI C Code using PIL ANSI C Code Running on Target HW & 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 design See memory/stack usage on MCU Start testing implementation on target ECM
Modeling style guidelines applied Start testing implementation approach Start testing implementation approach Code generate control algorithm +
Algorithm functional partitioning Target testing controls algorithm on MCU I/O drivers. Complete implementation on
Interfaces are defined here Testing of functional components of algorithm ECM. Test system in target environment
Test harness to validate all requirements Refine model for code generation Utilize calibration tools for data logging and
Test coverage of model here Function/File partitioning parameter tuning
Creates functional baseline of model Data typing to target environment done here
Scaling for fixed point simulation and code gen Execute code on target MCU
Testing of functional components of algorithm Functional testing in target environment
Test harness to validate all requirements Ensure execution on target is correct as well
Test coverage of model here as code generation on target is performing as
Creates functional baseline of model desired.
Equivalence testing

TM

External Use 23
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox
and use FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 24
Hands-on Demo: Tower Hardware
TWR-MKV10Z32 TWR-MC-LV3PH

Features: Features:
• MKV10Z32VLF7 MCU (48LQFP) • Input voltage 12-24V DC
• OpenSDA debug circuit with Micro USB connector and • Output current 5-10 Amps
virtual serial port • 3-phase MOSFET inverter
• MMA8451Q 3-axis digital accelerometer (i2c interface) • 3-phase pre-driver MC33937
• LEDs with connected buffers to PWM channels for dimming • Analog sensing
• 2 push buttons for user input or interrupts • Motor speed/position sensors interface
• 4 Thermistors for single ended or differential analogue • 2 pole-pair BLDC motor with Hall
inputs, 2 motor control auxiliary connectors sensors (4000 RPM rated speed)
• Compatible with TWR-MC-LV3PH motor driver peripheral • On-board power regulation for Tower
module (NOTE: TWR-MC-LV3PH module and TWR-ELEV System (single power supply via
module must be ordered separately if required. TWR-MC-LV3PH power jack)

TM

External Use 25
Hands-on Demo: Simple Model
Run Simple Model Simulation
1. Open Model “Blinky.slx”
2. You will see a model that toggles outputs
and will change the way it toggles the
outputs based on an input.
3. Run simulation and open the scope. You
should see the following on the scope:

TM

External Use 26
Hands-on Demo: Simple Model
Convert Simple Model and Run
1. Save model as “KV10_Blinky.slx”
2. Select KV10 TLC file to configure model for the MCU
3. Open Simulink library
4. Go to Motor Control Toolbox for Configuration Information Block
5. Drag the block into the model
6. Open block and go to PIL/BAM setup tab
7. Check download code after build
8. Enter the COM port number that you are using from PC
9. Delete Step block and Scope
10. Go back to library under General Purpose Blocks, drag in a Digital Output
block and connect to each mode output a Digital Output Block. Select the
output pins to use which are connected to an LED (See next Slide).
11. Go back to library under Motor Control Blocks and drag in a Digital input
block to read SW1 (PTA4).
12. Go back to the library and under utilities get a Profiler Function block so
that the execution time can be measured.

TM

External Use 27
Hands-on Demo: LED Simple Model
Convert Simple Model and Run
• This is what the model should look like after step 12

TM

External Use 28
Hands-on Demo: Simple Model

Convert Simple Model and Run


13. Go to Tools pull down menu and then select generate code / Build
Model.
14. Wait for model to generate code and then a prompt from the
RAppID Bootloader Utility will appear. Reset the MCU and then
select “OK”.
15. Once the download is complete you will observe LEDs blinking.
16. Press SW1 and you will see not all the LEDs blinking.

TM

External Use 29
Hands-on Demo: Simple Model

Using FreeMASTER with Hands-on Demo


17. Start FreeMASTER and open project KV10_Blinky.pmp. Just press OK
if a message comes up that the map file has been updated.
18. Go to Project Options Pull Down and select “Options”. Verify that COM
settings are the same as what were set in your model.
19. Once the COM settings are correct, press the STOP button and press
SW 1. You should see the following (next slide):

TM

External Use 30
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 19

TM

External Use 31
Hands-on Demo: Simple Model
Any Questions?

TM

External Use 32
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 33
Tower Motor Kit Overview

Features
• Electrical specifications:
− Input voltage 12-24V DC
− Output current 5-10 Amps
• 3-phase MOSFET inverter
• 3-phase pre-driver MC33937, configurable thru SPI
analog sensing (dcb voltage, dcb current, phase
currents, back-EMF voltage)
• Motor speed/position sensors interface (Encoder, Hall)
• Hardware over-current fault protection
• On-board power regulation for Tower System (single power supply via
TWR-MC-LV3PH power jack)
• Brushless DC (BLDC) Motor Linix 45ZWN24-40
Purpose
• The purpose of the Low Voltage Motor Control Tower module is to be
used by customers to prototype DC, BLDC and PMSM motor control
solutions and to evaluate/demonstrate various algorithms.

TM

External Use 34
Tower Motor Kit: TWR-MC-LV3PH Module

Motor Connector MOSFET H-Bridge Power Supply


Connector

Motor Hall/Encoder Freescale 3-Phase


Connector Pre-Driver Chip (MC33937)
TM

External Use 35
Tower Motor Kit: 3PP Driver Chip (MC33937)
Features
• Fully specified from 8.0V to 40V; covers 12V
and 24V automotive systems
• Extended operating range from 6.0V to 58V
covers 12V and 42V systems
• 1.0A gate drive capability with protection
• Protection against reverse charge injection
• Includes a charge pump to support full FET
drive at low battery voltages
• Dead time is programmable via the SPI
• Simultaneous output capability enabled via
safe SPI command
Purpose
• The IC contains three high-side FET pre-
drivers and three low-side FET pre-drivers.
Three external bootstrap capacitors provide
gate charge to the high side FETs.

The IC interfaces to an MCU via six input control signals, a SPI port for device setup and
asynchronous reset, enable and interrupt signals

TM

External Use 36
Tower Motor Kit: Brushless DC Motor

Features
Model: Linix 45ZWN24-40
Motor Type: Brushless DC
Windings: “Y” Connection Method
Pole Pairs: 2 pairs
Rated Voltage: 24V
Rated Current: 2.3 A
Rated Torque: 990 g.cm
Rated Power: 40 Watts
Rated Speed (Load): 4000 RPM
Speed (Un-Loaded): 4900 RPM
Position Sensing: Hall Type (A, B, C)

Note: Pole pair count for this motor means that every single mechanical
revolution equals two electrical revolutions. State change in Hall sensors
is every 60 degrees electrical.

TM

External Use 37
Introducing Kinetis V Series
Motor Control and Power Conversion MCUs
• Builds on Freescale’s motor and power
control expertise to address NEW mass
market customers.

• Enables efficient, next generation BLDC,


PMSM and ACIM designs through optimized
performance, analog and timing IP. High
speed DSC peripherals are ideal for
advanced motor control and power conversion
and include the fastest ADC in the Freescale
MCU portfolio.

• Features scalable, low-power families built


® ®
on ARM Cortex processors – starting with
the industry’s fastest ARM Cortex-M0+ MCU.

• Includes sophisticated enablement tools like


the new, easy-to-use Kinetis motor suite
which helps to reduce development time
and cost for every customer.

TM

External Use 38
Kinetis V Series Target Applications

Motor Control Digital Power Conversion

• Sensored BLDC / PMSM • Solar Inverters


• High Dynamic Control • Grid-Tied
• Sensored ACIM • Non Grid Tied
• Sensorless VOC • Power factor correction
• PMSM/BLDC • Switch Mode
Power Supplies
• High Dynamic Control
• AC/DC
• Low Dynamic Control
• DC/DC
• Sensorless ACIM
• UPS
• On-Line
• Offline
• Inductive cooking
• Multi cook plate

TM

External Use 39
Solutions for Motor Control and Digital Power Conversion

ARM Cortex-M0+ ARM Cortex-M4 ARM Cortex-M

+ Advanced Memory,
Connectivity and Communications
Performance

KVxx
2014 Families
+ High Speed ADC
KV4x Family
High performance
+ High Resolution PWM motors, UPS, solar and Increasing
mid range AC/DC control performance and
2014 feature
integration
KV3x Family + Multi Channel Timers
Mid range PMSM, Optimized
+ Floating Point Unit
UPS power control memory
2014 configurations
KV1x Family + Motor Control Software
BLDC, entry level PMSM

Feature Integration
Freescale IDE, RTOS, Software Libraries and Motor Control Development Tools

TM

External Use 40
Kinetis V Series Enablement
New Kinetis Motor Suite Motor Control Tools
A simple-to-use, motor New Freescale Enablement Software
Kinetis SDK, Kinetis Design Studio, Kinetis Bootloader
control development
suite that allows FreeMASTER: GUI-based run-time debug monitor and
data visualization tool
customers of all
experience levels to MCAT: FreeMASTER plug-in for real-time monitoring,
tuning and updating of control parameters
design applications
quickly, efficiently and Motor Control Toolbox: MATLAB™ modeling
without the need for environment plug-in for automatic code generation

in-depth motor control expertise. Software Libraries for CM0+/M4 & IEC60730:
Motor Parameters & Control
Math, General, Filter and Motor Control libraries.
• Turnkey solutions initially Sensorless algorithms for advanced control
targeting fans, compressors and ADRC

pumps. MCU interaction via GUI. Motor


Tower Development System, IDEs & Auto-code
Additional application areas will
Subsystem Generators: KDS, IAR, Keil & Processor Expert
be developed over time. Application
Real time
Extensive Ref. Design and App. Note Library:
view of
• Advanced solutions for user function
operation BLDC, PMSM, High Voltage Power Stage and more
Kinetis Motor
development of app. code, with Observer

Kinetis motor suite configuring Observer Kinetis Kinetis


motor motor
and controlling the motor sub- Config. tuner manager

system.

Supported by Freescale’s Motor Control Center of Excellence with 20+ years of


expertise in MCU development, enablement and customer support
TM

External Use 41
Kinetis V Series Availability

Starting From Expected


MCU Core / Flash FlexTimers / Price availability
ADC
Family Frequency Range eFlexPWM (10K# SRP, (Samples /
USD) Production)
Up to 8-ch.
2x 12bit FlexTimer
Cortex-M4 64-256
KV4x 4.1 MSps / / *$2.99 Sept
150 MHz KB
1.9 MSps 12-ch. eFlexPWM
+ Nano-Edge

Cortex-M4 64-512 2x 16-bit Up to 20-ch.


KV3x *$1.79 Apr / Aug
100/120 MHz KB 1.2 MSps FlexTimers

Cortex-M0+ 2x 16-bit Up to 10-ch.


KV1x 16-32 KB $0.99 Now
75 MHz 1.2 MSps FlexTimers
*Subject to change

TM

External Use 42
Tower Motor Kit: Kinetis V Series KV1x Overview
Core System Memories Clocks
Key Features:
Core/System ARM Cortex-M0+ Internal and
External
Program Flash SRAM Frequency-
75MHz 32KB 8KB Locked Loop
• 75MHz ARM CM0+ with 4ch DMA Watchdogs

• H/W DIV & SQRT block Debug HW Divide &


SqrRoot 4ch-DMA Low/High
Memory Interfaces
Frequency
• 32KB Flash, 8KB SRAM Interrupt
Oscillators
Inter-Module
Communications Controller
Crossbar
Internal
• Multiple serial ports Reference
Clocks
Analog
• 2 x 8ch 16-bit ADC
− 835nS conversion time
• 1 x12-bit DAC, Security Analog Timers Communication Interfaces HMI
• 2 x ACMP w/ 6b DAC and Integrity
Timers 2 x16-bit 6ch
Cyclic
• 1x6ch FlexTimer (PWM) Redundancy ADC FlexTimer 1xI2C GPIO
Check (CRC)
• 2x2ch FlexTimer (PWM/QDEC) 2x2ch
2 x ACMP FlexTimer
• Programmable Delay Block 2xUARTs
Others 1 x12-bit Programmable
• 32-bit CRC DAC Delay Block
1xSPI
• Inter-module Crossbar Switch
• Up to 35 I/Os Low-Power
Timer
• 1.71V-3.6V; -40 to 105°C
Packages
• 32QFN, 32LQFP, 48LQFP
• Pin-to-pin compatible with K series

A high performance, cost-optimized and best-in-class enabled 32-bit ARM


Cortex-M0+ MCU for low/mid range Brushless DC and FOC PMSM Motor Control
TM

External Use 43
Tower Motor Kit: System Diagram
Vb+

Phase
Voltages
A
Phase A

3PP Phase B
Driver Chip Phase C
(MC33937)
BLDC
Motor

Switches Hall Sensors


Vb-
SPI PWM

SPI FlexTimer GPIO FTM/GPIO


KV10
UART
GPIO

RAppID BL Utility LEDs

TM

External Use 44
Tower Motor Kit
Any Questions?

TM

External Use 45
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 46
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

TM

External Use 47
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

TM

External Use 48
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-
TM

External Use 49
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.
Phase Phase Phase
CW
A B C At
0/180○ Vb- NC Vb+ Cb Bb

30○ Vb- Vb+ NC


Bt o Ct
60○ NC Vb+ Vb- N
90○ Vb+ NC Vb-
Ab S S Ab
120○ Vb+ Vb- NC
150○ NC Vb- Vb+
Ct
N Bt
Vb+ Vb- NC
Top
Switch On Off Off Bb Cb
Bottom
At
Switch Off On Off

TM

External Use 50
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.
Phase Phase Phase
CCW At
A B C
Cb Bb
0/180○ Vb+ NC Vb-
30○ Vb+ Vb- NC Bt o Ct
N
60○ NC Vb- Vb+
90○ Vb- NC Vb+ Ab S S Ab
120○ Vb- Vb+ NC
150○ NC Vb+ Vb- N
Ct Bt
Vb+ Vb- NC
Top Bb Cb
Switch On Off Off
At
Bottom
Switch Off On Off

TM

External Use 51
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
TM
Hall C
External Use 52
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

TM

External Use 53
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

TM

External Use 54
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
TM

External Use 55
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

TM

External Use 56
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

TM

External Use 57
Trapezoidal Control
Any Questions?

TM

External Use 58
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 59
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
Summary Trapezoidal Motor Control on KV10 steps:
1. Open Trap_Ctrl.slx
2. Save model as KV10_Trap_Ctrl.slx
3. Configure KV10 configuration block
4. Configure Input port blocks to read motor hall position state
5. Configure Input Edge Capture Blocks to detect change in motor position
sensors
6. Configure an Input Edge Capture Block to measure one of the Hall sensor pulse
width for RPM calculation
7. Configure Digital Input for use in controlling RPM Request
8. Configure DSPI blocks to interface to Freescale 3PP driver
9. Connect and configure PWM blocks for output to switches

TM

External Use 60
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit

TM

External Use 61
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
Configure Hall Sensor Input Block using Digital I/O steps:
Set input blocks to correct pins.

TM

External Use 62
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
The Trapezoidal Control algorithm needs to run on any change of state or event so that we
can change our Commutation State as quickly as possible. Therefore we want to trigger off
of any rising or falling edge of the hall sensors.

Commutation Change event Commutation Change event

TM

External Use 63
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

TM

External Use 64
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
• Using the Input Edge Capture blocks we can monitor the transitions of the
hall sensors to trigger a function call to set a new commutation state. We
can measure the a hall sensor pulse time to determine RPM.

• We also can capture the number of changes in the hall sensors states and
save that for determining the motor RPM.
TM

External Use 65
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit

Make sure to check

TM

External Use 66
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit

TM

External Use 67
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
MotorSpeedReqInput Block steps:

TM

External Use 68
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.

TM

External Use 69
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
PWM Block steps:

TM

External Use 70
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
PWM Block steps:

TM

External Use 71
Hands-on Demo: Implement Trapezoidal Motor Control on
Motor Kit
3PhaseDutyCycleOut Block with Flex PWM Blocks steps:

TM

External Use 72
Hands-on Demo: FreeMASTER to Monitor and Tune
Parameters
Using FreeMASTER with Hands-on Demo
1. Start FreeMASTER and open project KV10_Trap_Ctrl.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 they were set to in your model.
3. Once the COM settings are correct, press the STOP button.
4. Change MotorSpeedReqFreemaster Variable to 1000 RPM.

TM

External Use 73
Hands-on Demo: How can we make the response better

Using FreeMASTER and PWM resolution


1. Adjust the Proportional and Integral gain constants for faster response.
2. See if change the PWM resolution can help (see screen shot)

Change scaling so that instead of 0-100


make it 0-1000 effectively making the PWM
resolution 0.1% vs. 1.0%.

TM

External Use 74
Hands-on Demo: Trapezoidal
Motor Control
Any Questions?

TM

External Use 75
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 76
SIL/PIL Demo

1. Open Model “KV10_FOC_PIL_REF.slx


2. You will see a motor simulation of an FOC control algorithm
3. Will run model and review results

TM

External Use 77
SIL/PIL Demo

1. You can switch between SIL and PIL by using the tools menu.

TM

External Use 78
SIL/PIL Demo
Any Questions?

TM

External Use 79
Agenda
• Overview: 30 minutes
− Introduction and Objectives
− Motor Control Development Toolbox: Library blocks, FreeMASTER,
and Bootloader
− Model Based Design Steps: Simulation, SIL, PIL and ISO26262
• Hands-on Demo: 20 minutes
− Convert simple model to run on Motor Kit with MCD Toolbox and use
FreeMASTER
• Motor Control: 30 minutes
− Motor Kit (Describe Freescale 3-Phase Motor Kit)
− Trapezoidal control and how to use it to turn a motor
• 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
• SIL/PIL Demo: 10 minutes
• Summary and Q&A: 10 minutes
TM

External Use 80
Summary
You now know how to do Trapezoidal Control and auto-generate
software with the Motor Control Development Toolbox directly from
the MATLAB™/Simulink™ for Freescale MCUs.

You now understand how to run SIL and PIL with MCD Toolbox and
how it can accelerate your development, including systems being
developed under IEC 61508 using PIL.

You have gained a good working knowledge of how FreeMASTER


works and how it can be used with MCD Toolbox to accelerate
development when working with the target hardware.

You have a working knowledge of how to use the Freescale Pre-


Driver chip with a motor control application.

You know how the Freescale MCU covered can fit into your motor
control application.

TM

External Use 81
Summary: Publications
MathWorks Announces Simulink Code Generation Targets in New Freescale Motor Control
Development Toolbox
www.mathworks.com
• Simulink and Embedded Coder enable engineers to generate production code for Freescale
MCUs in IEC 61508 (SIL3) and ISO 26262 (ASIL-D) compliant systems.

Freescale likes model-based design, says MathWorks


www.ElectronicsWeekly.com
• MathWorks says Freescale has made a major commitment to model-based design
methodologies by adopting Simulink code generation targets in its motor control development
toolbox. The toolbox, consisting of Simulink motor control blocks and target-ready …

A model-based tool to support rapid application development for Freescale MCUs


www.Freescale.com - Beyond Bits—Issue VIII
• Model-based design (MBD) is becoming the standard methodology for developing embedded
systems that implement the desired behavior of a control system. MBD is a graphical method

TM

External Use 82
Summary
Any Questions?

Please Fill Out Your Surveys.

Thank you for your time.

TM

External Use 83
TM

www.Freescale.com

© 2014 Freescale Semiconductor, Inc. | External Use

You might also like