Please, I need a help of how to write RPM Counter Code, to measure rpm of diesel engine. i will use a inductance proximity switch npn.
FYI , I will tell you what point i did reach. i could count the change of state of the input pulse, but what i need is how to count it with in 60 seconds, to measure the value of revolution per min't.
if you could help me, it will be highly appreciated.
The usual way to measure RPM is to have the input trigger an interrupt. In the interrupt service routine, call micros() to get the current time since startup, and store it. From the difference in time between two consecutive interrupts, you can get the time between interrupts, and hence calculate the RPM. This gives you greater resolution and faster response than measuring the number of pulses in a given period of time. See help in making engine digital RPM meter - #27 by dc42 - Programming Questions - Arduino Forum and other posts in the same thread for code examples.
Dear dc42 member,
Many thanks for your kind cooperation.
I checked your suggested code, but because of my poor experience in arduino uno programming, i could not understand most of the code.
Please, could you explain to me your suggested code, with my regards.