Pages: [1] 2 3 4   Go Down
Author Topic: help in making engine digital RPM meter  (Read 11453 times)
0 Members and 1 Guest are viewing this topic.
INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to build an RPM meter for an engine.

The process I have selected is by Capacitive RPM sensing circuit inspire by
http://www.sportdevices.com/rpm_readings/index.htm


Now on each rotation of the engine there is one spark. That is I get one pulse in each rotation..

But how do I now calculate it in rotations per minutes..??

Is it I will have to find the time difference between pulses and multiply it with 60...??

Or there is some other way too..??
« Last Edit: September 09, 2011, 12:32:46 am by Joy » Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 31
Posts: 2611
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hope, this article would help.
http://tronixstuff.wordpress.com/2011/06/22/tutorial-arduino-timing-methods-with-millis/
Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There are a couple common methods of calculating RPMs, and which is best to use depends on a variety of factors.

1. Measure the time between pulses.  Use that time to calculate RPMs.
  If the time between pulses is measured in milliseconds, then RPM can be calculated using:
  60000/time_between_pulses

2. Count the number of pulses that occur in an arbitrary period of time.  Use that value to calculate RPMs.
  If you count the number of pulses that occur in 1 second, then RPM can be calculated using:
  pulse_count*60

Both these calculations assume you have 1 pulse per revolution (as you mentioned).  Below are versions of the formula that add a pulses_per_rev parameter (which, when equal to one, will simplify to the above formulas)
60000/(time_between_pulses*pulses_per_rev)
(pulse_count/pulses_per_rev)*60

If, in the second formula you are counting the number of pulses in a period of time that is not 1 second, then you need to normalize the formula to a 1 second count period.
Logged


INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are a couple common methods of calculating RPMs, and which is best to use depends on a variety of factors.

1. Measure the time between pulses.  Use that time to calculate RPMs.
  If the time between pulses is measured in milliseconds, then RPM can be calculated using:
  60000/time_between_pulses

2. Count the number of pulses that occur in an arbitrary period of time.  Use that value to calculate RPMs.
  If you count the number of pulses that occur in 1 second, then RPM can be calculated using:
  pulse_count*60

Both these calculations assume you have 1 pulse per revolution (as you mentioned).  Below are versions of the formula that add a pulses_per_rev parameter (which, when equal to one, will simplify to the above formulas)
60000/(time_between_pulses*pulses_per_rev)
(pulse_count/pulses_per_rev)*60

If, in the second formula you are counting the number of pulses in a period of time that is not 1 second, then you need to normalize the formula to a 1 second count period.

I feel its better to go with the 1st option...

because if I am going with the pulse per second and i have each pulse every 1.5 seconds then the calculation will be lil hard...

And more over my engine's idle RPM is 600...
Logged

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I calculate the      time_between_pulse..??
Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I calculate the      time_between_pulse..??

Magician's link provides some good information on how to do that.
Logged


Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50924
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
because if I am going with the pulse per second and i have each pulse every 1.5 seconds then the calculation will be lil hard...
Quote
How do I calculate the      time_between_pulse..??
Seems to me you already told us the time between pulses...
Logged

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
because if I am going with the pulse per second and i have each pulse every 1.5 seconds then the calculation will be lil hard...
Quote
How do I calculate the      time_between_pulse..??
Seems to me you already told us the time between pulses...

yes i told but it is not same all the time it increases and decreases
Logged

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
yes i told but it is not same all the time it increases and decreases

@Joy

+ or -  ? you talking about the engine ? car engine usally do not have acurate RPM, also Lawn Mower engine... smiley-wink

So what the range ?  example : 450 to 650

If you have +/- 100, well that good right ? 
Logged

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
yes i told but it is not same all the time it increases and decreases

@Joy

+ or -  ? you talking about the engine ? car engine usally do not have acurate RPM, also Lawn Mower engine... smiley-wink

So what the range ?  example : 450 to 650

If you have +/- 100, well that good right ? 

I will be reading the rpm of a single cylinder engine. That is of my bike..

the idle rpm of the engine is around 600
Logged

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried this code idea from here http://www.arduino.cc/playground/Learning/Tachometer

Code:
//
// This example shows one way of creating an optoswitch
// using an IR LED as emiter and an IR LED receiver as
// light sensor.
// On this case it acts as a tachometer to count the
// revolutions per second of an aeromodelism plane's
// propeller.
//
//           + GROUND                                 +GROUND         
//           |                                        | 
//           <                                        <
//           > 220 ohm resistor                       > 220 omh resistor
//           <                                        <     
//           |                                        | 
//           |                                        |
//         -----                                    -----
//          / \    >>IR LED emiter >>>>>>>>>>>>>>>>  / \   IR LED receiver
//         -----                                    -----
//           |                                        |
//           |                                        |
//           + +5VCD                                  +  ANALOG INPUT 0
//


int val;
long last=0;
int stat=LOW;
int stat2;
int contar=0;

int sens=75;  // this value indicates the limit reading between dark and light,
              // it has to be tested as it may change acording on the
              // distance the leds are placed.
int nPalas=2; // the number of blades of the propeller

int milisegundos=500; // the time it takes each reading
void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}

void loop()
{
  val=analogRead(0);
  if(val<sens)
    stat=LOW;
   else
    stat=HIGH;
   digitalWrite(13,stat); //as iR light is invisible for us, the led on pin 13
                          //indicate the state of the circuit.

   if(stat2!=stat){  //counts when the state change, thats from (dark to light) or
                     //from (light to dark), remmember that IR light is invisible for us.
     contar++;
     stat2=stat;
   }
   if(millis()-last>=milisegundos){
     double rps=((double)contar/nPalas)/2.0*1000.0/milisegundos;
     double rpm=((double)contar/nPalas)/2.0*60000.0/(milisegundos);
     Serial.print((contar/2.0));Serial.print("  RPS ");Serial.print(rps);
     Serial.print(" RPM");Serial.print(rpm);Serial.print("  VAL ");Serial.println(val);
     contar=0;
     last=millis();
   }
}


in the code if I change    int nPalas=2; // the number of blades of the propeller     to    int nPalas=1;

as in my engine one pulse output is one rotation..


and the code checks for number of pulses in 500 miliseconds, the reading is not that accurate all the time..
it fluctuates a lot
Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 17
Posts: 781
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and the code checks for number of pulses in 500 miliseconds, the reading is not that accurate all the time..
it fluctuates a lot

This goes along the lines of what I was saying in my first post.  With only 1 pulse per rotation, and relatively low speed, you won't get many counts in a 500 millisecond window, which means any fluctuation  in counts is going to create a magnified fluctuation in RPMs.

The easiest way to remedy that is to increase the duration in which you're counting pulses, possibly increasing it to several seconds.  Unless you are using the RPM as an input to some other high speed process, like a PID, that shouldn't be a problem.
Logged


Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Joy

First. Check your sensor and make sure it is "clean" <--- no bouncing

So you are using one cylinder engine  <-- Just like a lawn mower  smiley-grin

My Theory :
Let assume the RPM is 600.  600 pulse / min  / 60 second = 10 pulse / second  +/- 100 rpm or 1 pulse / second ( the variation )

If using 500 ms, you should get 5 pulse / 500 ms = 10 pulse / second

In you code you have "contar" meaning count, can you modify so you can see the variale "contar" to check your "pulse", if you have 5 pulse +/- 1, well it work fine, if not, check the calculations, maybe check sensor, and maybe re-modify the code.

Code:
int val;
long last=0;
int stat=LOW;
int stat2;
int contar=0;

int sens=75;  // this value indicates the limit reading between dark and light,
              // it has to be tested as it may change acording on the
              // distance the leds are placed.
int nPalas=2; // the number of blades of the propeller

int milisegundos=500; // the time it takes each reading
void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}

void loop()
{
  val=analogRead(0);
  if(val<sens) // Software comparator
  {
    stat=LOW;
  }
   else
  {
    stat=HIGH;
  }
   digitalWrite(13,stat); //as iR light is invisible for us, the led on pin 13
                          //indicate the state of the circuit.

   if(stat2!=stat)
 {  //counts when the state change, thats from (dark to light) or
                     //from (light to dark), remmember that IR light is invisible for us.
     contar++;
     stat2=stat;
   }

if(millis()-last>=milisegundos)
{ // isolated the calculations to check the pulse count and check the pulse counting routine
/*
     double rps=((double)contar/nPalas)/2.0*1000.0/milisegundos;
     double rpm=((double)contar/nPalas)/2.0*60000.0/(milisegundos);
     Serial.print((contar/2.0));Serial.print("  RPS ");Serial.print(rps);
     Serial.print(" RPM");Serial.print(rpm);Serial.print("  VAL ");Serial.println(val);
*/
     Serial.println(contar); // to check the contar variable
     contar=0; // reset contar variable
     last=millis();
  }
}

Logged

Columbus, Ohio USA
Offline Offline
Full Member
***
Karma: 3
Posts: 110
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could feed the pulses to a frequency-to-voltage converter chip:

http://www.national.com/ds/LM/LM2907.pdf
http://parts.digikey.com/1/parts/483487-ic-converter-freq-volt-14-dip-lm2907n-nopb.html

...and then the rpm reading becomes just an analog read and scale factor & no need to worry about timing pulses. Note the "minimum component tachometer" on p. 8.

Joe

Logged

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could feed the pulses to a frequency-to-voltage converter chip:

http://www.national.com/ds/LM/LM2907.pdf
http://parts.digikey.com/1/parts/483487-ic-converter-freq-volt-14-dip-lm2907n-nopb.html

...and then the rpm reading becomes just an analog read and scale factor & no need to worry about timing pulses. Note the "minimum component tachometer" on p. 8.

Joe




Thats a great thing I have come through,..

It will be great..
But can u help me out like how to do with it...??


how do I know what frequency input is what output voltage..

The datasheet is not clear to me...
Logged

Pages: [1] 2 3 4   Go Up
Jump to: