How do I calculate the rpm of the fan connected to my Raspberry Pi? [closed]












1















So what I've got is a Noctua fan(product link: https://noctua.at/en/products/fan/nf-a4x20-5v/specification) connected to a Raspberry Pi 3. I want to know the RPM of the fan at every second interval. I have a python script that gives me a value for the RPM but the RPM does not seem to be accurate. The fan speed is 5000rpm(+/-10%) at full capacity whereas the script gives an RPM value which is half of what is expected. I need help with how to get an accurate reading using PWM(pulse width modulation) or any other technique.



def calculate_elapse(channel):              # callback function
global pulse, start_timer, elapse
pulse+=1 # increase pulse by 1 whenever interrupt occurred
elapse = time.time() - start_timer # elapse for every 1 complete rotation made!
start_timer = time.time() # let current time equals to start_timer

def calculate_speed(r_cm):
global pulse,elapse,rpm,dist_km,dist_meas,km_per_sec,km_per_hour
if elapse !=0: # to avoid DivisionByZero error
rpm = 1/elapse * 60
circ_cm = (2*math.pi)*r_cm # calculate wheel circumference in CM
dist_km = circ_cm/100000 # convert cm to km
km_per_sec = dist_km / elapse # calculate KM/sec
km_per_hour = km_per_sec * 3600 # calculate KM/h
dist_meas = (dist_km*pulse)*1000 # measure distance traverse in meter
return km_per_hour


Screen grab of the output that I am getting










share|improve this question













closed as off-topic by DavidPostill Jan 22 at 15:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about computer hardware or software, within the scope defined in the help center." – DavidPostill

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Welcome to Super User! Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.

    – DavidPostill
    Jan 22 at 15:09
















1















So what I've got is a Noctua fan(product link: https://noctua.at/en/products/fan/nf-a4x20-5v/specification) connected to a Raspberry Pi 3. I want to know the RPM of the fan at every second interval. I have a python script that gives me a value for the RPM but the RPM does not seem to be accurate. The fan speed is 5000rpm(+/-10%) at full capacity whereas the script gives an RPM value which is half of what is expected. I need help with how to get an accurate reading using PWM(pulse width modulation) or any other technique.



def calculate_elapse(channel):              # callback function
global pulse, start_timer, elapse
pulse+=1 # increase pulse by 1 whenever interrupt occurred
elapse = time.time() - start_timer # elapse for every 1 complete rotation made!
start_timer = time.time() # let current time equals to start_timer

def calculate_speed(r_cm):
global pulse,elapse,rpm,dist_km,dist_meas,km_per_sec,km_per_hour
if elapse !=0: # to avoid DivisionByZero error
rpm = 1/elapse * 60
circ_cm = (2*math.pi)*r_cm # calculate wheel circumference in CM
dist_km = circ_cm/100000 # convert cm to km
km_per_sec = dist_km / elapse # calculate KM/sec
km_per_hour = km_per_sec * 3600 # calculate KM/h
dist_meas = (dist_km*pulse)*1000 # measure distance traverse in meter
return km_per_hour


Screen grab of the output that I am getting










share|improve this question













closed as off-topic by DavidPostill Jan 22 at 15:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about computer hardware or software, within the scope defined in the help center." – DavidPostill

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Welcome to Super User! Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.

    – DavidPostill
    Jan 22 at 15:09














1












1








1








So what I've got is a Noctua fan(product link: https://noctua.at/en/products/fan/nf-a4x20-5v/specification) connected to a Raspberry Pi 3. I want to know the RPM of the fan at every second interval. I have a python script that gives me a value for the RPM but the RPM does not seem to be accurate. The fan speed is 5000rpm(+/-10%) at full capacity whereas the script gives an RPM value which is half of what is expected. I need help with how to get an accurate reading using PWM(pulse width modulation) or any other technique.



def calculate_elapse(channel):              # callback function
global pulse, start_timer, elapse
pulse+=1 # increase pulse by 1 whenever interrupt occurred
elapse = time.time() - start_timer # elapse for every 1 complete rotation made!
start_timer = time.time() # let current time equals to start_timer

def calculate_speed(r_cm):
global pulse,elapse,rpm,dist_km,dist_meas,km_per_sec,km_per_hour
if elapse !=0: # to avoid DivisionByZero error
rpm = 1/elapse * 60
circ_cm = (2*math.pi)*r_cm # calculate wheel circumference in CM
dist_km = circ_cm/100000 # convert cm to km
km_per_sec = dist_km / elapse # calculate KM/sec
km_per_hour = km_per_sec * 3600 # calculate KM/h
dist_meas = (dist_km*pulse)*1000 # measure distance traverse in meter
return km_per_hour


Screen grab of the output that I am getting










share|improve this question














So what I've got is a Noctua fan(product link: https://noctua.at/en/products/fan/nf-a4x20-5v/specification) connected to a Raspberry Pi 3. I want to know the RPM of the fan at every second interval. I have a python script that gives me a value for the RPM but the RPM does not seem to be accurate. The fan speed is 5000rpm(+/-10%) at full capacity whereas the script gives an RPM value which is half of what is expected. I need help with how to get an accurate reading using PWM(pulse width modulation) or any other technique.



def calculate_elapse(channel):              # callback function
global pulse, start_timer, elapse
pulse+=1 # increase pulse by 1 whenever interrupt occurred
elapse = time.time() - start_timer # elapse for every 1 complete rotation made!
start_timer = time.time() # let current time equals to start_timer

def calculate_speed(r_cm):
global pulse,elapse,rpm,dist_km,dist_meas,km_per_sec,km_per_hour
if elapse !=0: # to avoid DivisionByZero error
rpm = 1/elapse * 60
circ_cm = (2*math.pi)*r_cm # calculate wheel circumference in CM
dist_km = circ_cm/100000 # convert cm to km
km_per_sec = dist_km / elapse # calculate KM/sec
km_per_hour = km_per_sec * 3600 # calculate KM/h
dist_meas = (dist_km*pulse)*1000 # measure distance traverse in meter
return km_per_hour


Screen grab of the output that I am getting







python raspberry-pi fan raspbian sensors






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 22 at 0:53









jaitjait

62




62




closed as off-topic by DavidPostill Jan 22 at 15:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about computer hardware or software, within the scope defined in the help center." – DavidPostill

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by DavidPostill Jan 22 at 15:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about computer hardware or software, within the scope defined in the help center." – DavidPostill

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome to Super User! Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.

    – DavidPostill
    Jan 22 at 15:09



















  • Welcome to Super User! Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.

    – DavidPostill
    Jan 22 at 15:09

















Welcome to Super User! Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.

– DavidPostill
Jan 22 at 15:09





Welcome to Super User! Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.

– DavidPostill
Jan 22 at 15:09










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Сан-Квентин

8-я гвардейская общевойсковая армия

Алькесар