Shop OBEX P1 Docs P2 Docs Learn Events
PWMPAL as a tachometer? — Parallax Forums

PWMPAL as a tachometer?

jefmjefm Posts: 50
edited 2010-05-17 01:51 in BASIC Stamp
Hi gang,
I'm trying to use the PWMPAL to measure speed of a processor fan. The fan is getting PWM from the 'Pal already, thought I'd try to put the counter to use. I hooked the 'speed' lead from the fan to a 220 ohm resistor (needed? just being safe) and to my surprise I got results, because I really had no idea what kind of signal comes from the fan.

First question, I didn't get data until I added a clear counter to the loop of my code. Before, I would just get an infinitely incrementing number no matter what the fan speed was. I guess the clear is needed, but it was not in the sample code.

Second, I get odd results. My "program" allows me to type in fan speed, then it waits a moment and takes a reading. Here are some of the speeds and readings:
0% 2001
30% 2722
70% 2567 (slower?)
100% 647 (slowest?)
I can verify with my eyes that the fan certainly goes faster as I type in higher speeds.

Third, I wonder if I can use the PWMPAL as a tach at all. It does keep count of how many times something happened. But there's no timer in itself to make a frequency from. From what I gather the Stamp is not the best at measuring time, unless you pull it away from other things. My final program might be to busy to have it clear the counter, wait a certain time, then get the counter.

I'm attaching the code I use if it's of help. It should look familiar since it's basically Parallax code :} I know the DEBUG is screwed up, I haven't worked it out yet and just clear the screen while waiting for the speed :/
Thanks for any help!
Sign In or Register to comment.