Hi,
so, it is the same drill with the chair but I have tried it today. Disabling the display and most of the stuff will not do any change unfortunately. However, I have tried only the RPM part from Bald engineer guide, this was working and thus I have tried to do more tests and the results are as follows:
- The RPM works if I do not regulate the PWM (yes, I was slowing down the FAN with my fingers to achieve lower revolutions
). This applies only for the RPM part from Bald engineers guide. I guess the circuit could be right in this case then. - If I changed the code only to the one below, the RPM was wrong again, however, if I have disabled the PIN9 as output, it was working
//configure Timer 1 (pins 9,10) to output 25kHz PWM
void setupTimer1(){
//Set PWM frequency to about 25khz on pins 9,10 (timer 1 mode 10, no prescale, count to 320)
TCCR1A = (1 << COM1A1) | (1 << COM1B1) | (1 << WGM11);
TCCR1B = (1 << CS10) | (1 << WGM13);
ICR1 = 320;
OCR1A = 0;
OCR1B = 0;
}
//equivalent of analogWrite on pin 9
void setPWM1A(float f){
f=f<0?0:f>1?1:f;
OCR1A = (uint16_t)(320*f);
}
unsigned long previousRPMMillis;
unsigned long previousMillis;
float RPM;
unsigned long interval = 1000;
const int reedPin = 2;
volatile unsigned long pulses=0;
unsigned long lastRPMmillis = 0;
void countPulse() {
// just count each pulse we see
// ISRs should be short, not like
// these comments, which are long.
pulses++;
}
void setup(){
//enable outputs for Timer 1
//pinMode(9,OUTPUT); //1A
setupTimer1();
//enable outputs for Timer 2
//setPWM1A(0.5f); //set duty to 50% on pin 9
Serial.begin(9600);
pinMode(reedPin,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(reedPin), countPulse, FALLING);
}
unsigned long calculateRPM() {
unsigned long RPM;
noInterrupts();
float elapsedMS = (millis() - lastRPMmillis)/1000.0;
unsigned long revolutions = pulses/2;
float revPerMS = revolutions / elapsedMS;
RPM = revPerMS * 60.0;
lastRPMmillis = millis();
pulses=0;
interrupts();
Serial.print(F("elpasedMS = ")); Serial.println(elapsedMS);
Serial.print(F("revolutions = ")); Serial.println(revolutions);
Serial.print(F("revPerMS = ")); Serial.println(revPerMS);
return RPM;
}
void loop(){
if (millis() - previousMillis > interval) {
Serial.print("RPM=");
Serial.println(calculateRPM());
previousMillis = millis();
}
}
So, all is good until I try to regulate the FAN and lower the PWM. According to the noctua specification, it should accept 21-28kHz and apparently the regulation works, why it do a mess with the RPM, that is very strange. Moreover, the same happens on a different fan from a different brand so it is not brand related.
The connection to the PWM fan pin is made directly from the PIN 9, no pull resistor in between, however, does this could make any difference?
I am quite lost at this moment ![]()
thx, Tomas