Go Down

Topic: help in making engine digital RPM meter (Read 12222 times) previous topic - next topic

jmknapp


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


Joy

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

jmknapp


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

Joy

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

PaulS

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.

Techone

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

Joy

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)

PaulS

Quote
convert the frequency to 0 - 5 volt

Frequency of what? How will you convert that frequency to a voltage?

Joy


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

dc42

#24
Sep 13, 2011, 08:04 pm Last Edit: May 18, 2013, 10:33 pm by dc42 Reason: 1
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.
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.

Joy


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

dc42

#26
Sep 13, 2011, 09:02 pm Last Edit: Sep 13, 2011, 09:09 pm by dc42 Reason: 1
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: [Select]
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).
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.

Joy

Thank you so much... :)

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

retrolefty

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


Joy


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: [Select]
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...??

Go Up