Vous êtes sur la page 1sur 8

Motor control with STM32

32‑bit ARM®‑based MCU

STMicroelectronics

For 3‑phase brushless motor vector drives

www.st.com/mcu
Vector control made simple
STMicroelectronics’ STM32 offers the performance of the industry‑standard Cortex™‑M3 core at the service
of vector (or field‑oriented) control algorithms. Vector‑control algorithms are widely used in high‑performance
drives. They provide precise and responsive torque and speed control, and guarantee optimized efficiency
during transient operations. Practically, they also have the advantage of using the same framework to control
an asynchronous or synchronous motor. This is interesting for development teams that have to deal with
various applications and motor types. Finally, the sensorless algorithms for rotor speed and position detection
are also of interest when trying to reduce the cost of the drive. The benefits of the ARM architecture combined
with motor‑control dedicated peripherals makes the STM32 MCU family ideally suited to optimize the overall
performance of execution while reducing the overall system cost.

STM32F‑1 series block diagram


Up to 1-Mbyte Applications
Flash memory
System
Upt to 96-Kbyte SRAM QQ Appliances
Power supply
FSMC/ QQ Washing machines
1.8 V regulator
POR/PDR/PVD SRAM/NOR/NAND/CF/ QQ Dishwasher pumps

Xtal oscillators LCD parallel interface


QQ Refrigerators
32 kHz + 3 ~25 MHz 84-byte backup data
QQ Air conditioners
Internal RC oscillators
40 kHz + 8 MHz
Connectivity
QQ Medical
Internal multispeed QQ Sleep apnea CPAP, VPAP
ULP RC oscillator ARM Cortex-M CPU Consumer electronics
24 to 72 MHz control (CEC) QQ Wheel chairs
64 kHz to 4 MHz
2x I²S QQ Pumps
PLL
Clock control 2x I²C QQ Industrial
2x CAN 2.0B QQ Electric vehicles
RTC/AWU
QQ Low‑end and
SysTick timer USB 2.0 FS/OTG
Ethernet MAC 10/100 medium‑range industrial
2x watchdogs
(independent and window) with IEEE 1588 drives
3x SPI QQ HVAC actuators and fans
37/51/80/112 I/Os
SDIO QQ Pumps
Cyclic redundancy
check (CRC) Nested vector QQ Blowers
interrupt 5x USART
controller (NVIC) LIN, smartcard, IrDA, QQ Vending and cash machines
modem control
JTAG/SW debug
Control Analog
2x 16-bit motor control 2-channel 12-bit DAC
PWM
Synchronized AC timer AHB bus matrix 3x 12-bit ADC
21 channels / 1 MSPS
10x 16-bit timer
12-channel DMA Temperature sensor

Abbreviations:
AWU: Auto wake up from halt PDR: Power down reset RTC: Real time clock
BOR: Brown out reset POR: Power on reset SPI: Serial peripheral interface
Motor control
I²C: Inter integrated circuit PVD: Programmable voltage detector USART: Universal sync/async receiver transmitter

QQ The STM32 embeds features that QQ Free motor control firmware libraries QQ Run your motor in just a few steps:
are perfectly suited to three‑phase supporting AC induction motor QQ STM3210B‑MCKIT full developer

brushless motors: (sensored) and PMSM motor kit for vector drives
QQ Powerful Cortex‑M3 core (sensorless, Hall‑sensor or encoder) QQ In the Performance line, for devices
QQ 6 PWM advanced control timers vector control starting at 256 Kbytes of Flash, two
with embedded deadtime QQ Less than 21 µs for sensorless advanced control PWM timers and
generation vector control loop three ADCs are on board for dual
QQ Numerous PWM outputs allowing QQ Class B compliancy with the motor control,
multiple DC‑brush, stepper or EN/IEC60335‑1 norm: triple sample
universal motor drives QQ Pre‑certified full set of self‑test and hold
QQ Single/dual sample and hold routines capabilities.
ADC, 12‑bit resolution, 1 µs
conversion time

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 safety‑critical 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 read‑only if protected) QQ Hardware protection of power
3‑axis, 120º shifted coordinates QQ Once the two lock bits are stage whatever the status of MCU
into 2‑axis orthogonal rotating written, they cannot be modified oscillator
coordinates until next MCU reset (write‑once QQ Safety hardware features to comply
QQ These last variables are DC, or bits) with IEC 60335‑1 norm
slowly varying values, which QQ If main clock fails, an internal RC
can be regulated by means of oscillator (FREEOSC, ~5 MHz
simple PID controllers and then average frequency) starts
transformed back to the fixed immediately
stator windings frame using QQ Interrupt can be generated
reverse transforms, as shown in for shut‑down or safe restart
the diagram above sequences
QQ Requirements QQ Dual watchdog architecture with
QQ Intensive math computations
independent clock sources
(trigonometric functions, multiple
QQ Embedded reset circuitry (power‑on
PID regulators, speed calculation)
reset, power‑down reset,
QQ Minimum
resolution of 16 bits for programmable voltage detector)
the main control variables, with
QQ Emergency stop dedicated input
a need for 32‑bit intermediate
pin with programmable state
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 3‑phase brushless motor control
PWM timer features ADC features Speed feedback
QQ Motor control timer clock QQ Single/dual/triple ADC with QQ Handled by the general‑purpose
QQ Maximum input clock is simultaneous conversion mode timers
72 MHz to provide 13.9 ns edge QQ 12‑bit resolution QQ Direct interface with incremental
resolution (12‑bit @ 16 kHz QQ Down to 1 µs conversion time encoder and 1 to 3 Hall sensor logic
edge‑aligned PWM) QQ Up to 21 channels, plus internal outputs
QQ Double‑update mode temperature sensor and Vref
QQ No loss of resolution in
QQ External and internal trigger
center‑aligned mode (including PWM timer)
QQ Done using an additional
QQ Versatile channel sequencer
interrupt per PWM cycle or DMA
QQ DMA capable
transfers
QQ Programmable sampling rate
QQ Burst mode
QQ Possibility to update several Benefits
registers of the peripheral using a QQ Suitable for three‑phase brushless
single DMA stream PMSM or AC induction motors
QQ Programmable reload rate QQ Sensor and sensorless
QQ Versatile PWM output management configurations
QQ Individually selectable polarities

QQ Redirection circuitry for 6‑step

drives
QQ Programmable hardware deadtime
generation
QQ 8‑bit register with 13.9 ns

resolution at 72 MHz

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
STM3210B‑MCKIT
Run your motor in just a few steps
In just a few minutes, you can QQ Bus‑voltage and power‑stage you just open the libraries, develop
run the kit’s PMSM synchronous temperature monitoring the application, fine tune the code
motor with the standalone demo, in QQ Selection of variables to put on and parameters and compile. You can
torque‑control or speed‑control mode, output for DAC functionality fine tune the application while running
using the LCD and the joystick on the implementation the motor thanks to the real‑time
STM3210B‑EVAL control board. You can apply changes to real‑time debugging capability of the Segger
You can then fine tune or change settings to tune the drive parameters J‑Link.
many parameters using the LCD user on‑the‑fly and get feedback values
interface (as shown on LCD screen from the changed settings. Application‑specific
captures below) and run the PM Once familiar with the demo, you requirements
synchronous motor, or an induction will be able to explore our motor Using the same hardware and
motor: control library that supports FOC firmware platform, you may
QQ Real‑time tuning of torque, flux and (field‑oriented control) drive of PMSM incorporate application‑specific
speed PIDs and induction motors. requirements by taking advantage of
QQ B‑EMF observer gain tuning (for The library sources are free upon the STM3210B‑EVAL control board
sensorless control) request, and help speed up and the inverter board extension
QQ Variation of target speed (speed development of motor control features (USART/LIN port, standalone
control) or target torque and flux applications. With the free 32‑Kbyte operation potentiometer, wrapping
(torque control) evaluation version of IAR’s EWARM, area).

Start LCD menu – speed control demo Speed control can be modified during run‑time using joystick

Torque control demo – Iq and Id parameters can be adjusted PID regulators can be adjusted during run‑time

STM32 motor control starter kit

Inverter board
STM32
controller board Induction motor
Debugger/programmer ST7MC-MOT/IND
Isolation board
PMSM
motor

SEGGER J-Link (Optional)

(Included)
AI-JTAG/OPTO-1

STM3210B-MCKIT STM3210B-EVAL

5
STM3210B‑MCKIT
STM32 motor control tool ordering information
Part number Description
Optimized, documented C firmware libraries for control of 3‑phase PMSM or AC induction brushless motors. In torque or speed
STM3210B MC library
control with STM32, sensor mode, sensorless for PMSM. These are the standalone libraries of the STM3210B‑MCKIT.
The isolation board included in the STM3210B‑MCKIT can also be ordered separately. It provides galvanic isolation between
AI‑JTAG/OPTO‑1 the J‑Link from Segger and any high‑voltage target board. The isolation board has two JTAG connectors (in/out). Available from
distributors and ST sales offices.
Demonstration, evaluation and development kit for STM32 includes firmware, LCD user interface, STM3210B‑EVAL board (control
STM3210B‑MCKIT* board), 7 A three‑phase inverter board, isolation board (AI‑JTAG/OPTO‑1), Segger J‑Link debugger/programmer and 24 VDC Shinano
PMSM motor. Available from distributors and ST sales offices.
240 V/800 W Selni 3‑phase induction motor for use with STM3210B‑MCKIT, or with the ST7MC‑KIT using induction motor default
ST7MC‑MOT/IND
values (for evaluation purposes).

Note:
* Dedicated motor-control documents are available upon request. Contact your ST sales office.

Vector control library


STM32 library Single‑shunt current sensing Dual motor control and triple
Optimized and documented C The STM32 motor control library ADC system
firmware libraries for control of both version 2.0 supports single‑shunt The high‑density STM32 devices
PMSM (sensor and sensorless mode) current sensing, for applications embed three ADCs and two motor
and AC induction (sensor mode) requiring lowest system costs. The control capable timers. This allows
brushless motors are available for free proposed solution maximizes the DC two brushless motors to be driven
upon request. bus voltage use, while minimizing simultaneously, or to have a triple
These libraries support IAR (EWARM), current distorsion and acoustical sample and hold current acquisition for
Keil and Greenhills toolchains. noise, and has been patented by ST. very high‑end control systems. These
The STM32‑MCKIT can be easily features are supported by additional
These modular libraries support
reconfigured in one‑shunt mode, for interrupt vectors and a second DMA
both types of motor in standalone
evaluation purposes. controller.
mode using the hardware of the
STM3210B‑MCKIT. The source files
are provided free of charge upon Internal permanent magnet Field weakening and
request. These libraries offer: motors (IPM) feed‑forward control
QQ Different current‑sensing As a result of their higher power density The stator voltage closed‑loop field
methodologies and very high speed capabilities, weakening control implemented is
QQ
Isolated current sensing brushless IPM motors are used in able to expand the operating limits of
QQ Three shunt resistors an increasing number of designs both surface‑mounted and internal
QQ Single shunt topology with dual compared to their surface‑mounted PMSM, as many applications require.
sample and hold utilization and magnets counterpart. The STM32 MC This algorithm strongly reduces
advanced methodology for better library supports this kind of motor with sensitivity to motor parameters and
bus voltage exploitation specific algorithms, such as MTPA environmental variations.
QQ Different rotor‑position feedback (maximum torque per ampere) control
In addition, feed‑forward control
QQ Tachometer (AC motor)
strategy.
allows improved bus voltage ripple
QQ Hall sensors (60° and 120°
compensation and better current
placement) regulation during high‑speed flux
QQ Sensorless (PMSM motor only) weakening operations.
Total execution time of the
field‑oriented control in sensorless
mode for PMSM motors is less than
21 µs. Total CPU load at 10 kHz
sampling time is below 25 %; code size
is less than 14 Kbytes.

6
Vector control library
Motor control development tools: what’s new Class B compliancy – how
A new motor control software library V3.0 will be released late Q4 2010. we help
QQ Based on the ARM’s CMSIS compliant STM32 peripheral library Two key features help compliance
QQ Offering extended customizability with the EN/IEC 60335‑1 norm:
QQ Supporting latest members of the STM32 product line the dual watchdog architecture
QQ Full support of dual motor control drives (using STMF103x high‑density devices) and the internal clock circuitry. In
QQ Including application example based on FreeRTOS order to make certification even
simpler with the STM32, a set
of self‑test routines has been
A field‑oriented control dedicated GUI (FOCGUI) provides help when configuring developed to fulfill most of table
the motor control software library by means of: H11.12.7 requirements. These
QQ Clear configuration windows for the various items (including power stage, routines have been certified by the
motor, speed and current feedbacks) VDE, a worldwide recognized test
QQ Direct electrical‑parameter entry, without need for conversion to fixed‑point institute, and do not need to be
format re‑evaluated if left unchanged.
QQ Configuration header‑file generation

Dual motor control and PFC


Dual motor control
The STEVAL‑IHM022V1 demonstration board is designed as a dual motor‑control
development platform for the STM32F103ZE microcontroller.
The board features full speed USB 2.0 and CAN 2.0 A/B compliant interfaces,
2x I²S, 2x I²C, 5x USART, 3x SPI, 2x DAC, internal 64‑Kbyte SRAM and 512‑Kbyte
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 motor‑control application is available upon
request at ST sales offices.
Extension headers make it easy to connect a daughterboard or wrapping board
for specific applications.
STEVAL‑IHM022V1

7
Dual motor control and PFC
Digital power factor correction (PFC)
Why PFC? Active or passive PFC?
For all motor‑control applications, While passive PFC is cheaper, active PFC can reach higher power factors (>98%).
electric power efficiency increases the Passive PFC is also heavier and larger in size compared to active PFC.
profitability of the application, and is a
selling factor. Active PFC implementation with STM32
A low power factor means poor
L D
electrical efficiency: PFC is an
environment friendly technology, +
reducing the harmonics that create Q

electrical pollution and saving energy


to benefit the society as a whole. Co
AC input
The international norm IEC 61000‑3‑2
controls the harmonic content of the
currents for appliances and electronic
equipment up to 16 A.
-

ADC ADC ADC


channel channel channel New duty cycle

VDC
- PI regulator x VAC - I AC PI regulator
VDCREF VERR V PI I ERR
Voltage error Current error
+
compensator x IACREF +
compensator

A demonstration software running a digital PFC and a dual FOC drive with the
STM32F103ZE using the STEVAL‑IHM022V1 STM32 board and
STEVAL‑ISF002V1 driver board is available upon request at ST sales offices.

Digital PFC demonstration software characteristics


Parameter DC‑DC converter in boost
Switching frequency 80 kHz
Control loop frequency 40 kHz
Mains range 185 Vrms to 265 Vrms
Output DC voltage 400 V (ripple < 5%)
Output power 1.4 kW
PFC at full power > 0.99%
CPU load 14% @ 72 MHz

© STMicroelectronics - September 2010 - Printed in Italy - 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: BRSTM32MC0910 For more information on ST products and solutions, visit www.st.com