Forum 2005-2010 (read only) > Frequently-Asked Questions

arduino RPM meter for laser project

(1/1)

tomas:
hello
I am using arduino to make an RPM meter to read the pulses off an ordinary intel cpu fan with 3 leads (+,-, rpm signal)
I tried using digitalread() and pulsein() but I get fuzzy results.
anyone knows how to read those signals reliably?

code examples:




void loop()
{
 
 scanvalue=digitalRead(7);
 if (scanvalue!=previous_scan) {pulsecount++; previous_scan=scanvalue;}
   
  if (millis() - previousMillis > interval)
 {
  interval=((millis() - previousMillis)/pulsecount)*50
  previousMillis = millis();    
  pulsecount=0;

  //code blinking code here
  }
}

Benoît ROUSSEAU:
Hello Tomas,

You have to use an external interruption. Look at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1147164546, link is in french but you can understand code. In summary, the SIGNAL(SIG_INTERRUPT0) function is called each time the state of the digital digital change.

Benoît ROUSSEAU:
Hello Tomas,

I've made a reply with code here : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1152891511/0.

tomas:
thanks very much!
merci

ts

Navigation

[0] Message Index

Go to full version