Go Down

Topic: Fan RPM readout not correct when powered by PWM (Read 1 time) previous topic - next topic

MG2R

I'm trying to control a 3-pin pc fan with PWM while reading out the RPM. When the fan is powered by a 'constant' voltage (that is, not controlled by PWM) I can read out the RPM perfectly using the sketch below. But when I power the fan by a PWM signal (even when it is 255, constantly on), the RPM signal gets screwed up (I guess) and the readout isn't correct at all. Does anyone know what causes this and/or how I can fix it? :)

Thanks!

--PWM readout sketch--
Code: [Select]
unsigned long time;
unsigned int rpm;

void setup()
{
  Serial.begin(9600);
  digitalWrite(2, HIGH);
}

void loop()
{
  time=pulseIn(2,HIGH);
  rpm=(1000000*60)/(time*4);
  Serial.println(rpm,DEC);
  delay(700);
}

RIDDICK

1.
can u build a little "oscilloscope" with an analog pin?
2.
i did that too and the pulled up tacho line looks very funny...
not like a square wave...
but with spikes and smooth curves...
like there is an inductance involved...   :~
3.
i pulled the tacho up to Vfan+ (12V) and then i used an opamp to translate the voltage to 0V..5V...
and i did some digital debouncing which worked fine 2...
-Arne

MG2R


1.
can u build a little "oscilloscope" with an analog pin?
2.
i did that too and the pulled up tacho line looks very funny...


I borrowed my uncle's scope... You can see the signal in the attachments. I'm going to filter that signal with a 1µF cap and I hope that should do the trick. Thank you for your advice, I'll let you know how it goes :D

MG2R

#3
Feb 21, 2012, 03:48 pm Last Edit: Feb 21, 2012, 04:08 pm by MG2R Reason: 1
Right, got a lot of measurements and test done... I'm filtering the RPM-signal with a 33nF cap, which gives me an error of 9.4% @ 700 rpm, which is adequate for my application :)


MG2R


cool


Yeah, that's what I thought too... Apparantly the screwed-up signal wasn't because of the PWM, but because the fan was turning so slow (powered by 5V instead of 12 V) ... With PWM, you get an interruption of the RPM signal every time the input goes low, resulting in an unfilterable signal.

I'm going to work on a schematic to provide linear voltage regulation, using a bipolar transistor and an opamp, which is driven by a filtered PWM signal, I'll keep you posted if you want ;)

RIDDICK

oops
i almost forgot this thread...  :)

u could use a cap and a coil instead of the opamp...
http://en.wikipedia.org/wiki/Buck_converter
the BJT would be turn on+off by the PWM signal directly...
-Arne

Go Up