My team is trying to figure out in autonomous when to run our conveyor belt based on if the flywheel is at the top speed, but we are not sure how to calculate the rpm based on the IME’S recordings. Could Someone Please Give me some sample code or a demonstration on how to do so.

task velocity()
{
// This task determines the current velocity of the shooter wheels
float L = 0;
float circ = 5*3.1415926535;//finds the circumfrence of the wheel
while(true)
{
L = (nMotorEncoder[I2C_2]+ nMotorEncoder[I2C_3])/2; // how would i do this with ime's
velocityIn = (circ/12)*(L/392)*50*21; // determines how far the wheels spun in last 20 MS and converts it to FPS
velocity = L*50*25;
clearLCDLine(0);
clearLCDLine(1);
SensorValue[I2C_2] = SensorValue[I2C_3] = 0;
wait1Msec(20);
}
}

here is a code example for a shooter using 2 IME’s on motors to power a one wheel shooter, the motors are speed motors, and they are geared 25 to one to the shooter wheel

If your flywheels are mechanically linked, then you only need to calculate the velocity for one side, as they must be the same. Otherwise, use two velocities (and perhaps compare them to make sure they are at least close). Here’s some pseudocode:

This gives you the rotational velocities of each flywheel. The gear ratio then scales this value by (input/output). the gear ratio must be a decimal, and you might as well declare it as a constant, unless you have a transmission on your flywheel. It looks like this:

What exactly do all those factors mean? and btw we have an 87-12 gear ratio to get that right. And are those factors for a certain wheel . For details. We have a 87-12 gear ratio a dual flywheel with 5’ wheels with two motors per wheel and two 87 turning a 12 on each wheel and each 87 being turned by a highspeed motor. I am really trying to make this right so if you could provide some reasoning behind the math for an engineering notebook page that would be great.

Anyway, to calculate the RPM of a flywheel, you first must figure out how fast the motor attached to a flywheel is moving. You can do that by taking an IME reading, waiting, then taking another IME reading. Then to get the ticks per milisecond you take the last IME reading, minus the first IME reading, then divide by the time. You then times by 7 to get the flywheel ticks p/s and finally times by 60 and divide by a motors full rotation (260 - 360) to get the RPM.