vijay s
Full Member level 3
- Joined
- Jun 14, 2008
- Messages
- 159
- Helped
- 27
- Reputation
- 54
- Reaction score
- 9
- Trophy points
- 1,298
- Location
- Coimbatore, India
- Activity points
- 2,152
Hi
i wrote a program to Measure RPM.. i am using Capture and Timer1... Capture is configured to capture on every 16 rising edge...
I am using PIC18F4550 with 48Mhz PLL... the RPM Measurement accuracy is good in range 300 - 20000... How to improve its range.. when i use this to measure 30000RPM.. the result is oscillating between 30000 and 15000... same happens to other high RPM... why it is oscillating between its original and Half RPM....
Here is My code to Measure RPM
Interrupt Service Routine
and is there anyway to calculate its accuracy Mathematically...........
i wrote a program to Measure RPM.. i am using Capture and Timer1... Capture is configured to capture on every 16 rising edge...
I am using PIC18F4550 with 48Mhz PLL... the RPM Measurement accuracy is good in range 300 - 20000... How to improve its range.. when i use this to measure 30000RPM.. the result is oscillating between 30000 and 15000... same happens to other high RPM... why it is oscillating between its original and Half RPM....
Here is My code to Measure RPM
Code:
WORD MeasureRPM(void)
{
static WORD PrevPeriod = 0;
static WORD CurPeriod = 0;
DWORD Period = 0;
CurPeriod = ReadPulseTime(); /* Capture Every 16 rising Edge */
Period = (RollOver * (DWORD)0XFFFF) - (DWORD)PrevPeriod + (DWORD)CurPeriod; /* Calc Interval Between Two 16 Pulses */
Period = Period >> 4; /* Divide By 16 to Calc Single Pulse Interval */
PrevPeriod = CurPeriod; /* Store Current Pulse period */
RPM = (DWORD)(90000000.36/Period); /* Calc RPM */
RollOver = 0; /* Timer1 Roll Over */
}
Interrupt Service Routine
Code:
void HighPriorityISRCode()
{
if(PIR1bits.TMR1IF == 1)
{
PIR1bits.TMR1IF = 0;
RollOver++;
}
if(PIR1bits.CCP1IF == 1)
{
PIR1bits.CCP1IF = 0;
MeasureRPM();
}
}
and is there anyway to calculate its accuracy Mathematically...........