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 oers the perormance o the industry‑standard Cortex™‑M3 core at the service o vector (or feld‑oriented) control algorithms. Vector‑control algorithms are widely used in high‑perormance drives. They provide precise and responsive torque and speed control, and guarantee optimized efciency during transient operations. Practically, they also have the advantage o using the same ramework to control an asynchronous or synchronous motor. This is interesting or development teams that have to deal with various applications and motor types. Finally, the sensorless algorithms or rotor speed and position detection are also o interest when trying to reduce the cost o the drive. The benefts o the ARM architecture combined with motor‑control dedicated peripherals makes the STM32 MCU amily ideally suited to optimize the overall perormance o execution while reducing the overall system cost.
STM32F‑1 series block diagram System Power supply 1.8 V regulator POR/PDR/PVD Xtal oscillators 32 kHz + 3 ~25 MHz Internal RC oscillators 40 kHz + 8 MHz Internal multispeed ULP RC oscillator 64 kHz to 4 MHz
Upt to 96-Kbyte SRAM FSMC/ SRAM/NOR/NAND/CF/ LCD parallel interface 84-byte backup data
Connectivity ARM Cortex-M CPU 24 to 72 MHz
Consumer electronics control (CEC)
PLL
2x I²S
Clock control
2x I²C
RTC/AWU
2x CAN 2.0B
SysTick timer
USB 2.0 FS/OTG
2x watchdogs (independent and window)
Ethernet MAC10/100 with IEEE 1588
37/51/80/112 I/Os
3x SPI
Cyclic redundancy check (CRC)
Applications
Up to 1-Mbyte Flash memory
Nested vector interrupt controller (NVIC)
SDIO 5x USART LIN, smartcard, IrDA, modem control
Appliances Washing machines Dishwasher pumps Rerigerators Air conditioners Medical Sleep apnea CPAP, VPAP Wheel chairs Pumps Industrial Electric vehicles Low‑end and medium‑range industrial drives HVAC actuators and ans Pumps Blowers Vending and cash machines
JTAG/SW debug Control 2x 16-bit motor control PWM Synchronized AC timer 10x 16-bit timer
Analog 2-channel 12-bit DAC AHB bus matrix
3x 12-bit ADC 21 channels / 1 MSPS
12-channel DMA
Temperature sensor
Motor control
2
The STM32 embeds eatures that are perectly suited to three‑phase brushless motors: Powerul Cortex‑M3 core 6 PWM advanced control timers with embedded deadtime generation Numerous PWM outputs allowing multiple DC‑brush, stepper or universal motor drives Single/dual sample and hold ADC, 12‑bit resolution, 1 µs conversion time
Free motor control irmware libraries supporting AC induction motor (sensored) and PMSM motor (sensorless, Hall‑sensor or encoder) vector control Less than 21 µs or sensorless vector control loop Class B compliancy with the EN/IEC60335‑1 norm: Pre‑certiied ull set o sel‑test routines
Run your motor in just a ew steps: STM3210B‑MCKIT ull developer kit or vector drives In the Perormance line, or devices starting at 256 Kbytes o Flash, two advanced control PWM timers and three ADCs are on board or dual motor control, triple sample and hold capabilities.
Field‑orientation in sensorless torque control – PMSM STM32 saety eatures or greater control robustness
Vector control drive
Features
Theory Changing reerence coordinates rom ixed stator coils to the moving rotor rame greatly simpliies the equation describing the motor Method Clarke and Park transormations convert variables with ixed 3‑axis, 120º shited coordinates into 2‑axis orthogonal rotating coordinates These last variables are DC, or slowly varying values, which can be regulated by means o simple PID controllers and then transormed back to the ixed stator windings rame using reverse transorms, as shown in the diagram above Requirements Intensive math computations (trigonometric unctions, multiple PID regulators, speed calculation) Minimum resolution o 16 bits or the main control variables, with a need or 32‑bit intermediate results, such as integral terms Free CPU load must be kept or the remaining applicative tasks, such as communication and user interace
Benefts
Saety critical registers can be locked to prevent power stage damage (sotware runaway) Deadtime, PWM output polarit y, emergency input enable All target registers are read/write until lock activation (and then read‑only i protected) Once the two lock bits are written, they cannot be modiied until next MCU reset (write‑once bits) I main clock ails, an internal RC oscillator (FREEOSC, ~5 MHz average requency) starts immediately Interrupt can be generated or shut‑down or sae restart sequences Dual watchdog architecture with independent clock sources Embedded reset circuitry (power‑on reset, power‑down reset, programmable voltage detector) Emergency stop dedicated input pin with programmable state
Strengthens control algorithm to protect motor operation rom external disturbance Protects saety‑critical registers in case o system hang Quick error diagnosis and ault management Hardware protection o power stage whatever the status o MCU oscillator Saety hardware eatures to comply with IEC 60335‑1 norm
Vector control block diagram o PMSM drive 3-phase inverter iqs*
PID
ids*
PID iqs ids
Vqs Vds
Reverse park and circle limitation
PMSM motor
Vabc Vaβ s
CALC SVPWM
θrel
Park
iaβ s
Clarke
iabcs
Current reading
θrel Sensorless
rotor position observer Notes: SVPWM: Space vector PWM * Target setting
3
Vector control with STM32 STM32 dedicated peripherals or 3‑phase brushless motor control PWM timer eatures
ADC eatures
Motor control timer clock Maximum input clock is 72 MHz to provide 13.9 ns edge resolution (12‑bit @ 16 kHz edge‑aligned PWM) Double‑update mode No loss o resolution in center‑aligned mode Done using an additional interrupt per PWM cycle or DMA transers Burst mode Possibility to update several registers o the peripheral using a single DMA stream Programmable reload rate Versatile PWM output management Individually selectable polarities Redirection circuitry or 6‑step drives Programmable hardware deadtime generation 8‑bit register with 13.9 ns resolution at 72 MHz
Speed eedback
Single/dual/triple ADC with simultaneous conversion mode 12‑bit resolution Down to 1 µs conversion time Up to 21 channels, plus internal temperature sensor and Vre External and internal trigger (including PWM timer) Versatile channel sequencer DMA capable Programmable sampling rate
Handled by the general‑purpose timers Direct interace with incremental encoder and 1 to 3 Hall sensor logic outputs
Benefts
Suitable or three‑phase brushless PMSM or AC induction motors Sensor and sensorless conigurations
Vector control implementation: hardware/sotware positioning STM32
Vα
Va
d,q
α,β
Vb
SV PWM
Vβ
r
Vc
6x PWM 6-channel PWM timer
d,q r
Inverter
Ia
s
Iα
Fault
Ia α,β
Iβ
Ib a,b
α,β
Dual/triple 12-bit 1 µs A/D converter
Ib
Vbus
θr θr
ωm
Sensorless estimation θr Legend: Software Hardware
4
T Speed/position feedback timer E
H T: Tachogenerator E: Encoder H: Hall sensors
Motor
STM3210B‑MCKIT Run your motor in just a ew steps In just a ew minutes, you can run the kit’s PMSM synchronous motor with the standalone demo, in torque‑control or speed‑control mode, using the LCD and the joystick on the STM3210B‑EVAL control board. You can then fne tune or change many parameters using the LCD user interace (as shown on LCD screen captures below) and run the PM synchronous motor, or an induction motor:
Real‑time tuning o torque, lux and speed PIDs B‑EMF observer gain tuning (or sensorless control) Variation o target speed (speed control) or target torque and lux (torque control)
Bus‑voltage and power‑stage temperature monitoring Selection o variables to put on output or DAC unctionality implementation You can apply changes to real‑time settings to tune the drive parameters on‑the‑y and get eedback values rom the changed settings.
Once amiliar with the demo, you will be able to explore our motor control library that supports FOC (feld‑oriented control) drive o PMSM and induction motors. The library sources are ree upon request, and help speed up development o motor control applications. With the ree 32‑Kbyte evaluation version o IAR’s EWARM,
you just open the libraries, develop the application, fne tune the code and parameters and compile. You can fne tune the application while running the motor thanks to the real‑time debugging capability o the Segger J‑Link.
Application‑specifc requirements Using the same hardware and frmware platorm, you may incorporate application‑specifc requirements by taking advantage o the STM3210B‑EVAL control board and the inverter board extension eatures (USART/LIN port, standalone operation potentiometer, wrapping area).
Start LCD menu – speed control demo
Speed control can be modifed 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 Debugger/programmer
Induction motor ST7MC-MOT/IND
Isolation board PMSM motor
(Optional)
SEGGER J-Link (Included)
AI-JTAG/OPTO-1 STM3210B-MCKIT
STM3210B-EVAL
5
STM3210B‑MCKIT STM32 motor control tool ordering inormation Part number
Description
STM3210B MC library
Optimized, documented C frmware libraries or control o 3‑phase PMSM or AC induction brushless motors. In torque or speed control with STM32, sensor mode, sensorless or PMSM. These are the standalone libraries o the STM3210B‑MCKIT.
AI‑JTAG/OPTO‑1
The isolation board included in the STM3210B‑MCKIT can also be ordered separately. It provides galvanic isolation between the J‑Link rom Segger and any high‑voltage target board. The isolation board has two JTAG connectors (in/out). Available rom distributors and ST sales ofces.
STM3210B‑MCKIT*
Demonstration, evaluation and development kit or STM32 includes frmware, LCD user interace, STM3210B‑EVAL board (control 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 rom distributors and ST sales ofces.
ST7MC‑MOT/IND
240 V/800 W Selni 3‑phase induction motor or use with STM3210B‑MCKIT, or with the ST7MC‑KIT using induction motor deault values (or evaluation purposes).
Note: * Dedicated motor‑control documents are available upon request. Contact your ST sales ofce.
Vector control library STM32 library
Single‑shunt current sensing
Optimized and documented C frmware libraries or control o both PMSM (sensor and sensorless mode) and AC induction (sensor mode) brushless motors are available or ree upon request.
The STM32 motor control library version 2.0 supports single‑shunt current sensing, or applications requiring lowest system costs. The proposed solution maximizes the DC bus voltage use, while minimizing current distorsion and acoustical noise, and has been patented by ST. The STM32‑MCKIT can be easily reconfgured in one‑shunt mode, or evaluation purposes.
The high‑density STM32 devices embed three ADCs and two motor control capable timers. This allows two brushless motors to be driven simultaneously, or to have a triple sample and hold current acquisition or very high‑end control systems. These eatures are supported by additional interrupt vectors and a second DMA controller.
Internal permanent magnet motors (IPM)
Field weakening and eed‑orward control
As a result o their higher power density and very high speed capabilities, brushless IPM motors are used in an increasing number o designs compared to their surace‑mounted magnets counterpart. The STM32 MC library supports this kind o motor with specifc algorithms, such as MTPA (maximum torque per ampere) control strategy.
The stator voltage closed‑loop feld weakening control implemented is able to expand the operating limits o both surace‑mounted and internal PMSM, as many applications require. This algorithm strongly reduces sensitivity to motor parameters and environmental variations.
These libraries support IAR (EWARM), Keil and Greenhills toolchains. These modular libraries support both types o motor in standalone mode using the hardware o the STM3210B‑MCKIT. The source fles are provided ree o charge upon request. These libraries oer: Dierent current‑sensing methodologies Isolated current sensing Three shunt resistors Single shunt topology with dual sample and hold utilization and advanced methodology or better bus voltage exploitation Dierent rotor‑position eedback Tachometer (AC motor) Hall sensors (60° and 120° placement) Sensorless (PMSM motor only) Total execution time o the feld‑oriented control in sensorless mode or 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
Dual motor control and triple ADC system
In addition, eed‑orward control allows improved bus voltage ripple compensation and better current regulation during high‑speed ux weakening operations.
Vector control library Motor control development tools: what’s new A new motor control sotware library V3.0 will be released late Q4 2010.
Based on the ARM’s CMSIS compliant STM32 peripheral library Oering extended customizability Supporting latest members o the STM32 product line Full support o dual motor control drives (using STMF103x high‑density devices) Including application example based on FreeRTOS
A feld‑oriented control dedicated GUI (FOCGUI) provides help when confguring the motor control sotware library by means o:
Clear coniguration windows or the various items (including power stage, motor, speed and current eedbacks) Direct electrical‑parameter entry, without need or conversion to ixed‑point ormat Coniguration header‑ile generation
Class B compliancy – how we help Two key eatures help compliance with the EN/IEC 60335‑1 norm: the dual watchdog architecture and the internal clock circuitry. In order to make certifcation even simpler with the STM32, a set o sel‑test routines has been developed to ulfll most o table H11.12.7 requirements. These routines have been certifed by the VDE, a worldwide recognized test institute, and do not need to be re‑evaluated i let unchanged.
Dual motor control and PFC Dual motor control The STEVAL‑IHM022V1 demonstration board is designed as a dual motor‑control development platorm or the STM32F103ZE microcontroller. The board eatures ull speed USB 2.0 and CAN 2.0 A/B compliant interaces, 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 oers an advanced user I/O interace (LCD QVGA display and joystick key). Demonstration sotware or the dual motor‑control application is available upon request at ST sales ofces. Extension headers make it easy to connect a daughterboard or wrapping board or specifc applications. STEVAL‑IHM022V1
7
Dual motor control and PFC Digital power actor correction (PFC) Why PFC?
Active or passive PFC?
For all motor‑control applications, electric power efciency increases the proftability o the application, and is a selling actor.
While passive PFC is cheaper, active PFC can reach higher power actors (>98%). Passive PFC is also heavier and larger in size compared to active PFC.
Active PFC implementation with STM32
A low power actor means poor electrical efciency: PFC is an environment riendly technology, reducing the harmonics that create electrical pollution and saving energy to beneft the society as a whole. The international norm IEC 61000‑3‑2 controls the harmonic content o the currents or appliances and electronic equipment up to 16 A.
L
D
+ Q
Co AC input
-
ADC channel
ADC channel
ADC channel
VDC -
VERR
VDCREF +
PI regulator Voltage error compensator
x
V PI x
-
VAC
New duty cycle
I AC
PI regulator
I ERR
IACREF
+
Current error compensator
A demonstration sotware 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 ofces.
Digital PFC demonstration sotware characteristics Parameter
DC‑DC converter in boost
Switching requency
80 kHz
Control loop requency
40 kHz
Mains range Output DC voltage Output power PFC at ull power CPU load
185 Vrms to 265 Vrms 400 V (ripple < 5%) 1.4 kW > 0.99% 14% @ 72 MHz
© STMicroelectronics ‑ September 2010 ‑ Printed in Italy ‑ All rights reserved The STMicroelectronics corporate logo is a registered trademark o the STMicroelectronics group o companies All other names are the property o their respective owners Order code: BRSTM32MC0910
For more inormation on ST products and solutions, visit www.st.com