How to use expansion board based on the stsafe-a110 secure element (14 pages)
Summary of Contents for ST STM32
Page 1
A prerequisite for using this library is basic knowledge of the C programming language, three phase motor drives and power inverter hardware. In-depth knowledge of STM32 functions is only required for customizing existing modules and for adding new ones for complete application development.
Firmware package architecture overview ........19 How to identify the six-step library version ........22 Getting started with the STM32 six-step firmware library ..23 Designing an application at user level using the firmware library32 Run a different BLDC motor ............32 DAC settings for debug ..............
Page 3
UM2124 List of tables List of tables Table 1: List of acronyms ..........................5 Table 2: Six-step firmware library version....................6 Table 3: ROM and RAM requirements ....................... 6 Table 4: Main mapped peripherals ......................24 Table 5: Header file basic parameters ...................... 24 Table 6: Header file advanced parameters (open loop control) ...............
Page 4
List of figures UM2124 List of figures Figure 1: BLDC motor control sequence ....................8 Figure 2: six-step phase voltage with BEMF sequence and PWM modulation .......... 8 Figure 3: Current mode control ......................... 10 Figure 4: ETR function on current mode control ..................10 Figure 5: Voltage mode control .........................
UM2124 Acronyms and abbreviations Acronyms and abbreviations Table 1: List of acronyms Acronym Description acceleration constant application programming interface autoreload register BEMF back electromotive force BLDC brushless DC motor digital to analog converter direct current external trigger integrated development environment PMSM permanent magnet synchronous motor pulse-width modulation...
The BLDC software library source code is available on www.st.com. The six-step library is included in two different firmware packages called X-CUBE-SPN7 (tailored for X-NUCLEO-IHM07M1) and X-CUBE-SPN8 (tailored for X-NUCLEO-IHM08M1) which provide the compliance with STM32 ODE in STM32 Nucleo expansion platforms. The main library features are: •...
X-CUBE-SPN7 or X-CUBE-SPN8 firmware packages from www.st.com. open the project workspace from the IDE tool available (IAR EWARM, Keil MDK- ARM v.5 or AC6 Workbench) choosing the right STM32 Nucleo development board. change the motor and drive parameters...
Implementation of six-step motor control UM2124 algorithm in STM32 Nucleo microcontroller Implementation of six-step motor control algorithm in STM32 Nucleo microcontroller Introduction to BLDC theory A brushless three phase motor is made of a fixed part (a three winding set called "stator") and a mobile part (containing a permanent magnet called "rotor").
UM2124 Implementation of six-step motor control algorithm in STM32 Nucleo microcontroller Rotor synchronization The BLDC drive is a synchronous control drive: the maximum efficiency is achieved if the commutation between two consecutive steps is performed only when the rotor is in the right spatial position, which occurs when the BEMF signal and the phase current are synchronized.
Implementation of six-step motor control UM2124 algorithm in STM32 Nucleo microcontroller Figure 3: Current mode control shows how the ETR works during the Figure 4: "ETR function on current mode control" normal operation. The red line is the motor current regulated at a fixed current reference (green).
UM2124 Implementation of six-step motor control algorithm in STM32 Nucleo microcontroller 3.3.2 Voltage mode control In the voltage mode driving method, the loop generates the output through a PI regulator which compares the speed reference to the actual speed motor feedback. No ETR function is needed because the output calculates the new duty cycle value of PWM signals.
Implementation of six-step motor control UM2124 algorithm in STM32 Nucleo microcontroller 3.3.3 Rotor speed measurement The sinusoidal and the trapezoidal motor structures are mentioned in this document. The motor structure can be recognized by rotating the motor by hand and connecting a probe to two motor phases.
UM2124 Implementation of six-step motor control algorithm in STM32 Nucleo microcontroller Figure 7: Trapezoidal construction The rotor magnetic field produces a BEMF signal in the stator windings. If the motor is intrinsically sinusoidal or trapezoidal, the induced BEMF signals are periodic and their frequency is proportional to the frequency of the motor turns.
Implementation of six-step motor control UM2124 algorithm in STM32 Nucleo microcontroller Figure 8: High and low frequency timer signals 3.3.4 Commutation, demagnetization delay and zero crossing event Since the BLDC is a synchronous motor, the drive main objective is to ensure the rotor position synchronization with the stator magnetic field.
UM2124 Implementation of six-step motor control algorithm in STM32 Nucleo microcontroller Figure 9: BEMF signal and zero crossing detection Figure 10: Demagnetization time This method is managed through firmware (see Figure 11: "Demagnetization: delay time (N=3)"). Two different modes have been implemented, one is based on look-up-table and one is based on the current step time duration multiplied by a constant.
Implementation of six-step motor control UM2124 algorithm in STM32 Nucleo microcontroller Figure 11: Demagnetization: delay time (N=3) Figure 12: Demagnetization: delay time (N=2) 16/39 DocID029868 Rev 1...
UM2124 Implementation of six-step motor control algorithm in STM32 Nucleo microcontroller 3.3.5 Zero crossing detection method In order to synchronize the BLDC motor with the driver, when the BEMF signal becomes equal to the motor neutral voltage a zero crossing point occurs.
Implementation of six-step motor control UM2124 algorithm in STM32 Nucleo microcontroller 3.3.6.1 Alignment phase During the alignment phase, the rotor is forced at a specified position through a specific switch configuration. A fixed current (managed by firmware) is maintained to move the rotor at the closest pole pair position.
UM2124 X-CUBE-SPN7 and X-CUBE-SPN8 software expansion for STM32Cube X-CUBE-SPN7 and X-CUBE-SPN8 software expansion for STM32Cube Firmware package architecture overview The firmware example in X-CUBE-SPN7 and X-CUBE-SPN8 is provided for three different IDE tools, IAR EWARM, Keil MDK-ARM, AC6 Workbench. In this case the IAR IDE workspace appears as shown in the following figure.
X-CUBE-SPN7 and X-CUBE-SPN8 software UM2124 expansion for STM32Cube Figure 16: X-CUBE-SPN7 software architecture Figure 17: X-CUBE-SPN8 software architecture The software architecture is mainly composed by: • Middleware • Examples • Driver (BSP/Component). Since the X-NUCLEO-IHM07M1 contains the L6230 driver and the X-NUCLEO-IHM08M1 contains the L6398 driver, in the firmware package, inside BSP/Components, the specific driver is provided according to the power board used (see Figure 18: "X-CUBE-SPN8...
(6Step_Lib.c/h) and interface files (stm32f302_ihm0xm1.c/h). The interface file includes the map of STM32 MCU peripherals used (for instance, advanced TIMx, general TIMx, ADCx, DACx, UART etc.) to operate with the MC six-step library. This file must be updated...
X-CUBE-SPN7 and X-CUBE-SPN8 software UM2124 expansion for STM32Cube How to identify the six-step library version In order to identify the version of six-step firmware library it is recommended to open the “6Step_Lib.c” file and check for the versioning as shown in the following figure. Figure 19: six-step library version 22/39 DocID029868 Rev 1...
STM32CubeMX. The stm32F302_nucleo_ihm08m1.c file contains all code with specific hardware dependencies and the initialization function that depends on the STM32 Nucleo board or microcontroller used. The stm32F302_nucleo_ihm08m1.h file shows the list of the real MCU peripherals used (for instance TIM1, ADC1, DAC1). It is the interface between the MCU and the six-step library: for instance, if the high frequency timer (PWM) is TIM1, this file maps the “htim1”...
Getting started with the STM32 six-step firmware UM2124 library The table below shows the list of the main peripherals mapped: Table 4: Main mapped peripherals Six-step library name MCU structure name #define HF_TIMx htim1 #define LF_TIMx htim6 #define ADCx hadc1...
UM2124 Getting started with the STM32 six-step firmware library Unit / max. and Constant name Description typical value Maximum number of steps for acceleration 16 bit during the open loop phase. If the closed unsigned NUMBER_OF_STEPS loop validation is not completed at the end of...
Getting started with the STM32 six-step firmware UM2124 library Table 7: Six-step advanced parameters for motor driving (current mode) Closed loop control Current mode Unit msec, 16 bit SPEED_LOOP_TIME Time for new execution of speed loop unsigned KP_GAIN Proportional term of PI regulator...
UM2124 Getting started with the STM32 six-step firmware library Table 8: Six-step advanced parameters for motor driving (voltage mode) Closed loop control Voltage mode Unit KP_GAIN_VM Proportional term of PI regulator 16 bit signed KI_GAIN_VM Integral term of PI regulator...
Getting started with the STM32 six-step firmware UM2124 library Closed loop control Voltage mode Unit Time (msec) to keep the motor in stop msec, 16 bit DEMO_STOP_TIME mode unsigned Notes: This parameter is available for firmware v.1.1.0 only or higher This time is available if the DEMO mode is selected during the compiling phase 6Step_Lib.c contains the six-step library and the main functions are listed in the following...
Page 29
UM2124 Getting started with the STM32 six-step firmware library Low priority task: it is dedicated to the low frequency function (SysTick timer for Speed Loop timing) and it is managed at the lowest priority. The MC_SysTick_SixStep_MediumFrequencyTask() is called at SysTick frequency (1 msec), while the speed loop function is managed by SPEED_LOOP_TIME (msec) defined in the MC_SixStep_param.h file.
UM2124 Getting started with the STM32 six-step firmware library Figure 23: six-step main firmware routines: medium priority task Figure 24: six-step main firmware routines: high priority task DocID029868 Rev 1 31/39...
STM32 Nucleo board rotate the potentiometer at the minimum value power on the X-NUCLEO board and press the blue button on the STM32 Nucleo board. 32/39 DocID029868 Rev 1...
UM2124 Designing an application at user level using the firmware library If the values modified above are correct and the default parameters are good for the current motor connected, the system starts as shown in the following figure. Figure 25: New motor running Figure 22: "six-step main firmware routines: low priority task"...
Page 34
Designing an application at user level using the UM2124 firmware library Figure 26: Motor successful initialization Figure 27: Motor successful initialization zoom 34/39 DocID029868 Rev 1...
Page 35
UM2124 Designing an application at user level using the firmware library In case of different current views, unsuccessful motor iniziatization or fault (visible through the SIXSTEP_parameters.STATUS variable), it is suggested to adjust the parameters mentioned above as follows: Current (peak) control during the open loop check if TIME_FOR_ALIGN (alignment time) has the right duration to align the motor check if the NUM_POLE_PAIRS is correct check STARTUP_CURRENT_REFERENCE (current peak threshold) during the open...
By default PA4 pin is configured, it is accessible through the ST morpho connector and it is typically connected to DAC_CH1 (NUCLEO-F302R8). If the user chooses a different pin or peripheral, the stm32Fxxx_nucleo_ihm0xm1.h file must be modified as described in Section 5: "Getting started with the STM32 six-step firmware...
Page 37
UM2124 Designing an application at user level using the firmware library The MC_EXT_button_SixStep() is the command called by the HAL_GPIO_EXTI_Callback(), see the file stm32Fxxx_nucleo_ihm0xm1.c associated to an external push button. It sends a start or a stop motor function on the basis of the control previous status: for instance, if the six-step algorithm is in run state, it stops the control;...
Revision history UM2124 Revision history Table 12: Document revision history Date Version Changes 09-Nov-2016 Initial release. 38/39 DocID029868 Rev 1...
Page 39
ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.
Need help?
Do you have a question about the STM32 and is the answer not in the manual?
Questions and answers