Go Down

Topic: arduino RPM meter for laser project (Read 761 times) previous topic - next topic

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.
Cordialement,
Benoît ROUSSEAU

Benoît ROUSSEAU

Cordialement,
Benoît ROUSSEAU

tomas


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy