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 Antonio Vilei

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

/media/uploads/avilei/x-nucleo-ihm07m1_jumpers.jpg
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

/media/uploads/avilei/wirings.jpg
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.
/media/uploads/avilei/terminal.png

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:

Files at this revision

API Documentation at this revision

Comitter:
avilei
Date:
Wed Oct 19 09:30:46 2016 +0000
Parent:
9:25961e94de0e
Child:
11:0120619cdfb7
Commit message:
Add definitions for X-NUCLEO-IHM07M1 pins

Changed in this revision

X_NUCLEO_IHM07M1/x_nucleo_ihm07m1_targets.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/X_NUCLEO_IHM07M1/x_nucleo_ihm07m1_targets.h	Tue Oct 18 11:09:44 2016 +0000
+++ b/X_NUCLEO_IHM07M1/x_nucleo_ihm07m1_targets.h	Wed Oct 19 09:30:46 2016 +0000
@@ -36,16 +36,43 @@
 #ifndef __X_NUCLEO_IHM07M1_TARGETS_H_
 #define __X_NUCLEO_IHM07M1_TARGETS_H_
 
-// Default pin configuration for X-NUCLEO-IHM07M1 with STM32 Nucleo boards
+// Default pin configuration for X-NUCLEO-IHM07M1 with STM32 Nucleo-64 boards
+
+// Logic input pins
 #define P_IN1 PA_8
 #define P_IN2 PA_9
 #define P_IN3 PA_10
+
+// Enable channel pins
 #define P_EN1 PC_10
 #define P_EN2 PC_11
 #define P_EN3 PC_12
+
+// Hall sensors pins
 #define P_HALL1 PA_15
 #define P_HALL2 PB_3
 #define P_HALL3 PB_10
+
+// Temperature pin
+#define P_TEMP PC_2
+
+// Fault LED
 #define P_FAULT PB_2
 
+// Speed potentiometer
+#define P_SPEED PB_1
+
+// Back EMF pins
+#define P_BEMF1 PC_3
+#define P_BEMF2 PB_0
+#define P_BEMF3 PA_7
+
+// Current pins
+#define P_CURR1 PA_0
+#define P_CURR2 PC_1
+#define P_CURR3 PC_0
+
+// Voltage bus pin
+#define P_VBUS PA_1
+
 #endif // __X_NUCLEO_IHM07M1_TARGETS_H_
--- a/main.cpp	Tue Oct 18 11:09:44 2016 +0000
+++ b/main.cpp	Wed Oct 19 09:30:46 2016 +0000
@@ -35,13 +35,11 @@
              );
              
 // Pin to check temperature on the X-NUCLEO-IHM07M1 board
-AnalogIn temperature(PC_2);
+AnalogIn temperature(P_TEMP);
 
 void checkTemperature()
 {
-    float t = temperature.read()* 100.0f;
-
-    if (temperature.read() > 0.55f){
+    if (temperature > 0.55f){
         printf("Overheating... Turning off now\n\r");
         M.setDutyCycle(0);
         M.coast();