6-step - Optimization and troubleshooting of sensor-less firmware parameters

Revision as of 07:18, 6 October 2023 by Registered User

1. Introduction

This document describes how to optimize the configuration parameters for 6-step sensor-less algorithm to obtain a smooth and fast start-up procedure, a stable closed loop behavior. Additionally, it will be explained how to reach a proper switch between Back-emf zero crossing detection during PWM OFF-time and PWM ON-time when spinning the motor at high speed with voltage mode driving technique. For further details about 6-step firmware algorithm and voltage/current driving technique, please refer to the related user manual included in the X-CUBE-MCSDK [1] documentation package.

2. Acronyms and abbreviations

Table 1: Acronyms and abbreviations
Acronym Description
MCSDK Motor Control Software Development Kit (X-CUBE-MCSDK)
HW Hardware
IDE Integrated Development Environment
MCU Micro-Controller Unit
GPIO General Purpose Input Output
ADC Analog to Digital Converter
VM Voltage Mode
SL Sensors-Less
BEMF Back Electromotive Force
FW Firmware
ZC Zero-Crossing
GUI Graphical user interface
MC Motor control
OCP Over current protection
PID Proportional-integral-derivative (controller)
SDK Software development kit
UI User interface
MC Workbench Motor control workbench tool, part of MCSDK
MC Profiler Motor control profiler tool, part of MCSDK
Motor Pilot Motor Pilot tool, part of MCSDK

3. Overview

In the 6-step sensor-less driving mode, the firmware exploits the Back Electromotive Force (BEMF) sensed at the floating phase. The position of the rotor is obtained by detecting the zero-crossing of the BEMF. This is commonly done using an ADC as shown in Figure 1. In particular, when the magnetic field of the rotor crosses the high impedance phase, the corresponding BEMF voltage changes its sign (zero-crossing). The BEMF voltage can be scaled at the ADC input, thanks to a resistor network that divides the voltage coming from the motor phase.

However, since the BEMF signal is proportional to the speed, the rotor position cannot be determined at start-up or at very low speed. Therefore, the motor must be accelerated in open-loop until a sufficient BEMF voltage, that allows the synchronization of the step commutation with the rotor position, is reached.

In the following paragraphs, the start-up procedure and the closed loop operation together with the parameters to tune them will be described.

Figure 1: Motor with sensor-less circuit

3.1. BEMF Zero Crossing detection

The Back-EMF waveform of a brushless motor changes along with the rotor position and speed and is in a trapezoidal shape. Figure 2 shows the waveform of the current and back-EMF for one electrical period, where the solid line denotes the current (ripples are ignored for the sake of simplicity), the dashed line represents the back electromotive force, and the horizontal coordinate represents the electric perspective of motor rotation.

Figure 2: BLDC current and back-EMF waveforms


The middle of every two phase-switching points corresponds to one point whose back electromotive force polarity is changed, the zero-crossing-point. Once the zero-crossing point is identified, the phase-switching moment is set after an electrical delay of 30°. In order to detect the zero-crossing of the BEMF the center tap (the point where the three motor phases are connected together) voltage has to be known. Some motors make the center tap available. In other cases, it can be reconstructed through the phase voltages. The 6-step algorithm here presented exploits the presence of a BEMF sensing network connected to the motor phases that allows to calculate the center tap voltage.

Two different strategies are available for the identification of the zero-crossing point:

• Back-EMF sensing during the PWM OFF-time

• Back-EMF sensing during the PWM ON-time (currently supported in voltage mode only)

During the PWM OFF-time, the floating phase voltage is acquired by the ADC. Since no current is flowing in the floating phase and the other two are connected to ground, when the BEMF crosses zero in the floating phase, it has equal and opposite polarity on the other phases: the center tap voltage is therefore zero. Hence, the zero-crossing point is identified when the ADC conversion raises above (or falls below) a defined threshold.

On the other hand, during the PWM ON-time, one phase is connected to the bus voltage and one to ground (Figure 3). In this condition, the center tap voltage reaches half of the bus voltage value when the BEMF in the floating phase is zero. Like previously, the zero-crossing point is identified when the ADC conversion raises above (or falls below) a defined threshold that corresponds to VS / 2.

Figure 3 : BEMF sensing during PWM ON-time


3.2. BEMF sensing network design

In Figure 4 the commonly used network to sense the BEMF is shown. Its purpose is to divide the motor phase voltage to be properly acquired by the ADC. R2 and R1 value should be chosen according to the bus voltage level. User should be aware that implementing a R1 / (R2 + R1) ratio much lower than needed, the BEMF signal may result in too low and the control not robust enough.

On the other hand, a ratio higher than needed would lead in frequent turning-on/off of the D1 protection diodes whose recovery current may inject noise. The recommended value is:

STM32 MC SL Parameter Optimization Formula1.png

Very low values for R1 and R2 should be avoided to limit current tapped from the motor phase.

R1 is sometimes connected to a GPIO instead of GND, allowing the network to be run-time enabled or disabled.

In 6-step firmware the GPIO is always in reset state and the network enabled. However, the eventual presence of D3 must be considered when setting the BEMF thresholds for sensing during the PWM on-time: it usually adds 0.5÷0.7V to the ideal threshold.

STM32 MC SL Parameter Optimization Formula2.png

C1 is for filtering purposes and should not limit the signal bandwidth in the PWM frequency range.

D4 and R3 are for fast discharge of BEMF_SENSING_ADC node during PWM commutations especially in high voltage boards.

D1 and D2 diodes are optional and should be added only in case of risk of violating the BEMF sensing ADC channel maximum ratings.


Figure 4 : BEMF sensing network

4. Optimization of control algorithm parameters

4.1. Start-up procedure

The start-up procedure is usually made up of a sequence of three stages:

1. Alignment. The rotor is aligned at a predetermined position.

2. Open loop acceleration. The voltage pulses are applied in a predetermined sequence to create a magnetic field that will cause the rotor to start rotating. The sequence’s rate is progressively increased to allow the rotor to reach a certain speed.

3. Switch-over. Once the rotor has reached a certain speed, the algorithm switches to closed-loop 6-step control sequence to maintain control of the motor's speed and direction.

As shown in Figure 5, the user can customize the start-up parameters in the MC Workbench before generating the code. Two different driving modes are available:

• Voltage mode. The algorithm controls the speed by varying the duty cycle of the PWM applied to the motor phases: a target Phase Voltage is defined for each segment of the start-up profile

• Current mode. The algorithm controls the speed by varying the current that flows in the motor phases: a Current target is defined for each segment of the start-up profile


Figure 5 : Start-up parameters in the MC Workbench

4.1.1. Alignment

In Figure 5, the Phase 1 always corresponds to the alignment step. The rotor is aligned to the 6-step position closest to the “Initial electrical angle”.

It is important to note that, by default, the duration of the Phase 1 is 200ms. During this step the duty cycle is linearly increased to reach the target Phase Voltage (Phase Current, if the current driving mode is selected). However, with bulky motors or in case of high inertia the suggested duration or even the target Phase Voltage/Current may not be sufficient to properly start the rotation.

In Figure 6, a comparison between a wrong alignment condition and a proper one is provided. If the target value or duration of Phase 1 are not enough to force the rotor in the starting position, the user can see the motor vibrating without starting to rotate while the current absorption increases. The current during the first period of the start-up procedure increases but the torque is not sufficient to overcome the inertia of the motor. The user can see at the top of the Figure 6 (A) the current increasing but without any evidence of BEMF: the motor is stalled. Once the acceleration step is started, the uncertain position of the rotor will prevent the algorithm to complete the start-up procedure and run the motor.


Increasing the Phase Voltage/Current during Phase 1 may fix the issue.

Figure 6 : Alignment– troubleshooting


In voltage mode, the target voltage during the start-up can be customized with the Motor Pilot without the need to regenerate the code. In the Motor Pilot, rev-up section, the same acceleration profile of Figure 1 is reported (see Figure 7). Please note that here the Phase Voltage can be shown as the pulse set into the timer register (S16A unit) or as the corresponding to output voltage (Vrms unit).

Once the user finds the proper values that suit best his motor, they can be feedbacked into the MC Workbench project to regenerate the code to apply this default value. The below formula explains the correlation between Phase Voltage in Vrms and S16A units.

STM32 MC SL Parameter Optimization Formula3.png

Where

STM32 MC SL Parameter Optimization Formula4.png

In current mode, in the Motor Pilot GUI, the target current is only shown in S16A and its conversion in ampere depends on the shunt value and the amplification gain used in the current limiter circuitry.

Figure 7 : Start-up parameters in the Motor Pilot


4.1.2. Open loop acceleration

In Figure 5, the Phase 2 corresponds to the acceleration phase. The 6-step sequence is applied to speed up the motor in open loop, hence, the rotor position is not synchronized with the 6-step sequence. The phase currents are then higher than optimum and the torque lower.

In the MC Workbench (Figure 5) the user can define one or more acceleration segments: in particular in case of a bulky motor, it is recommended to accelerate it with a slower ramp to overcome the inertia before performing a steeper ramp. During each segment the duty cycle is linearly increased to reach the final target Phase Voltage/Current of that segment forcing the commutation of the phases at the corresponding speed indicated in the same configuration table.

In Figure 8, a comparison between an acceleration with too low phase voltage (A) and a proper one (B) is provided.

Figure 8 : Acceleration – troubleshooting 1


If the target voltage/current of one phase or its duration are not enough to allow the motor to reach that corresponding speed, the user can see the motor stop spinning and start vibrating. At the top of Figure 8, the current suddenly increases when the motor stalls while, when proper accelerated, the current increase is without discontinuities. Once the motor stops the start-up procedure fails.


Increasing the Phase Voltage/Current may fix the issue.


On the other hand, if the set Phase Voltage/Current is too high, since the motor is running inefficiently in open-loop, the current may rise and reach the overcurrent. The motor suddenly stops, and an overcurrent alarm is shown by the Motor Pilot. The behaviour of the current is shown in Figure 9

Figure 9 : Acceleration – troubleshooting 2


Decreasing the Phase Voltage/Current may fix the issue.

As the alignment step, the target voltage/current during the start-up can be run-time customized with the Motor Pilot without the need to regenerate the code and feedbacked into the MC Workbench project when the proper setting is identified.

4.1.3. Switch-over

The last step of the start-up procedure is the switch-over. During this step the algorithm exploits the sensed BEMF to synchronize the 6-step sequence with the rotor position. The switch-over starts in the segment indicated in the parameter indicated in Figure 10 and configurable in the sensor-less start-up parameters section of the MC Workbench.

Figure 10 : Switch-over start condition


After a valid BEMF zero crossing detection signal (to fulfil this condition see section 2.1), the algorithm switches to close loop operation. The switch-over step may fail due to the following reasons:

• Switch-over speed is not properly configured

• PI gains of the speed loop are too high

• Thresholds to detect the BEMF zero-crossing event are not properly set


4.1.3.1. Switch-over speed not properly configured

The speed at which the switch over starts is by default the same as the initial target speed that can be configured in the Drive Settings section of the MC Workbench. The user should be aware that, as soon as the speed loop is closed, the motor will be instantaneously accelerated from the switch-over speed to the target speed. If these two values are very far apart, an overcurrent failure may rise.

4.1.3.2. PI gains of the speed loop too high

During switch-over, the algorithm moves from forcing a predefined sequence to measure the speed and calculate the output values accordingly, compensating the actual speed that is the result of the open loop acceleration. If the PI gains are too high, a temporary instability can be experienced but it can lead to overcurrent failure if exaggerated.

Figure 11 shows and example of such instability during transition from open-loop to close-loop operation.

Figure 11 : Switch-over instability


4.1.3.3. Wrong BEMF thresholds

If wrong BEMF thresholds are set, the zero crossing is detected either in advance or late. This will provoke two main effects:

1. The waveforms are asymmetric and the control inefficient leading to high ripples of torque (Figure 12)

2. The speed loop becomes unstable trying to compensate the ripples of torque

The user would experience unstable speed control and, in the worst cases, a de-synchronization of the motor driving with the control leading to overcurrent event.

The proper setting of BEMF thresholds is crucial for good performances of the algorithm. Thresholds also depend on the bus voltage value and sensing network. Refer to Section 2.1 to check how align voltage levels to the nominal one set in the MC Workbench is recommended.

Figure 12 : Effect of wrong BEMF thresholds


4.2. Closed loop operation

If the motor completes the acceleration phase, the BEMF zero crossing is detected, the rotor is synchronized with the 6-step sequence and closed-loop operation is obtained. However, further parameter optimization can be carried out to improve the performances. For instance, as described in the previous paragraph 3.1.3 (“Wrong BEMF thresholds”), the speed loop, even if working, may appear unstable and BEMF thresholds may need some refinement. Additionally, the following aspects should be taken into consideration if motor is requested to work at high speed or driven with high PWM duty cycle:

• PWM frequency

• Speed loop PI gains

• Phase demagnetization blanking period

• Delay between zero crossing and step commutation

• Switch between PWM OFF-time and ON-time sensing


4.2.1. PWM frequency

Sensor-less 6-step algorithm performs an acquisition of the BEMF every PWM cycle. In order to properly detect the zero-crossing event, a sufficient number of acquisitions is required. As a role of thumb, for proper operation, at least 10 acquisitions over 60 electrical angle grants good and stable rotor synchronization.

Therefore:

STM32 MC SL Parameter Optimization Formula5.png

where:x

STM32 MC SL Parameter Optimization Formula6bis.png

4.2.2. Speed loop PI gains

Speed loop PI gains affects the responsiveness of the motor to any command of acceleration of deceleration. A theoretical description of how a PID regulator works is beyond the scope of this document. However, the user should be aware that speed loop regulator gains can be changed run-time through the Motor Pilot and be adjusted as desired.

Figure 13 : PI gains in Motor Pilot

4.2.3. Phase demagnetization blanking period

The demagnetization of the floating phase is a period after the change of phases energization during which, due to the current discharge (Figure 14), the Back-EMF reading is not reliable. Therefore, the algorithm should ignore the signal before it is elapsed.

This period is defined in the MC Workbench as a percentage of a step (60 electrical degrees) and can be run-time changed through the Motor Pilot as shown in the Figure 15. The higher the motor speed, the faster the demagnetization period: the demagnetization by default reaches a lower limit set to 3 PWM cycles at 2/3 of the maximum rated speed.

If the phase inductance of the motor is low and doesn’t require much time to demagnetize, the user can reduce the masking period or the speed at which the minimum period is set.

However, it is not recommended to lower the masking period below 2 - 3 PWM cycles because the control can incur sudden instability during step commutation.

Figure 14 : Demagnetization of the phase


Figure 15 : Demagnetization period in Motor Pilot

4.2.4. Delay between BEMF zero crossing and step commutation

Once the BEMF zero crossing event has been detected, the algorithm normally waits 30 electrical degrees until step sequence commutation (Figure 16), in this way the zero crossing is positioned at the mid-point of the step targeting the maximum efficiency.

Figure 16 : Zero crossing delay definition (30degrees nominal)

Since the accuracy of the zero crossing detection depends on the number of acquisitions, hence on the PWM frequency (see Section 3.2.1), at high speed the accuracy of its detection may become relevant, generating an evident asymmetricity of the waveforms and the distortion of the current (see Figure 17). This can be compensated reducing the delay between zero crossing detection and step commutation. Zero crossing delay can be run-time changed by the user through the Motor Pilot as shown in Figure 18.

Figure 17 : Effect of non-compensated zero-crossing delay


Figure 18 : Zero crossing delay in Motor Pilot

4.2.5. Switch between PWM OFF-time and ON-time sensing

While increasing the speed or the load current (i.e. motor’s output torque), the duty cycle of the PWM driving increases. Thus, time for sampling the BEMF during the OFF-time is reduced. In order to reach 100% of the duty cycle, the ADC conversion is triggered during the ON time of the PWM, thus switching from BEMF sensing during the PWM OFF-time to PWM ON-time.

A wrong configuration of the BEMF thresholds during ON-time leads to the same issues described in the section 3.1.3 (“Wrong BEMF thresholds”).

By default, BEMF ON-sensing thresholds are set to half of the bus voltage (see section 2.1). The user should consider that actual thresholds depend on the bus voltage value and sensing network. So, follow indications in Section 2.1 and take care to align voltage level to the nominal one set in the MC Workbench.


Values of the thresholds and PWM duty cycle at which the algorithm swaps between OFF and ON-sensing is run-time configurable through the Motor Pilot (Figure 19) and available in Voltage mode driving only.

Figure 19 : PWM on-sensing parameters in Motor Pilot

5. Troubleshooting

What do I have to take care of to properly spin a motor with sensor-less 6-step algorithm?'

Spinning a motor with sensor-less 6-step algorithm implies being able to properly detect the BEMF signal, accelerate the motor and synchronize the rotor with the control algorithm.

The proper measurement of the BEMF signals lies in the effective design of the BEMF sensing network (see Section 2.1).

The target voltage (voltage mode driving) or current (current mode driving) during start-up sequence depends on the motor parameters. The definition (and eventually the duration) of the phase voltage/current during alignment, acceleration and switch-over steps are crucial for a successful procedure (see Section 3).

In the end, the synchronization of the rotor and the ability to increase the speed motor up to the rated speed depends on the optimization of the PWM frequency, BEMF thresholds, demagnetization period and delay between zero crossing detection and step commutation, as described in Section 3.2


'What is the right value of the BEMF resistor divider?'

The user should be aware that a wrong BEMF resistor divider value may remove any chance of properly driving the motor. For further details on hot to design the BEMF sensing network, please refer to Section 2.1


How do I configure the start-up procedure?'

To optimize the start-up process, it is recommended to increase the duration of each step of the rev-up phase to several seconds. It will then be possible to understand whether the motor properly accelerates or at which speed/step of the open-loop procedure fails.

It is not advisable to accelerate high inertia motor with a too steep ramp.

If the configured phase voltage or current is too low, the motor will stall, if it is too high overcurrent will be triggered. Gradually increasing the phase voltage (voltage mode driving) or current (current mode driving) during the alignment and acceleration steps will allow the user to understand the range of working of its motor and finding the optimum.

When it comes to switch to closed loop operation, at first the gains of the PI should be reduced to exclude that a loss of control or instability is due to speed loop. At this point being sure that BEMF sensing network is properly designed (se Section 2.1) and BEMF signal is properly acquired is crucial. The user can access the reading of the BEMF and plot it in the Motor Pilot (see Figure 20) by selecting the available registers BEMF_U, BEMF_V and BEMF_U in the ASYNC plot section of the tool.

Once the motor is in RUN state, the speed loop controller gains can be optimized. For further details or parameter optimization, see Sections 3 and 3.2

Figure 20 : BEMF signals in Motor Pilot


What can I do if the motor doesn’t move at start-up?'

At start-up a linearly increasing voltage (voltage mode driving) or current (current mode driving) is provided to the phases of the motor in order to align it at a known and predefined position. If this voltage is not high enough (especially with motors with a high inertia constant), the motor doesn’t move and the procedure fails. For further information about possible solutions, please refer to Section 3.1.1


What can I do if the motor doesn’t complete the acceleration phase?'

Like for the alignment phase, the motor is accelerated in open loop by applying a linearly increasing voltage (voltage mode driving) or current (current mode driving) to the phases of the motor. Default values don’t consider eventual applied mechanical load or motor constants are not accurate and/or known. Therefore, the acceleration procedure may fail with motor stall or overcurrent event. For further information about possible solutions, please refer to Section 3.1.2


Why doesn’t the motor switch over into closed speed loop?'

If the motor properly accelerate to target speed but it suddenly stops, something may be wrong in the BEMF threshold configuration or PI controller gains. Please refer to the Section 3.1.3 for further details


Why does the speed loop look unstable?'

An increase of the noise of the measurement with the speed is expected since the higher the speed is, the lower the number of BEMF samples for zero crossing detection and, consequently, the accuracy of its calculation. However, an excessive instability of the speed loop may be also the symptom of wrong BEMF threshold or PI gains not properly configured as highlighted in Section 3.1.3


How can I increase the maximum reachable speed?'

Maximum reachable speed is usually limited by several factors: PWM frequency, loss of synchronization due to excessive demagnetization period or wrong delay between zero crossing detection and step commutation, inaccurate BEMF thresholds. For further details on how to optimize these elements please refer to Sections 3.2.1, 3.2.3, 3.2.4 and 3.2.5.


Why does the motor suddenly stop at a certain speed?'

It is likely due to an inaccurate PWM on-sensing BEMF threshold configuration. Please refer to Section 3.2.5 for further details.


No categories assignedEdit