STM32 Motor Control

If you like it, share it

STM has released (March 2018) the new FOC Motor Control for CUBE-MX.
The main feature is that now the new FOC use the HAL/LL libraries.

The concepts of the new FOC are the same of the old one, change the implementations that now use HAL/LL libraries and there is a good integration in CUBE-MX.


FOC – old version that use the Standard Libraries.
Please, for new project use the new FOC Motor Control see above.

mclogo

STM32 PMSM FOC Software Development Kit – MC library (UM1052)

ST’s STM32 offers the performance of the industry-standard Cortex®-M core at the service of vector (or field-oriented) control (FOC) algorithms, widely used in high-performance drives.

The STM32 PMSM FOC SDK(STSW-STM32100), which includes the PMSM FOC FW library and ST MC Workbench, allows the user to evaluate the STM32 performance in applications driving single or dual Field Oriented Control of 3-phase Permanent Magnet motors (PMSM, BLDC).

STM32 PMSM FOC SDK is part of ST’s motor control ecosystem which offers a wide range of hardware and software solutions for motor control applications.
ST MC Workbench is a PC software which reduces the design effort and time in the STM32 PMSM FOC firmware library configuration.
The user, through a graphical user interface (GUI), generates all parameter header files which configure the library according to the application needs and can in real time monitor and change some variables of the algorithm.

Key Features

  • Single/Dual simultaneous vector control (FOC).
  • Motor Profiler and one Touch Tuning for a fast startup of unknown motors.
  • Current reading topologies supported:
    1 shunt resistor;
    3 shunt resistors;
    2 ICS (isolated current sensor).
  • Speed/position sensors (Encoder and Hall) as well as sensorless operation (State observer, High frequency Injection HFI, On-the-Fly startup for fans) are supported.
    Speed and torque control.
  • Wide range of STM32 microcontrollers supported, the full list is detailed in RN0085, available on www.st.com.
  • Full customization and real time communication through PC software ST MC Workbench:
    New project creation starting from the board.
  • Motor control algorithms implemented for specific applications like Maximum Torque Per Ampere (MTPA), Flux Weakening and more.
  • Firmware ANSI C, MISRA compliant.

.

 


Introduction

A generic motor controller kit is show below.

mckit

  • The FOC SW/FW is here (STSW-STM32100), this package contain the:
    • ST MC Workbench (PC GUI configuration and monitor tool)
    • All the SW that is necessary for STM32xxx MCU
  • The Inverter Board must be chosen to meet the motor characteristics.
    See here the STEVAL-IHMxxx. See also here.

ST MC Workbench is a PC software which reduces the design effort and time in the STM32 PMSM FOC firmware library configuration.
The user, through a graphical user interface (GUI), generates all parameter header files which configure the library according to the application needs and can in real time monitor and change some variables of the algorithm.

mcimageofenviroment

 

Go on TOP


Introduction to motors topology

 A tutorial on the electrical motors is here.

mc-pmsmmotors

mc-bldcmotors

Go on TOP


.

Introduction to FOC

mc-foc1

mc-foc2

mc-foc3

mc-foc4

mc-foc5

 Go on TOP


How to convert RPM to the Frequency of the sinusoidal current that must be generated for each phase, considering the number of pole pairs

Suppose to have a 3 phase motor
mc-foc6

Suppose to have 20000 rpm, this means 20000 laps (mechanical) per minute
and suppose that the motor is a 4 pole pairs.

The formula for calculate the mechanical frequency (MF) is:
MF = rpm/60
20000 rpm ==> laps (mechanical) per minute ==> 20000/60 = 333.33 per second (mechanical frequency)

To calculate the electrical frequency (Hz) is necessary multiplied the mechanical frequency by the number of pole pairs.
Hz = MF x Number_of_Pole
333.33 x 4 = 1333.33 Hz
This is the frequency of the sinusoid of current that must be generated for each phase.
But…
The sinusoid must be (Nyquist) at least twice but as we know it is not enough… we say that takes at least 10-12 times, (most bigger is, the better is) to get an accurate reconstruction of the curve… the PWM frequency is our sampling frequency (in the case in which the vector control is done every period of PWM).
So the PWM frequency is:
Fpwm >= 1333.33 * 12 = 16 KHz
Consider that 16 KHz is the minimum conditions.
If it is possible the suggestion is: go up in frequency but take care the switching losses.

 Go on TOP


Tutorial and Technical and MKT presentation

 mc-foc7

  • FOC 4.0
    Only for SILICA customers
    The Ref.Cod. is: STM32_FOC_SDK_4.0.0_Confidential_140630
    IMPORTANT NOTE
    At the moment, this SW is only for SILICA customers.
    If you are SILICA customer send me an email and ask me:
    STM32_FOC_SDK_4.0.0_Confidential_140630
    Please specify your Name, CITY, COUNTRY and your contact in SILICA.
    If you are STM customer please contact directly your local office of STM.

  • Training FOC 4.0 and Analog – Catania Luglio 2014
    Only for SILICA customers
    The Ref.Cod. is: Training Motor control Catania 2014
    IMPORTANT NOTE
    At the moment, this SW is only for SILICA customers.
    If you are SILICA customer send me an email and ask me:
    Training Motor control Catania 2014
    Please specify your Name, CITY, COUNTRY and your contact in SILICA.
    If you are STM customer please contact directly your local office of STM.

  • Motor Control v.2.0 – ACIM and PMSM
    Only for SILICA customers
    The Ref.Cod. is: Motor Control v.2.1.200(Beta) – ACIM and PMSM
    IMPORTANT NOTE
    At the moment, this SW is only for SILICA customers.
    If you are SILICA customer send me an email and ask me:
    Motor Control v.2.1.200(Beta) – ACIM and PMSM
    Please specify your Name, CITY, COUNTRY and your contact in SILICA.
    If you are STM customer please contact directly your local office of STM.

Go on TOP


How to create a KIT for develop a Motor Control SW

For make a kit for develop a motor control software follow the steps below.

  1. Install the FOC sw:
    STSW-STM32100 – STM32 PMSM FOC Software Development Kit – MC library (UM1052) on your PC.
  2. Choose a STM32 in according with the image below.
    Take in consideration this parameters (see yellow boxes):

    • Max FOC frequency
    • 1 or 3 shunt for monitor the current on the motor

      focselez
  3. Now run the FOC sw (see below)
    focsw
    and choose a STM32 Evaluation Board according on the boards that you see in the image below.
    For example if you are decide that for your application is necessary an STM32F4 you have the possibility to choose the STM3240G-EVAL (see the red box below).

    fockithw_2
    In the colon: Power Board
    There is also a suggester Power Stage evaboard.
    NOTE:
    The characteristic is that in the STM32 board and also in the Power Stage board  there is the rectangular connector for connect this two boards together.
  4. Now you must choose a Power Stage eveboard according with the characteristics of your motor.
    STM release a lot of power stage boards, some are shown below.

    fockithw_3

  5. A tipical HW KIT must be similart to the image below
    fockithw

Go on TOP