# Frequency measurement vs microprocessor speed.

I am replicating someone else's project, and so far it's going well...
the project involves reading RPM off an engine. The code uses PulseIn() and looks for a reading of 14000 for 800 RPM. (I don't understand why, I would assume it's 1 pulse per revolution.)

While I am struggling to understand that bit of logic, another question popped into my head -- how does microprocessor speed (ie: 8mhz vs 16mhz) effect the min/max reading for PulseIn() and other frequency counting functions? (or does the microprocessor speed have nothing to do with it at all?)
Thanks.

800 RPM is 13.333 per second, may that explain your number?

Microcontroller executing at 8 MHz executes some 600.000 instructions between each tick from an axle spinning at 13.333 rotations per second. Said in another way, a millisecond (1/1000 of a second) is a really long time for a microcontroller at 8 MHz.

Thanks for the reply.... I must have a block. I don't understand how we get 14000 from 800 rpm if it's reading pulses/microsecond, wouldn't it be 13300?

So it shouldn't matter if I use a microcontroller at 8 or 16mhz for reading rpm's? It seems from what I understand (which is a bit muddled right now) that 0 to 16,000 rpm should be trivial for 8mhz microcontroller to read.

Thank you... I really want to understand this; but I am missing something obvious...

daveyjones:
Thank you... I really want to understand this; but I am missing something obvious...

Yes, a link to the project.

Well; here’s the relevant bits…

``````#define LED_PIN 17 // internal LED pin
#define RPM_PIN 9 // rpm input pin
#define LED_ON LOW // the micro has it reversed...
#define LED_OFF HIGH // ON = LOW, OFF = HIGH
#define THRESHOLD 44000 // 800 RPM

uint32_t duration;

void setup () {
pinMode (LED_PIN, OUTPUT); // set the pin D17 to output
pinMode (RPM_PIN, INPUT_PULLUP); // switch pullup for RXD pin

digitalWrite (RPM_PIN, LOW); // set pin to HIGH level
digitalWrite(LED_PIN, HIGH);
}

void loop () // void main(void) {
duration = pulseIn(RPM_PIN, HIGH);

if (duration < THRESHOLD)
digitalWrite(LED_PIN, LOW);
else
digitalWrite(LED_PIN, HIGH);
delay(500); // for the test only
}
``````

There was no notation of what board was used, and the engine is capable of rpm’s in excess of 18000… Which is what got me wondering about 8mhz vs 16mhz and if it had an effect on what frequencies could be read…

8 vs 16 MHz is accounted for in the code that is chosen by the IDE to match the board that you have selected. I guess the site is top secret, since you won't link to it? I don't work with people that don't do what I ask, when it's a perfectly reasonable request.

daveyjones:
There is no "link" to the project, it was emailed to me... I can't give you what does not exist...
I guess thanks for your time, sorry it was utterly wasted on us both...

Can you not post anything? You have it on your computer, no?

Don't blame me if you ask a question and time is wasted because you posted incomplete information. I like to help people, but when getting simple information is like pulling teeth, it's too frustrating.