Living
Outside
Play
Technology
Workshop
Table of Contents
Measure RPM - Optical Tachometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 7: Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Step 8: Explanation and Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Step 9: Testing and Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Step 10: Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
Author:electro18
Hey there ! I'm an electronic hobbyist interested in making robots and sharing stuff. I hope that my instructables help you in solving your problems Happy
Tinkering !
File Downloads
LCD_TACHOMETER.ino (3 KB)
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'LCD_TACHOMETER.ino']
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
Step 7: Program
Code
COPY THIS CODE INTO YOUR ARDUINO IDE
#include<ShiftLCD.h>
ShiftLCD lcd(8 ,10 , 9);
volatile byte REV;
//
//
//
//
long prevtime = 0;
//
void setup()
{
Serial.begin(9600);
STATUS LED
//
INTEGERS TO STORE LED VALUE AND CURRENT RPM AND PREVIOUS RPM
lcd.begin(16, 2);
// INITIATE LCD
//
//
rpm = 0;
time = 0;
pinMode(ledPin, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(3, HIGH);
//
digitalWrite(4, LOW);
lcd.print("TACHOMETER");
lcd.setCursor(0, 1);
lcd.print("- ELECTRO18");
delay(2000);
lcd.clear();
//
//
STARTUP TEXT
THAT'S ME
}
void loop()
{
long currtime = millis();
//
//
if(flag==0)
// CLEAR THE LCD TO AVOID ANY GARBAGE TEXT
{
lcd.clear();
lcd.print("SENSOR MEASURING");
flag=1;
//
AFTER FLAG = 1 , THE LOOP WILL NOT EXECUTE AGAIN
}
rpm = 30*1000/(millis() - time)*REV;
if(rpm > maxRPM)
maxRPM = rpm;
//
//
CALCULATE
time = millis();
REV = 0;
int x= rpm;
while(x!=0)
{
x = x/10;
RPMlen++;
}
//
if(RPMlen!=prevRPM)
{
lcd.clear();
prevRPM = RPMlen;
flag=0;
lcd.print("SENSOR MEASURING");
}
lcd.setCursor(0, 1);
lcd.print(rpm,DEC);
// IF THE RPM FALLS TO A LOWER NUMBER WITH LESS DIGITS , THE LCD WILL GET CLEARED
//
lcd.setCursor(6,1);
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
lcd.print("RPM");
delay(500);
prevtime = currtime;
// RESET IDLETIME
}
if(idletime > 5000 )
{
if(flag==1)
{
lcd.clear();
flag=0;
}
//
IF THERE ARE NO READING FOR 5 SEC , THE SCREEN WILL SHOW MAX RPM
lcd.clear();
lcd.print("MAXIMUM RPM");
lcd.setCursor(0, 1);
lcd.print(maxRPM,DEC);
lcd.print("
RPM");
delay(2000);
lcd.clear();
lcd.print("IDLE STATE");
lcd.setCursor(0, 1);
lcd.print("READY TO MEASURE");
delay(2000);
prevtime = currtime;
}
}
void RPMCount()
{
REV++;
// EVERYTIME WHEN THE SENSOR GOES FROM LOW TO HIGH , THIS FUNCTION WILL BE INVOKED
// INCREASE REVOLUTIONS
if (led == LOW)
{
led = HIGH;
//
}
else
{
led = LOW;
}
digitalWrite(ledPin, led);
}
//////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
This line attaches an interrupt to pin 2 on arduino in "RISING" mode. This means that whenever the sensor goes from LOW to HIGH , the function RPMCount(); is
invoked.
This means that in one revolution , the function will be called twice ( REV++ ). Therefore actualREV = REV/ 2.
rpm = 30*1000/(millis() - time)*REV;
To calculate the actual RPM, we need the time taken for one revolution. And (millis() - time) is the time taken for one full revolutions.
In this case , let t be the time taken for one full revolution , so the total number of revolutions RPM in 60sec ( 60*1000 millisecond ) is :
rpm = 60*1000 / t * actualREV => rpm = 60*1000 / (millis() - time ) * REV/2
OR rpm = 30*1000 / (millis() - time) * REV;
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
Serial.println( digitalRead(2) ) ;
if your sensor doesn't show " 1 " when any object is placed in front of it then try increasing the value of 33k resistor.
Related Instructables
Arduino-Based
Optical
Tachometer by
CMPalmer
Bench top
dynomometer
by Bill WW
DIY LED
Tachometer
(video) by
abo_hosni
Tachometer
made from a
bicycle
speedometer
(cyclocomputer)
by josie
Sound Card
Tachometer by
wotboa
Advertisements
Comments
14 comments Add Comment
thr8088 says:
good
electro18 says:
Thanks :)
Tachyon says:
electro18 says:
FoamboardRC says:
electro18 says:
:D I'm sorry about that but thanks ! BTW congratulations on bagging the first prize in RC contest !
Though you can still make yours and enter the Remix contest.
FoamboardRC says:
Thanks! I was so happy!
Naw, it would be an replica of yours :D
Good luck in the contest, gave ya a vote!
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
electro18 says:
Thanks a lot ! :)
BLR_RAVI says:
electro18 says:
Thanks ! :)
BeachsideHank says:
I like all your stuff, so I'm following you. Just a thoughtthe composition of your Instructables are of course, up to you but I think your
stated mission is to share, so the
choice of fonts can be somewhat critical to those of us in the over 40 club
(you've got a while before you need to worry ;-) ). Specifically, open frame
and shadowing of textual descriptions tend to appear blurry, slowing down the
assimilation of critical data. This in no way diminishes your noteworthy
accomplishments, but I just thought you'd like to know the perspective from the
other side of the hill and in closing, congratulations on some very fine work,
you will go far I do believe.
electro18 says:
seamster says:
electro18 says:
Thanks ! :)
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/