PDA

View Full Version : Converting PULSIN reading to RPM, from PC Fan?



CuriousOne
- 17th October 2020, 14:07
Hello.
I have a simple circuit with PC fan. It's tachometer output is tied to VDD via 10K resistor and goes into PIC16F886. Fan model is AD0812UX-A7BGL-LF
and rated speed is 3700 RPM. It has PWM input pin, which I control via the same IC. Code is below



CHECK:
if BUT3=0 then dly=dly-1
if BUT4=0 then dly=dly+1
pulsin rpm,0, cnt


lcdout $fe, $1, "PWM=", #dly, " ", #cnt, " "
hpwm 2,dly,20000
pause 100
GOTO CHECK


PULSIN inputs some readings, which are consistent with fan speed, but how to convert them into RPM?
AT PWM=0, PULSIN returns 3700. With increase of fan speed, value drops, at PWM=255, it returns 820.

Any ideas?

CuriousOne
- 17th October 2020, 20:56
I've connected same fan to motherboard, and used it's bios settings to change speeds from min to max and based on that, updated the code, and now it delivers results consistent with motherboard readings.

cnt=60000/cnt*50.

Amoque
- 18th October 2020, 16:17
It makes very little difference now that you've managed a method that works, but there is a pretty good read on measuring frequency with Pulsin here: http://batdetector.freevar.com/ArduBat/PulseIn.html (notice the misspelling).

Acetronics2
- 18th October 2020, 19:50
Hmmm ...

I do not think at all PULSIN is the command to use ...

just open your Holy manual :rolleyes: on page 129 ...

May be you should consider closer the waveforms to choose the good measuring method.

I could also lead you to use the "capture" module of the processor ... but here I think a simple method would be much much followed by usable results ... :rolleyes:

Alain

CuriousOne
- 19th October 2020, 07:01
Well, at page 129, there is DEBUG statement described, have no idea, how to use it for RPM measurement :D

Acetronics2
- 19th October 2020, 07:51
Well, at page 129, there is DEBUG statement described, have no idea, how to use it for RPM measurement :D

Hmmm ...

Here I do recognise THE Curious one ...

Are you really sure you open your manual on page 129 ??? ... I think ( and I am sure !!! ) you open it on page 131 ...

BTW ... open your eyes too !!! ( at bottom right ... and not top browser page window :rolleyes: )

Alain

CuriousOne
- 19th October 2020, 08:08
I already tried COUNT. Returns very low number of pulses - for 3700rpm it returns something like 120. Absolutely not precise.

Ioannis
- 19th October 2020, 11:12
There is this Tip n Tricks pdf that has #5 about RPM measurment using CCP in combination with #1 and #2 tips.

Ioannis

8958

CuriousOne
- 19th October 2020, 12:35
All my PWM/CCP channels are busy :)
Too bad they don't make chips with 8-16 PWM outputs :)

Ioannis
- 19th October 2020, 12:44
In your case you need an input.

Can you multiplex with another CCP input?

Ioannis

Acetronics2
- 23rd October 2020, 11:28
1) https://noctua.at/pub/media/wysiwyg/Noctua_PWM_specifications_white_paper.pdf

2) @ these very low frequencies, the use of a divider per 2 ( so ... to measure the rotation period ! ) and using interrupts to drive a custom counter is to consider ...

aside that that wouldn't interfere much with the general timing ...

Now, being too accurate to measure a PC fan speed is somewhat a nonsense ... ( except for some geeks ... :D )

Alain

Ioannis
- 23rd October 2020, 17:48
Maybe you mean x2 instead of divide by 2.

Ioannis

Acetronics2
- 24th October 2020, 10:17
Maybe you mean x2 instead of divide by 2.

Ioannis

Hi, Ioannis

No, no ... it's not an error : if you divide the pulse train per 2 ( D Flip-flop ...) ... the High or low pulse you get @ output has the exact rotation period ... ( remember how you did that with ol' 74 or 4000 logic chips ... ;) )
rising edge fires the counter ... falling edge stops it.

easy then to care with an IOC interrupt stubb ...


Best Regards
Alain

Ioannis
- 24th October 2020, 11:12
I was thinking in terms of frequency and the low frequency you stated pushed me into that error. Sorry...

Thanks for the clarification.
Ioannis

Acetronics2
- 25th October 2020, 08:24
I was thinking in terms of frequency and the low frequency you stated pushed me into that error. Sorry...

Thanks for the clarification.
Ioannis

You're Welcome Ioannis ...

AND we are old friends !!! ;)

8959

Alain

Ioannis
- 25th October 2020, 17:06
Yeap! That's right! Nice picture with the two grands! Well I hope I don't look that old though...

Ioannis