Motor control with STM32
32bit ARMbased MCU
STMicroelectronics
For 3phase brushless motor vector drives
www.st.com/mcu
Vector control made simple
STMicroelectronics STM32 offers the performance of the industrystandard CortexM core at the service of
vector (or fieldoriented) control algorithms, widely used in highperformance drives. They provide precise and
responsive torque and speed control, and guarantee optimized efficiency during transient operations.
The STM32, offering a wide and compatible portfolio, is part of a complete motor control ecosystem:
QQ 3-phase permanent magnet synchronous motor (PMSM) field-oriented control (FOC) firmware library
QQ Graphical configuration tool (MC Workbench)
QQ Graphical real-time diagnostic tool (STM Studio)
QQ Complete motor control kit
STM32
STM32 block
blockdiagram
diagram
Up to 1-Mbyte Flash memory
Applications
System Up to 192-Kbyte SRAM QQ Appliances
Power supply FSMC/ QQ Washing machines
Internal regulator SRAM/NOR/NAND/CF/ QQ Dishwasher pumps
POR/PDR/PVD ARM Cortex-M LCD parallel interface
Up to 168 MHz QQ Refrigerators
Xtal oscillators
High- and low-speed Backup data + backup SRAM1
QQ Air conditioners
Internal RC oscillators OTP bytes1 QQ Medical
High- and low-speed
QQ Sleep apnea CPAP, VPAP
PLL Floating point unit (FPU)2 Connectivity QQ Wheel chairs
Clock control Nested vector Camera interface QQ Pumps
RTC/AWU interrupt
controller (NVIC) SPI, IS, IC QQ Industrial
SysTick timer
Ethernet MAC 10/100 QQ Electric vehicles
2x watchdogs MPU 1
with IEEE 1588 QQ Lowend and
(independent and window) JTAG/SW debug/ETM1 CAN 2.0B mediumrange industrial
Up to 140 I/Os
Cyclic redundancy USB 2.0 OTG FS/HS1 drives
check (CRC) ART Accelerator 1
SDIO QQ HVAC actuators and fans
USART QQ Pumps
Multi-AHB bus matrix LIN, smartcard, IrDA, QQ Blowers
modem control
Multi-channel DMA QQ Vending and cash machines
Control Crypto/hash processor1
2x 16-bit motor control Analog
PWM 3DES, AES 256 2-channel 2x 12-bit DAC
Synchronized AC timer SHA-1, MD5, HMAC 3x 12-bit ADC
16-bit timers Multi-channel
and 32-bit timers
Temperature sensor
True random number1
generator (RNG)
Notes:
1. STM32 F2 and F4 series
2. STM32 F4 series only
2
Field orientation in sensorless torque control PMSM
Vector control drive STM32 safety features for greater control robustness
QQ Theory Features Benefits
QQ Changing reference coordinates QQ Safety critical registers can be QQ Strengthens control algorithm
from fixed stator coils to the locked to prevent power stage to protect motor operation from
moving rotor frame greatly damage (software runaway) external disturbance
simplifies the equation describing QQ Deadtime, PWM output polarity, QQ Protects safetycritical registers in
the motor emergency input enable case of system hang
QQ Method QQ All target registers are read/write QQ Quick error diagnosis and fault
QQ Clarke and Park transformations until lock activation (and then management
convert variables with fixed readonly if protected) QQ Hardware protection of power
3axis, 120 shifted coordinates QQ Once the two lock bits are stage whatever the status of MCU
into 2axis orthogonal rotating written, they cannot be modified oscillator
coordinates until next MCU reset (writeonce QQ Safety hardware features comply
QQ These last variables are DC, or bits) with IEC 603351
slowly varying values, which QQ If main clock fails, an internal RC
can be regulated by means of oscillator (FREEOSC, ~5MHz
simple PID controllers and then average frequency) starts
transformed back to the fixed immediately
stator windings frame using QQ Interrupt can be generated for
reverse transforms, as shown in shutdown or safe restart sequences
the diagram below
QQ Dual watchdog architecture with
QQ Requirements independent clock sources
QQ Intensive math computations
QQ Embedded reset circuitry (poweron
(trigonometric functions, multiple
reset, powerdown reset,
PID regulators, speed calculation)
programmable voltage detector)
QQ Minimum
resolution of 16 bits for
QQ Emergency stop dedicated input
the main control variables, with
pin with programmable state
a need for 32bit intermediate
results, such as integral terms
QQ Free
CPU load must be kept for
the remaining applicative tasks,
such as communication and
user interface
Vector control block diagram of PMSM drive
3-phase inverter PMSM motor
iqs* Vqs Vabc
PID Reverse park
Va s CALC
and circle
ids* Vds limitation SVPWM
PID
rel
iqs
ia s iabcs Current
ids Park Clarke
reading
rel
Sensorless
rotor position
observer
Notes:
SVPWM: Space vector PWM
* Target setting
3
Vector control with STM32
STM32 dedicated peripherals for 3phase brushless motor control
PWM timer features Benefits
QQ Motor control timer clock QQ Programmable hardware deadtime QQ Suitable for threephase brushless
QQ Maximum input clock is generation PMSM or AC induction motors
72MHz to provide 13.9 ns edge QQ 8bit register with 13.9 ns QQ Sensor and sensorless
resolution (12bit @ 16 kHz resolution at 72MHz (F1series) configurations
edgealigned PWM with and 6.0 ns resolution at
STM32F1 series and up to 168MHz(F4 series) Speed feedback
168MHz (6.0 ns resolution) with QQ Handled by the generalpurpose
the STM32 F4 series ADC features timers
QQ Doubleupdate mode QQ Single/dual/triple ADC with QQ Direct interface with incremental
QQ No loss of resolution in
simultaneous conversion mode encoder and 1 to 3 Hall sensor logic
centeraligned mode QQ 12bit resolution outputs
QQ Uses an additional interrupt per QQ Down to 0.5s (F2 or F4 series) or
PWM cycle or DMAtransfers 1s (F1 series) conversion time
QQ Burst mode QQ Up to 24 channels, plus internal
QQ Possibility to update several temperature sensor and Vref
registers of the peripheral using a QQ External and internal trigger
single DMA stream (including PWM timer)
QQ Programmable reload rate QQ Versatile channel sequencer
QQ Versatile PWM output management QQ DMA capable
QQ Individually selectable polarities QQ Programmable sampling rate
QQ Redirection circuitry for
6stepdrives
Vector control implementation: hardware/software positioning
STM32
V Va 6x PWM
d,q
Vb Fault
SV 6-channel
PWM PWM timer
V Vc Inverter
,
r s Ia
I Ia
d,q r , Dual/triple
Ib
I Ib
12-bit 1 s
A/D converter
, a,b Vbus
r
m
r T Motor
Speed/position
feedback timer
Sensorless
estimation E
r
Legend: H
Software T: Tachogenerator
Hardware E: Encoder
H: Hall sensors
4
STM32 motor control kits
Run your motor in just a few steps Applicationspecific
In just a few minutes, you can run the You can apply changes to realtime requirements
kits PMSM synchronous motor with the settings to tune the drive parameters
Using the same hardware and firmware
standalone demo, in torquecontrol or onthefly and get feedback values from
platform, you may incorporate
speedcontrol mode, using the LCD and the changed settings.
applicationspecific requirements
the joystick on the STM32 evaluation Once familiar with the demo, you will by taking advantage of the STM32
control board (included in the kit). be able to explore our motor control evaluation control board and the
You can then fine tune or change many library that supports FOC (fieldoriented inverter board extension features
parameters using the LCD user interface control) drive of PMSM and induction (USART/LIN port, standalone operation
(as shown on LCD screen captures motors. potentiometer, wrapping area).
below) and run the PM synchronous The library sources are free upon
motor, or an induction motor: request, and help speed up Flexibility
QQ Realtime tuning of torque, flux and development of motor control
Other control and power boards
speed PIDs applications. With the free 32Kbyte
are available and compatible with
QQ BEMF observer gain tuning (for evaluation version of IARs EWARM,
the kit. Future evaluation boards for
sensorless control) you just open the libraries, develop
motor control will also be compatible.
Variation of target speed (speed the application, fine tune the code and
QQ
For more information, contact your ST
control) or target torque and flux parameters and compile. You can fine
sales office.
(torque control) tune the application while running the
QQ Busvoltage and powerstage motor using the realtime debugging
temperature monitoring capability of the Segger JLink.
QQ Selection of variables to put on output
for DAC functionality implementation
STM32 FOC library
STM32 motor control kits
STM32 Power stage
controller board
Debugger/programmer Induction motor
Isolation board
PMSM
motor
Segger J-Link (not included)
(Included)
AI-JTAG/OPTO-1
5
STM32 motor control kits
STM32 motor control tool ordering information
Part number Description
The isolation board included in the STM3210BMCKIT can also be ordered separately. It provides galvanic isolation between
AIJTAG/OPTO1 the JLink from Segger and any highvoltage target board. The isolation board has two JTAG connectors (in/out). Available from
distributors and ST sales offices.
Demonstration, evaluation and development kit for the STM32 includes firmware, LCD user interface, STM3210BEVAL board
STM3210BMCKIT* (controlboard), 1 kW 3phase inverter board, isolation board (AIJTAG/OPTO1), Segger JLink debugger/programmer and 24 VDC
Shinano PMSM motor. Available from distributors and ST sales offices.
Demonstration, evaluation and development kit for STM32 includes firmware, LCD user interface, STM32100BEVAL board
STM32100BMCKIT* (controlboard), 1 kW 3phase inverter board, isolation board (AIJTAG/OPTO1), Segger JLink debugger/programmer and 24 VDC
Shinano PMSM motor. Available from distributors and ST sales offices.
Note:
* Dedicated motor-control documents are available upon request. Complementary control and power boards are available. Contact your ST sales office.
Vector control library
STM32 library Singleshunt current sensing Dual motor control and triple
Optimized and documented C The STM32 motor control library ADC system
firmware libraries for control of both supports singleshunt current sensing, The highdensity STM32 devices
PMSM (sensor and sensorless mode) for applications requiring lowest embed three ADCs and two motor
and AC induction (sensor mode) system costs. Theproposed solution control capable timers. This allows
brushless motors are available for free maximizes the DC bus voltage use, two brushless motors to be driven
upon request. while minimizing current distorsion simultaneously, or to have a triple
These libraries support IAR (EWARM), and acoustical noise, and has been sample and hold current acquisition
Keil and Greenhills toolchains. patented by ST. The STM32MCKIT for very highend control systems.
can be easily reconfigured in oneshunt Thesefeatures are supported by
By default the libraries are customized
mode, for evaluation purposes. additional interrupt vectors and a
to run STM32-KIT. The source files are
provided free of charge upon request. second DMA controller.
These libraries offer: Internal permanent magnet
QQ Different currentsensing motors (IPMSM) Field weakening and
methodologies As a result of their higher power density feedforward control
QQ Isolated current sensing and very high speed capabilities, The stator voltage closedloop field
QQ Three shunt resistors with dual brushless IPMSM motors are used weakening control implemented is
sample and hold utilization and in an increasing number of designs able to expand the operating limits of
advanced methodology for better compared to their surfacemounted both surfacemounted and internal
bus voltage exploitation magnet counterpart. The STM32 MC PMSM, as many applications require.
QQ Proprietary algorithm for single library supports this kind of motor with This algorithm strongly reduces
shunt resistor specific algorithms, such as MTPA sensitivity to motor parameters and
QQ Different rotorposition feedback (maximum torque per ampere) control environmental variations.
QQ Tachometer (AC motor)
strategy.
In addition, feedforward control
QQ Hall sensors (60 and 120
allows improved bus voltage ripple
placement) compensation and better current
QQ Sensorless (PMSM motor only) regulation during highspeed flux
Total execution time of the weakening operations.
fieldoriented control in sensorless
mode on the STM32 F1 series for
PMSM motors is less than 21s (and
below 10s with the new STM32F4).
Total CPU load at 10 kHz sampling
time is below 25 %; code size is less
than 14Kbytes.
6
Motor control development tools: whats new
A new motor control software library STM32 FOC PMSM SDK is now available. Class B compliancy how
QQ Based on the ARMs CMSIS compliant STM32 peripheral library we help
QQ Offering extended customizability
Two key features help compliance
QQ Supporting latest members of the STM32 product line
with the EN/IEC 603351 norm:
QQ Full support of dual motor control drives (using any STM32F1 device)
the dual watchdog architecture
QQ Including application example based on FreeRTOS and the internal clock circuitry. In
order to make certification even
A fieldoriented control dedicated GUI (ST Motor Control Workbench) provides simpler with the STM32, a set
help when configuring the motor control software library by means of: of selftest routines has been
QQ Clear configuration windows for the various items (including power stage, developed to fulfill most of table
motor, speed and current feedbacks) H11.12.7 requirements. These
routines have been certified by the
QQ Direct electricalparameter entry, without need for conversion to fixedpoint
VDE, a worldwide recognized test
format
institute, and do not need to be
QQ Configuration headerfile generation reevaluated if left unchanged.
Dual motor control
The STEVALIHM022V1 demonstration board is designed as a dual motorcontrol
development platform for the STM32F103ZE microcontroller.
The board features full speed USB 2.0 and CAN 2.0 A/B compliant interfaces,
2x IS, 2x IC, 5x USART, 3x SPI, 2x DAC, internal 64Kbyte SRAM and 512Kbyte
Flash memory, and JTAG and SWD debugging support.
The board is designed to implement multiple motor control (up to three MC
connectors are available) and offers an advanced user I/O interface (LCD QVGA
display and joystick key).
Demonstration software for the dual motorcontrol application is available upon
request at ST sales offices.
Extension headers make it easy to connect a daughterboard or wrapping board
for specific applications.
STEVALIHM022V1
STM Studio
STMicroelectronics STM Studio is a graphical user interface which helps debug
and diagnose STM32 applications, while they are running, by reading and
displaying their variables in real time.
Running on a PC, STM Studio interfaces with STM32 MCUs via standard
development tools, such as the lowcost STLINK and STXRLINK.
STM Studio is a nonintrusive tool, preserving the realtime behavior of
applications. STM Studio perfectly complements traditional debugging tools to
fine tune applications, and is well suited for debugging applications that cannot be
stopped, such as motor control applications.
7
Motor control and PFC
Digital power factor correction (PFC)
Why PFC?
For all motorcontrol applications, electric power efficiency increases the profitability of the application, and is a selling factor.
A low power factor means poor electrical efficiency: PFC is an environment friendly technology, reducing the harmonics that
create electrical pollution and saving energy to benefit the society as a whole.
The international norm IEC 6100032 controls the harmonic content of the currents for appliances and electronic equipment
up to 16 A.
Active or passive PFC?
While passive PFC is cheaper, active PFC can reach higher power factors (>98%). Passive PFC is also heavier and larger in size
compared to active PFC.
Active PFC implementation with STM32
L D
Co
AC input
ADC ADC ADC
channel channel channel New duty cycle
VDC
- x VAC - IAC
PI regulator PI regulator
VDCREF VERR VPI IERR
+ Voltage error IACREF + Current error
x
compensator compensator
A demonstration software running a digital PFC and FOC drive with the STM32F103 is available upon request at ST sales
offices.
STMicroelectronics - December 2011 - Printed in United Kingdom - All rights reserved
The STMicroelectronics corporate logo is a registered trademark of the STMicroelectronics group of companies
All other names are the property of their respective owners
Order code: BRSTM32MC1211 For more information on ST products and solutions, visit www.st.com