STM32 for Motor Control. Applications. Features and benefits. MCU Division. Applications

Similar documents
For reference only Refer to the latest documents for details

STM32 PMSM FOC SDK v3.2. 蒋建国 MCU Application Great China

STM32 motor control firmware library. STM32 FOC PMSM SDK v3.0.

RX23T inverter ref. kit

RL78 Motor Control. YRMCKITRL78G14 Starter Kit. Renesas Electronics Europe. David Parsons Application Engineering Industrial Business Group.

Motor Control using NXP s LPC2900

Sensorless Vector Control and Implementation: Why and How

User Guide IRMCS3041 System Overview/Guide. Aengus Murray. Table of Contents. Introduction

Sistemi per il controllo motori

User Guide Introduction. IRMCS3043 System Overview/Guide. International Rectifier s imotion Team. Table of Contents

Hello, and welcome to this presentation of the STM32 Digital Filter for Sigma-Delta modulators interface. The features of this interface, which

Sensorless Vector Control with RL78G14

Designing with STM32F3x

3-in-1 Air Condition Solution

2014 Texas Instruments Motor Control Training Series. -V th. Dave Wilson

National Infotech. Electrical Drive Trainers. Developed By: : Authorized Dealer : Embedded System Solutions

DMCode-MS(BL) MATLAB Library

Sensorless PMSM Field-Oriented Control on Kinetis KV and KE

Overview of the STM32F103xx ACIM and PMSM motor control software libraries release 2.0

UM2392. STM32 motor control SDK. User manual. Introduction

CHAPTER 4 CONTROL ALGORITHM FOR PROPOSED H-BRIDGE MULTILEVEL INVERTER

Sensorless Vector Control with RL78G14

Electric Bike BLDC Hub Motor Control Using the Z8FMC1600 MCU

AP CANmotion. Evaluation Platform with BLDC Motor featuring XC886CM Flash Microcontroller Version 2007/10. Microcontrollers

AN4277 Application note

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

Lab 10. Speed Control of a D.C. motor

CHAPTER-5 DESIGN OF DIRECT TORQUE CONTROLLED INDUCTION MOTOR DRIVE

A Practical Primer On Motor Drives (Part 13): Motor Drive Control Architectures And Algorithms

2013 Texas Instruments Motor Control Training Series. -V th. InstaSPIN Training

Hello, and welcome to this presentation of the STM32G0 digital-to-analog converter. This block is used to convert digital signals to analog voltages

DRM100 Designer Reference Manual. Devices Supported: 56F801X

Lab 9. Speed Control of a D.C. motor. Sensing Motor Speed (Tachometer Frequency Method)

Using the HCS08 TPM Module In Motor Control Applications

AN Sensorless single-shunt FOC on LPC2900. Document information. LPC2900, FOC, SVPWM, SMC, current observer, PMSM, single shunt DC-link

VORAGO Timer (TIM) subsystem application note

Microcontrollers: Lecture 3 Interrupts, Timers. Michele Magno

CIS009-2, Mechatronics Signals & Motors

High-speed and High-precision Motion Controller

STSPIN L6480 and L6482. ST motor drivers are moving the future

A COMPARISON STUDY OF THE COMMUTATION METHODS FOR THE THREE-PHASE PERMANENT MAGNET BRUSHLESS DC MOTOR

Developer Day. XMC technical presentation & Introduction to DAVE. Cristian Zaharia Field Application Engineering Industrial MCU June, 2014

Vector Control of a 3-Phase PMSM Using the ZNEO Z16FMC MCU

32-Bit-Digital Signal Controller TMS320F2812

UM0486 User manual. STM3210B-MCKIT motor control starter kit. Introduction. In this manual, you will find information on:

Motor Control Solutions

Single Phase Two-Channel Interleaved PFC Operating in CrM Using the MC56F82xxx Family of Digital Signal Controllers

MTY (81)

AN3252 Application note

Application Note. Brushless DC Motor Control AN-1114

MTY (81)

Introduction to BLDC Motor Control Using Freescale MCU. Tom Wang Segment Biz. Dev. Manager Avnet Electronics Marketing Asia

HPVFP High Performance Full Function Vector Frequency Inverter

maxon document number:

LM4: The timer unit of the MC9S12DP256B/C

Implementation of Brushless DC motor speed control on STM32F407 Cortex M4

DISCONTINUED PRODUCT FOR REFERENCE ONLY.

3-Phase Switched Reluctance Motor Control with Encoder Using DSP56F80x. 1. Introduction. Contents. Freescale Semiconductor, I

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

AN3165 Application note

32-bit ARM Cortex-M0, Cortex-M3 and Cortex-M4F microcontrollers

Tarocco Closed Loop Motor Controller

STM32L100C6 STM32L100R8 STM32L100RB

Course Introduction. Purpose: Objectives: Content: 24 pages 3 questions. Learning Time: 35 minutes

EE152 Final Project Report

STM32L151xC STM32L152xC

Firmware plugin for STSW-ESC001V1 board with ST Motor Control FOC SDK

EIE/ENE 334 Microprocessors

Peak Current. Continuous Current. See Part Numbering Information on last page of datasheet for additional ordering options.

LINEAR IC APPLICATIONS

Advanced Regulating Pulse Width Modulators

DT9838. Strain- and Bridge-Based Measurement Module. Key Features: Bridge Configurations. Analog Input Features

Digital Power: Consider The Possibilities

HIGH PERFORMANCE CONTROL OF AC DRIVES WITH MATLAB/SIMULINK MODELS

ML ML Bit A/D Converters With Serial Interface

Three-Phase BLDC Sensorless Motor Control Using the MKV4x In Quadcopter Application

Analog input/output. Textbook: Chapter 20, Analog-to-Digital Converter Chapter 21, Digital-to-Analog Converter

DISCONTINUED PRODUCT 8902 A REPLACED BY A8904SLB & A8904SLP 3-PHASE BRUSHLESS DC MOTOR CONTROLLER/DRIVER WITH BACK-EMF SENSING FEATURES

Design of double loop-locked system for brush-less DC motor based on DSP

SixPac Series of SCR AC Controller and DC Converters

Chapter 6 PROGRAMMING THE TIMERS

CHAPTER 4 HARDWARE DEVELOPMENT OF STATCOM

TUTORIAL Simulation and Code Generation of TI InstaSPIN Using DRV8312 EVM

Optimizing System Operation Using a Flexible Digital PWM Controller

STM32L100x6/8/B-A. Ultra-low-power 32-bit MCU ARM -based Cortex -M3, 128KB Flash, 16KB SRAM, 2KB EEPROM, LCD, USB, ADC, DAC.

Design of Joint Controller Circuit for PA10 Robot Arm

3KDVH 6LQH *HQHUDWRU ZLWK 9DULDEOH3KDVH&RQWURO

Sensors and Sensing Motors, Encoders and Motor Control

3-phase Sensorless PMSM Motor Control Kit with S32K144

PowerAmp Design. PowerAmp Design PAD117A RAIL TO RAIL OPERATIONAL AMPLIFIER

Hybrid Controller. 3-Phase SR Motor Control with Hall Sensors Reference Design. Designer Reference Manual. Freescale Semiconductor, I

CHAPTER 4 FUZZY BASED DYNAMIC PWM CONTROL

Application - Power Factor Correction (PFC) with XMC TM. XMC microcontrollers July 2016

MTS Automation P R O D U C T S P E C I F I C A T I O N. MaxPlus Digital Servo Drive. MP-FLX 230 Series. MP-FLX 230 Series. Single- and Dual-Axis

Analog Servo Drive. Peak Current 16 A (11.3 A RMS )

LM12L Bit + Sign Data Acquisition System with Self-Calibration

Dual FOC Servo Motor Control on i.mx RT

LCC-10 Product manual

BLuAC5 Brushless Universal Servo Amplifier

ATmega16A Microcontroller

Transcription:

STM32 for Motor Control Applications MCU Division Applications Features and benefits

Plan PWM generation Speed / position feedback Multi timer configuration Analog to Digital converter Current sensing and ADC synchronization Field Oriented Control Motor Control Tools 1

Advanced timer Features overview ETR Clock ITR 1 ITR 2 ITR 3 ITR 4 Trigger/Clock Controller Trigger Output 16-Bit Prescaler +/- 16-Bit Counter Auto Reload REG CH1 CH2 CH3 CH4 BKIN Capture Compare Capture Compare Capture Compare Capture Compare CH1 CH1N CH2 CH2N CH3 CH3N CH4 2

High-resolution PWM generation Motor Control Timer clock Can be 2x the APB bus frequency Max input clock is 72MHz to provide 13.8ns edge resolution (12-bit @16kHz edge-aligned PWM) Edge or center-aligned patterns Double-update mode (cf next slide) No loss of resolution in center-aligned mode Done thanks to an additional interrupt per PWM cycle or DMA transfers 3

Double Update Mode An Update event (U) during the Overflow of the PWM counter improves duty cycle resolution. MCPU U on overflow N N+1 U on underflow U on underflow Comp = N Comp = N + 1 Comp from N to N + 1 U event during Underflow Single update U event during Over & Underflow Double update 4

PWM main Interrupt Service Routine So-called U (Update) event Synchronously transfers all preload into active registers 3 (4) compares for duty cycles Preload mechanism can be disabled if needed 1 Auto Reload for PWM switching period allows changing on-the-fly the PWM frequency while maintaining duty cycles PWM clock pre scaler Adjustable U event rate programmable through a 8-bit repetition counter Allows to choose Overflow/Underflow or both for update 5

Repetition Counter PWM counter Double update REP=0 Single update OVF REP=1 Single update UDF REP=1 ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR t t t REP=2 ISR ISR ISR t REP=3 ISR ISR t 6

Other interrupts and DMA Other interrupt sources available on PWM timer Each Compare match (up or down counting selectable) or capture Trigger events Emergency Stop Some events are also mapped on the DMA controller 7

PWM s DMA burst transfer Allows to update several registers with a single DMA event Efficient use of DMA (a single stream is required) RAM Registers OC1 t0 OC2 t0 OC3 t0 OC1 OC2 OC3 OC1 t1 OC2 t1 OC3 t1 Virtual Register OC1 t2 OC2 t2 OC3 t2 8

PWM outputs management Programmable hardware deadtime generation 8-bit register with 13.8ns max resolution at 72MHz (from 0 to 14µs, non-linear) OC1REF CH1 CH1N Delay 5V 0V 5V 0V 5V 0V Internal PWM before dead time generator High side PWM Low side PWM Delay Individually selectable polarity selection Dedicated emergency stop input Shuts down the 6 PWM outputs and issues an interrupt Asynchronous operation (operates without clock source) 9

Versatile PWM redirection circuitry 1/2 PWM timer used as a GP timer Motor Control (sinewave) Motor Control (6-steps) Motor Control (sinewave) Outputs disconnected from I/O ports All PWMs OFF (low Z for safe stop) 10

Versatile PWM redirection circuitry 2/2 Example: 6-steps (or block commutated) drives T1 T3 T5 T1 T2 T4 T6 T2 T3 Step High Low OC1 OC1N OC2 OC2N OC3 OC3N 1 T1 T4 oc1ref 0 0 1 0 0 2 T1 T6 oc1ref 0 0 0 0 1 3 T3 T6 0 0 oc2ref 0 0 1 4 T3 T2 0 1 oc2ref 0 0 0 5 T5 T2 0 1 0 0 oc3ref 0 6 T5 T4 0 0 0 0 oc3ref 0 T4 T5 T6 Phase current 11

Break input A break event can be generated by: The BRK input which has a programmable polarity and an enable bit BKE The Clock Security System When a break occurs: The MOE bit (Main Output Enable) is cleared The break status flag is set and an interrupt request can be generated Each output channel is driven with the level programmed in the OISx bit For instance all low side switches ON for PM motors in field weakening mode Break applications: If the AOE is Reset, the MOE remains low until you write it to 1 again Normally used for security with break input connected to an alarm feedback from power stage, thermal sensors or any security components. If the AOE (Automatic Output Enable) bit is set, the MOE bit is automatically set again at the next update event UEV Typically be used for cycle-by-cycle current regulation Current regulation can also be performed using External trigger input (ETR) 12

Smoke inhibit protections Safety critical registers can be locked, to prevent power stage damages (software run-away, ) Dead time, PWM outputs polarity, emergency input enable, All target registers are read/write until lock activation (and then read-only if protected) Once the two lock bits are written, they cannot be modified until next MCU reset (write-once bits) 4 lock levels offer full flexibility depending on the application (e.g. 6-steps vs sine) GPIO configuration can be locked to avoid having the PWM alternate function outputs reprogrammed as standard outputs 13

Debug feature Motor control applications are usually tricky to debug using breakpoints Standard breakpoints may damage the power stage Closed loop systems can hardly be stopped and restarted A configuration bit allows to program the behavior of the PWM timer upon breakpoint match Normal mode: the timer continues to operate normally May be dangerous in some case since a constant duty cycle is applied to the inverter (interrupts not serviced) Safe mode: the timer is frozen and PWM outputs are shut down Safe state for the inverter. The timer can still be restarted from where it stops. 14

Plan PWM generation Speed / position feedback Multi timer configuration Analog to Digital converter Current sensing and ADC synchronization Field Oriented Control Motor Control Tools 15

Speed Feedback Handled by the general purpose timers, with dedicated modes These functions are available on all timers Hall sensors Hall Sensor interface (XOR ed inputs) Encoder Encoder modes 1, 2 & 3 (2x, 4x) Tacho feedback Clear on capture to measure exact period 16

TIM Block Diagram in encoder mode CLK ITR1 ITR2 ITR3 ITR4 Trigger Controller Controller TRGx 16 bit Prescaler 16 bit AutoReload Register +/- 16-Bit Counter Encoder Interface TI1 TI2 Polarity Select & Edge Controller Polarity Select & Edge Controller 17

Interfacing a TIM timer with an encoder Encoders and STM32 connection example: An incremental encoder can be connected directly to the MCU without external interface logic. The third encoder output which indicates the mechanical zero position (Z or index), may be connected to an external interrupt and trigger a counter reset Example of counter operation in Encoder Interface mode forward reversal backward reversal forward IC2 IC1 Up Down Up Counter 18

Key encoder features Programmable counting rate x4: normal mode, all edges active a 1000 lines encoder will give 4000 counts per revolution x2: counts on input A (or B) only, but direction still determined with A and B velocity mode : encoder clock can be further prescaled if needed Programmable encoder resolution When programming the autoreload register with the number of counts per revolution, the counter register directly holds the angle or the position No need to do the difference vs previous counter value If set to 0xFFFF, can be made compatible with previous designs using a free-running counter Possibility to generate one/multiple interrupts per revolution: once every 360 once 60, 90, (depending on autoreload register setting) 19

Hall sensor Interface Hall A TI1F_ED Trigger & Slave Mode Controller Hall B Hall C XOR Input Filter & Edge detector TRC IC1 Prescaler Capture/Compare 1 Register Input Filter & Edge detector TRC IC2 Prescaler Capture/Compare 2 Register Input Filter & Edge detector TRC IC3 Prescaler Capture/Compare 3 Register TI4 Input Filter & Edge detector TRC IC4 Prescaler Capture/Compare 4 Register 20

Plan PWM generation Speed / position feedback Multi timer configuration Analog to Digital converter Current sensing and ADC synchronization Field Oriented Control Motor Control Tools 21

Timer Link system The three general purpose and the advanced timers are linked together and can be synchronized or chained, thanks to a Trigger output and several selectable trigger inputs. For TIM2:0, the input pins(ti1 and TI2) can also be used as triggers Trigger inputs CK_TIM TRG1 TRG2 TRG3 TIM0 Trigger Controller TRGO TRG0 Trigger outputs TI1 TI2 Timer control signals: clock, reset, update, enable, 22

Synchronization Mode Configuration When in master mode, the trigger output can be: Counter reset Counter enable Update event Output Compare signal When configured as slave, the timer can work in the following modes: Triggered Gated Reset External clock Triggered Mode Gated Mode Clock Master ARR Master CNT Master Trigger Out Slave CNT Clock New Master OCR1 Master OCR1 Master CNT Master OC1 Slave CNT 23

MASTER Example 1/3: chained timers Cascade mode (for instance, chained time bases) CLOCK Timer 0 prescaler Update Trigger Controller TRG 0 counter SLAVE / MASTER ITR 0 ITR 1 ITR 2 Timer 1 prescaler counter Trigger Controller Update TRG 2 ITR0 SLAVE Timer 2 ITR 1 ITR 2 prescaler counter 24

Examples 2/3: synchronized start MASTER CLOC K prescaler counter Timer 0 Update Trigger Controller TRG 0 ITR 0 ITR 2 ITR 3 SLAVE 1 Timer 1 prescaler counter SLAVE 2 Timer 2 ITR 0 One Master several slaves ITR 1 ITR 3 prescaler counter SLAVE 3 ITR 0 PWM ITR 1 ITR 2 prescaler counter 25

Examples 3/3: block commutation A TIM timer handles Hall feedback and triggers an advanced timer for step commutation MASTER (TIM) Hall XOR ITR 0 ITR 1 Timer 1 prescaler Trigger Controller TRG 2 SLAVE (ADVANCED TIM) ITR0 Timer 2 ITR 2 counter Update ITR 1 ITR 2 prescaler counter 26

Plan PWM generation Speed / position feedback Multi timer configuration Analog to Digital converter Current sensing and ADC synchronization Field Oriented Control Motor Control Tools 27

ADC Features (1/3) ADC conversion rate 1 MHz and 12-bit resolution 107ns min sampling time ADC input range: 0 VIN VREF+ (VREF+ only on LQFP100 package) Up to 18 multiplexed channels: 16 external channels 2 internal channels: Temperature sensor and voltage reference Interrupt generation End of Conversion, End of Injected conversion, Analog watchdog DMA capability On ADC1, but possibility to transfer also ADC2 result if sync d Channels conversion groups: Up to 16 channels regular group Up to 4 channels injected group 28

ADC Injected Conversion Regular Scan mode Scan mode with injected conversion First channel Conversion First channel Conversion First injected channel Conversion Second channel Conversion Trigger Second channel Conversion Second injected channel Conversion Last channel Conversion Last channel Conversion Last injected channel Conversion Interrupt 29

ADC Features (2/3) Analog Watchdog (1 channel or all regular or all injected) Sequencer-based scan mode Any channel, any order (e.g. Ch3, Ch2, Ch11, Ch11, Ch3) up to 16 regular conversion (transferred by DMA) up to 4 injected conversion stored in internal registers Multiple trigger sources for both regular and injected conversion Each group can be started by 6 events from the 4 timers (compare, over/underflow) External event and software trig also available 30

ADC Features (3/3) Left or right Data alignment with inbuilt data coherency 4 offset compensation registers Compensates external conditioning components offsets (such as Operational Amplifiers). Provides signed results if needed. Channel-by-channel programmable sampling time to be able to convert signals with various impedances From 1µs (for Rin < 1.2KΩ) to 18µs (Rin < 350KΩ), 8 values External voltage follower not mandatory when converting at 1MSps 31

VREF+ ADC Block Diagram VREF- VDDA VSSA ADCCLK ADC Prescalers: Div2, Div4, Div6 and Div8 PCLK2 ADC_IN0 ADC_IN1... ADC_IN15 GPIO Ports Temp Sensor ANALOG MUX Up to 4 Up to 16 ADC Injected Channels Regular Channels Regular data register (12bits) Injected data registers (4x12bits) DMA Request Address/data bus VREFINT Analog Watchdog End of conversion End of injected conversion TIM1_TRGO TIM1_CC4 TIM1_TRGO TIM2_CC1 Start Trigger (injected group) High Threshold register (12bits) Analog watchdog event Ext_IT_15 TIM3_CC4 TIM4_TRGO TIM1_CC1 JEXTRIG bit JEXTSEL[2:0] bits Low Threshold register (12bits) AWD EOC JEOC AWDIE EOCIE JEOCIE Flags Interrupt enable bits TIM1_CC2 TIM1_CC3 TIM2_CC2 Start Trigger (regular group) Ext_IT_11 TIM3_TRGO TIM4_CC4 EXTSEL[2:0] bits EXTRIG bit ADC interrupt to NVIC 32

ADC dual modes (1/2) Available in devices with two ADCs (Performance line) ADC1 and ADC 2 can work independently or coupled (master/slave) 8 ADC dual modes VREFINT ADC_IN15 ADC_IN1ADC_IN0 Temp Sensor GPIO Ports ANALOG MUX Up to 4 injected channels Up to 16 regular channels External event (Regular group) ADC1 Analog External event sync ADC2 Analog External event (Injected group) Digital Master Data register Digital Slave EOC/JEOC 33

ADC dual modes example (2/2) Injected simultaneous mode on 4 injected channels Sampling ADC2 CH0 CH1 CH2 CH3 Conversion ADC1 CH15 CH13 CH1 CH2 Trigger for injected channels End of Injected Conversion on ADC1 and ADC2 Fast Interleaved mode on 1 regular channel in continuous conversion mode ADC2 ADC1 CH0 7 ADCCLK cycles CH0 CH0 CH0 CH0 CH0 Up to 2 MSps continuous data throughput (DMA-based) Trigger for regular channels 34

Plan PWM generation Speed / position feedback Multi timer configuration Analog to Digital converter Current sensing and ADC synchronization Field Oriented Control Motor Control Tools 35

Isolated Current transducers 1/2 ADC Motor Isolated / floating sensors PWM synchronization is possible when all low sides and / or all high sides are ON ( crest or valley ) Two sensors are enough (currents are always readable) The current can be read twice per PWM period 36

Isolated Current transducers 2/2 Counter Compare 1 compare 2 Low side 1 Low side 2 Phase current Average current ADC Sampling 37

Shunt based current sensing 1/2 ADC ADC ADC Using 3 shunts PWM synchronization mandatory Need to sample when all low side switches are ON, in the middle of PWM period ( crest ) Current cannot be read during 33% of sine period, but two phases at least are readable The third one can be reconstructed (Ia = -Ib-Ic) 38

Shunt based current sensing 2/2 Counter Compare 1 Compare 2 Low side 1 Low side 2 Phase current Average current 0V ADC input (Phase 1) ADC Sampling 39

ADC synchronization in STM32 Done thanks to a synchronization unit embedded in the PWM timer. 2 options available: Direct synchronization on PWM crest, valley, or both. Delayed synchronization with the 4 th Compare channel The ADC results can be then processed with an end of conversion interrupt or transferred by DMA. 40

Direct synchronization The PWM timer update signal triggers Simultaneous injected conversions on both ADCs No error due to sequential phase sampling MASTER CLOC K prescaler counter Update PWM Trigger Controller TRG 0 Injection trigger ADC1&2 41

Plan PWM generation Speed / position feedback Multi timer configuration Analog to Digital converter Current sensing and ADC synchronization Field Oriented Control Motor Control Tools 42

Field oriented control (FOC): a quick overview Mathematical technique utilized for achieving decoupled control of the flux and torque in a three-phase machine (ACIM or PMSM) Stator current is decomposed into: the magnetizing current Ids, producing a magnetic field algebraically added to the one of the rotor The quadrature current Iqs which controls torque just like the armature current does in the DC motor Benefits (vs scalar control) Precise and responsive speed control when the load changes Optimized efficiency even during transient operation Allows position control (through instantaneous torque control) 43

FOC in torque control (Open loop) AC Mains 3 phase inverter PMSM Motor ~ i qs * i ds * + + - - PID PID v qs v ds REVERSE PARK & circle limitation v α β s v a,b,c CALC SVPWM θ rel i qs i ds PARK i αβ s CLARKE i abc s CURRENT READING θ rel ROTOR SPEED/POSITION FEEDBACK DC Domain AC Domain 44

FOC in speed control (Closed loop) AC Mains 3 phase inverter PMSM Motor ~ v a,b,c TORQUE AND FLUX CONTROLLER i qs * + - i ds * + - PID PID v qs v ds REVERSE PARK & circle limitation v α β s CALC SVPWM θ rel + - ωr * i qs i ds ω r PARK θ rel ROTOR SPEED/POSITION FEEDBACK i αβ s CLARKE i abc s CURRENT READING DC Domain AC Domain 45

FOC computational requirements The complete vector control algorithm must be continuously recomputed, at a rate of between 1 and 10kHz (1ms down to 100µs loop time, depending on the final application) 16-bit is the minimum required accuracy for the main control variables, with a need for 32-bit calculations The algorithm intensively requires math computations (trigonometric functions, PID regulator, real-time flux and torque estimation based on motor parameters) 46

A sensorless control method: the B-emf observer In control theory a system is observable, if it is possible to fully reconstruct the system state from its output measurements The state observer is a system that provides an estimation of the internal state of the observed system given its input and output measurements. U PLANT (X) Y Y Yˆ Observer Ŷ K Χˆ 47

Luenberger Observer for PMSM FOC u (v PMSM MOTOR + q,vd ) y (iq,id ) B C + A x (i qs,i ds,e Q,e D ) B + + + PMSM STATE OBSERVER C yˆ (i q,i d ) - + A x ˆ ( i, i, e, e D Q Q D ) K 48

Getting the rotor angle Once êα and êβ have been determined, rotor angle position could be simply computed by formula: θ r = arctg eˆ eˆ α β And thus the speed could be computed as derivative of rotor angle Rotor angle can also be estimated with a software PLL solution to avoid arctg function (low accuracy at 90 ) and derivative (noise sensitive) 49

FOC algorithm execution time With Cortex-M3 running at 72 MHz from embedded flash, fully code in C (optimized for speed) i qs * i ds * + - + - PID PID v qs v ds REVERSE PARK & circle limitation v α β s CALC SVPWM θ rel i qs i ds PARK i αβ s CLARKE i abc s 3-SHUNT CURRENT READING 1.6μsec 3.6μsec 1.7μsec 2.7μsec 5.5μsec 2.6μsec each 21μsec θ rel SENSORLESS ROTOR POSITION FEEDBACK For reference, Sensored FOC is ~17µs (vs 25µs with ARM7-based STR750, ie ~30% gain) 50

FOC software library memory footprint Thanks to the high density of Thumb2 instruction set, the preliminary overall size of PMSM FOC software library is 26Kb Excluding only the LCD and Joystick management the overall code size falls to 16Kb Preliminary, Code optimized for speed 51

Practical results 700W AC induction motor, sensored field oriented control 52

Plan PWM generation Speed / position feedback Multi timer configuration Analog to Digital converter Current sensing and ADC synchronization Field Oriented Control Motor Control Tools 53

STM32 Software library for PMSM FOC (1/2) Supported current sensing methodologies: Isolated Current sensing Three shunt resistors Single shunt resistor (future development) Supported rotor position feedback: Encoder Hall sensors: 60 and 120 placement Sensorless 54

STM32 Software library for PMSM FOC (2/2) Developers' support Progressive system development for guiding users during their own development DAC functionality for tracing the most important software variables User interface for real time tuning of PIDs and observer gains (via LCD and joystick) MISRA 2004 compliant Free of charge and open source Demonstration kit available e/o Oct 07 55

Progressive system development Guide user in his development, gradually take him towards sensorless solution Allows to avoid the inclusions of the code lines implementing not used functionalities /************** Current sensing by ICS (Isolated current sensors) ************/ //#define ICS_SENSORS /************** Current sensing by Three Shunt resistors *******************/ #define THREE_SHUNT /************** Position sensing by Incremental encoder *******************/ //#define ENCODER /*********************** Speed sensing by Hall sensors ******************/ //#define HALL_SENSORS /****************************** No speed sensors *********************/ #define NO_SPEED_SENSORS //#define VIEW_HALL_FEEDBACK //#define VIEW_ENCODER_FEEDBACK /******************** PI + Differential term for Id & Iq regulation **********/ #define Id_Iq_DIFFERENTIAL_TERM_ENABLED /***************** PI + Differential term for speed regulation **************/ //#define SPEED_DIFFERENTIAL_TERM_ENABLED /********************** PIDs Parameter regulation software **************/ //#define FLUX_TORQUE_PIDs_TUNING #define OBSERVER_GAIN_TUNING /********************** PIDs Parameter regulation software **************/ #define DAC_FUNCTIONALITY 56

DAC functionality Implemented using two out of the four TIM3 output compare channels Allow the simultaneous monitoring of up to two software variables selectable in real-time using a dedicated menu Can be disabled simply commenting one code line STM32 Motor Control PMSM FOC ver 0.2 Speed Signal (rpm) on PB0 Iqref Signal on PB1 Ia Move Change 57

User interface Real time tuning of torque, flux and speed PIDs Observer gains tuning (in case of sensorless) Variation of target speed (speed control) or target torque and flux (torque control) Bus voltage and power stage temperature monitoring Selection of variables to put on output for DAC functionality implementation STM32 Motor Control PMSM FOC ver 0.2 Observer Torque Gains Closed Power P Speed K1 Loop Signal Stage (rpm) I on Status PB0 K2 D Observed 15000-00650 Speed El 00570 Angle (rpm) -04500 4000 DC Ref Ref Signal bus = on 320 PB1 Meas Meas Volt Measured 02500 02500 T = El 24 Angle Celsius 00000 00000 Proportional Speed K1 gain control Term mode Move Change 58

STM32 demonstration kit Three-phase power stage with shuntbased current reading Complete source files software libraries for 3-PH Induction and PMSM motors provided Brushless PM Motor with encoder included 59

STM32-MCKIT (alpha version) Brushless PM Motor with encoder Opto-isolated JTAG Three-phase Power stage with shuntbased current reading Evaluation board (final STM32 version has a color LCD) 60