Professional Documents
Culture Documents
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 non-contact 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 Idle
Automatically toggles modes from "Idle" to "reading"
Can be adjusted to match the ambient lighting conditions
It is comparatively cheap and easy to build
Can work without an LCD
Programmable and supports customization
Connect an SD card to the Arduino to keep logs
Attachments
LCD_TACHOMETER.ino
Teacher Notes
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
Soldering Iron
Solder
Pins
Screws
Motors and DC fan
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.
In my case :
1. Orange wire --> LED's positive pin and photodiode's shorter lead
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 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.
The full instruction guide and the library can be downloaded from THIS WEBSITE !
## Recent Update : The library provided on the website has a lot of errors and
conflicts. I've uploaded my version of enhanced ShiftLCD library. I recommend you
to use the one attached below.
Attachments
ShiftLCD.rar
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.
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.
Step 7: Program
Code
COPY THIS CODE INTO YOUR ARDUINO IDE
#include<ShiftLCD.h>
unsigned long int rpm, maxRPM; // DEFINE RPM AND MAXIMUM RPM
int led = 0,RPMlen , prevRPM; // INTEGERS TO STORE LED VALUE AND CURRENT RPM AND PREVIOUS RPM
int flag = 0; // A VARIABLE TO DETERMINE WHETHER THE LCD NEEDS TO BE CLEARED OR NOT
attachInterrupt(0, RPMCount, RISING); // ADD A HIGH PRIORITY ACTION ( AN INTERRUPT) WHEN THE
SENSOR GOES FROM LOW TO HIGH
rpm = 0;
time = 0;
pinMode(ledPin, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
void loop()
{
long currtime = millis(); // GET CURRENT TIME
rpm = 30*1000/(millis() - time)*REV; // CALCULATE RPM USING REVOLUTIONS AND ELAPSED TIME
time = millis();
REV = 0;
if(RPMlen!=prevRPM) // IF THE RPM FALLS TO A LOWER NUMBER WITH LESS DIGITS , THE
LCD WILL GET CLEARED
{
lcd.clear();
prevRPM = RPMlen;
flag=0;
lcd.print("SENSOR MEASURING");
}
lcd.setCursor(0, 1);
lcd.print(rpm,DEC); // PRINT RPM IN DECIMAL SYSTEM
lcd.setCursor(6,1);
lcd.print("RPM");
delay(500);
if(idletime > 5000 ) // 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); // DISPLAY MAX RPM
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() // EVERYTIME WHEN THE SENSOR GOES FROM LOW TO HIGH , THIS
FUNCTION WILL BE INVOKED
{
REV++; // INCREASE REVOLUTIONS
if (led == LOW)
{
else
{
led = LOW;
}
digitalWrite(ledPin, led);
}
////////////////////////////////////////////////////////////// END OF THE PROGRAM ///////////////////////////////////////////////////////////////////////
The Arduino Uno has 3 interrupts and the Interrupt 0 is pin 2 on the arduino.
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.
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 :
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
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.
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.
Feel free to ask anything about this project. Suggestions , queries , corrections and
"grammatical errors" are welcome !
Happy Tinkering :)