Advertisement

Quick Links

Using STM32 motor control workbench with STSPIN32F0
Introduction
The STSPIN32F0 and STSPIN32F0A are systems-in-package providing an integrated
solution suitable for driving 3-phase BLDC motors using different driving modes. The
integrated MCU (STM32F031x6) allows the performance of field-oriented control.
This document explains how to drive the STSPIN32F0 or STSPIN32F0A with FOC
algorithms, using the STM32 motor control workbench software to generate all the
parameter header files, to configure the STM32 PMSM FOC library according to application
needs.
To drive a motor with FOC algorithms using the STSPIN32F0 or STSPIN32F0A device,
follow this simple workflow:
1.
Set up the hardware.
2.
Use STM32 motor control workbench to configure the library and generate the code.
3.
Create the library and download the firmware.
4.
Control the motor.
October 2018
Figure 1. STM32 motor control workbench start window
DocID030267 Rev 4
UM2168
User manual
and STSPIN32F0A
1/30
www.st.com
30

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the UM2168 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for ST UM2168

  • Page 1 UM2168 User manual Using STM32 motor control workbench with STSPIN32F0 and STSPIN32F0A Introduction The STSPIN32F0 and STSPIN32F0A are systems-in-package providing an integrated solution suitable for driving 3-phase BLDC motors using different driving modes. The integrated MCU (STM32F031x6) allows the performance of field-oriented control.
  • Page 2: Table Of Contents

    ......... . . 3 Create new project for ST STEVAL-SPIN3201 board ....3 Create new project for ST STEVAL-SPIN3202 board .
  • Page 3: Set Up Hardware

    Set up hardware Set up hardware  Choose the board according to the target: you can use the ST STEVAL-SPIN3201 or STEVAL-SPIN3202 boards or you can use a custom board;  Connect the board, power supply and plug in your motor.
  • Page 4: Create New Project For St Steval-Spin3202 Board

    Using the STEVAL-SPIN3201 device, the configuration parameters for the Power Stage, Drive Management, and Control Stage are already set. Create new project for ST STEVAL-SPIN3202 board The STEVAL-SPIN3202 board is a three-phase brushless DC motor driver board based on the STSPIN32F0A, a 3-phase controller with integrated STM32 MCU.
  • Page 5 UM2168 Use STM32 motor control workbench to configure the library and generate the code Using the STEVAL-SPIN3202 device, the configuration parameters for the Power Stage, Drive Management and Control Stage are already set. Figure 4. Parameter window for STEVAL-SPIN3202 Figure 5. Pre-configured motor window...
  • Page 6: Create A New Project For Stspin32F0/A Mounted On A Custom Board

    Use STM32 motor control workbench to configure the library and generate the code UM2168 Create a new project for STSPIN32F0/A mounted on a custom board To create a new project for STM32 motor control workbench using a custom board, follow the procedure: ...
  • Page 7 UM2168 Use STM32 motor control workbench to configure the library and generate the code A configuration window appears, allowing the parameters to be set for: – “Motor” – “Power Stage” – “Drive Management” (i.e. FOC algorithm configuration) – “Control Stage” (i.e. MCU configuration) ...
  • Page 8 Use STM32 motor control workbench to configure the library and generate the code UM2168 Table 2. STSPIN32F0A: Accessible pins for integrated MCU Name Function MCU PF0 MCU PF1 NRST MCU reset pin MCU PA0 MCU PA1 MCU PA2 MCU PA3...
  • Page 9: Customize Parameters For Application Needs

    UM2168 Use STM32 motor control workbench to configure the library and generate the code Customize parameters for application needs When a project is opened by the STM32 motor control workbench, a configuration window appears allowing the user to easily manage parameters for the FOC firmware library. There are 4 families of parameters that should be changed to best fit the characteristics of the application.
  • Page 10: Power Stage Parameters

    Use STM32 motor control workbench to configure the library and generate the code UM2168 Figure 9. Motor parameters window 2.4.2 Power stage parameters There is a family of parameters which are not covered in Figure 10 that are related to the hardware of the board.
  • Page 11 UM2168 Use STM32 motor control workbench to configure the library and generate the code Using the STEVAL-SPIN3201 or STEVAL-SPIN3202 device, the Power Stage parameters are already set. If the supply voltage is changed or if the hardware of the board is modified (changing MOSFETs, adjusting the gain of the sensing circuitry, etc.) or if a custom board is...
  • Page 12 Use STM32 motor control workbench to configure the library and generate the code UM2168  In “Current Sensing” choose the sensing network. If the user wants to change the sensing circuit, they should also change the model used by the algorithm by changing the “Current reading topology”...
  • Page 13: Drive Management Parameters

    UM2168 Use STM32 motor control workbench to configure the library and generate the code Figure 14. Amplifying network gain calculator  Click on “Power Switches” and set their characteristics. Figure 15. Power switch parameters 2.4.3 Drive management parameters There is a family of parameters, shown in...
  • Page 14 Use STM32 motor control workbench to configure the library and generate the code UM2168 Figure 16. Drive management setting  In the Speed Sensing window choose “Sensor selection” to select the sensing algorithm you want to use (Figure 17). Figure 17. Sensor selection ...
  • Page 15 UM2168 Use STM32 motor control workbench to configure the library and generate the code Figure 18. Start-up parameters This is an example of a basic control of speed and current in open loop. The red line is the speed profile while the blue line is the current profile chosen by editing the parameters on the left of the graph.
  • Page 16 Use STM32 motor control workbench to configure the library and generate the code UM2168 Figure 19. : Advanced start-up parameters Figure 20. Drive settings window  To select the PWM frequency, right click on “Firmware Drive Management” and choose “Drive Settings”: note that the PWM frequency / Execution rate must be below 14 KHz, so adjust the Execution rate if you want to increase PWM frequency.
  • Page 17: Control Stage Parameters

    UM2168 Use STM32 motor control workbench to configure the library and generate the code Target speed for the application. The user can also set the Cut-off frequency for the stability of closed loop (Figure 20). 2.4.4 Control stage parameters There is a family of parameters, shown in...
  • Page 18 Use STM32 motor control workbench to configure the library and generate the code UM2168 Figure 22. MCU and clock frequency window  The “Digital I/O” →“Pin Map” (Figure 23), should follow the internal mapping of the device, shown in Table 3.
  • Page 19 24); the Pin Map has to be set as shown in Table Table 4. Hall sensor interface for STSPIN32F0 and for STSPIN32F0A TIM2 , A15 1. If you use the ST STEVAL-SPIN3201 or STEVAL-SPIN3202 board, choose CH1 = A0. 2. A15 available only for STSPIN32F0A. DocID030267 Rev 4 19/30...
  • Page 20 Table 5. Encoder interface for STSPIN32F0 TIM2 TIM3 A0 or A5 1. If you use the ST STEVAL-SPIN3201 board, choose TIM2 and CH1 = A0. Table 6. Encoder interface for STSPIN32F0A TIM2 , A5, A15 1. If you use the STEVAL-SPIN3202 board, choose CH1 = A0.
  • Page 21 USART1 Baud rate 9600 B6 or A2 or A14 B7, A3, A15 1. If you use the ST STEVAL-SPIN3201 or STEVAL-SPIN3202 board, choose TX = B6 and RX = B7. 2. A15 available only for STSPIN32F0A. DocID030267 Rev 4 21/30...
  • Page 22 Use STM32 motor control workbench to configure the library and generate the code UM2168 Figure 26. Serial communication for STEVAL-SPIN3201 or STEVAL-SPIN3202 boards  It is recommended to use the minimum Baud rate for the communication because a higher value could reflect on the functionality of the environment. Remember to match the Baud rate in the monitor window of the STM32 motor control workbench, when using UART connection.
  • Page 23: Create The Library And Download The Firmware

    UM2168 Create the library and download the firmware Create the library and download the firmware In this section the user can understand how to use the STM32 motor control workbench to create the code and control the motor. It is possible to customize the firmware via one of the supported different IDEs available on the STM32 motor control workbench.
  • Page 24 Create the library and download the firmware UM2168 In the generation window:  STM32CubeMx should be the latest version;  Choose your preferred Target Toolchain;  Choose HAL-Hardware Abstraction Layer in Driver Selection;  Click on Generate. The STM32 motor control workbench generates, in the user folder, the directory 'Application' (Figure 28).
  • Page 25: Using Stsw-Spin3201

    UM2168 Create the library and download the firmware Those folders contain: ®  Drivers: the HAL driver library and the CMSIS files from ARM  IDE WORKING FOLDER: this is the working folder of the IDE chosen in the Target...
  • Page 26: Compile And Download The Firmware

    Create the library and download the firmware UM2168 To use STSW-SPIN3201 on the STEVAL-SPIN3201 board, refer to UM2152 available on www.st.com. Compile and download the firmware After the generation of the application code, the library is ready to be compiled and downloaded.
  • Page 27: Control The Motor

    UM2168 Control the motor Control the motor The user can now control the motor through the STM32 motor control workbench:  Open STM32 motor control workbench  Click on the “Open Monitor” icon: to open the 'Monitor and spin control GUI' as shown in Figure Figure 31.
  • Page 28  Using the STM32 motor control workbench it is also possible to monitor the speed and change the variables of the algorithm in real time. For details of the use of the STM32 motor control workbench v5, see UM2374 and UM2380 available on www.st.com. 28/30 DocID030267 Rev 4...
  • Page 29: Revision History

    UM2168 Revision history Revision history Table 8. Document revision history Date Revision Changes 14-Feb-2017 Initial release. Updated note below Table 7 on page 21 (replaced 09-Mar-2017 “A3” by “B7”). 11-Apr-2018 Updated Section 3 on page Updated to Revision 5.2.0 of STM32 Motor Control SDK.
  • Page 30 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.

This manual is also suitable for:

Stm32Stspin32f0Stspin32f0a

Table of Contents