So, I have this task to calculate the RPM of the side of my robot by averaging out 2 quad encoder values then calculating stuff.
(Gonna make lookup tables)
However I think my calculations are incorrect as the RPM don’t really match under load.
Can someone have a look over the code and correct it?
Thanks
task cMotorRpm(){
float mRecordedValues[128];
float curValue;
float nextValue;
float curRPM;
for (int i = 0; i <= 127; i++)
{
SensorValue[encLeftF] = 0;
SensorValue[encLeftB] = 0;
motor[port2] = i;
wait1Msec(500);
curValue = (SensorValue[encLeftF] + SensorValue[encLeftB])/2;
wait1Msec(3000);
nextValue = (SensorValue[encLeftF] + SensorValue[encLeftB])/2;
curRPM = ((nextValue - curValue)/90.0)*60.0;
mRecordedValues* = curRPM;
motor[port2] = 0;
wait1Msec(1000);
}
motor[port2] = 0;
for (int i = 0; i <=127; i++){
writeDebugStreamLine("%d", mRecordedValues*);
}
}
**