STMicroelectronics X-NUCLEO-IHM16M1 User Manual
जाहिरात
जाहिरात
UM2419
User manual
Getting started with the X-CUBE-SPN16 three-phase brushless DC motor driver software expansion for STM32Cube
Introduction
The X-CUBE-SPN16 is an expansion software package for STM32Cube . The software runs on the STM32 Nucleo providing management of STSPIN830 to control three-phase brushless DC motors. The expansion is built on STM32Cube software technology to ease portability across different STM32 microcontrollers.
The software comes with a sample implementation driving a three-phase brushless DC motor, with BEMF sensing.
It is compatible with the NUCLEO-F030R8 , NUCLEO-F302R8 , NUCLEO-F303RE or NUCLEO-F401RE development boards when connected to an X-NUCLEO-IHM16M1 expansion board.
The package contains a user interface layer enabling real-time transmission of data to a PC through the terminal.
UM2419 - Rev 1 - May 2018
For further information contact your local STMicroelectronics sales office.
www.st.com
1 Acronyms and abbreviations
Acronym
API
BSP
CMSIS
HAL
SPI
IDE
LED
Table 1. List of acronyms
Description
Application programming interface
Board support package
Cortex ® microcontroller software interface standard
Hardware abstraction layer
Serial port interface
Integrated development environment
Light emitting diode
UM2419
Acronyms and abbreviations
UM2419 - Rev 1 page 2/18
2
2.1
UM2419
What is STM32Cube?
What is STM32Cube?
STM32Cube ™ represents the STMicroelectronics initiative to make developers’ lives easier by reducing development effort, time and cost. STM32Cube covers the STM32 portfolio.
STM32Cube version 1.x includes:
•
•
STM32CubeMX, a graphical software configuration tool that allows the generation of C initialization code using graphical wizards.
A comprehensive embedded software platform specific to each series (such as the STM32CubeF4 for the
STM32F4 series), which includes:
– the STM32Cube HAL embedded abstraction-layer software, ensuring maximized portability across the
STM32 portfolio
– a consistent set of middleware components such as RTOS, USB, TCP/IP and graphics
– all embedded software utilities with a full set of examples
STM32Cube architecture
The STM32Cube firmware solution is built around three independent levels that can easily interact with one another, as described in the diagram below.
Figure 1. Firmware architecture
UM2419 - Rev 1
Level 0 : This level is divided into three sub-layers:
• Board Support Package (BSP): this layer offers a set of APIs relative to the hardware components in the hardware boards (Audio codec, IO expander, Touchscreen, SRAM driver, LCD drivers. etc…); it is based on modular architecture allowing it to be easily ported on any hardware by just implementing the low level routines. It is composed of two parts: page 3/18
UM2419 - Rev 1
UM2419
STM32Cube architecture
•
•
– Component: is the driver relative to the external device on the board and not related to the STM32, the component driver provides specific APIs to the external components of the BSP driver, and can be ported on any other board.
– BSP driver: links the component driver to a specific board and provides a set of easy to use APIs. The
API naming convention is BSP_FUNCT_Action(): e.g., BSP_LED_Init(), BSP_LED_On().
Hardware Abstraction Layer (HAL): this layer provides the low level drivers and the hardware interfacing methods to interact with the upper layers (application, libraries and stacks). It provides generic, multiinstance and function-oriented APIs to help offload user application development time by providing ready to use processes. For example, for the communication peripherals (I²C, UART, etc.) it provides APIs for peripheral initialization and configuration, data transfer management based on polling, interrupt or DMA processes, and communication error management. The HAL Drivers APIs are split in two categories: generic
APIs providing common, generic functions to all the STM32 series and extension APIs which provide special, customized functions for a specific family or a specific part number.
Basic peripheral usage examples: this layer houses the examples built around the STM32 peripherals using the HAL and BSP resources only.
Level 1 : This level is divided into two sub-layers:
• Middleware components: set of libraries covering USB Host and Device Libraries, STemWin, FreeRTOS,
FatFS, LwIP, and PolarSSL. Horizontal interaction among the components in this layer is performed directly by calling the feature APIs, while vertical interaction with low-level drivers is managed by specific callbacks and static macros implemented in the library system call interface. For example, FatFs implements the disk
I/O driver to access a microSD drive or USB Mass Storage Class.
• Examples based on the middleware components: each middleware component comes with one or more examples (or applications) showing how to use it. Integration examples that use several middleware components are provided as well.
Level 2 : This level is a single layer with a global, real-time and graphical demonstration based on the middleware service layer, the low level abstraction layer and basic peripheral usage applications for board-based functions.
page 4/18
3
UM2419
X-CUBE-SPN16 software expansion for STM32Cube
X-CUBE-SPN16 software expansion for STM32Cube
3.1
3.2
Overview
•
•
•
•
•
•
The X-CUBE-SPN16 software package extends STM32Cube functionality and features:
• Sample application to drive a three-phase brushless motor, managing a single driver (
STM32 Nucleo expansion board ( X-NUCLEO-IHM16M1 ).
STSPIN830 ) and an
•
GPIO, PWM and IRQ configuration
API function available to send any application command to the motor driver
User interface utility based on PC terminal to control the motor
Speed control through potentiometer
Motor control by user button
Easy portability across different MCU families, thanks to
Free, user-friendly license terms
STM32Cube
To use the STSPIN830 driver library, first call its initialization function to:
•
•
• set up the required GPIOs to handle the bridges, enable the EN/FAULT and the STBY/RESET pins set up the drivers load the driver parameters with the values in "MC_SixStep_param_Fxxx.h" (acceleration, deceleration, minimum and maximum speed, starting Duty Cycle, PWM frequency, etc.).
You can easily modify the driver parameters in “MC_SixStep_param_Fxxx.h”.
The speed profile is completely handled by the microcontroller depending on the potentiometer setting.
The 6-step algorithm is based on the single shunt current sensing mode and the sensorless algorithm for BEMF detection.
Motor activity is driven differently, depending on the workspace configuration:
• configuration mode firmware
: waits for the blue button event to start the motor and the black button to reset the
• comm mode : enables communication via an external PC terminal
A motion command can be stopped at any moment by pushing the user button or via the external PC terminal.
The firmware can be reset by pushing the reset button on the STM32 Nucleo development board.
Architecture
This fully compliant STM32Cube software expansion enables development of BLDC applications using motor drivers.
UM2419 - Rev 1 page 5/18
Figure 2. X-CUBE-SPN16 architecture
UM2419
Folder structure
3.3
The software is based on the STM32CubeHAL hardware abstraction layer for the STM32 microcontroller and extends STM32Cube with a board support package (BSP) for the DC motor driver expansion board ( X-NUCLEO-
IHM16M1 ) and some middleware components for motor control and serial communication with a PC.
The software layers used by the application software to access and use the three-phase brushless DC motor drivers expansion board are:
• STM32Cube HAL layer : provides a generic, multi-instance set of simple APIs (application programming interfaces) to interact with the upper layers (application, libraries and stacks). These generic and extension
APIs are based on a common architecture and the layers above them, like the middleware layer, can function without requiring specific hardware configuration data for a given microcontroller unit (MCU). This structure improves the library code reusability and guarantees easy portability across other devices.
• Board support package (BSP) layer : supports the peripherals on the STM32 Nucleo board, except for the
MCU. This limited set of APIs provides a programming interface for certain board specific peripherals (like the user button, the reset button, etc.) and helps in identifying the specific board version. The BSP in the X-
CUBE-SPN16 software provides the drivers to manage the STSPIN830 motor driver.
Folder structure
Figure 3. X-CUBE-SPN16 package folder structure
UM2419 - Rev 1
The software is packaged in the following main folders:
• Documentation : with a compiled HTML file generated from the source code that details the software components and APIs.
page 6/18
3.4
3.5
UM2419
APIs
•
•
• Drivers :
– STM32Cube HAL driver files located in the STM32Fxxx_HAL_Driver subdirectories. These files are not described here as they derive directly from the STM32Cube framework. Only those files required to run the motor driver examples are present.
– CMSIS folder with the CMSIS (Cortex ® microcontroller software interface standard) files from ARM.
These files form a vendor-independent hardware abstraction layer for the Cortex-M processor series.
This folder is also unchanged from the STM32Cube framework.
– BSP folder with code files required to the STSPIN830 driver and the motor control API. The
STSPIN830.c file implements all the API functions to manage the motor driver: start/stop PWM signals, enable/disable each inverter leg, etc.
Projects : contains a sample MC application using the X-NUCLEO-IHM16M1 expansion board plugged on top of a NUCLEO-F030R8 , NUCLEO-F302R8 , NUCLEO-F303RE or NUCLEO-F401RE board.
Middlewares : contains MC libraries and the serial driver-PC communication protocol. The middleware folder includes the core 6-step sensorless algorithm with BEMF detection, able to drive a generic three-phase brushless DC motor with speed control loop. The respective header file contains the data structure and the list of main APIs for the MC.
APIs
Detailed function and parameter descriptions for the user-APIs are compiled in an HTML file in the software package Documentation folder.
Sample application description
A sample application using the X-NUCLEO-IHM16M1 expansion board mounted on different STM32 Nucleo board is provided in the Projects directory. Ready to be built projects are available for multiple IDEs.
In this application, a low voltage three-phase brushless motor is driven by the STSPIN830 device. The firmware implements a 6-step sensorless algorithm.
The main functions are:
MC_SixStep_INIT();
MC_StartMotor();
MC_StopMotor();
MC_SetSpeed(value);
UM2419 - Rev 1 page 7/18
UM2419
System setup guide
4 System setup guide
4.1
4.1.1
Hardware description
STM32 Nucleo platform
STM32 Nucleo development boards provide an affordable and flexible way for users to test solutions and build prototypes with any STM32 microcontroller line.
The Arduino™ connectivity support and ST morpho connectors make it easy to expand the functionality of the
STM32 Nucleo open development platform with a wide range of specialized expansion boards to choose from.
The STM32 Nucleo board does not require separate probes as it integrates the ST-LINK/V2-1 debugger/ programmer.
The STM32 Nucleo board comes with the comprehensive STM32 software HAL library together with various packaged software examples.
Figure 4. STM32 Nucleo board
4.1.2
Information regarding the STM32 Nucleo board is available at www.st.com/stm32nucleo
X-NUCLEO-IHM16M1 three-phase motor driver expansion board
The X-NUCLEO-IHM16M1 motor driver expansion board is based on the STSPIN830 monolithic driver for threephase brushless motors.
It represents an affordable, easy-to-use solution for driving brushless motors in your STM32 Nucleo project, implementing single and three-shunt current sensing.
The STSPIN830 embeds a PWM current limiter with adjustable threshold together with a full set of protections.
UM2419 - Rev 1 page 8/18
UM2419
Software description
The X-NUCLEO-IHM16M1 expansion board is compatible with the Arduino and ST morpho connectors, so it can be plugged to an STM32 Nucleo development board and stacked with additional STM32 Nucleo expansion boards.
Figure 5. X-NUCLEO-IHM16M1 expansion board
4.1.3
4.2
Miscellaneous hardware components
•
•
•
•
To complete the hardware setup, you need:
• an STM32 Nucleo development board (
NUCLEO-F401RE )
NUCLEO-F030R8 a three-phase brushless DC motor an external DC power supply with two electric cables
, NUCLEO-F302R8 a USB type A to mini-B USB cable to connect the STM32 Nucleo to a PC a Windows™ (v. 7 and above) – laptop or PC
, NUCLEO-F303RE or
Software description
•
•
•
The following software components are needed for a suitable development environment for applications based on the motor driver expansion board:
ST-LINK/V2-1 USB driver
ST-LINK/V2-1 firmware upgrade
X-CUBE-SPN16 expansion for STM32Cube dedicated to STSPIN830 three-phase brushless motor driver application development. The X-CUBE-SPN16 firmware and related documentation are available on www.st.com.
• One of the following development tool-chain and compilers:
– Keil RealView Microcontroller Development Kit ( MDK-ARM-STM32 ) toolchain V5.22
– IAR Embedded Workbench for ARM ( IAR-EWARM ) toolchain V7.80
– OpenSTM32 System Workbench for STM32 ( SW4STM32 ) V4.6.3
UM2419 - Rev 1 page 9/18
UM2419
Hardware and software setup
4.3
4.3.1
Hardware and software setup
Setup to drive a three-phase brushless motor
Step 1.
Configure your STM32 Nucleo development board.
JP1 off JP5 (PWR) on UV5 side JP6 (IDD) on.
Step 2.
Configure the STM32 Nucleo expansion board ( X-NUCLEO-IHM16M1 ) depending on the STM32
Nucleo development board you are using (see UM2415 on www.st.com for details on the mounting configuration).
Step 3.
Configure the STM32 Nucleo expansion board to work on the 6-step algorithm: J5 open, J6 open.
Step 4.
Configure the STM32 Nucleo expansion board to operate in voltage mode: J2 closed on 2-3 position,
J3 closed on 1-2 position.
Step 5.
Plug the X-NUCLEO-IHM16M1 expansion board onto the ST morpho connectors on the STM32
Nucleo board.
Figure 6. STM32 Nucleo board plus X-Nucleo-IHM16M1 expansion board
UM2419 - Rev 1
Step 6.
Connect the STM32 Nucleo development board to a PC with the USB cable through USB connector
CN1 to power the board.
Step 7.
Power the X-NUCLEO-IHM16M1 expansion board on by connecting its connectors Vin and Gnd to the
DC power supply. The DC supply must be set to deliver the required voltage to the three-phase brushless motor.
Step 8.
Connect the three-phase of motor to the X-NUCLEO-IHM16M1 bridge connectors U,V,W.
Step 9.
Open your preferred toolchain (MDK-ARM from Keil, EWARM from IAR, or SW4STM32 from www.openstm32.org).
Step 10.
Open the software project in \Projects\Multi\Applications\MotorControl\ YourToolChainName\STM32
Nucleo board name.
Step 11.
Adapt the default parameters used by the STSPIN830 to your three-phase brushless DC motor characteristics by modifying the parameters in \Projects\Multi\Applications\MotorControl\Inc page 10/18
UM2419
Hardware and software setup
4.3.2
\MC_SixStep_param_Fxxx.h (which contains all the motor driving parameters like the number of pole pairs, target speed, PI parameters for speed regulation, etc.).
For more information about the use of parameters from the middleware MC_6Step_Lib, refer to
UM2124 on www.st.com.
Step 12.
Compile and download the firmware into the target memory.
Step 13.
Run the sample application.
Step 14.
Push the blue button to start and the black button to stop the motor.
Step 15.
Push the black button to reset the firmware.
Step 16.
You can also use a user interface utility based on PC terminal to control the motor (see
).
PC utility
The X-CUBE-SPN16 expansion for STM32Cube implements serial communication between the STM32 Nucleo board UART peripheral and a Windows PC-terminal.
This utility is available by recompiling the project in COMM mode and configuring a terminal emulation software supporting COM connection. Before using this utility, ensure that the necessary drivers are installed and the expansion board along with STM32 Nucleo board is connected to a PC.
Step 1.
Ensure you have the minimum requirements
– PC with Intel or AMD/INTEL processor running one of following Microsoft operating systems:
◦
◦
Windows XP SP3
Windows Vista
◦ Windows 7
– At least 128 MBs of RAM
– 1 x USB port
– Terminal emulation software (e.g. Hyper-terminal, PuTTY, Tera Term).
Step 2.
Find the ST COM port number in Device Manager (COM4 in the example below).
Figure 7. Finding the STlink COM Port number in Windows Device Manager
UM2419 - Rev 1 page 11/18
UM2419
Hardware and software setup
Step 3.
Open an IDE like IAR Workbench and open the EWARM project. On the project configuration tool selector, select COMM mode and upload the firmware to the STM32 Nucleo board.
Figure 8. IAR Workbench - compiling in COMM mode and uploading firmware
UM2419 - Rev 1
Step 4.
Launch the terminal emulation software on the PC and check that the COM Device number for the current STM32 expansion board is correct and set the parameters as shown below.
page 12/18
UM2419 - Rev 1
Figure 9. PC terminal parameters
UM2419
Hardware and software setup
Once connection is established, a list of commands is shown.
page 13/18
Revision history
Date
21-May-2018
Table 2. Document revision history
Version
1
Changes
Initial release.
UM2419
UM2419 - Rev 1 page 14/18
UM2419
Contents
Contents
X-NUCLEO-IHM16M1 three-phase motor driver expansion board . . . . . . . . . . . . . . . . . . . 8
UM2419 - Rev 1 page 15/18
UM2419
List of tables
List of tables
UM2419 - Rev 1 page 16/18
UM2419
List of figures
List of figures
UM2419 - Rev 1 page 17/18
UM2419
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
UM2419 - Rev 1 page 18/18
डाउनलोड
जाहिरात