Exceptionally, this wiki is under maintenance.

You can continue to browse it but contributors can not improve their favorite articles, during phase.

Thank you for your understanding.

Frequently Asked Questions (FAQ)

Revision as of 21:54, 12 May 2021 by Registered User (Escoda Michael moved page STM32 MC Frequently Asked Questions to STM32MotorControl:Frequently Asked Questions without leaving a redirect)


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 an advanced timer (refer to the appropriate release note for more information), and it is composed of:

  • STM32 MC Firmware (STM32 MC FW) library
    • Currently only the PMSM FOC control 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 up to 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 provided with each released version.

1.3 What is the STM32 MC SDK Version 5.Y?

STM32 MC SDK is available in two 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 such as discontinuous PWM, single shunt phase shift, overmodulation
    • New six 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.

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

  • Project generated with STM32 MC SDK version 5.4 deliveries are 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 do 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, use the version 5.4.6
  • If you want a well established mature SDK version with no surprise, use the version 5.4.6
  • If you use STM32F1, use the version 5.4.6
  • For dual motor application, use the version 5.4.6

But:

  • If you need new debug capabilities and dumping features to mature your application, use the version 5.Y
  • If you are interested by any of the following features: discontinuous PWM, single shunt phase shift, overmodulation, use the version 5.Y
  • If you want to use the new STSPING4, use the version 5.Y
  • For asynchronous motor application , 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. The specification of an electric motor may not be known and is determined in less than a minute.

The algorithm determines the motor parameters needed to configure the STM32 MC FW library : stator resistance Rs; stator inductance Ls; back EMF constant; motor ionertia and friction.

Refer to the STM32 MC SDK tools document for more details (UM2380).

1.6 What is the STM32 MC Motor Pilot tool?

The STM32 MC Motor Pilot is a new control and monitoring PC tool in version 5.Y, which replaced the monitor currently delivered with the STM32 MC Motor Workbench.

It is built on a brand new communication protocol that allows for faster and more reliable communication while consuming less MIPS from the MCU.

With this protocol, internal motor control signals are monitored in real time with no or controlled subsampling.

2 STM32 MC SDK Usage

2.1 How to create a motor control project?

First read the STM32 MC SDK - Getting Started manual (UM2374). Then, start from either a motor control example project, or from a new project design.

Tips :

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

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

The STM32 MC Workbench migrates automatically older *.stmcx file to the current version. Note that before the migration, an information window pops-up requesting confirmation. Click yes if you agree with this conversion (note that the previous configuration is lost after migration).

Regarding to the user application software itself, refer to "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:

  • Projects generated with STM32 MC SDK version 5.4.x cannot be reused with the new version 5.Y

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

User may start from :

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

Either a pre-configured motor control application example project, or a newly created one, via the STM32 MC Workbench usage. Then, the 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, proceed as follows:

  • Apply a nominal voltage
  • Select the power stage with proper current range
  • Fill the nominal motor speed parameter or play with this value
  • Decrease the nominal current parameter
  • Decrease the 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 problems, profile your motor manually using the following procedure: How To manually configure the motor parameters.

2.5 Why does my motor not 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, the motor starts the first time :

  • Check the box “Include alignment before ramp-up”;
  • Set the motor alignment “Duration” to 2000 ms;
  • Set the motor alignment “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, fine tune these parameters.

DriveManagement StartUp-Parameters1.png

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 enough for most cases.
  • In all cases, check the maximum 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 an “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 does not fit in the PWM period.

Open the "Drive Settings" window and decrease the ratio between the PWM period execution rate in the "Torque and flux regulators" section as shown below (increase this execution rate by one for example).

DriveManagement DriveSettings1.png

2.9 Why do I have an “Over current” fault message and the motor does not even try to start?

This fault message appears from the following situation :

  1. A wrong current sensing topology is selected. Check and select the right current sensing configuration.
  2. A Wrong current sensing parameter is set. Check and correct the current sensing parameters.
PowerStage CurrentSensing.png
  1. The current regulation loop bandwidth is too high for the HW setup. Open the "Drive Settings" window and decrease the current regulation loop cut-off frequency (for example 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.
DriveManagement DriveSettings2.png

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

Often, this fault message appears following an abrupt torque variation demand at the end of the start-up phase. As a result, the "Back-EMF estimator" is spoilt.

  • 1. The observer gain G2 is too high and this makes the speed reconstruction a bit noisy to be used by the speed PI gains (causing estimator reliability trouble). Possible solutions are :
    • Decreasing the observer gain G2 by successive steps : /2, /4, /6, /8.
DriveManagement SpeedPositionFeedbackManagement1.png
    • Run the motor in torque mode until the trouble disappears. The draw back is that the speed regulator gains are not optimal. Trim the gain values (refer to the dedicated FAQ).
  • 2. The start-up phase ends too early. Possible solutions are :
    • Increasing the “Consecutive successful start-up output tests” parameter (not set to more than 4-5);
    • Setting the “Minimum start-up output speed” parameter to 15% of your maximum application speed, then decreasing it for fine tuning.
DriveManagement StartUp-Parameters2.png

Tips :

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

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

Typically, this fault message appears because there is insufficient current provided to support the required 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 maximum 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 the motor;
    • Check the “Include alignment before ramp-up” box to make the start-up phase more deterministic, and follow the FAQ on "Basic parameters settings for the ramp-up".
DriveManagement StartUp-Parameters3.png

2.12 Why do I have a “Start-up failure” error 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 results in a noisy the speed reconstruction for the PI speed gains used (causing estimator reliability trouble). Possible solutions are :
    • Decrease the observer gain G2 by successive steps : /2, /4, /6, /8.
DriveManagement SpeedPositionFeedbackManagement1.png
    • Increase the “Variance threshold” parameter to release the check mechanism : Up to 80% for Observer+PLL, Up to 400% for Observer+CORDIC.
DriveManagement SpeedPositionFeedbackManagement2.png
  • 2. The reliability capture window of the estimator is too small. The possible solution is :
    • Increase the “Speed ramp final value” parameter up to 40% of the maximum application speed;
    • Decrease the “Minimum start-up output speed” parameter down to 10% of the maximum application speed.
DriveManagement StartUp-Parameters4.png

2.13 How to interface the STM32 MC Firmware library?

Several motor control APIs are implemented to offer basic interaction with the firmware library.

Please, refer to the on-line firmware reference information, which contains 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 maximum current (torque) used by your application is different from the maximum current of the motor.

As a consequence, the motor spin must adapted to the selected Power board range.

Of course, the best case is when the maximum current of the motor is part of the current range offered by the selected Power board.

2.15 How to debug a motor control application?

A motor control application cannot use the standard debug mechanism which are HW or SW breakpoints for holding the program.

The reason is that during the break, your application loses the real rotor position with respect to the needed magnetic field computation phasing defined by the firmware execution.

So, the DAC (or an emulated DAC, thanks to a PWM output) and/or the USART communication are used as outlined below:

  • The DAC generates a voltage reflecting internal signals (for example 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 provides data, but at a lower rate than the DAC. It requires the two Tx/Rx pins and the STM32 MC Workbench tool to monitor the data.
STMCWB Monitoring1.png

2.16 How to make the current more sinusoidal when the motor spins?

One possible cause is that the PI gains of the speed regulator are incorrect.

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, an example is described as follows:

  1. Run the motor and connect it to the STM32 MC Workbench,
  2. Open the Monitor mode and switch the plotter window on,
  3. In the “Final ramp speed” box, enter the new reference speed (for example change speed from 2 000 RPM to 4 000 RPM).
  4. In the plotter windows, check the measured speed reaction. It may exhibit a fast reaction but present oscillation around final value, or have a slow reaction, refer to the following solutions:
  • 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.
STMCWB Plotting1.png

2.18 How to connect ICS with the MC FW library?

Our implemented ICS requires usage on 2 phases from a 3 phase power supply.

The STM32 MC FW library operates only on Phase U and Phase V, this is where the user must connect each ICS.

2.19 Why use the FOC as opposed to a 6-Steps control for PMSM drive?

The FOC brings the following benefits :

  • Better energy efficiency;
  • Improver responsiveness of speed control;
  • Precise positioning control;
  • Lower acoustic noise.

2.20 Why use the 3-Shunts as opposed to a 1-Shunt resistor implementation for current measurement?

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

However, some motor (for example a low inductance motor) require current measurements on two phases simultaneously. Only the 3-Shunts implementation manage this configuration.

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 dual drive motors?

Yes, the STM32 MC SDK supports 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 provide project examples using FOC or 6-Steps control for PMSM drive?

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

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