Skip to main content
VRavi.1
Associate
January 13, 2020
Solved

Tools and software for STM32 (positioning)?

  • January 13, 2020
  • 4 replies
  • 4753 views

Hi. ST MC Workbench is a PC software which reduces the design effort and time in the STM32 PMSM FOC firmware library configuration. Is there any similar software for positioning?

This topic has been closed for replies.
Best answer by Claire O.

Dear RPate.1,

The position control mode is accessible from MC Workbench:

Control Unit> Firmware Drive Management> Drive Setting 

Also I copied below some extract from the release note:

"Using the Position Control feature

The position control feature can be activated on any configuration that uses an Encoder for speed and position feedback. To activate it, open the Drive Settings dialog from the main configuration panel of the workbench, and select the Position Control item from the Control mode combo box. Dual drive configurations are also supported; the position control can then be activated on any motor equipped with an Encoder.

A set of new APIs is provided to exercise the feature. Among these, the most important ones are the following:

  • void MC_ProgramPositionCommandMotor*(float fTargetPosition, float fDuration)
  • to set the mechanical angle the rotor is to reach and the duration of the movement to reach it
  • float MC_GetCurrentPosition1( void )
  • to retrieve the current rotor position
  • float MC_GetTargetPosition1( void )
  • to get the target rotor position
  • float MC_GetMoveDuration1( void )
  • to get the duration of the programmed movement.

The

MC_ProgramPositionCommandMotor*

functions work as the other ramp functions of the API. For a complete description of this API, refer to the reference documentation of the Motor Control SDK.

Note that when the Position Control is activated on a motor, the speed and torque control mode cannot be used.

The Position Control feature uses floating point arithmetic. It may require a lot of CPU power on STM32F0 and STM32G0 devices that do not have an FPU."

We are also preparing a specific application note on this topic.

Thanks and best regards,

Claire

4 replies

Tesla DeLorean
Guru
January 13, 2020
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
VRavi.1
VRavi.1Author
Associate
January 13, 2020

I'm talking about the position of the PMSM shaft

Claire O.
Technical Moderator
January 17, 2020

Hello VRavi.1,

Did you tried the position control feature available from MCSDK5.4.3?

It may help you,

Best regards,

Claire

RPate.11
Associate II
January 21, 2020

I am seeking same feature to Control Accurately angular position. My applications currently running in Speed Control Mode with Encoder configured with MCWB 5.4.1. It works great but Application Demands position control feature.

I have downloaded MCSDK 5.4.3 and reconfigured my project with MCWB 5.4.3. But I am unable to find any thing related to Position Control!! It seems all similar to me. Am I missing something?

Please point me in correct direction to avail such feature. Please provide me any sort of related material that can help me in developing.

Thank You.

Claire O.
Claire O.Answer
Technical Moderator
January 23, 2020

Dear RPate.1,

The position control mode is accessible from MC Workbench:

Control Unit> Firmware Drive Management> Drive Setting 

Also I copied below some extract from the release note:

"Using the Position Control feature

The position control feature can be activated on any configuration that uses an Encoder for speed and position feedback. To activate it, open the Drive Settings dialog from the main configuration panel of the workbench, and select the Position Control item from the Control mode combo box. Dual drive configurations are also supported; the position control can then be activated on any motor equipped with an Encoder.

A set of new APIs is provided to exercise the feature. Among these, the most important ones are the following:

  • void MC_ProgramPositionCommandMotor*(float fTargetPosition, float fDuration)
  • to set the mechanical angle the rotor is to reach and the duration of the movement to reach it
  • float MC_GetCurrentPosition1( void )
  • to retrieve the current rotor position
  • float MC_GetTargetPosition1( void )
  • to get the target rotor position
  • float MC_GetMoveDuration1( void )
  • to get the duration of the programmed movement.

The

MC_ProgramPositionCommandMotor*

functions work as the other ramp functions of the API. For a complete description of this API, refer to the reference documentation of the Motor Control SDK.

Note that when the Position Control is activated on a motor, the speed and torque control mode cannot be used.

The Position Control feature uses floating point arithmetic. It may require a lot of CPU power on STM32F0 and STM32G0 devices that do not have an FPU."

We are also preparing a specific application note on this topic.

Thanks and best regards,

Claire

PSedl.1
Visitor II
February 24, 2020

Hello,

The previous discussion helped me a lot. I am new on motion control and also at the ST platform at all. Could you help me with a few questions, please?

I would like to drive a gimbal motor assembled with Cui AMT103 quadrature encoder. 

My configuration is Nucleo F303RE + X-NUCLEO-IHM07M1.

I configured the motor using ST Motor Profiler and made code in MC Workbench.

Any hints on how to test function? Is it possible to try it via a serial monitor, or something similar using commands?

(Am I understand well that position operations on MC Workbench are on early stage and will be released in April, right? )

In the beginning, I would like to try encoder reading and then position control.

Thank you very much, best regards 

Pavel 

PSedl.1
Visitor II
February 29, 2020

Hello,

After some learning, I found the test code in a position control example. So I used it as is but the motor vibrating a lot and turning really "randomly". 

Do you have some hints for tuning? 

Thank you, BR

Pavel

/* USER CODE BEGIN WHILE */
 
 // Wait encoder alignment and finding zero angle
 while (MC_GetAlignmentStatusMotor1() != TC_ALIGNMENT_COMPLETED);
 
 while (1)
 {
 
 if (demoMode == DEMO_TRAJECTORY_CONTROL)
 {
 // Execute demo code - trajectory control
 if (MC_GetControlPositionStatusMotor1() == TC_READY_FOR_COMMAND)
 {
 float TargetPos;
 HAL_Delay(HOLD_TIME*1000);
 TargetPos = TargetPositionSequence[TargetPosIndex];
 TargetPosIndex++;
 MC_ProgramPositionCommandMotor1( TargetPos, MovementDuration );
 
 if (TargetPosIndex >= TARGET_POS_LEN)
 {
 TargetPosIndex = 0;
 }
 }
 
 }
 
 if (demoMode == DEMO_FOLLOW_MODE) {
 // Execute demo code - follow mode
 float target = 0.0f;
 volatile float incAngle = 0.0314;
 
 for (uint16_t i = 0; i < 100; i++) {
 	MC_ProgramPositionCommandMotor1( target, 0.0f );
 HAL_Delay(9);
 target += incAngle;
 }
 
 for (uint16_t i = 0; i < 100; i++) {
 	MC_ProgramPositionCommandMotor1( target, 0.0f );
 HAL_Delay(9);
 target -= incAngle;
 }
 }
 
 /* USER CODE END WHILE */

RPate.11
Associate II
March 2, 2020

First, I have not seen example code that you are talking about. I believe above code is in main loop.

Code seems OK as you are giving command to motor for target position and time. You have gave 0 time to reach target position. Controller will try to reach target instantly. Provide some time to reach there. Also keep in mind the max speed for given time.

One more thing. Check encoder power. Is it OK? Does power board provide it on encoder connector? Refer its datasheet for connection pinouts. Are you able to run motor smoothly in speed control mode with speed feedback from Encoder? First run motor smoothly with encoder and then go for position control with same motor and encoder settings.

I have run motor smoothly with STM32 in position control mode. I was just using MC_ProgramPositionCommandMotor1( target, time ); command for rotation. It works.

JEsca.1
Associate II
June 23, 2020

@PSedl.1​ hello how did you find the correct PID coefficient ? by loop on each one ?

regards

PSedl.1
Visitor II
June 24, 2020

Hello,

To be honest, I still don't have the proper configuration of PID. 

It's working somehow, but I should do config of all loops from the beginning. 

I am not really sure how to tune the torque loop in a proper way. 

BR,

Pavel.