Sei sulla pagina 1di 12

5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

Tachometer Using Arduino and Hall Effect


Sensor
 August 13, 2017 (http://engineerexperiences.com/tachometer-using-arduino.html)  Ankit Negi
(http://engineerexperiences.com/author/ankit-negi)  Arduino
(http://engineerexperiences.com/category/arduino), Article
(http://engineerexperiences.com/category/article), DIY (http://engineerexperiences.com/category/diy),
Project (http://engineerexperiences.com/category/project)

Table of Contents 

Introduction to Tachometer
In this project we will make a tachometer using Arduino
(http://engineerexperiences.com/category/arduino). It is a device which is used to measure
the RPM (revolution per minutes) of rotating objects like a shafts or wheels etc. This project
differ from other projects present around web as it uses a Hall Effect sensor rather an IR
LED sensor which means it can be used in any prevailing ambient conditions.

TECPEL Test measurement


Ad provides high Quality multimeters at
affordable price from stock.
tecpel.com

Learn more

COMPONENTS
Hall Effect Sensor
Arduino Uno
Rotating Shaft (Who’s RPM to be measured)
Small magnet
Connecting wires

http://engineerexperiences.com/tachometer-using-arduino.html 1/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

Let us first start with the principle of a Hall Effect sensor.


(http://engineerexperiences.com/using-hall-sensor.html) Click on link
(http://engineerexperiences.com/using-hall-sensor.html)to learn about Halls Effect sensor
and working.

NOTE: This tutorial makes use of the Timer Interrupts of Arduino Uno defined in previous
article to measure the RPM more precisely and accurately rather than other prevailing
methods present. If you are not familiar with this concept than check out that article first.
(http://engineerexperiences.com/arduino-uno-timer-and-interrupts.html)

SETUP
The setup for making this project is very simple.

A small magnet is placed (fixed) on the shaft/wheel whose RPM is to be measured.


The detector of Hall Sensor placed in the proximity of the shaft (perpendicular to axis of
shaft).
Hookup the Vcc and Gnd pin of the hall sensor to Arduino’s 5V and Gnd respectively
using jumpers.
We will use the Timer0 of Arduino Uno (http://engineerexperiences.com/arduino-uno-
timer-and-interrupts.html)for this project, so, after connecting Vcc and Gnd pin of the
Sensor connect its output pin to the pin 2 of Uno for readings.

The setup to measure shaft RPM is shown in figure below:

(https://lh3.googleusercontent.com/Eza7BZ4NlWRStIJnaPVGNNh-
32Rp8jPnuZUIdnX5_TAeuRjsrwAjjf8LRxF5pSF5fnSx5ZaP6zxH-
woIFoTOF_BWzQDavChk9_zlzd9nTjxySfaYntsDHQ1xshXHahfdJrGo-
12fzW4G8EA8LUgEK5vHTHz1Fb0GxOvLGEV3KxUgwJCG4Tx6pjSDn4TVluSyN835AdB8
LWllB8S1lfuPOdLM5SqDvN_0k1ee7kp287tYR30H8R9775FWVg6W_lHC9d4kErx-
n1deWMhhPI5WiBD2dZgppT3rT1SElAR88GsXYUWCNoHePaIEDw7kpvhIeTVMsi9732hL
yoSNTaDFVVucpUeldEfkwG-keoxIBnfUQQ-ekVpyEFQ2- 
rfgsAVQZwwZRubn1xX0ZMF1dzWVetsgibVpQjM2zMZe9mRozRxmdreYJua0qYEkTPQ6F

http://engineerexperiences.com/tachometer-using-arduino.html 2/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

ql7TgMIHbkx5YrRRXD5wGiowBOZF3OyjFk9qFox_s75y9CBTxxlAKv7Bshg2xZyGlYhohAV
grXhxuL6z-5NVB16dZmMGUOwc1VMH-
A9cmlkmSiqAkJNhuoVQzweJPRXcO63ZtONNyZHaZwrJ6taiBY3eghNXa4Kc6iLvCANwcH
myBr2ngd5i1fYwKAY=w1366-h417-no)

Figure: Techometer Circuit Configuration

Code:

http://engineerexperiences.com/tachometer-using-arduino.html 3/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

int hallsensor = 2; // Hall sensor at pin 2

volatile byte counter;

unsigned int rpm;

unsigned long passedtime;

void isr()

//Each rotation, this interrupt function is run twice, so take that into consideration
for

//calculating RPM

//Update count

counter++;

}
void setup()

{Serial.begin(9600);

//Intiates Serial communications

attachInterrupt(0, isr, RISING); //Interrupts are called on Rise of Input

pinMode(hallsensor, INPUT); //Sets hallsensor as input

counter = 0;

rpm = 0;

passedtime = 0; //Initialise the values

}
void loop()
{
delay(1000);//Update RPM every second

detachInterrupt(0); //Interrupts are disabled

rpm = 60*1000/(millis() - passedtime)*counter;

passedtime = millis();

counter = 0;

Serial.print("RPM=");

http://engineerexperiences.com/tachometer-using-arduino.html 4/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

Serial.println(rpm); //Print out result to monitor

attachInterrupt(0, isr, RISING); //Restart the interrupt processing

UNDERSTANDING CODE
Most of the code is clear from the comments mentioned.

Interrups:
The code as mentioned above makes use of the Arduino Interrupts
(http://engineerexperiences.com/arduino-uno-timer-and-interrupts.html). Now as we know
the Interrupts execute a set of instruction when called no matter what the Arduino was doing
before. Here, Interrupts are called when the magnet passes through the detector.

TECPEL Test measurement


Ad provides high Quality multimeters at
affordable price from stock.
tecpel.com

Learn more

We use Interrupts here to count the number of times the Hall sensor detects the magnet.
Whenever there is a hike in Input pin the Interrupt routine (ISR function) named as “isr” is
called which increment the counter value and thus makes a count.

Use of Interrupts increases the accuracy of reading as Interrupt is called every time the
magnet passes and Uno counts it this is different from other methods in which the Arduino
has to wait for whole code to be finished before getting back to read the Sensor reading
again and if the code is large due some other reasons the reliability of the reading decreases
drastically.

The Interrupts in Arduino Uno are initiated or called on either using Falling, Rising or Logic
type. In our Program we have used the Rising type Interrupt initiator; Rising type calls the
Interrupt every time the detector pin detects a rise in input from LOW to HIGH.

If you are using an IR LED based sensor you can also use Falling type, in this case the
Interrupt will be called every time the detector pin detects a fall in the input i.e. from HIGH to
LOW. 

http://engineerexperiences.com/tachometer-using-arduino.html 5/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

Another thing to note is the formula for the rpm calculation; it is based on simple math and
unitary method to calculate number of revolution made by the shaft-

i.e. RPM= No. of counts / Time taken to count

Time taken to count will be measured through millis function of Arduino


(http://engineerexperiences.com/millis-function-arduino.html). Study complete article about
millis function here (http://engineerexperiences.com/millis-function-arduino.html).

Delay Function:
The delay(1000) is used in the code it determine after how much time the value to be
changed on your display, you can set it according to your needs.

TECPEL Test measurement


provides high Quality multimeters at affordable price from stock. tecpel.com/

The display device used in this tutorial is the Serial Monitor of the Arduino itself; instead of
this you can also use 16*2 LCD or LED shields to display the RPM values using the
respective libraries and hardware.

Calculations:
The value obtained from this project can further be used for measuring the speed of the
wheel/disc to which the shaft is connected using the relation-(3.14*D*N)/60 here, D is
diameter of the wheel/disc and N is the RPM. This relation will give the speed in m/s. This
speed further can be converted to Kmph or Mph.

The value obtained can also be used in positioning of some other components relative to
shaft or for feedback and control.

Feel Free to contact us, comment below and provide us with your feedback to improve our
services. Like our facebook page (https://www.facebook.com/EngineerExperiences) for more
posts.

Share this:

 (http://engineerexperiences.com/tachometer-using-arduino.html?share=twitter&nb=1)

 (http://engineerexperiences.com/tachometer-using-arduino.html?share=facebook&nb=1)
3

 (http://engineerexperiences.com/tachometer-using-arduino.html?share=google-plus-1&nb=1)

http://engineerexperiences.com/tachometer-using-arduino.html 6/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

TECPEL Test DC/AC Current CO2 Fabric Laser Arduino based


measurement Measurements Cutter Tiltmeter
Using Hall-Effect...
Ad www.tecpel.com engineerexperiences.com Ad SENFENG Laser engineerexperiences.com

Stainless steel cable Calculations for Advantages and Power factor


tie - Directly factory Design Parameters Disadvantages of measurement using
wholesale of Transformer Using Arduino ATmega8 /16
Ad market.onloon.cc engineerexperiences.com engineerexperiences.com engineerexperiences.com

Arduino (http://engineerexperiences.com/tag/arduino)

hall e ect sensor (http://engineerexperiences.com/tag/hall-e ect-sensor)

Techometer (http://engineerexperiences.com/tag/techometer)

Techometer with Arduino (http://engineerexperiences.com/tag/techometer-with-arduino)

ANKIT NEGI (HTTP://ENGINEEREXPERIENCES.COM/AUTHOR/ANKIT-NEGI)

I am an electrical engineering student and a youtuber. My YouTube channel THE-


ELECTRONIC-GUY (https://www.youtube.com/c/THEELECTRONICGUY) is dedicated to
electronics and all. I am an avid publisher, I write technical articles and make electronic
projects regularly.

One thought to “Tachometer Using Arduino and Hall Effect


Sensor”


PASCHALIS
April 10, 2018 at 12:02 am (http://engineerexperiences.com/tachometer-using-arduino.html#comment-452)

http://engineerexperiences.com/tachometer-using-arduino.html 7/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

there is a slight miscalculation in your sketch:


rpm = 60*1000/(millis() - passedtime)*counter;
rpm = 60*1000*counter/(millis() - passedtime);
as multiplications nish before divisions

REPLY

WHAT DO YOU THINK?

Enter your comment here...

 Taser Gun using 555 IC (http://engineerexperiences.com/teaser-gun-using-555-c.html)

ARDUINO UNO TIMER AND INTERRUPTS  (http://engineerexperiences.com/arduino-uno-timer-and-interrupts.html)

SEARCH HERE

SEARCH
Custom Search

GET FREE UPDATES

Join 564 other subscribers

Email Address

SUBSCRIBE

RECENT POSTS

Ultrasonic Sensor based Water Level Controller (http://engineerexperiences.com/ultrasonic-sensor-


based-water-level-controller.html)

Digital Thermometer using Arduino Celsius and Farenheit Display 


(http://engineerexperiences.com/digital-thermometer-using-arduino-celsius-and-farenheit-
display.html)

http://engineerexperiences.com/tachometer-using-arduino.html 8/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

Cable Insulation Testing (http://engineerexperiences.com/cable-insulation-testing.html)

Basic Terminologies Related to Electrical Engineering (http://engineerexperiences.com/basic-


terminologies-related-to-electrical-engineering.html)

DESIGN AND CONSTRUCTION POWER INVERTER (http://engineerexperiences.com/design-and-


construction-power-inverter.html)

CO2 Fabric Laser Cutter

Ad SENFENG Laser

China PCB Manufacturer

Ad Chee mau

Calculations for Design


Parameters of Transformer
engineerexperiences.com

Stainless steel cable tie -


Directly factory wholesale
Ad market.onloon.cc

Arduino based Tiltmeter

engineerexperiences.com

DC/AC Current Measurements


Using Hall-Effect Sensors
engineerexperiences.com

Advantages and Disadvantages


of Using Arduino
engineerexperiences.com

Power factor measurement


using ATmega8 /16
engineerexperiences.com

http://engineerexperiences.com/tachometer-using-arduino.html 9/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

TOP POSTS

Calculations for Design Parameters of Transformer (http://engineerexperiences.com/design-


calculations.html)

Advantages and Disadvantages of Using Arduino (http://engineerexperiences.com/advantages-and-


disadvatages.html)

Tachometer Using Arduino and Hall E ect Sensor (http://engineerexperiences.com/tachometer-


using-arduino.html)

Turns per Volts Derivation Transformer Design (http://engineerexperiences.com/turns-per-volts-


transformer-design.html)

Power factor measurement using ATmega8 /16 (http://engineerexperiences.com/power-factor-


measurement.html)

Installation of Arduino Support Package in MATLAB (http://engineerexperiences.com/arduino-


matlab-installation.html)

AC Voltage Measurement using ATmega8 (http://engineerexperiences.com/ac-voltage-


measurement.html)

Smart Energy Meter using Atmel AVR Microcontrollers (http://engineerexperiences.com/smart-


energy-meter.html)

3 Phase Smart Energy Meter using Arduino (http://engineerexperiences.com/3-phase-smart-


energy-meter-using-arduino.html)

ARDUINO UNO TIMER AND INTERRUPTS (http://engineerexperiences.com/arduino-uno-timer-and-


interrupts.html)

http://engineerexperiences.com/tachometer-using-arduino.html 10/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

BLOG STATS

293,421 hits

GET FREE UPDATES

Join 564 other subscribers

Email Address

SUBSCRIBE

RECENT POSTS

Ultrasonic Sensor based Water Level Controller (http://engineerexperiences.com/ultrasonic-sensor-based-


water-level-controller.html)

Digital Thermometer using Arduino Celsius and Farenheit Display (http://engineerexperiences.com/digital-


thermometer-using-arduino-celsius-and-farenheit-display.html)

Cable Insulation Testing (http://engineerexperiences.com/cable-insulation-testing.html)

http://engineerexperiences.com/tachometer-using-arduino.html 11/12
5/2/2018 Tachometer Using Arduino and Hall Effect Sensor | Engineer Experiences

(htt

ps://

ww

w.yo

utub

 e.co

(htt m/c

p://f han 

aceb nel/ (htt

ook. UCb ps://

com ToA twitt

/eng oCq er.c

inee bY- om/

rexp YEE EE_E

erie CI5k xper

nces AGyi ienc

) A) es)

HOME (HTTP://ENGINEEREXPERIENCES.COM) CONTACT US (HTTP://ENGINEEREXPERIENCES.COM/CONTACT-US)

SITEMAP (HTTP://ENGINEEREXPERIENCES.COM/SITEMAP) TERMS (HTTP://ENGINEEREXPERIENCES.COM/TERMS)

PRIVACY POLICY (HTTP://ENGINEEREXPERIENCES.COM/PRIVACY-POLICY)

sparkling Theme by Colorlib (http://colorlib.com/) Powered by WordPress (http://wordpress.org/)

http://engineerexperiences.com/tachometer-using-arduino.html 12/12

Potrebbero piacerti anche