STM32 Motor Control

If you like it, share it

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

In the package you has:
ST MC FOC FW library
ST MC Six-Step FW library
ST MC Workbench software tool

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

Now there are two release of SW that are:
X-CUBE-MCSDK – STM32 Motor Control Software Development Kit.
Ready to use on all STM32, some part of it (Cordic, MTPA, ecc) are pre compiled.
X-CUBE-MCSDK-FUL – STM32 Motor Control Software Development Kit (MCSDK) – FULL source code – Registration and approbation needed for download

After the installation you find on your PC the two icon shown below.

For start a new project you run the Motor Control Workbench and you must see the image below.

Now you choose the micro and/or evaboard to use and continue following the various pages that appears, read the documentations below.

Last but not least there is also the:
ST-MC-SUITE -> FIND EVERYTHING YOU NEED IN ONE PLACE
ST-MC-SUITE lets users gather tutorials and documentation, store project setups (hardware and software), get links to download software solutions including the newly updated X-CUBE-MCSDK package.

We suggest you to read the below manuals:

  • AN5166: Guidelines for control and customization of power boards with STM32 MC SDK v5.x
  • UM2374: Getting started with STM32 motor control SDK v5.0
  • UM2392: STM32 motor control SDK
  • UM2380: STM32 motor control SDK v5.2 tools
  • UM2312: Development checklist for STM32Cube Expansion Packages
  • UM2285: Development guidelines for STM32Cube Expansion Packages

We suggest also to see this training (is on YouTube)
The SW is here.

During this training session, you will learn how to:

  • Characterize a 3-phase BLDC motor with the Motor Profiler
  • Get started with motor control development using the new SDK v5.x
  • Integrate your motor control design into the rest of your project using STM32CubeMX and the TrueSTUDIO® for STM32 IDE
  • Control and tune your motor using the Motor Control Workbench Monitor

X-NUCLEO-IHM09M1 is a motor control connector that provides an easy way to evaluate motor control solutions for three-phase motors by adapting the STM32 Nucleo board with an external ST motor control power board, thanks to ST morpho and motor control connector. The 34-pin motor control connector is compatible with all major ST motor control power boards, requiring an external digital section (MCU) to drive a three-phase motor. The DAC connector supports user code development and testing with easy access to the MCU peripherals. A LED is available for fault condition signaling or status indication.

LINKs

  • Industrial Motor Control is here.



Old docs

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

mc-foc6

Suppose to have a 3 phase motor

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 – NO LONGER AVAILABLE
    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.

  • Install the FOC sw:
    STSW-STM32100 – STM32 PMSM FOC Software Development Kit – MC library (UM1052) on your PC.
  • 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

  • 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.
  • 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

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

Go on TOP