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

1

0

Browse other questions tagged .