Skip to main content
SDall
Associate III
June 15, 2021
Question

motor control closed loop

  • June 15, 2021
  • 2 replies
  • 1542 views

hi I was using STM32CubeExpansion_SPN7_V1.1.0 with f401re and IHM071M1 the motor with the potentiometer runs well without problems, but what I wanted to do and control the motor direction of rotation, speed and finally stop motor, I wanted to do it via software in order to control each cycle in the while (1), starting with small speeds

thank you

This topic has been closed for replies.

2 replies

Cristiana SCARAMEL
Technical Moderator
June 16, 2021

Hi @SDall​,

you can find all details in the user manual UM1946

In the Projects directory of  X-CUBE-SPN7 package you can find an example application using the X-NUCLEO-IHM07M1 expansion board with NUCLEO-F401RE boards. Ready to build projects are available for multiple IDEs.

In this application, a low voltage 3ph motor is driven by the L6230 device. The firmware implements a 6-Step MC algorithm. The current measured in single shunt mode is compared with a reference generated by a digital speed loop for current control.

Inside the Documentation folder you can find a compiled HTML file generated from the source code and documents the software component and API details.

The L6230.c file implements all the API functions to manage the motor driver; in particular, it is possible to start/stop PWM signals, enable/disable each inverter leg, etc. At the user level, MC_SixStep_param.h contains all the motor driving parameters like the number of pole pairs, target speed, PI parameters for speed regulation, etc.

An alternative option to program the X-NUCLEO-IHM07M1 with the NUCLEO-F401RE is use the last release of STM32 Motor Control SDK (X-CUBE-MCSDK-Y).

Here you can find some examples for reference.

Let me know if this info is useful to you, if yes please "Select as Best" button to close the topic.

"If you feel a post has answered your question, please click ""Accept as Solution"""
SDall
SDallAuthor
Associate III
June 20, 2021
hi I did as you told me using the l6230.h library but I tried to make the executable code but the motor does not move and does not even enable, where can the error be thanks! #include "main_F401.h" #include "stm32f4xx_hal.h" #include "l6230.h" #include "6Step_Lib.h" EnableInput_CH1_E_CH2_E_CH3_D(); EnableInput_CH1_E_CH2_D_CH3_E(); EnableInput_CH1_D_CH2_E_CH3_E(); HF_TIMx_SetDutyCycle_CH1(1000); HF_TIMx_SetDutyCycle_CH2(1000); HF_TIMx_SetDutyCycle_CH3(1000); Current_Reference_Setvalue(1000); Current_Reference_Start(); /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { L6230_Start_PWM_generation(); HAL_Delay(400); L6230_Stop_PWM_generation(); HAL_Delay(400); 2021-06-16 10:38 GMT+02:00, ST Community :
Cristiana SCARAMEL
Technical Moderator
June 24, 2021

Hi @SDall​,

for your purpose I suggest to use the high level functions listed in the 6Step_Lib.c :

  • MC_StartMotor() --> Send Start motor command:
  • MC_StopMotor() --> Send Stop motor command
  • MC_SetSpeed(value) --> Send change motor speed (positive value for clockwise, negative value for counterclockwise)

In any case remember to set the motor parameters in the MC_SixStep_param.h

"If you feel a post has answered your question, please click ""Accept as Solution"""
SDall
SDallAuthor
Associate III
June 22, 2021

Please someone answer me!​