Hi all,
I am fairly new to the raspberry pi micro computer and I am working on a project which I would like to count up to 8000 RPM. Currently I have the program to running however when RPM gets about 5800-6000 I begin to drop signals.
My code:
import time
last_time=0
this_time=0
rpm=0
calc=0
def RPM(channel):
global rpm,this_time, last_time,calc
if GPIO.input(channel) >0.5:
this_time = time.time()
rpm=(1/(this_time-last_time))*60
last_time=this_time
print(rpm)
GPIO.add_event_detect(24,GPIO.RISING,callback=RPM)
My question is am I doing something fundamentally wrong or is is my code inefficient, or is the pi just not able yo keep up at that rate?
Thanks for your help in advance