I'm the programmer on Team 473. I've been trying to use Kevin Watson's encoder code to measure the RPMs of our transmission in order to write a shift scheduler. I've been trying to do this by getting the number of encoder counts which occur over 25 cycles of Process_Data_From_Master_uP. Since Process_Data_From_Master_uP runs every 26.2 ms, I can convert from rpms into encoder cycles per Process_Data_From_Master_uP runs. However, this is not giving me anything near an accurate RPM output (I have a digital tachometer to check the RPMs with).
Here's my code from Process_Data_From_Master_uP:
Code:
if (++counter >= (24))
{
Left_Encoder_Count = Get_Left_Encoder_Count();
printf("RPM Left: %5d\n",(int)((Left_Encoder_Count - previous_count_left)*0.698666667));
previous_count_left = Left_Encoder_Count;
counter = 0;
}
0.698666667 is the conversion factor counts per 25 Process_Data_From_Master_uP cycle to RPMs. (1 rotation/1 min*1 min/60 sec*1 sec/1000ms*655 ms (25*26.2ms)/1 program cycle*65 counts/1 rotation)
Either my conversion factor is totally wrong or my method is totally wrong (or my tachometer is wrong, but since it's digital I don't think it is). Can anyone help?
Thanks,