Skip to main content
Associate III
December 14, 2023
Question

By using MC_ProgramSpeedRampMotor1 api trying to change ramp in six step algorithm

  • December 14, 2023
  • 4 replies
  • 3637 views

The MC_ProgramSpeedRampMotor1 api is created in six steps to modify the ramp; however, ramp changes cannot be made with this api.It is possible to modify the ramp in FOC by using the MC_ProgramSpeedRampMotor1_F api.

Additionally, two produced APIs are supplied in FOC; however, in the Six Step, just MC_ProgramSpeedRampMotor1 generated.

I am unable to modify the ramp using the MC_ProgramSpeedRampMotor1 api in six step. Could you please assist me? Is there another method to modify the ramp in a six-step algorithm?

    This topic has been closed for replies.

    4 replies

    SRedd.5
    Senior III
    December 14, 2023


    __weak bool MC_StopSpeedRampMotor1(void)
    {
    return (MCI_StopSpeedRamp(pMCI[M1]));
    }

    /**
    * @brief Stops the execution of the on-going ramp for Motor 1, if any.
    *
    * If a ramp is currently being executed, it is immediately stopped, the torque or the speed
    * of Motor 1 is maintained to its current value.
    */
    __weak void MC_StopRampMotor1(void)
    {
    MCI_StopRamp(pMCI[M1]);
    }

    /**
    * @brief Returns true if the last ramp submited for Motor 1 has completed, false otherwise
    */
    __weak bool MC_HasRampCompletedMotor1(void)
    {
    return (MCI_RampCompleted(pMCI[M1]));
    }

    I have not used 6 step, but can you use the above functions to verify if the ramp is complete or not and then change the ramp or stop the ramp etc.

     

    Associate III
    December 14, 2023

    I used MC_HasRampCompletedMotor1 flag to check weather the ramp is completed or not and then i getting the message that rampl is completed but the speed is not reflecting in motor.

     

    SRedd.5
    Senior III
    December 14, 2023

    void MC_ProgramSpeedRampMotor1(int16_t hFinalSpeed, uint16_t hDurationms)

    The ramp is with respect to the time that is you may want to achieve the speed in 5seconds, 10 seconds etc. To change the speed you have to update the  hFinalSpeed, provide different values as arguments to the function MC_ProgramSpeedRampMotor1 for example 100, 200 RPM (verify the units the function MC_ProgramSpeedRampMotor1 expects). Can you show how you are passing parameters to  the MC_ProgramSpeedRampMotor1 function?

     

    SRedd.5
    Senior III
    December 14, 2023

    I find mistakes duration is unsigned but you are checking for less than 0

    The targetspeed is a signed value but you are passing unsigned value. Please check those coding errors.

    Associate III
    December 15, 2023

    soundarya_h_s_0-1702618269134.png

    I have changed to signed but still the ramp is not reflecting in the motor

     

    SRedd.5
    Senior III
    December 15, 2023

    You have to learn to debug the code use break points to verify if the expected the actual values are matching. You can also use the Cubemonitor to watch variables during the run time. 

    You are checking the duration < 0, but that will never be True.

    Associate III
    December 15, 2023

    Both actual and expected values are matching.

    SRedd.5
    Senior III
    December 15, 2023

    Can you install CubeMonitor and try using it and post the images of the variables?

    ADAVE.1
    ST Employee
    December 18, 2023

    I generated a 6step project and added

    MC_ProgramSpeedRampMotor1(333, 5000); 

    in main.c and it works pretty well. The speed is gradually changed to 2krpm in 5s. Consider that a change of sign in the speed (spin rotation change) is not allowed in 6step and forces the motor to stop. What exactly is the issue you are facing?

    Associate III
    December 19, 2023

    soundarya_h_s_0-1702965132823.png

    This is the code i am using to generate the ramp in six step algorithm, The MC_ProgramSpeedRampMotor1 api is created in six steps to modify the ramp; however, ramp changes cannot be made with this api.  Could you please assist me? Is there another method to modify the ramp in a six-step algorithm?

    ADAVE.1
    ST Employee
    December 19, 2023

    Are you sure that the effect of your code is not an overcurrent event?

    I see an error in the usage of the speed. As indicated in the documentation the api accepts the speed expressed in #SPEED_UNIT. 

    ADAVE1_0-1702973702660.png

    So, I suggest to use the macro RPM_2_SPEED_UNIT(rpm) to convert it before calling the function.

    MC_ProgramSpeedRampMotor1(RPM_2_SPEED_UNIT(target_speed), duration);