Frequently Asked Questions (FAQ)

Revision as of 07:05, 20 April 2021 by Registered User (Update some links)


This page contains some Frequently Asked Questions (FAQ) related to Motor Control with STM32 (STM32 MC).

Main sections

  1. STM32 MC Ecosystem
  2. STM32 MC SDK Usage
  3. STM32 MC SDK Features

Acronyms and abbreviations

  • FOC = Field Oriented Control (algorithm)
  • MC = Motor Control
  • PMSM = Permanent Magnet Synchronous Motor
  • SDK = Software Development Kit

1. STM32 Motor Control Ecosystem

1.1. What is the purpose of the STM32 MC SDK?

The ST Motor Control Ecosystem includes also the STM32 Motor Control Software Development Kit (download the "X-CUBE-MCSDK" deliverable to install). Its purpose is to speed up the evaluation and development of a FOC algorithm (Field Oriented Control) and six steps for Permanent Magnet Synchronous Motor (PMSM) applications.

The STM32 MC SDK is running with the STM32 MCU families implementing advanced timer (Cf. its Release Note for more information), and it is composed of:

  • STM32 MC Firmware (STM32 MC FW) library
    • Currently PMSM FOC control only is available for all configurations
    • PMSM Six Step and Asynchronous motor FOC getting started in the MCSDK as examples
  • STM32 MC Workbench (STM32 MC WB)
    • PC Graphical User Interface (GUI) tools to configure the FOC firmware library parameters and to perform real time monitoring (monitoring with the STM32 MC WB only until version 5.4.6)
  • STM32 MC Motor Profiler (STM32 MC MP)
    • PC tools able to measure the Motor Parameter automatically and to update the STM32 MC FW library, through the ST MC Workbench usage

1.2. What are the changes from previous version?

Please, refer to the STM32 MC SDK Release Notes as provided with each version released.

1.3. What is the STM 32 SDK Version 5.Y?

STM32 MC SDK is available in 2 versions of the "X-CUBE-MCSDK" deliverable:

  • STM32 MC SDK version 5.4.6, correcting few problems of the 5.4 series. It is fully compatible with previous versions.
  • STM32 MC SDK version 5.Y, that is a first step in our innovative roadmap. It includes:
    • A new communication protocol and its associated monitoring tools, the SM32 MC Motor Pilot
    • New algorithms like discontinuous PWM, Single shunt phase shift, Overmodulation
    • New 6 step examples compatible with the new STM32 MC Motor Pilot
    • New Sensorless Asynchronous Motor example compatible with the new STM32 MC Motor Pilot
    • New STSpinG4 support
    • MISRA support for STM32G4 series

The main limitation of STM32 MC SDK version 5.Y are:

  • Project generated with STM32 MC SDK version 5.4 deliveries will not be compatible with version 5.Y
  • STM32 MC SDK version 5.Y does not support STM32F1 series
  • STM32 MC SDK version 5.Y does not support dual motor

1.4. How to I choose between STM32 MC SDK 5.4.6 and 5.Y versions?

  • If you are already using STM32 MC SDK version 5.4 and need to keep the compliancy, please use the version 5.4.6
  • If you want a well establish matured version with no surprise, please use the version 5.4.6
  • If you use STM32F1, please use the version 5.4.6
  • For Dual Motor Application, please use the version 5.4.6

But:

  • If you need new debug capabilities and dumping features to mature your application, please use the version 5.Y
  • If you are interested by any of these features: discontinuous PWM, Single shunt phase shift, Overmodulation, please use the version 5.Y
  • If you want to use the new STSPING4, please use the version 5.Y
  • For Asynchronous Motor application , please use the version 5.Y

1.5. What is the STM32 MC Motor Profiler tool?

This is a tool that automatically measure the electrical parameters of PMSM motors. It is useful to run motor with unknown specifications in less than a minute.

The used algorithm determines the motor parameters needed to configure the STM32 MC FW library : Stator resistance Rs; Stator inductance Ls; Back EMF Constant; Motor Inertia and Friction.

Please, refer to the STM32 MC SDK tools document for more details ([UM2380]). ).

2. STM32 MC SDK Usage

2.1. How to create a Motor Control project?

Please, read first the STM32 MC SDK - Getting Started manual ([UM2374]). Then, you can either starts from a motor control example project, or either from a new project design.

Tips :

  • Don’t forget to create and save your project into your dedicated working directory.

2.2. How to handle project made with previous version of the STM32 MC Workbench?

The STM32 MC Workbench migrates automatically older *.stmcx file to the current version. Please, note that before the migration, an information window is popping-up to prevent you. Click yes if you agree with this conversion (Please, note that there is no backward possibility after migration).

With regards to the user application software itself, please, refer to the document "How to migrate motor control application software from STM32 MC SDK v4.3 to v5.x" ([AN5143]).

Tips:

  • Get a copy of all your original files.
  • Don’t forget to create and save your project into your dedicated working directory.

Warning:

  • There is no possibility to reuse a project generated with STM32 MC SDK version 5.4.x with the new version 5.Y

2.3. How to get a project framework for particular IDE (IAR, KEIL, …)?

User may start from :

Either a motor control application software example as provided into the “./Projects” directory for all supported IDE : IAR, KEIL or GCC based (Please, read its attached ReadMe.txt file);

Either a pre-configured motor control application example project, or a new created one, via the STM32 MC Workbench usage. Then, user selects the wanted IDE, as well as the STM32CubeMX version, before to generate his/her motor control application software example.

Tips :

  • Don’t forget to create and save your project into your dedicated working directory.

2.4. Why the STM32 Motor Profiler Tool doesn’t recognize my motor?

If the STM32 Motor Profiler tool does not recognize your motor, please proceed as following:

  • Apply nominal voltage
  • Select the power stage with proper current range
  • Fill nominal motor speed parameter or play with this value
  • Decrease nominal current parameter
  • Decrease applied bus voltage

Warning:

  • The STM32 MC Motor Profiler has the following limitation. It cannot recognize motors with Rs > 1 Ω, Ls > 1 mH

If you still face problem please profile your motor manually using the following procedure (documentation available soon)

2.5. Why my motor doesn’t start immediately?

Although your motor is running fine, it doesn’t start immediately for one of the following reason:

  1. During initialization, a motor alignment is needed to start from a known position. In other words, it means the initialization phase sets a static stator vector and waits until the rotor vector aligns with this position.
  2. When the “On-the-Fly startup” feature is Enabled. Before any motor drive, this feature starts a detection phase:
  • When the rotation is detected, it skips the start-up phase and runs directly in the close-loop mode.
  • When the rotation is not detected, it runs the start-up phase : alignment, ramp-up, …

2.6. How to choose the basic set of ramp-up parameters for a motor?

Most of the time, we have noticed that setting the ramp-up parameters as follow makes motor will run the first time :

  • Check the box “Include alignment before ramp-up”;
  • Set the motor alignment “Duration” to 2000 ms;
  • Set the motor alignement “Final current ramp value” from ½ of nominal motor current (in A);
  • Set the “Speed ramp duration” to 3000 ms;
  • Set the “Speed ramp final value” to 30% of maximal motor speed (in rpm);
  • Set the “Current ramp final value” from ½ of nominal motor current (in A);
  • Set the “Minimum start-up output speed” to 15% of maximal motor speed (in rpm).

After a first successful run, you need to fine tune these parameters.

2.7. How To choose the PWM frequency and the FoC execution rate?

The choice of the PWM frequency and the FOC execution rate is a compromise between available speed and switching losses.

  • In case of a high speed motor or a low inductance motor, you have to use a high PWM frequency (e.g. 30 kHz).
  • In other cases, a lower PWM frequency (e.g. 16 kHz) is, most of the time, enough.
  • In all cases, you have to check the maximal PWM frequency capability for the selected MCU.
  • In case of a low inductance motor, it is possible to increase the FOC execution rate while keeping a high PWM frequency to save CPU load; or to migrate to a lower performance MCU (e.g. PWM = 30 kHz and a FOC execution rate = 2 means the FOC algorithm runs @ 15 kHz).

2.8. Why do I have a “FOC duration” fault message and the motor don’t even try to start?

This fault message appears when the FOC execution rate is too high and the FOC algorithm computation cannot fit within the PWM period.

Open the Drive Settings window and decrease the ratio between the PWM frequency and the Torque and flux regulators execution rate as shown below (e.g. Increase this execution rate by one).

2.9. Why do I have an “Over current” fault message and the motor don’t even try to start?

This fault message appears from the following situation :

  1. A wrong current sensing topology has been selected. Please, check and select the right current sensing configuration.
  2. A Wrong current sensing parameters has been set. Please, check and correct the current sensing parameters.
  1. The current regulation loop bandwidth is too high for this HW setup. Please, open the Drive Settings window and decrease the current regulation loop cut-off frequency (e.g. Down to 2000 rad/s for a 3-shunt topology and 1000 rad/s for a 1-shunt topology). Typical maximum current regulation loop bandwidth values are 9000 rad/s for a 3-shunt topology and 4500 rad/s for a 1-shunt topology.

2.10. Why do I have a “Speed feedback” fault message during the acceleration phase and the motor stop?

Often, this fault message appears following an abrupt Torque variations demand at the end of the start-up phase. This spoils the Back-EMF estimator.

  • 1. The observer gain G2 is too high and this makes the speed reconstruction a bit noisy for the used speed PI gains (causing estimator reliability trouble). Then, possible solutions are :
    • Decreasing the observer gain G2 by successive steps : /2, /4, /6, /8.
    • Running the motor in torque mode. When this trouble disappears in torque mode, it means the speed regulator gains are not optimal. Please, trim the gain values (Cf. dedicated FAQ).
  • 2. The start-up phase ends too early. Then, possible solution are :
    • Increasing the “Consecutive successful start-up output tests” parameter (normally not more than 4-5);
    • Setting the “Minimum start-up output speed” parameter to 15% of your maximal application speed, then decreasing it for fine tuning.

Tips :

  • Smooth the speed variation between the “Minimum start-up output speed” and the “Speed ramp final value” playing with the “Speed ramp duration”.

2.11. Why do I have a “Start-up failure” fault message during the rev-up phase and the motor stop?

Typically, this fault message appears because the provided current is not enough to support the speed acceleration.

  • 1. Decrease the speed acceleration rate :
    • Increase the “Speed ramp duration” parameter;
    • Set the “Speed ramp final value” parameter to 30% of your maximal application speed.
  • 2. Increase the start-up current :
    • Increase the “Current ramp initial value” parameter;
    • Increase the “Current ramp final value” parameter up to the “Nominal Current” parameter of your motor;
    • Check the “Include alignment before ramp-up” box to make the start-up phase more deterministic … and follow the FAQ about Basic parameters settings for the ramp-up.

2.12. Why do I have a “Start-up failure” fault message during the acceleration following the rev-up phase and the motor stop?

Often, this fault message appears following an abrupt Torque variations demand at the end of the start-up phase. This spoils the Back-EMF estimator.

  • 1.The observer gain G2 is too high and this makes the speed reconstruction a bit noisy for the used speed PI gains (causing estimator reliability trouble). Then, possible solutions are :
    • Decreasing the observer gain G2 by successive steps : /2, /4, /6, /8.
    • Increase the “Variance threshold” parameter to release the check mechanism : Up to 80% for Observer+PLL, Up to 400% for Observer+CORDIC.
  • 2. The reliability capture window of the estimator is too small. Then, possible solution is :
    • Increase the “Speed ramp final value” parameter up to 40% of your maximal application speed;
    • Decrease the “Minimum start-up output speed” parameter down to 10% of your maximal application speed.

2.13. How To interface the STM32 MC Firmware library?

Several Motor Control APIs has been implemented to interact with the firmware library in a basic way.

Please, refer to the on-line Firmware Reference information, which content all these details and more :

  • From the STM32 MC Workbench menu (Documentation -> Firmware Reference);
  • From the Windows Start-up menu (ST Motor Control SDK xxx -> Reference Manual xxx).

2.14. How To choose the hardware Power board?

While it is not true for the nominal bus voltage, usually, the maximal current (torque) used by your application is different from the maximum current of the motor.

As a consequence, you can spin a motor with a reduced power range for your Power board.

Of course, the best case is when the maximum current of the motor is part of the current range from your Power board.

2.15. How To debug a motor control application?

A Motor Control application cannot use the standard debug mechanism : HW or SW breakpoints holding the program.

The reason is that during the break, your application is losing the real rotor position Vs the needed magnetic field computation phasing with the firmware execution.

So, we usually use the DAC (or an emulated DAC, thanks to a PWM output) and/or the USART communication:

  • The DAC can generate a voltage reflecting internal signals (e.g. Currents, B-EMF voltage, or reconstructed angle). Then, it provides capability to scope this waveform during the motor spin. Best is to dedicate two pins of a DAC output
  • The USART can provide data, but at a lower rate than the DAC. It requires the two Tx/Rx pins and the STM32 MC Workbench tool to monitor these data.

2.16. How To make the current more sinusoidal when motor spin?

Probably, the PI gains of the Speed regulator are incorrects.

Decrease the Kp gain and act on the Ki gain (evaluating the speed regulation) to check over/under-shooting during transients.

2.17. How To tune the PI Speed regulator?

Among the possible ways, one is pragmatic as described follow:

  1. Run the motor and connect it to the STM32 MC Workbench;
  2. Open its monitor mode and switch-on the plotter window;
  3. In the “Final ramp speed” box, enter the new reference speed (e.g. Change speed from 2 000 rpm to 4 000 rpm).
  4. In the plotter windows, check the measured speed reaction : fast but oscillation existence around final value, or too slow reaction :
  • If regulated variable oscillates around a value, then decrease KI or increase KP.
  • If the trend of regulated variable is too slow or not stabilize, then increase KI.

2.18. How To connect ICS with the MC FW library?

Our implemented ICS requires usage on 2 phases among the 3.

As the STM32 MC FW library is operating only Phase U and Phase V, this is where user should connect each ICS.

2.19. Why using the FOC Vs 6-Steps control for PMSM drive?

The FOC brings the following benefits :

  • Better energy efficiency;
  • Responsive time of speed control;
  • Precise position control;
  • Lower acoustical noise.

2.20. Why using the 3-Shunts Vs 1-Shunt resistors implementation for current measurement?

Using the 1-Shunt implementation for measurement is the cheapest solution.

However, some motor (e.g. a low inductance motor) require currents measurement on two phases simultaneously. Then, only the 3-Shunts implementation can match.

3. STM32 MC SDK Features

3.1. Does the STM32 MC SDK support Power Factor Corrector?

Yes, it does.

Power Factor Correction examples are accessible from the STM32 MC Workbench First page, in the example list.

3.2. Does the STM32 MC SDK support a Dual drive motors?

Yes, the STM32 MC SDK supports a Dual drive motors using only one MCU.

Warning:

  • This functionality has been temporarily removed in the STM32 MC SDK version 5.Y

3.3. Does the STM32 MC SDK provides project examples using FOC or 6-Steps control for PMSM drive?

Yes, the STM32 MC SDK provides project examples to demonstrate FOC or 6-Steps control implementation.

They are accessible from STM32 MC Workbench first page.

3.4. What are the new features of STM32 MC SDK version 5.Y?

STM32 MC SDK version 5.Y, is a first step in our innovative roadmap. It includes:

  • A new communication protocol and its associated monitoring tools, the STM32 MC Motor Pilot
  • New algorithms like discontinuous PWM, Single shunt phase shift, Overmodulation
  • New 6 step examples compatible with the new STM32 MC Motor Pilot
  • New Sensorless Asynchronous Motor example compatible with the new STM32 MC Motor Pilot
  • New STSpinG4 support
  • MISRA support for STM32G4 series