Skip to main content
Associate III
November 27, 2023
Question

how to set the speed in rpm in the code

  • November 27, 2023
  • 1 reply
  • 1669 views

I have imported the motor details from motor pilot and workbench, but now the main challenge is to set the speed in the code 

is there any direct api to change the speed in rpm in the code?

used the below api for starting the motor, it ran smoothly. I want to change the speed next how can i do it

MC_StartMotor1();

This topic has been closed for replies.

1 reply

GMA
Technical Moderator
November 27, 2023

Hello,

You can use:

MC_ProgramSpeedRampMotor1_F(FinalSpeed_in_rpm,  RampDuration_in_ms)
If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA
Associate III
November 27, 2023

Hello @GMA 
I have tried this before but when i measured the output by tachometer, i was not getting the same speed that i have set using this api 

MC_ProgramSpeedRampMotor1_F(FinalSpeed_in_rpm,  RampDuration_in_ms)

SRedd.5
Senior III
November 27, 2023

Check the number of poles and the API 

MC_ProgramSpeedRampMotor1(RequestedSpeed * ((int16_t)SPEED_UNIT)) / (int16_t)U_RPM,RampDuration_in_ms);

The RequestedSpeed is the actual speed you need, you have to include the SPEED_UNIT / U_RPM factor.