RobotC Vex IQ command to get rpm of motor

I am trying to get a command to check the real rpm of a motor. I found that on RobotC, getMotorSpeed actually gets the speed it is supposed to be, not the actual speed, so it is kind of useless to me. I was wondering if there is a real way to get the rpm and update it constantly. Or is there none?

A more reliable way of finding out the rpm is to probably find the position the wheel is and a set amount of time between when you get the next position. So you would do some basic math to see how much the rotation of the motor changed in a set amount of time to get somewhat accurate rpm. Are you programming with text or blocks?

20 characters e

So if you were to do it in text, you should create a loop that includes variables like “currentPosition” and “previousPosition”. Once you’ve coded the two positions, you should subtract the previousPosition from the currentPosition to get the change in position. Now, all you need to do is divide by the amount of time that has passed and convert to rpm. I haven’t coded in robotC in like forever, so it might be wrong. The code would look something like this:

int rpm(){
double currentPosition = 0;
double previousPosition = 0;

currentPosition = (however you define the motor's position in robotC);

double calculation = (currentPosition - previousPosition)/time;
previousPosition = currentPosition;
return 1;
1 Like

no im using it for a flywheel for the pitching in game

Ah gotcha, well i’m not very sure on how to do that while the flywheel is running. Someone else might be able to help.