Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Improving Range of RPM Measurement

Status
Not open for further replies.

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
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...........
 

HI

Use a hardware timer as counter instead of triggering on a bit - You can also use an external frequency divider if count frequency is to high

All the best

Bobi

The microcontroller specialist
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top