using st mc workbench with stspin32f0 - st.com · stage, control stage and ... three main...

20
April 2018 DocID030267 Rev 3 1/20 20 UM2168 User manual Using ST MC Workbench with STSPIN32F0 Introduction The STSPIN32F0 is a system-in-package providing an integrated solution suitable for driving three-phase BLDC motors using different driving modes. The integrated MCU (STM32F031x6) allows performance of field-oriented control. This document explains how to drive the STSPIN32F0 with FOC algorithms, using the ST Motor Control Workbench software to generate all the parameter header files, to configure the FOC FW library according to your application needs. To drive a motor with FOC algorithms using the STSPIN32F0 device, follow this simple workflow: 1. Set up the hardware. 2. Use the ST Motor Control Workbench to configure the library. Figure 1. ST Motor Control Workbench start window 3. Compile and download the firmware. www.st.com

Upload: vuthu

Post on 26-Aug-2018

244 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

April 2018 DocID030267 Rev 3 1/20

20

UM2168User manual

Using ST MC Workbench with STSPIN32F0

Introduction

The STSPIN32F0 is a system-in-package providing an integrated solution suitable for driving three-phase BLDC motors using different driving modes. The integrated MCU (STM32F031x6) allows performance of field-oriented control.

This document explains how to drive the STSPIN32F0 with FOC algorithms, using the ST Motor Control Workbench software to generate all the parameter header files, to configure the FOC FW library according to your application needs.

To drive a motor with FOC algorithms using the STSPIN32F0 device, follow this simple workflow:

1. Set up the hardware.

2. Use the ST Motor Control Workbench to configure the library.

Figure 1. ST Motor Control Workbench start window

3. Compile and download the firmware.

www.st.com

Page 2: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Contents UM2168

2/20 DocID030267 Rev 3

Contents

1 Set up hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Use ST Motor Control Workbench to configure library . . . . . . . . . . . . . 3

2.1 Create new project for ST STEVAL-SPIN3201 board . . . . . . . . . . . . . . . . 3

2.2 Create new project to configure library for custom STSPIN32F0 board . . 5

2.3 Motor parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.4 Power Stage parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.5 Drive Management parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.6 Control Stage parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3 Compile and download firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1 STSW-SPIN3201 FW presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.1 Common folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.2 Docs folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.3 Web folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.2 Generation of configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.3 Building and loading a customized firmware . . . . . . . . . . . . . . . . . . . . . . 17

3.4 Using the demonstration applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Page 3: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 3/20

UM2168 Set up hardware

20

1 Set up hardware

Choose the board according to the target: you can use the ST STEVAL-SPIN3201 board or you can use a custom board

Connect the board, power supply and plug in your motor.

2 Use ST Motor Control Workbench to configure library

The ST Motor Control Workbench can be used to configure the FW FOC library to use in your application. You can use the ST STEVAL-SPIN3201 board or you can use a custom board.

2.1 Create new project for ST STEVAL-SPIN3201 board

Open the ST Motor Control Workbench v4.3

Click on “New Project” and a parameter window will appear

Choose the “Inverter” board type and select the STEVAL-SPIN3201 from the drop-down list. In this way, the application automatically loads all the hardware-related parameters for the FOC library.

Figure 2. Parameter window for STEVAL-SPIN3201

From the motor list, you can select one of the pre-configured motors or select a generic starting model.

Page 4: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Use ST Motor Control Workbench to configure library UM2168

4/20 DocID030267 Rev 3

Figure 3. Pre-configured Motor window

Click OK. A new project is now created according to the starting parameters you selected.

A configuration window will appear, allowing you to set the parameters for:

– “Motor”

– “Power Stage”

– “Drive Management” (i.e. FOC algorithm configuration)

– “Control Stage” (i.e. MCU configuration)

Using the STEVAL-SPIN3201 device, the configuration parameters for the Power Stage, Control Stage and Drive Management are already set.

Page 5: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 5/20

UM2168 Use ST Motor Control Workbench to configure library

20

2.2 Create new project to configure library for custom STSPIN32F0 board

Open the ST Motor Control Workbench v4.3

Click on New Project and a parameter window will appear

Select the options as shown in Figure 4:

Figure 4. Parameter window for custom board

From the motor list, you can select one of the pre-configured motors or select a generic starting model.

Figure 5. Pre-configured Motor window

Click OK. A new project is now created according to the starting parameters you selected.

Page 6: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Use ST Motor Control Workbench to configure library UM2168

6/20 DocID030267 Rev 3

A configuration window will appear, allowing you to set the parameters for:

– “Motor”

– “Power Stage”

– “Drive Management” (i.e. FOC algorithm configuration)

– “Control Stage” (i.e. MCU configuration)

Using a custom board, choose the configuration parameters for the Power Stage and Control Stage that best fit to your application.

To use the integrated MCU (STM32F031x6), remember that you can access a limited number of pins as you can see in the STSPIN32F0 datasheet. Here is a list of pins you can use to access the integrated MCU:

Table 1. Accessible pin of integrated MCU

No. Name Type Function

4 PF0 Digital in MCU PF0

5 PF1 Digital in MCU PF1

7 NRST Digital in MCU reset pin

11 PA0 Analog in MCU PA0

12 PA1 Analog in MCU PA1

13 PA2 Analog in MCU PA2

14 PA3 Analog in MCU PA3

15 PA4 Analog in MCU PA4

16 PA5 Analog in MCU PA5

17 PA6 Digital in MCU PA6

18 3FG_PA7 Digital I/O 3FG open-drain output or MCU PA7

19 PB1 Analog in MCU PB1

37 PA13_SWD_IO Digital I/O MCU PA13/SWDIO (system debug data via ASIC)

38 PA14_SWD_CLK Digital I/O MCU PA14/SWDCLK (system debug clock)

39 PB6 Digital I/O MCU PB6

40 PB7 Digital in MCU PB7

Page 7: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 7/20

UM2168 Use ST Motor Control Workbench to configure library

20

2.3 Motor parameters

In the configuration window you can manually insert the motor parameters by clicking on the Motor → M and filling the fields. If you click on “save parameters”, you can add your motor to the preset list of the motors.

Figure 6. Motor parameters window

Page 8: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Use ST Motor Control Workbench to configure library UM2168

8/20 DocID030267 Rev 3

2.4 Power Stage parameters

In the configuration window you can manually insert the Power Stage parameters by clicking on its icon and choosing the area you want to set. Using the STEVAL-SPIN3201 device, the configuration parameters for the Power Stage are already set. You should set the parameters related to your application (for example the “Rated Bus Voltage”).

Select the Power Stage → “Rated Bus Voltage Info” and set the voltage range related to your application.

Figure 7. Rated Bus Voltage parameters

Select the Power Stage → “Bus Voltage Sensing” and set the parameters for the sensing of the Vbus.

Figure 8. Vbus sensing parameters

In the Power Stage → ”Current Sensing” choose the sensing network.

Page 9: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 9/20

UM2168 Use ST Motor Control Workbench to configure library

20

Figure 9. Current Sensing parameters

In the Power Stage → select the parameters of the “Power Switches”.

Figure 10. Power Switch parameters

Page 10: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Use ST Motor Control Workbench to configure library UM2168

10/20 DocID030267 Rev 3

2.5 Drive Management parameters

In the configuration window you can manually insert the Drive Management parameters by clicking on its icon and choosing the area you want to set.

In the Drive Management → ”Speed/Position” feedback management in the “Sensor selection” you can select the sensing algorithm you want to use.

Figure 11. Drive Management Sensor selection

In the Drive Management → ”Start-up parameters” you can set the starting speed and current profile.

Figure 12. Start-up parameters

In the Drive Management → ”Drive Settings”: remember that the PWM frequency/ Execution rate must be below 15 KHz, so adjust those two parameters.

Page 11: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 11/20

UM2168 Use ST Motor Control Workbench to configure library

20

Figure 13. Drive Settings window Execution rate

Page 12: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Use ST Motor Control Workbench to configure library UM2168

12/20 DocID030267 Rev 3

2.6 Control Stage parameters

In the configuration window you can manually insert the Drive Management parameters by clicking on its icon and choosing the area you want to set. Using the STEVAL-SPIN3201 device, the general configuration parameters for the Control Stage are already set.

If you use custom HW remember to select the STSPIN32F0 as a microcontroller in the Control Stage → ”MCU and Clock Frequency” → STM32 sub-family.

Figure 14. MCU and Clock Frequency window

Never change the Control Stage → ”Digital I/O” → ”Pin Map”, as the internal mapping of the device is shown in Table 2:

Table 2. Pin Map for STSPIN32F0

TIM1

CH1 A8

CH2 A9

CH3 A10

CH1N B13

CH2N B14

CH3N B15

BKIN B12

Page 13: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 13/20

UM2168 Use ST Motor Control Workbench to configure library

20

Figure 15. Digital I/O Pin Map for STSPIN32F0

If the “Hall” sensor position feedback is used, in the Control Stage → Digital I/O → Hall sensor interface, the Pin Map has to be set as shown in Table 3:

Figure 16. Digital I/O Hall sensor settings for STEVAL-SPIN3201

Table 3. Hall sensor interface for STSPIN32F0

TIM2

CH1 A0 or A5(1)

CH2 A1

CH3 A2

1. If you use the ST STEVAL-SPIN3201 board, choose CH1 = A0.

Page 14: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Use ST Motor Control Workbench to configure library UM2168

14/20 DocID030267 Rev 3

If the “Encoder” position feedback is used, in the Control Stage → Digital I/O → Hall sensor interface, the Pin Map has to be set as shown in Table 4:

Figure 17. Digital I/O encoder for STEVAL-SPIN3201

To define the “Serial Communication” select the pin used for the UART communication in the Control Stage → Digital I/O → Serial Communication.

Remember to use the minimum baudrate for the communication.

Table 4. Encoder interface for STSPIN32F0

TIM2(1) TIM3

CH1 A0 or A5 CH1 A6

CH2 A1 CH2 A7

1. If you use the ST STEVAL-SPIN3201 board, choose TIM2 and CH1 = A0.

Table 5. Serial Communication parameters for STSPIN32F0

Serial Communication

Channel USART1

Baudrate 9600

TX(1) B6 or A2 or A14

RX B7 or A3

1. If you use the ST STEVAL-SPIN3201 board, choose TX = B6 and RX = B7.

Page 15: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 15/20

UM2168 Use ST Motor Control Workbench to configure library

20

Figure 18. Serial Communication for STEVAL-SPIN3201

Page 16: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Compile and download firmware UM2168

16/20 DocID030267 Rev 3

3 Compile and download firmware

3.1 STSW-SPIN3201 FW presentation

In association with the evaluation board STEVAL-SPIN3201, STSW-SPIN3201 firmware example allows to control a 3-phase permanent magnet motor with field-oriented control algorithms in sensorless operations.

The STSW-SPIN3201 firmware is a customization of the STM32 PMSM FOC FW library, a part of the STM32 PMSM FOC Software Development Kit V4.3 (STSW-STM32100).

The STSW-SPIN3201 package is provided under the form of a zip file. Once unzipped, three main subfolders are available: Common, Docs, Web.

3.1.1 Common folder

The contents folder can be classified in two categories:

The source code of the standard STM32 library (all the subfolders which are prefixed by the STM32)

The CMSIS files from ARM®. These files are a vendor-independent hardware abstraction layer for the Cortex®-M processor series.

3.1.2 Docs folder

This folder contains the help documentation of the STM32 PMSM FOC SDK.

3.1.3 Web folder

The folder contains the interface files for:

The STM32 PMSM motor control software library in the subfolder: MCLibrary.

The STM32 PMSM motor control software API in the subfolder: MCApplication.

The STM32 PMSM motor control user interface library API in the subfolder: UILibrary.

The “SystemDriveParams” subfolder contains the configurations files. These are the files which are automatically generated by the ST MC workbench according to the board and motor configuration.

The “Utilities” subfolder contains the MC workbench example project file: SDK43x-STEVALSPIN3201-BullRunning.stmcx. It corresponds to a setup with the STEVAL-SPIN3201 board in association with the Bull-Running BR2804-1700 kV motor.

The “Project” folder contains all the IDEs project files and the code of the demonstration application (main.c, stm32f0xx_it.c/h…).

The “Binaries” folder contains a pre-compiled binary file performing the standalone mode (EWARM_STEVAL_SPIN3201_BullRunning_Potentiometer.bin) and a pre-compiled binary file for the usage of the board with the MC workbench (EWARM_STEVAL_SPIN3201_BullRunning_MCWorkbench.bin). Both the binaries are dedicated to a setup with the STEVAL-SPIN3201 board in association with the Bull-Running BR2804-1700 kV motor.

Page 17: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 17/20

UM2168 Compile and download firmware

20

3.2 Generation of configuration file

Before proceeding with creating the configuration files save the project: a *.stmcx file will be saved in the FOC library. This file will be loaded any time you need to use the ST MC Workbench.

Select the output path in the option form and choose the “SystemDriveParams” present in the FW working folder \Web

Figure 19. Directory organization

Click on the “Generation” button to generate the configuration (*.h) file for the firmware library. You must generate a new configuration file any time you change parameters in the ST MC Workbench.

Figure 20. Generation button

3.3 Building and loading a customized firmware

After the generation of the configuration files, in the directory \Web\SystemDriveParams the ST MC Workbench updates the files:

Control stage.parameters.h

Drive parameters.h

PMSM motor parameters.h

Power stage parameters.h

The environment is now ready to be compiled and downloaded.

Page 18: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

Compile and download firmware UM2168

18/20 DocID030267 Rev 3

Refer to section 3.3 and 3.4 of the UM2152 for details of how to build the firmware in one of the supported different IDEs. The UM2152 is available on www.st.com.

3.4 Using the demonstration applications

STSW-SPIN3201 firmware example with customized parameters is now loaded to the board and is ready to spin the motor. There are two utilization modes:

A standalone mode where the motor is driven only with the user keys and the potentiometer available on the board.

A connected mode where the motor is dynamically driven via UART communications by the ST motor control workbench GUI.

For both these modes, the ST motor control workbench can be used to compute the setting parameters according to the application and to generate the associated header files.

Refer to section 3.5 of the UM2152 for details of how to use the demonstration applications. The UM2152 is available on www.st.com.

Page 19: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

DocID030267 Rev 3 19/20

UM2168 Revision history

20

4 Revision history

Table 6. Document revision history

Date Revision Changes

14-Feb-2017 1 Initial release.

09-Mar-2017 2Updated note 1. below Table 5 on page 14 (replaced “A3” by “B7”).

11-Apr-2018 3 Updated Section 3 on page 16.

Page 20: Using ST MC Workbench with STSPIN32F0 - st.com · Stage, Control Stage and ... three main subfolders are available: Common, Docs, Web. ... The “SystemDriveParams” subfolder contains

UM2168

20/20 DocID030267 Rev 3

IMPORTANT NOTICE – PLEASE READ CAREFULLY

STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to 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.

Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers’ products.

No license, express or implied, to any intellectual property right is granted by ST herein.

Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.

ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.

Information in this document supersedes and replaces information previously supplied in any prior versions of this document.

© 2018 STMicroelectronics – All rights reserved