|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
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;
}
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, |
|
#2
|
||||
|
||||
|
Re: Kevin Watson's encoder code with RPM output
Two things...
1. The cycle time of 26.2 ms is approximate. To get accurate timing, write a timer interrupt routine. 2. Integer arithemetic! You are multiplying by 1... Try doing the math outside of the printf. Multiply by 6987 and store into a long int variable. Now divide by 10000 and store in an int variable. Now printf your int. Regards, |
|
#3
|
||||
|
||||
|
Re: Kevin Watson's encoder code with RPM output
Quote:
-Kevin |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |
| Kevin Watson's Kick-off Demo Code! | Mr. Lim | Programming | 27 | 22-01-2005 03:38 |
| Updated Encoder Code Available | Kevin Watson | Programming | 2 | 04-01-2005 01:00 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |
| Rookie Programmer has question about the default code | DanL | Programming | 3 | 26-01-2002 19:59 |