Motor RPM using interrupt ESP IDF

bhavikbhansali
Posts: 4
Joined: Fri Jan 12, 2018 1:48 pm

Motor RPM using interrupt ESP IDF

Postby bhavikbhansali » Thu Jun 10, 2021 10:49 am

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
Attachments
motor.jpg
motor.jpg (973.5 KiB) Viewed 5197 times

ESP_jakob
Posts: 49
Joined: Mon Jun 01, 2020 6:28 am

Re: Motor RPM using interrupt ESP IDF

Postby ESP_jakob » Fri Jun 11, 2021 4:52 am

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

bhavikbhansali
Posts: 4
Joined: Fri Jan 12, 2018 1:48 pm

Re: Motor RPM using interrupt ESP IDF

Postby bhavikbhansali » Fri Jun 11, 2021 4:22 pm

Thanks Jakob,

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

Who is online

Users browsing this forum: Bing [Bot] and 236 guests