Pages: 1 [2] 3 4   Go Down
Author Topic: help in making engine digital RPM meter  (Read 10022 times)
0 Members and 2 Guests are viewing this topic.
Columbus, Ohio USA
Offline Offline
Full Member
***
Karma: 3
Posts: 110
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

The datasheet is not clear to me...

Check out the equation given:

Vout = fin * Vcc * R1 * C1

So just for the sake of argument say you wanted the full-scale reading (Vout = Vcc) to be at 2000 Hz (2000 rpm in your case as I understand it):

R1 * C1 = 1/2000 = .0005

On p. 7 of the data sheet there are some guidelines for choosing R1 and C1, although as you say it's not exactly clear--maybe just experiment.

Joe

Logged

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

I want pick the capacitive pulse with a ne555 like here http://www.sportdevices.com/rpm_readings/index.htm
and feed it to the LM2917..

now in my single cylinder bike there is one spark in every rotation..

so if the engine is running at 2000 rpm then what will be the frequency (Fin) ..??
2000 Hz or (2000/60 )Hz...??
Logged

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

I want pick the capacitive pulse with a ne555 like here http://www.sportdevices.com/rpm_readings/index.htm
and feed it to the LM2917..

now in my single cylinder bike there is one spark in every rotation..

so if the engine is running at 2000 rpm then what will be the frequency (Fin) ..??
2000 Hz or (2000/60 )Hz...??

Oh, sorry--right you are, it's 33 1/3 Hz. Funny, that!

Joe
Logged

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

first I want to ask that should I convert the frequency to 0 - 5 volt ( taking Vout = 5 volt at 7000 Rpm) and read it with the analog input pin..??

so my 0 - 7000 RPM will be analog read    rpm = map(rpm, 0, 1023, 0, 7000)

                                    OR

There is other better way to do it for better precession and accuracy..??
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There is other better way to do it for better precession and accuracy..??
None of what you suggest here will make for better precision or accuracy. Multiplying an inaccurate value won't make it more accurate.

Getting the signal each and every time, at the exact time it is sent, is how you improve accuracy. Precision is rather meaningless in this context. Either you got the pulse or you didn't. There isn't any middle ground.
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

If I may add to Pauls, also depend on the rotation device ( ei : your bike motor )
Logged

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

So should I just go for -

convert the frequency to 0 - 5 volt ( taking Vout = 5 volt at 7000 Rpm) and read it with the analog input pin..??

so my 0 - 7000 RPM will be analog read    rpm = map(rpm, 0, 1023, 0, 7000)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
convert the frequency to 0 - 5 volt
Frequency of what? How will you convert that frequency to a voltage?
Logged

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

Quote
convert the frequency to 0 - 5 volt
Frequency of what? How will you convert that frequency to a voltage?

PaulS this is the IC which converts frequency to voltage

http://www.national.com/ds/LM/LM2907.pdf

and the calculation for it is

Vout = Vcc * Fin * R1 * C1
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Converting what is essentially a digital signal to analog via a frequency-to-voltage chip and then converting it back to digital strikes me as being a very silly way to make a digital RPM meter. Much better is to:

1. Clean up the input pulse if necessary so that you get one (or more) well-defined pulse(s) per revolution (you would have to do this anyway if you use a frequency-to-voltage chip);

2. Feed the pulse into an Arduino pin that supports interrupts. In the ISR, record the time that the pulse occurred using a call to micros(), and calculate the time since the previous pulse. Then the RPM is just 60 divided by the interval (in seconds) between pulses.
« Last Edit: May 18, 2013, 03:33:05 pm by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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

Converting what is essentially a digital signal to analog via a frequency-to-voltage chip and then converting it back to digital strikes me as being a very silly way to make a digital RPM meter. Much better is to:

1. Clean up the input pulse if necessary so that you get one (or more) well-defined pulse(s) per revolution (you would have to do this anyway of you use a frequency-to-voltage chip);

2. Feed the pulse into an Arduino pin that supports interrupts. In the ISR, record the time that the pulse occurred using a call to micros(), and calculate the time since the previous pulse. Then the RPM is just 60 divided by the interval (in seconds) between pulses.

You are right.. I even had the same thought in my mind that why convert frequency to voltage and feed arduino when arduino itself can take the frequency directly..

If you read my posts right from the beginning, you will notice thats what I wanted to do ..

I wanted to find the time gap between pulses and calculate the RPM...But I just couldn't get how to find the interval...

can you please help me with the coding as you said..??
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I'll assume you are using an Arduino Uno. This can generate interrupt 0 on pin 2 and interrupt 1 on pin 3. I'll assume you are feeding the ignition pulse (cleaned up if necessary) to pin 2. Here is a sketch to calculate the rpm:

Code:
const int ignitionPin = 2;
const int ignitionInterrupt = 0;
const unsigned int pulsesPerRev = 1;

unsigned long lastPulseTime = 0;
unsigned long rpm = 0;

void ignitionIsr()
{
  unsigned long now = micros();
  unsigned long interval = now - lastPulseTime;
  if (interval > 2000)
  {
     rpm = 60000000UL/(interval * pulsesPerRev);
     lastPulseTime = now;
  }  
}

void setup()
{
  pinMode(ignitionPin, INPUT);
  attachInterrupt(ignitionInterrupt, &ignitionIsr, RISING);
}

void loop()
{
  // insert code here to show the RPM on the display and delay for e.g. 0.2 seconds
}

I've included some pulse cleanup in the software (i.e. ignore pulses that are less than 2ms apart).
« Last Edit: September 13, 2011, 02:09:14 pm by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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

Thank you so much... smiley

I have a Arduino duemilanove with the Atmega328.. Hope it will also able to take interrupts as the uno on the same pins.. as the uno also uses the 328...
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17259
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
have a Arduino duemilanove with the Atmega328.. Hope it will also able to take interrupts as the uno on the same pins.. as the uno also uses the 328...

As far as software code and hardware pin numbers there is no difference between Uno and your board. Only difference for Uno is smaller size bootloader that also uploads at a faster baudrate, everthing else is the same.


Lefty

Logged

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

OK, I'll assume you are using an Arduino Uno. This can generate interrupt 0 on pin 2 and interrupt 1 on pin 3. I'll assume you are feeding the ignition pulse (cleaned up if necessary) to pin 2. Here is a sketch to calculate the rpm:

Code:
const int ignitionPin = 2;
const int ignitionInterrupt = 0;
const unsigned int pulsesPerRev = 1;

unsigned long lastPulseTime = 0;
unsigned long rpm = 0;

void ignitionIsr()
{
  unsigned long now = micros();
  unsigned long interval = now - lastPulseTime;
  if (interval > 2000)
  {
     rpm = 60000000UL/(interval * pulsesPerRev);
     lastPulseTime = now;
  }  
}

void setup()
{
  pinMode(ignitionPin, INPUT);
  attachInterrupt(ignitionInterrupt, &ignitionIsr, RISING);
}

void loop()
{
  // insert code here to show the RPM on the display and delay for e.g. 0.2 seconds
}

I've included some pulse cleanup in the software (i.e. ignore pulses that are less than 2ms apart).



@ dc42 

First tell me how do I setup my hardware portion of pulse input to the arduino board..??
I thought of using something like this http://www.sportdevices.com/rpm_readings/index.htm
or
tell me if there is any other way to pickup and feed the pulse which will just match your coding..



I went through your code, its just what I want to do, but couldnt plot out how to do it as I am not much advance in coding..

will you please make me understand this part...     rpm = 60000000UL/(interval * pulsesPerRev);         what is that 60000000UL...??
Logged

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