Metering – Instrument Projects

Tachometer using arduino

Tachometer is a device used for measuring the number of revolutions of an object in a given interval of time. Usually it is expressed in revolutions per minute or RPM. Earlier tachometers purely mechanical where the revolution is transferred to the tachometer through mechanical coupling (cable or shaft) , the rpm is determined using a gear mechanism and it is displayed on a dial. With the advent of modern electronics, the tachometers have changed a lot. This article is about a contactless digital tachometer using arduino. The speed of the motor can be also controlled using the same circuit. The RPM and all the other informations are displayed on a 16×2 LCD screen. The circuit diagram of the digital tachometer using arduino is shown below.

tachometer-waveform
Counting the RPM.

Arduino is used for counting the RPM and displaying it on the LCD screen. Emitter of the photo transistor is connected to the Interrupt 0 (digital pin 2) of the arduino. The arduino interrupt is configured to be rising edge triggered. As a result the will be an interrupt for every upward shoot in the emitter waveform. The number of interrupts occurred in a given time is counted by incrementing a varible using the interrupt service routine.

tachometer-using-arduino

The time elapsed during te counting cycle is determined using the millis() function. The millis() function returns the number of milli seconds passed since the arduino board is switched ON. Calling the millis() function before and after the counting cycle and the taking their difference gives the times passed during the counting cycle. The (number of interrupts/time in milliseconds)*60000 will give the revolutions per minute (RPM).

Controlling the speed of motor.

A provision for controlling the motor speed using a potentiometer is also included in the circuit. Transistor Q1 is used for driving the motor. Its base is connected to pwm pin 9 of the arduino through the current limiting resistor R1. Wiper of the speed control POT R4 is connected to anlog pin A0 of the arduino. The voltage at this pin is converted into a value between 0 and 1023 using the anlogRead function. Then this value is divided by four to fit it into the 0 to 255 range. Then this value is written to the PWM pin 9 using the anlogWrite function. The result will be a square wave at pin 9 whose duty cycle is proportional to the value written using the analogWrite function. For example if the value is 255, the duty cycle will be 100% and if the value is 127, the duty cycle will be around 50%. D1 is  a free wheeling diode and C1 is a noise by-pass capacitor(de coupler).  The rpm and duty cycle are displayed on the LCD screen using the standard LiquidCrystal library. Read this article: Interfacing LCD to Arduino. Full program for the digital tachometer using arduino is shown below.

Program.

#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,6,5,4,3);
int pwm=9;
int pot=A0;
float value=0;
int percent;
float rev=0;
int rpm;
int oldtime=0;
int time;

void isr() //interrupt service routine
{
rev++;
}

void setup()
{
lcd.begin(16,2);                //initialize LCD
attachInterrupt(0,isr,RISING);  //attaching the interrupt
}

void loop()
{
delay(1000);
detachInterrupt(0);           //detaches the interrupt
time=millis()-oldtime;        //finds the time 
rpm=(rev/time)*60000;         //calculates rpm
oldtime=millis();             //saves the current time
rev=0;
value=analogRead(pot);        //reads the speed control POT
value=value/4;
analogWrite(pwm,value);       //sets the desired speed
percent=(value/255)*100;      //finds the duty cycle %
lcd.clear();
lcd.setCursor(0,0);
lcd.print("___TACHOMETER___");
lcd.setCursor(0,1);
lcd.print(rpm);
lcd.print(" RPM");
lcd.print("   ");
lcd.print(percent);
lcd.print("%");
attachInterrupt(0,isr,RISING);

}

For More Details: Tachometer using arduino

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close
Close