2024-01-03 10:27 AM
Hi,
I am trying to create a User Application where I pass in commands from a terminal application (ex: Putty or Ucon) which results in the motor doing something.
I have configured the MC Workbench with the following options:
Not using the MC Pilot so I have the following in User Interface:
For the first part of the application, I was passing 'SH\r' to start the motor and 'MO\r' to stop the motor.
The code in main.c is as follows:
#define BUFFER_SIZE 3
uint8_t data_buffer[BUFFER_SIZE];
main()
{
// auto generated code
...
HAL_UART_Receive_DMA(&huart1, data_buffer, BUFFER_SIZE);
while(1)
{
}
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if(huart == &huart1)
{
if(data_buffer[0] == 'S' && data_buffer[1] == 'H')
{
MC_StartMotor1();
}
else if (data_buffer[0] == 'M' && data_buffer[1] == 'O')
{
MC_StopMotor1();
}
}
}
The Motor Holds a position (not sure what is the default position set to?) when I send 'SH/r' and then rotor vibrates at that position.
Sending 'MO/r' stops the motor.
This is desirable but not quite.
I have the following BLDC motor:
BL17E40-01 | BL17 Series | BLDC Motor | Lin Engineering
and I have installed the following encoder:
AMT11 Series | Modular | Incremental | Rotary Encoders (cuidevices.com)
The problem I think is these are relative encoders, and the MC workbench calls encoders with Z pins as absolute encoders.
I want to extend my user application and send commands that move the rotor to a particular position in some time.
In order to do that, I first followed the example as given in AN5464 (Position control of a three-phase permanent magnet motor using X‑CUBE‑MCSDK or X‑CUBE‑MCSDK-FUL)
I ran the following code :
/* USER CODE BEGIN 2 */
MC_StartMotor1();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while(MC_GetAlignmentStatusMotor1()!=TC_ALIGNMENT_COMPLETED){}
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
MC_ProgramPositionCommandMotor1(3.14/2,0.1);
HAL_Delay(2000);
MC_ProgramPositionCommandMotor1(-3.14/2,0.1);
HAL_Delay(2000);
}
/* USER CODE END 3 */
When I run it, the rotor seems to move to a position which is not pie/2 or -pie/2 and then it just vibrates at whatever position it got to.
When I tried stepping through the code and added a breakpoint at
while(MC_GetAlignmentStatusMotor1()!=TC_ALIGNMENT_COMPLETED){}
I see that the Alignment never completes and the value on the left doesn't change to 2.
So, this example doesn't work as expected as given in the application note.
I want to pass strings like 'JG,3.14,1000\r' which should move the rotor 180 degrees in 1 second (something like that) but I don't even see this happening with the Application Example shared by STM32.
Please help resolve.
2024-01-05 06:57 AM
Hello @smaiti ,
Could you please provide the version of the MCSDK do you use, and the ST boards you are using. If you use your own board, then MCU part number is also a useful information.
Before debugging at application level, I strongly advise you to start at library level by making sure that your software is properly tuned according to your motor.
Did you try to profile your motor with the ST Profiler tool, or did you enter your motor's characteristics manually in the Workbench?
Once you are confident with your motor parameters, I strongly advise you to generate a project with Speed control mode and enable the communication with the Motor Control Pilot. The first step is to guarantee that your motor spin correctly out of reset. If it is not the case the Motor control Pilot will provide you a lot of info to understand what is wrong and all the controls required to fine tune your application.
Please let us know when you are able to control nicely your motor.
Regards
Cedric
2024-01-05 07:20 AM
Hi @cedric H ,
Hardware
MCU [EVSPIN32G4 - STSPIN32G4 demonstration board for three-phase brushless motors - STMicroelectronics ]
BLDC Motor [ BL17E40-01 | BL17 Series | BLDC Motor | Lin Engineering ]
Quadrature Encoder [AMT11 Series | Modular | Incremental | Rotary Encoders (cuidevices.com) ]
24 Volt Power Supply
The MCSDK version being used is 6.2.0
When I first got this board in December 23, I could profile the motor and follow the steps in your documents to spin the motor in Speed Control Mode. The observerless + PLL & Hall Sensors worked.
I wasted a lot of time trying to understand the ASPEP protocol and MCP used to send and receive data from the Motor pilot. While this GUI tool is good in the initial stages, I am at a stage where I need precise motor control using encoders. I have stopped using the GUI since that is not what our final application will be using. Need to send & receive data over UART from an STM32F4 board to control the motor and read certain outputs.
The Application Note was a good starting point, but it doesn't seem to help me achieve my goal.
I was initially supportive of the idea of using what you have. Just using the APIs and getting our application to work. But now it seems I have to start developing my firmware since I am running out of time trying to read the documentation and the code of MCSDK.
You have tried to build a product that is easy to use but in reality, it is not.
2024-01-05 08:36 AM
Hello @smaiti ,
First, I am glad to read that you succeed to control your motor without sensors and with Hall sensors.
I do not understand why you did not try to control your motor with your quadrature encoder ? It is the first step to do position control. Do you have a working project with your encoder ?
What do you mean by "it seems I have to start developing my firmware"? Do you plan to develop the full implementation of the FOC library? It seems to me that you are not far from having something working.
Could you help me to understand what is not easy from your point of view?
Regards
Cedric
2024-01-09 06:32 AM
Hi @cedric H ,
I think you didn't read my post properly.
I have been able to run the BLDC motor in the following modes :
The code that I have shared is from a working project that has been configured with Quadrature Encoders.
Let me ask you this. What do you think is going to happen if you configure your Motor Control Project with Quadrature encoders and run the following piece of code :
/* USER CODE BEGIN 2 */
MC_StartMotor1();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while(MC_GetAlignmentStatusMotor1()!=TC_ALIGNMENT_COMPLETED){}
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
MC_ProgramPositionCommandMotor1(3.14/2,0.1);
HAL_Delay(2000);
MC_ProgramPositionCommandMotor1(-3.14/2,0.1);
HAL_Delay(2000);
}
/* USER CODE END 3 */
What behavior do you expect ?
2024-01-10 01:18 AM
Hello @smaiti
In this simple example, two distinct movement commands are issued by utilizing the dedicated API MC_ProgramPositionCommandMotor1:
The first one to +90° (π/2) in 100ms and the second one to -90° (-π/2) in 100ms.
A delay of two seconds is set between the two commands, which are given in a loop.
Best regards,
Fouad
2024-01-11 06:15 AM
@FouadB ,
Thanks for your reply but its not doing that.
I have been able to locate the individual who is in charge of Motor Control products in North America.
I have shared the videos of the motor when I ran the code. Hoping to get some support from the Motor Control Team.
I think the ST community is not resourced to answer this question.
2024-01-15 06:27 AM
Hello @smaiti,
I sincerely hope you will receive the appropriate support from the Motor control team. Do not hesitate to share with the community your findings.
Regards
Cedric
2024-04-08 09:05 PM
Hi Smaiti,
I was reading all your posts on postion control using EVSPIN32G4. Have you found the solution for the issue. I am also working on the same project but for a 48V motor. Your reply will be very helpful for me.