Page 1 of 1

Motor RPM using interrupt ESP IDF

Posted: Thu Jun 10, 2021 10:49 am
by bhavikbhansali
Hello Members,

I hope you all are doing well. I am new to ESP IDF and need your help to develop a small code to measure the RPM of a Motor. I used a proximity sensor to detect the pulse at every rotation of a motor. Add its photo for a better idea.

I have the logic but I don't know how to write code for IDF.

Logic:
so using interrupt I want to measure the time between 2 pulses and out of that I want to calculate the RPM.
Example Let's say in 100 milliseconds will get 1 pulse, so in a minute/60 second/60000 milliseconds how many? so x=60000/100 so x=600 pulse in a minute which means the motor is rotating with 600RPM.

Can you please help me to write code for this?

Attaching the image for a better idea about I connect the sensor to get 1 pulse for a rotation.

Image

Re: Motor RPM using interrupt ESP IDF

Posted: Fri Jun 11, 2021 4:52 am
by ESP_jakob
I think the pulse counter peripheral may be more suited for your application.

Documentation and example code can be found here: https://docs.espressif.com/projects/esp ... /pcnt.html.

Best,
Jakob

Re: Motor RPM using interrupt ESP IDF

Posted: Fri Jun 11, 2021 4:22 pm
by bhavikbhansali
Thanks Jakob,

I tested the code but it only gives the pulse but for time-based calculation I need help.
Can you?