cancel
Showing results for 
Search instead for 
Did you mean: 

Tools and software for STM32 (positioning)?

VRavi.1
Associate II

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?

19 REPLIES 19

Hello RPate.1,

Thanks for your precious feedback. It will be taken into account to improve further implementation.

I will check how we can help with current implementation.

About the new release of MCSDK, my target is to add some post in this forum when it will be available. The information will be also avaialble in MC_SUITE tools. Target for improved version is end of April...

Thanks and best regards,

Claire

PSedl.1
Associate II

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 

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 */

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.

Hello, thank you for your answer! 

The problem seems to be in the encoder config. In default config, if I configure "Pulses per mechanical revolution = 2048" and also "Max measurement errors.. = 3" , "Average speed FIFO depth = 16" and "Input Capture.. = 0.7" after Encoder Alignment if I turn motor manually motor speed show some value. But if I try to run the motor, the motor only beeping and do nothing. 

I have no idea how to configure FIFO depth, Input Capture etc..

The second weird thing is if I choose Position control I can choose "CH1, CH2, and CH_Z" in Pin Map but if I choose Speed control I can choose only "CH1 and CH2", that's ok? 

My sensor is CUI Amt 103 in the version with dip switches, configured for 2048 pulses per rotation. 

Thank you, best regards

Pavel

Which version of MCWB you are using.?

I have used 10 measurement before error. Rest of parameter was same. No need to change them.

As per my knowledge about MCWB 5.4.3, code is not using Z pulse from encoder irrespective of Position or Speed control mode. They have used different topology for speed measurement. Only A and B is OK.

When you turn motor and speed is visible, that means encoder is doing good. But, I guess, problem should be with motor parameters, like line resistance and inductance. Those are quite important in running motor smoothly. Try to run motor in Observer and PLL method for constant speed first. If this goes OK, you have parameters. Then go for Encoder. Then go for Position control after success.

For PID constants for position control, try to zero I and D and keep only P. This will have error but you will have steady rotation test. If this success then proceed for I and D.

Hello, 

I am using the MCWB 5.4.3.

After some playing motor runs much better. There was a problem in wires (one wire was broken - really thin) and also in the config of the motor.

Now motor following positions and turning almost well. I think I should do some final tuning of PID, Execution-Rate, Cut-Off-Frequency, etc and then we will see 🙂

Anyway, thank you very much.

Best regards,

Pavel

Hello,

Position control works good but I still facing problems with PID. I am a beginner at PID tuning, I tried lot of changes but everything goes worse and worse. 

Do you have some hints about how to tune PID? I have a simple 2 channel oscilloscope.

Is it possible to use DAC and tune PID watching some signal? 

The best configuration I reached is P5000, I400, D700 but there are still big over shots, etc and motion isn't as smooth as I expected. 

Thank you, BR

Pavel

JEsca.1
Associate II

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

regards

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.