Example application for X-NUCLEO-IHM07M1 board connected to a 3-phase brushless motor with Hall sensors.
Dependencies: BLDCmotorDriver RateLimiter mbed
Fork of HelloWorld_IHM07M1 by
Getting Started with X-NUCLEO-IHM07M1
This example demonstrates how to use the X-NUCLEO-IHM07M1 component with one of the STM32 Nucleo-64 platforms and a three-phase brushless DC (BLDC) motor with Hall sensors.
HW Prerequisites
- X-NUCLEO-IHM07M1
- STM32 Nucleo-64 board
- external DC power supply
- low voltage three-phase BLDC motor with Hall sensors
X-NUCLEO-IHM07M1 Jumpers Configuration
Configure the jumpers of your X-NUCLEO-IHM07M1 board as shown below:
- JP1 open
- JP2 open
- JP3 closed
- J9 closed
- J5 closed on 2-3 (single shunt)
- J6 closed on 2-3 (single shunt)
- J7 open
For more details please refer to the X-NUCLEO-IHM07M1 user manual.
BLDCmotorDriver Library
This example is based on the BLDCmotorDriver motor control library by the TVZ Mechatronics Team, University of Applied Sciences Zagreb, Professional Study in Mechatronics. The BLDCmotorDriver library is a simple implementation of the six-step algorithm and needs Hall sensors to estimate the correct timing for commutation. If you want to use sensor-less BLDC motors with X-NUCLEO-IHM07M1 or if you want an optimized implementation, you must use a different software package like X-CUBE-SPN7, based on STM32Cube.
The HelloWorld_IHM07M1 application has been tested with the Nanotec DF45M024053-A2 motor, a 24V three-phase brushless motor with Hall sensors. This example implements a temperature check to prevent overheating.
If you use a different motor, please be advised that you may need to tweak the configuration parameters for the BLDCmotorDriver library.
Connecting the Motor
In the picture above you can see an example setup with the Nanotec DF45M024053-A2 motor and a 24V power supply.
If you use the same motor, please connect the brown, grey and yellow phases to the OUT1, OUT2 and OUT3 connectors of the X-NUCLEO-IHM07M1 board respectively. Then connect the blue, green, white, red and black wires for the Hall sensors to the A+/H1, B+/H2, Z+/H3, 5V, GND connectors as shown in the picture.
If your motor is different, you must pay attention to connect the motor phases and Hall sensors pins in the correct order otherwise the motor won't spin.
Spinning the Motor
Open a terminal window (baudrate 9600, 8N1) to display the user interface of the HelloWorld_IHM07M1 application.
Press the 'w' character to start spinning the motor and speed it up; press the 's' character to slow it down and turn it off.

Note
You need a terminal emulator installed on your PC to perform serial communications with your STM32 Nucleo platform. If you do not have it, please download and install one of the following terminal emulation programs:
X_NUCLEO_IHM07M1/x_nucleo_ihm07m1_targets.h@12:33614e1dc638, 2016-10-20 (annotated)
- Committer:
- avilei
- Date:
- Thu Oct 20 14:44:40 2016 +0000
- Revision:
- 12:33614e1dc638
- Parent:
- 10:5fbe1476624c
Improve comments
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| avilei | 2:4ae769d0b112 | 1 | /* mbed Microcontroller Library |
| avilei | 2:4ae769d0b112 | 2 | * Copyright (c) 2006-2016 ARM Limited |
| avilei | 2:4ae769d0b112 | 3 | * |
| avilei | 2:4ae769d0b112 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| avilei | 2:4ae769d0b112 | 5 | * you may not use this file except in compliance with the License. |
| avilei | 2:4ae769d0b112 | 6 | * You may obtain a copy of the License at |
| avilei | 2:4ae769d0b112 | 7 | * |
| avilei | 2:4ae769d0b112 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| avilei | 2:4ae769d0b112 | 9 | * |
| avilei | 2:4ae769d0b112 | 10 | * Unless required by applicable law or agreed to in writing, software |
| avilei | 2:4ae769d0b112 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| avilei | 2:4ae769d0b112 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| avilei | 2:4ae769d0b112 | 13 | * See the License for the specific language governing permissions and |
| avilei | 2:4ae769d0b112 | 14 | * limitations under the License. |
| avilei | 2:4ae769d0b112 | 15 | */ |
| avilei | 2:4ae769d0b112 | 16 | |
| avilei | 2:4ae769d0b112 | 17 | /** |
| avilei | 2:4ae769d0b112 | 18 | ****************************************************************************** |
| avilei | 2:4ae769d0b112 | 19 | * @file x_nucleo_ihm07m1_targets.h |
| avilei | 2:4ae769d0b112 | 20 | * @author STMicroelectronics |
| avilei | 2:4ae769d0b112 | 21 | * @brief Header file with pin definitions for X-NUCLEO-IHM07M1 board |
| avilei | 2:4ae769d0b112 | 22 | ****************************************************************************** |
| avilei | 2:4ae769d0b112 | 23 | * @copy |
| avilei | 2:4ae769d0b112 | 24 | * |
| avilei | 2:4ae769d0b112 | 25 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
| avilei | 2:4ae769d0b112 | 26 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
| avilei | 2:4ae769d0b112 | 27 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
| avilei | 2:4ae769d0b112 | 28 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
| avilei | 2:4ae769d0b112 | 29 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
| avilei | 2:4ae769d0b112 | 30 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
| avilei | 2:4ae769d0b112 | 31 | * |
| avilei | 2:4ae769d0b112 | 32 | * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> |
| avilei | 2:4ae769d0b112 | 33 | */ |
| avilei | 2:4ae769d0b112 | 34 | |
| avilei | 2:4ae769d0b112 | 35 | /* Define to prevent from recursive inclusion --------------------------------*/ |
| avilei | 2:4ae769d0b112 | 36 | #ifndef __X_NUCLEO_IHM07M1_TARGETS_H_ |
| avilei | 2:4ae769d0b112 | 37 | #define __X_NUCLEO_IHM07M1_TARGETS_H_ |
| avilei | 2:4ae769d0b112 | 38 | |
| avilei | 10:5fbe1476624c | 39 | // Default pin configuration for X-NUCLEO-IHM07M1 with STM32 Nucleo-64 boards |
| avilei | 10:5fbe1476624c | 40 | |
| avilei | 10:5fbe1476624c | 41 | // Logic input pins |
| avilei | 2:4ae769d0b112 | 42 | #define P_IN1 PA_8 |
| avilei | 2:4ae769d0b112 | 43 | #define P_IN2 PA_9 |
| avilei | 2:4ae769d0b112 | 44 | #define P_IN3 PA_10 |
| avilei | 10:5fbe1476624c | 45 | |
| avilei | 10:5fbe1476624c | 46 | // Enable channel pins |
| avilei | 2:4ae769d0b112 | 47 | #define P_EN1 PC_10 |
| avilei | 2:4ae769d0b112 | 48 | #define P_EN2 PC_11 |
| avilei | 2:4ae769d0b112 | 49 | #define P_EN3 PC_12 |
| avilei | 10:5fbe1476624c | 50 | |
| avilei | 10:5fbe1476624c | 51 | // Hall sensors pins |
| avilei | 2:4ae769d0b112 | 52 | #define P_HALL1 PA_15 |
| avilei | 2:4ae769d0b112 | 53 | #define P_HALL2 PB_3 |
| avilei | 2:4ae769d0b112 | 54 | #define P_HALL3 PB_10 |
| avilei | 10:5fbe1476624c | 55 | |
| avilei | 10:5fbe1476624c | 56 | // Temperature pin |
| avilei | 10:5fbe1476624c | 57 | #define P_TEMP PC_2 |
| avilei | 10:5fbe1476624c | 58 | |
| avilei | 10:5fbe1476624c | 59 | // Fault LED |
| avilei | 2:4ae769d0b112 | 60 | #define P_FAULT PB_2 |
| avilei | 2:4ae769d0b112 | 61 | |
| avilei | 10:5fbe1476624c | 62 | // Speed potentiometer |
| avilei | 10:5fbe1476624c | 63 | #define P_SPEED PB_1 |
| avilei | 10:5fbe1476624c | 64 | |
| avilei | 10:5fbe1476624c | 65 | // Back EMF pins |
| avilei | 10:5fbe1476624c | 66 | #define P_BEMF1 PC_3 |
| avilei | 10:5fbe1476624c | 67 | #define P_BEMF2 PB_0 |
| avilei | 10:5fbe1476624c | 68 | #define P_BEMF3 PA_7 |
| avilei | 10:5fbe1476624c | 69 | |
| avilei | 10:5fbe1476624c | 70 | // Current pins |
| avilei | 10:5fbe1476624c | 71 | #define P_CURR1 PA_0 |
| avilei | 10:5fbe1476624c | 72 | #define P_CURR2 PC_1 |
| avilei | 10:5fbe1476624c | 73 | #define P_CURR3 PC_0 |
| avilei | 10:5fbe1476624c | 74 | |
| avilei | 10:5fbe1476624c | 75 | // Voltage bus pin |
| avilei | 10:5fbe1476624c | 76 | #define P_VBUS PA_1 |
| avilei | 10:5fbe1476624c | 77 | |
| avilei | 2:4ae769d0b112 | 78 | #endif // __X_NUCLEO_IHM07M1_TARGETS_H_ |

X-NUCLEO-IHM07M1 Brushless DC Motor Driver