From 783a21d88d8f8684322a5e2225f0c0b990e6b7a9 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 3 Oct 2021 14:00:29 +0200 Subject: [PATCH] Fix for incorrect RPM reported. --- usermods/PWM_fan/usermod_PWM_fan.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usermods/PWM_fan/usermod_PWM_fan.h b/usermods/PWM_fan/usermod_PWM_fan.h index 624534b1..97e7cd12 100644 --- a/usermods/PWM_fan/usermod_PWM_fan.h +++ b/usermods/PWM_fan/usermod_PWM_fan.h @@ -80,7 +80,8 @@ class PWMFanUsermod : public Usermod { // detach interrupt while calculating rpm detachInterrupt(digitalPinToInterrupt(tachoPin)); // calculate rpm - last_rpm = counter_rpm * (60 / numberOfInterrupsInOneSingleRotation); + last_rpm = (counter_rpm * 60) / numberOfInterrupsInOneSingleRotation; + last_rpm /= tachoUpdateSec; // reset counter counter_rpm = 0; // store milliseconds when tacho was measured the last time