Measuring princip - Gramophone RPM?

I am planning to design a gramophone tacho / RPM tool.
I think I will use the ESP32 because I intent to use classic Bluetooth for datalogging.

Right now I am working on the code for a IR sensor and ESP32 measuring the RPM.

My question:
I work with the pulsIn function.
The solution are working very stable.

I have a feeling there is somthing I oversee?
Any ideas?

If it works, what is there to fix?

Why do you think that? Without seeing your code and knowing what your ultimate goal may be it is impossible to suggest any kind of improvement.

I will be happy to show the code when I have a working code.

I asked the question - hoping that someone who allready have done the considerations could give me som info.
I have Googled for ideas and all the codes I have found are based on itming controlled by interupts.

Thats why I feel I am on the wrong track by going for a solution based on pulsIn.

Good grief! Try both!!!

There are a few ways to measure the RPM, but in principle you will measure the time between two pulses from the IR-sensor. Less pulses means more accuracy but it will take a long time to see what happens when you change the RPM.. I would suggest to have about 5 pulses per rotation.
Trigger an interrupt can work fine.. The rest of the time can be used to calculate and create the right info for the display. And don't display more than 1 digit behind the comma.. It will fluctuate too much.. Maybe calculate the average over the last four or five measurements gives you a more relaxed display.

Is it one pulse per revolution? If the speed is stable, using pulseIn(pulsePin, HIGH) + pulseIn(pulsePin, LOW) should get you the total time for one revolution.

There are 60 million microseconds in a minute.
unsigned RPM = 60000000ul / (pulseIn(pulsePin, HIGH) + pulseIn(pulsePin, LOW));

Warning: If the turntable is stopped, both of the pulseIn() calls will time out and return zero. Dividing by 0 is a problem so you should check for timeout first:

unsigned RPM = 0;
unsigned long highTime = pulseIn(pulsePin, HIGH);
unsigned long lowTime = pulseIn(pulsePin, LOW);
if (highTime != 0 && lowTime != 0)
{
  RPM = 60000000ul / (highTime + lowTime);
}

You might want to read this article.

Thank you very much, I will use your recommendations.
Very helpfull, now I "beleive" in the use of pulsin :grinning:

Thank you very much - this is a really helpful article.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.