You are on page 1of 13

Food

Living

Outside

Play

Technology

Workshop

Measure RPM - Optical Tachometer


by electro18 on September 17, 2014

Table of Contents
Measure RPM - Optical Tachometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Intro: Measure RPM - Optical Tachometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 1: Part List : . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 2: Build the sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 3: Making the sensor board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 4: The 3-pin LCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 5: Make the box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 6: Finishing Touch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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 !

Intro: Measure RPM - Optical Tachometer


This Instructable will show you how to make a Portable Digital Optical Tachometer using an Arduino Uno. This project is inspired from This instructable and is an
enhanced version of it with an LCD display and a modified code.
Instead of a slotted sensor , it has a reflection based sensor. So :
1. You don't have to worry about the thickness of the rotor
2. The number of blades won't change your readings
3. It can also read the RPM of drum style rotors which slotted sensor can't
What is a tachometer ?
A tachometer is a device used to measure the RPM or Revolutions Per Minute of any rotating body. Tachometers can be contact based or non-contact ones. The noncontact or contact-less optical tachometers usually use laser or Infrared beam to monitor the rotation of any body. This is done by calculating time taken for one rotation.
FEATURES It can measure RPM over 20k Sensor range extends upto 7~8 cm Displays Maximum RPM when left IdleAutomatically toggles modes from "Idle" to
"reading"Can be adjusted to match the ambient lighting conditionsIt is comparatively cheap and easy to buildCan work without an LCDProgrammable and supports
customization Connect an SD card to the Arduino to keep logs

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']

Step 1: Part List :


Electronics
Arduino
Resistors - 33k , 270 ohm , 10k potentiometer
LED - blue
IR LED and Photodiode
16 x 2 LCD
74HC595 shift Register
Ribbon cable ( 3 wire )
Perfboard and headers
Tools and Hardware
Soldering Iron
Solder
Pins
Screws
Motors and DC fan

http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/

Step 2: Build the sensor


For the sensor you'll need an IR LED and a Photodiode.
1. Start by sanding the LED and photodiode to make it flat ( do not sand it too much or you'll destroy it ).
2. Then fold a strip of paper sheet as shown. Make two such Structures so that the LED and Photodiode fit tightly into it. Joint these together by glue and paint them
black.
3. Insert your LED and Photodiode in them in such a way that the positive ( longer ) lead of the LED is right above the shorter lead of the photodiode.
4. Glue them into the cover using superglue and solder the positive ( longer ) lead of the LED to the shorter lead of the photodiode.
5. Solder the 3 wire ribbon cable to the remaining leads
In my case :
1. Orange wire --> LED's positive pin and photodiode's shorter lead
2. Yellow wire --> photodiode's longer lead
3. Green Wire --> LED's ground pin
You're ready to make the board >>

http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/

http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/

Step 3: Making the sensor board


Take a small piece of Perfboard and place the components according to the schematics.
The resistor values may vary depending on what kind of photodiode are you using.
The potentiometer helps in reducing or increasing the sensitivity of the sensor.
Finally solder the sensor wires as shown and solder 3 headers.
The headers ( in order ) are shown on the left side of the schematic.
make a cuboidal paper tube whose length is equal to the sensor wires.

http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/

Step 4: The 3-pin LCD


This method uses a 8-bit shift register 74HC595 with a 16 x 2 LCD. Normally this LCD uses 6 pins but using a shift register reduces the pin requirement by 3.
The full instruction guide and the library can be downloaded from THIS WEBSITE !
The only thing that I've changed is :
instead of going for (2, 4, 3) configuration I've used (8, 10, 9)
So be sure to change the pin mapping accordingly

http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/

Step 5: Make the box


You can use any type of case for this but I've used a piece of cardboard to make enclosure.
Cut the cardboard as shown and cut appropriate sized slits for the USB port , power jack and the sensor board.
Mount the Arduino on the platform using screws.
Attach the sensor and push it through the hole.
Connect the LCD to Arduino as shown.
Close the box and paint.

http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/

Step 6: Finishing Touch


Make a small ( 5mm ) hole to fix the status LED. Solder a 270 ohm resistor to the LED and insert it into pin 12 on Arduino.
Fold the cardboard along the lines to complete the enclosure. Keep the folds in place by using pins.
Cover the sensor with a cubical paper tube to give additional mechanical strength.
Place the LCD module over the box.
Your device is ready for calibration and programming.

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;

// DEFINE LCD PINS


//

VOLATILE DATA TYPE TO STORE REVOLUTIONS

unsigned long int rpm, maxRPM;

//

unsigned long time;

DEFINE TIME TAKEN TO COVER ONE REVOLUTION

//

int ledPin = 12;

//

int led = 0,RPMlen , prevRPM;


int flag = 0;

//

long prevtime = 0;

//

void setup()
{
Serial.begin(9600);

DEFINE RPM AND MAXIMUM RPM

STATUS LED
//

INTEGERS TO STORE LED VALUE AND CURRENT RPM AND PREVIOUS RPM

A VARIABLE TO DETERMINE WHETHER THE LCD NEEDS TO BE CLEARED OR NOT


STORE IDLE TIME TO TOGGLE MENU

// GET VALUES USING SERIAL MONITOR

lcd.begin(16, 2);

// INITIATE LCD

attachInterrupt(0, RPMCount, RISING);


REV = 0;

//

//

ADD A HIGH PRIORITY ACTION ( AN INTERRUPT)

WHEN THE SENSOR GOES FROM LOW TO HIGH

START ALL THE VARIABLES FROM 0

rpm = 0;
time = 0;
pinMode(ledPin, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(3, HIGH);

//

digitalWrite(4, LOW);

// GND PIN FOR SENSOR

lcd.print("TACHOMETER");
lcd.setCursor(0, 1);
lcd.print("- ELECTRO18");
delay(2000);
lcd.clear();

//
//

VCC PIN FOR SENSOR

STARTUP TEXT
THAT'S ME

}
void loop()
{
long currtime = millis();

// GET CURRENT TIME

long idletime = currtime - prevtime;


if(REV >= 5 )
{

//

//

CALCULATE IDLE TIME

IT WILL UPDATE AFETR EVERY 5 READINGS

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

RPM USING REVOLUTIONS AND ELAPSED TIME

GET THE MAX RPM THROUGHOUT THE RUN

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);

CALCULATE NUMBER OF DIGITS IN RPM

// IF THE RPM FALLS TO A LOWER NUMBER WITH LESS DIGITS , THE LCD WILL GET CLEARED

//

PRINT RPM IN DECIMAL SYSTEM

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

// CLEAR THE LCD

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;

// DISPLAY MAX RPM

}
}
void RPMCount()
{
REV++;

// EVERYTIME WHEN THE SENSOR GOES FROM LOW TO HIGH , THIS FUNCTION WILL BE INVOKED
// INCREASE REVOLUTIONS

if (led == LOW)
{
led = HIGH;

//

TOGGLE STATUS LED

}
else
{
led = LOW;
}
digitalWrite(ledPin, led);
}
//////////////////////////////////////////////////////////////

END OF THE PROGRAM

///////////////////////////////////////////////////////////////////////

Step 8: Explanation and Calculation


This program basically monitors the IR sensor's value constantly and with the highest priority using Interrupts.
The Arduino Uno has 3 interrupts and the Interrupt 0 is pin 2 on the arduino.
attachInterrupt(0, RPMCount, RISING);

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;

Step 9: Testing and Troubleshooting


Testing :
1. Take a DC fan and stick a white tape to one of it's blades. Place the sensor 2~7 cm from the blades
2. The readings will appear on the LCD
3. If the sensor gets no readings for 5 sec then it will automatically display the idle screen
4. The Idle screen will display the maximum RPM reached in that particular run.
TROUBLESHOOTING :
1. If the status LED is not blinking, try to adjust the potentiometer until the sensor is able to get readings
2. Ambient light may sometimes interfere with the sensor. Decreasing the sensitivity would eliminate the chance of getting false readings.
3. Check the polarity of the photodiode properly.
4. If everything fails , check your sensor manually by using :

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.

Step 10: Conclusion


Though there are many optical tachometers available in the market, this device is comparatively cheap and works quite well. I've tested it above 20000 RPM and it works
every time ! Being open source and programmable , there arise infinite possibilities of customizing this project.
Feel free to ask anything about this project. Suggestions , queries , corrections and "grammatical errors" are welcome !
Happy Tinkering :)

Related Instructables

Arduino-Based
Optical
Tachometer by
CMPalmer

Bench top
dynomometer
by Bill WW

Cheap and Easy


Tachometer
(RPM Sensor)
for Brushed DC
Motors by
CalcProgrammer1

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:

Sep 19, 2014. 3:27 PM REPLY

good

electro18 says:

Sep 20, 2014. 3:46 AM REPLY

Thanks :)

Tachyon says:

Sep 19, 2014. 8:11 AM REPLY


I stand in front of these every time I'm in the local parts/tools store trying to come up with an excuse to spend the money on one. Now I'll likely build my own
instead.
However, I will definitely make one change. I'll add two buttons to let you adjust the number of counts per revolution to input that into the RPM calculation.
There's just a lot of thing you cant stick foam tape on. But being able to tell the system that there are say 4 spokes on the wheel will let me use it on that
wheel as is.
OK, two changes. I think I'll try and find a toy gun or power tool or similar to build it into. ;')
Thanks again. Nice work.

electro18 says:

Sep 19, 2014. 9:06 AM REPLY


Like I said , there are many possibilities to customize this project, your idea sounds awesome ! Good luck for your project :)

FoamboardRC says:

Sep 18, 2014. 10:47 AM REPLY


Hahaha you've got to be kidding me! I was just beginning to work on an instructable on a DIY tachometer, but you did such a good job, I'll not post mine!
Nice job, I'll post a pic of mine soon!

electro18 says:

Sep 18, 2014. 10:57 AM REPLY

: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/

Sep 18, 2014. 12:08 PM REPLY

electro18 says:

Sep 18, 2014. 12:10 PM REPLY

Thanks a lot ! :)

BLR_RAVI says:

Sep 18, 2014. 8:22 AM REPLY

excellent project..very nicely and neatly made..

electro18 says:

Sep 18, 2014. 8:25 AM REPLY

Thanks ! :)

BeachsideHank says:

Sep 17, 2014. 3:46 PM REPLY

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:

Sep 17, 2014. 8:35 PM REPLY


Thanks for the encouragement , it means a lot to me :) and thanks for the suggestion , I'll be sure to use a better font in my next instructable.

seamster says:

Sep 17, 2014. 3:04 PM REPLY

Wow! Nicely done!

electro18 says:
Thanks ! :)

http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/

Sep 17, 2014. 8:32 PM REPLY