Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 49

Department of Physics, Govt Emerson College,

Multan

Arduino Based RPM Counter

Project Submitted by:


Nadeem Ahmad MCEP-16-06

Shahbaz Ahmad MCEP-16-20

Muhammad Abbas MCEP-16-32

Muhammad Abu Bakkar MCEP-16-14

Faisal Yaseen MCEP-16-09

Supervisor:
Shafqat Hayyat

Department of Physics
Govt Emerson College, Multan

2016-2020
Arduino Based RPM Counter

A Project submitted to Department of Physics, Govt Emerson College Multan in


partial fulfillment of the requirements for the degree of BS Physics.

Nadeem Ahmad MCEP-16-06

Shahbaz Ahmad MCEP-16-20

Muhammad Abbas MCEP-16-32

Muhammad Abu Bakkar MCEP-16-14

Faisal Yaseen MCEP-16-09

Department of Physics,

Govt Emerson College, Multan

Session 2016-2020
DECLARATION
This is to certify that the project “Arduino Based RPM Counter” is our original work. No
part of this work is being submitted anywhere else partially or fully for the award of any
degree or diploma. Any material reproduced in this project, has been properly acknowledged.
Arduino Based RPM Counter

APPROVAL
The project titled - “Arduino Based RPM Counter” prepared by the following students has
been submitted to the following respective members of Department of Physics, Govt
Emerson College, Multan in partial fulfillment of the requirements for the degree of BS
Physics.

Nadeem Ahmad MCEP-16-06

Shahbaz Ahmad MCEP-16-20

Muhammad Abbas MCEP-16-32

Muhammad Abubakkar MCEP-16-14

Faisal Yaseen MCEP-16-09

Project Supervisor
Shafqat Hayyat
Department of Physics ………………………………
Govt Emerson College, Multan

Head of Department
Nadeem Iqbal
Department of Physics ………………………………..
Govt Emerson College, Multan

External Examiner
………………………………………..
Department of Physics ………………………………..
Bahauddin Zakariya University, Multan

4 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

ACKNOWLEDGEMENT

At first, we utter our deepest gratitude to the almighty Allah, whose boundless mercy made
the completion of the project.

We are very much happy that we have taken efforts. However, it would not be possible on
our part to complete it without the kind support and help of many individuals and
organization. We would like to express our gratitude towards all of them.

We are grateful to our supervisor Shafqat Hayyat for his continuous guidance and
supervision, and also for providing us the necessary information and equipment needed for
the project. We highly appreciate his time and encouragement that helps us to complete this
project. We would like to express our special thanks to the Department Chair Nadeem Iqbal
Our appreciation also goes to our beloved Department of Physics for providing us the
opportunities to prove ourselves.

Nadeem Ahmad MCEP-16-06

Shahbaz Ahmad MCEP-16-20

Muhammad Abbas MCEP-16-32

Muhammad Abu Bakkar MCEP-16-14

Faisal Yaseen MCEP-16-09

5 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Declaration…………………………………………………………………………………………….…………………. 03
Approval …………………………………………………………………………………………………………………....04
Acknowledgement………………………………………………………………………………………………………07
Abstract …………………………………………………………………………………………………………………..…08

Chapter-1
1.0 Introduction………………………………………………………………………………………………………….09

Chapter-2
2.1 Literature Review…………………………………………………………………..…….……….………………11

Chapter-3
3.1 List of Components……………………………………………………………………………….……………….13
3.2 Power Supply ……………………………………………………………………………..……….……………….14
3.3 Arduino Uno ………………………………………………………………………………………..……………...23
3.4 16*2 LCD Display Module…………………………………………………………………………….……….29
3.5 IR Sensor …………………………………………………………………………………………………….…………34
3.6 Relay Module………………………………………………………………………………………….……………..38
3.7 DC Fan……………………………………………………………………………………………………………………41

Chapter-4
4.1 Introduction………………………………………………………………………………………………………….45
4.2 Hardware Design …………………………………………………………………………………………………45

6 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

4.3 LCD Display Connection with Arduino………………………………………………………………….46


4.4 Connection of Arduino with Arduino…………………………………..……………………………….47
4.5 Overall Circuit Diagram…………………………………………………………….……………………….49
4.6 Software Design………………………………………………………………………………………………..49
4.7 Installing Arduino ………………………………………………………….………………………………...50
4.8 Verify the Hardware……………………………………………………………………………………………47
4.9 Arduino Language ……………………………………………………………………………………………..50

Chapter-5

5.2) Limitations………………………………………………,..……………………..52

5.4) Conclusion……………………………………………………………………………..52
5.5)Bibliography……………………………………………………………………………54

7 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Chapter 1

Introduction

8 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Introduction
Tachometer is a RPM counter which counts the no. of rotation per minute. There are two
types of tachometer one mechanical and other one is digital. Here we are going to design an
Arduino based digital tachometer using IR sensor module to detect object for count rotation
of any rotating body. As IR transmits IR rays which reflect back to IR receiver and then IR
Module generates an output or pulse which is detected by the arduino controller when we
press start button. It counts continuously for 5 seconds.

A programmable microchip sometimes referred to as a microcontroller. The best way to


explain microcontrollers is to start with your computer. Your desktop computer is comprised
of multiple parts, a CPU (such as a Pentium or Celeron), some RAM, a hard disk, a keyboard
and mouse and a monitor screen. Programs are stored on the hard disk and run on the CPU,
with temporary data stored in RAM. You can run multiple programs at a time by having one
'master program' called an operating system (such as Linux, Windows or Mac OS X) and that
master program keeps track of things for you. The microchip has components, to

Arduino is an open-source prototyping platform designed for anyone interested in electronics


and much more. The software and assembly is accessible to most people with a general
knowledge of electricity

9 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Chapter 2
Literature Review

10 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

LITERATURE SURVEY

DR.RAMKRISHNAN IYER

The purpose of the literature review is to provide appropriate background information which
will provide a give a foundation for the design process jack’s Phillies have accommodated.
The following topics will be discussed: Programmable microchips/boards, pre-fabricated
boards, Open energy monitoring systems, hardware involved, software, the microchips power
supply, WetLand power supply, and other similar projects.

A programmable microchip sometimes referred to as a microcontroller. The best way to


explain microcontrollers is to start with your computer. Your desktop computer is comprised
of multiple parts, a CPU (such as a Pentium or Celeron), some RAM, a hard disk, a keyboard
and mouse and a monitor screen. Programs are stored on the hard disk and run on the CPU,
with temporary data stored in RAM. You can run multiple programs at a time by having one
'master program' called an operating system (such as Linux, Windows or Mac OS X) and that
master program keeps track of things for you. The microchip has components, too. It has a
CPU, some flash storage, some RAM and some EEPROM, all in one little chip. The CPU is
just like the one in a computer, but it is much simpler and not nearly as fast. The flash storage
is just like the flash storage in your mp3 player or digital camera card, except it is used to
store programs. It is similar to the hard disk of the microcontroller, except you can only read
from it. The RAM is just like computer RAM. The EEPROM is similar to flash except you
cannot run a program from it, but it is used as long-term storage. The EEPROM doesn’t get
erased when the chip loses power.

11 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Chapter 3

Hardware Components

12 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

3.1 List of Components:

Following is the list of components that are necessary to build the assembly the project.

 Arduino Uno Board

 Voltage Regulator (7805)

 16×2 LCD display

 13V Step Down Transformer

 Male and Female Header

 Voltage Regulator

 Resistors

 IR Sensor
 LED

 Potentiometer – 10kΩ

 DC Fan

13 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

The system designed was based on fundamental and principles of electromagnetism,


electronic devices, interfacing, intelligent control systems, and software systems.

3.2 Power Supply


Understanding 7805 IC Voltage Regulator

Table of Contents

 Introduction
 A Brief Note on 7805 Voltage Regulator
 Pin Diagram of 7805 Voltage Regulator IC
 Basic Circuit of 7805 
 How to Get Constant DC Power Supply from AC?
o Circuit Diagram
o Components Required
o Working
 Important Points on 7805 Voltage Regulator IC 

Introduction

In this tutorial, we will see about one of the most commonly used regulator IC’s, the 7805
Voltage Regulator IC. A regulated power supply is very much essential for several electronic
devices due to the semiconductor material employed in them have a fixed rate of current as
well as voltage. The device may get damaged if there is any deviation from the fixed rate.

One of the important sources of DC Supply are Batteries. But using batteries in sensitive
electronic circuits is not a good idea as batteries eventually drain out and loose their potential
over time. 

Also, the voltage provided by batteries are typically 1.2V, 3.7V, 9V and 12V. This is good
for circuits whose voltage requirements are in that range. But, most of the TTL IC’s work on
5V logic and hence we need a mechanism to provide a consistent 5V Supply.  

14 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Here comes the 7805 Voltage Regulator IC to the rescue. It is an IC in the 78XX family of
linear voltage regulators that produce a regulated 5V as output.

A Brief Note on 7805 Voltage Regulator

7805 is a three terminal linear voltage regulator IC with a fixed output voltage of 5V which is
useful in a wide range of applications. Currently, the 7805 Voltage Regulator IC is
manufactured by Texas Instruments, ON Semiconductor, STMicroelectronics, Diodes
incorporated, Infineon Technologies, etc. 

They are available in several IC Packages like TO-220, SOT-223, TO-263 and TO-3. Out of
these, the TO-220 Package is the most commonly used one (it is the one shown in the above
image). 

15 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Some of the important features of the 7805 IC are as follows: 

 It can deliver up to 1.5 A of current (with heat sink). 


 Has both internal current limiting and thermal shutdown features. 
 Requires very minimum external components to fully function.

Pin Diagram of 7805 Voltage Regulator IC

As mentioned earlier, 7805 is a three terminal device with the three pins being 1. INPUT, 2.
GROUND and 3. OUTPUT. The following image shows the pins on a typical 7805 IC in To-
220 Package. 

16 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

The pin description of the 7805 is described in the following table:

PIN NO. PIN DESCRIPTION

1 INPUT Pin 1 is the INPUT Pin. A positive unregulated voltage is given as


input to this pin.

2 GROUND Pin 2 is the GROUND Pin. It is common to both Input and Output.

3 OUTPUT Pin 3 is the OUTPUT Pin. The output regulated 5V is taken at this
pin of the IC.

Basic Circuit of 7805 

As I have previously talked about regulated power supply as a device that works on DC
voltages and it can uphold its output accurately at a fixed voltage all the time even if there is
a significant alteration in the DC input voltage.

As per the datasheets of 7805 IC, the basic circuit required for 7805 to work as a complete
regulator is very simple. In fact, if the input supply is an unregulated DC Voltage, then all
you need are two capacitor (even those are not mandatory depending on the
implementation). 

17 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

The above circuit shows all the components required for a 7805 IC to work properly. The
0.22μF Capacitor near the input is required only if the distance between the regulator IC and
the power supply filter is high. Also, the 0.1μF Capacitor near the output is optional and if
used, it helps in the transient response. 

In this circuit, VIN is the input voltage to the 7805 IC and the source can be from either a
battery of an unregulated DC. VOUT is the output of the 7805 IC, which is a Regulated 5V.

How to Get Constant DC Power Supply from AC?

18 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Although batteries can be used as input to the 7805 Voltage Regulator IC, we face certain
bumps like frequent discharge of batteries and reduction of battery voltage levels over a
period of time. 

The best alternative to using Batteries is to provide an unregulated but rectified DC Voltage
from an AC Source. Since AC Source is easily available as mains supply, we can design a
circuit to convert AC Mains to DC and provide it as input to the 7805 Voltage regulator IC. 

Circuit Diagram

The following image shows the circuit diagram of producing a regulated 5V from AC Mains
supply.

Components Required

 230V-12V Step Down Transformer 


 Bridge Rectifier (or 4 PN Diodes – 1N4007) 
 1A Fuse 
 1000μF Capacitor 
 7805 Voltage Regulator IC 
 0.22μF Capacitor 
 0.1μF Capacitor 
 1N4007 Diode 

19 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Working

The AC power supply from mains first gets converted into and unregulated DC and then into
a constant regulated DC with the help of this circuit. The circuit is made up of transformer,
bridge rectifier made up from diodes, linear voltage regulator 7805 and capacitors. 

If you observe, the working of the circuit can be divided into two parts. In the first part, the
AC Mains is converted into unregulated DC and in the second part, this unregulated DC is
converted into regulated 5V DC. So, let us start discussing the working with this in mind. 

Initially, a 230V to 12V Step down transformer is taken and its primary is connected to mains
supply. The secondary of the transformer is connected to Bridge rectifier (either a dedicated
IC or a combination of 4 1N4007 Diodes can be used). 

A 1A fuse is placed between the transformer and the bridge rectifier. This will limit the
current drawn by the circuit to 1A. The rectified DC from the bridge rectifier is smoothened
out with the help of 1000μF Capacitor. 

So, the output across the 1000μF Capacitor is unregulated 12V DC. This is given as an input
to the 7805 Voltage Regulator IC. 7805 IC then converts this to a regulated 5V DC and the
output can be obtained at its output terminals. 

Important Points on 7805 Voltage Regulator IC 

 The first important point to note is that the input voltage should always be greater
than the output voltage (atleast by 2.5V). 
 The input current and output current are almost identical. This means that when a
7.5V 1A supply is given at input, the output will be 5V 1A. 
 The remaining power is dissipated as heat and hence a heat sink like the one shown
below must be used with 7805 IC. 

20 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

3.3 Arduino Uno

Arduino UNO

Arduino Uno SMD R3

Developer Arduino

Manufacturer Many

Type Single-board microcontroller[1]

Operating system None

CPU Microchip AVR (8-bit)

Memory SRAM

Storage Flash, EEPROM

21 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

The Arduino UNO is an open-source microcontroller board based on


the Microchip ATmega328P microcontroller and developed by Arduino.cc. The board is
equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to
various expansion boards (shields) and other circuits. The board has 14 Digital pins, 6 Analog
pins, and programmable with the Arduino IDE (Integrated Development Environment) via a
type B USB cable.[4] It can be powered by a USB cable or by an external 9 volt battery,
though it accepts voltages between 7 and 20 volts. It is also similar to the Arduino Nano and
Leonardo. The hardware reference design is distributed under a Creative
Commons Attribution Share-Alike 2.5 license and is available on the Arduino website.
Layout and production files for some versions of the hardware are also available. "Uno"
means one in Italian and was chosen to mark the release of Arduino Software (IDE) 1.0.The
Uno board and version 1.0 of Arduino Software (IDE) were the reference versions of
Arduino, now evolved to newer releases. The Uno board is the first in a series of USB
Arduino boards, and the reference model for the Arduino platform. The ATmega328 on the
Arduino Uno comes preprogrammed with a bootloader that allows uploading new code to it
without the use of an external hardware programmer. It communicates using the original
STK500 protocol. The Uno also differs from all preceding boards in that it does not use the
FTDI USB-to-serial driver chip. Instead, it uses the Atmega16U2 (Atmega8U2 up to version
R2) programmed as a USB-to-serial converter. ‘

Contents

 1Background
 2Technical specifications
 3Pins
o 3.1General Pin functions
o 3.2Special Pin Functions

 4Communication
o 4.1Automatic (Software) Reset

 5See also
 6References
 7External links

22 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Background

an early production board

The Arduino project started at the Interaction Design Institute Ivrea (IDII) in Ivrea, Italy. At
that time, the students used a BASIC Stampmicrocontroller at a cost of $100, a considerable
expense for many students. In 2003 Hernando Barragán created the development
platform Wiring as a Master's thesis project at IDII, under the supervision of Massimo Banzi
and Casey Reas, who are known for work on the Processing language. The project goal was
to create simple, low-cost tools for creating digital projects by non-engineers. The Wiring
platform consisted of a printed circuit board (PCB) with an ATmega168 microcontroller, an
IDE based on Processing and library functions to easily program the microcontroller. [8] In
2003, Massimo Banzi, with David Mellis, another IDII student, and David Cuartielles, added
support for the cheaper ATmega8 microcontroller to Wiring. But instead of continuing the
work on Wiring, they forked the project and renamed it Arduino. Early arduino boards used
the FTDI USB-to-serial driver chip and an ATmega168.The Uno differed from all preceding
boards by featuring the ATmega328P microcontroller and an ATmega16U2 (Atmega8U2 up
to version R2) programmed as a USB-to-serial converter.

Technical specifications

 Microcontroller: Microchip ATmega328P 
 Operating Voltage: 5 Volts
 Input Voltage: 7 to 20 Volts
 Digital I/O Pins: 14 (of which 6 provide PWM output)
 Analog Input Pins: 6

23 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

 DC Current per I/O Pin: 20 mA


 DC Current for 3.3V Pin: 50 mA
 Flash Memory: 32 KB of which 0.5 KB used by bootloader
 SRAM: 2 KB
 EEPROM: 1 KB
 Clock Speed: 16 MHz
 Length: 68.6 mm
 Width: 53.4 mm
 Weight: 25 g

Pins

Arduino UNO

General Pin functions

 LED: There is a built-in LED driven by digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, it's off.
 VIN: The input voltage to the Arduino/Genuino board when it's using an external
power source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the power
jack, access it through this pin.
 5V: This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 20V), the USB connector (5V),

24 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

or the VIN pin of the board (7-20V). Supplying voltage via the 5V or 3.3V pins bypasses
the regulator, and can damage the board.
 3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current draw
is 50 mA.
 GND: Ground pins.
 IOREF: This pin on the Arduino/Genuino board provides the voltage reference with
which the microcontroller operates. A properly configured shield can read the IOREF pin
voltage and select the appropriate power source or enable voltage translators on the
outputs to work with the 5V or 3.3V.
 Reset: Typically used to add a reset button to shields which block the one on the
board.

Special Pin Functions

Each of the 14 digital pins and 6 Analog pins on the Uno can be used as an input or output,
using pinMode(),digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin
can provide or receive 20 mA as recommended operating condition and has an internal pull-
up resistor (disconnected by default) of 20-50k ohm. A maximum of 40mA is the value that
must not be exceeded on any I/O pin to avoid permanent damage to the microcontroller.The
Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution
(i.e. 1024 different values). By default they measure from ground to 5 volts, though is it
possible to change the upper end of their range using the AREF pin and the
analogReference() function.[

In addition, some pins have specialized functions:

 Serial / UART: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL
serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-
to-TTL Serial chip.
 External Interrupts: pins 2 and 3. These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value.
 PWM (Pulse Width Modulation): 3, 5, 6, 9, 10, and 11 Can provide 8-bit PWM
output with the analogWrite() function.
 SPI (Serial Peripheral Interface): 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These
pins support SPI communication using the SPI library.

25 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

 TWI (Two Wire Interface) / I²C: A4 or SDA pin and A5 or SCL pin. Support TWI


communication using the Wire library.
 AREF (Analog REFerence): Reference voltage for the analog inputs.[

Communication

The Arduino/Genuino Uno has a number of facilities for communicating with a computer,
another Arduino/Genuino board, or other microcontrollers. The ATmega328 provides UART
TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An
ATmega16U2 on the board channels this serial communication over USB and appears as a
virtual com port to software on the computer. The 16U2 firmware uses the standard USB
COM drivers, and no external driver is needed. However, on Windows, a .inf file is required.
The Arduino Software (IDE) includes a serial monitor which allows simple textual data to be
sent to and from the board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial
communication on pins 0 and 1). A SoftwareSerial library allows serial communication on
any of the Uno's digital pins.

Automatic (Software) Reset

Rather than requiring a physical press of the reset button before an upload, the
Arduino/Genuino Uno board is designed in a way that allows it to be reset by software
running on a connected computer. One of the hardware flow control lines (DTR) of the
ATmega8U2/16U2 is connected to the reset line of the ATmega328 via a 100 nanofarad
capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the
chip.

This setup has other implications. When the Uno is connected to a computer running Mac OS
X or Linux, it resets each time a connection is made to it from software (via USB). For the
following half-second or so, the bootloader is running on the Uno. While it is programmed to
ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first
few bytes of data sent to the board after a connection is opened.

3.4 16x2 LCD Display Module

26 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

16x2 LCD Display Module with HD44780 Controller

16×2 LCD is named so because; it has 16 Columns and 2 Rows. There are a lot of
combinations available like, 8×1, 8×2, 10×2, 16×1, etc. But the most used one is the 16*2
LCD, hence we are using it here.

All the above mentioned LCD display will have 16 Pins and the programming approach is
also the same and hence the choice is left to you. Below is the Pinout and Pin Description
of 16x2 LCD Module:

Sr.
Pin No. Pin Name Pin Type Pin Description Pin Connection
No
1 Pin 1 Ground Source Pin This is a ground pin of Connected to the
LCD ground of the MCU/

27 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Power source
Connected to the
This is the supply
2 Pin 2 VCC Source Pin supply pin of Power
voltage pin of LCD
source
Connected to a
Adjusts the contrast of
3 Pin 3 V0/VEE Control Pin variable POT that
the LCD.
can source 0-5V
Connected to a MCU

Toggles between pin and gets either 0


4 Pin 4 Register Select Control Pin Command/Data or 1.

Register 0 -> Command Mode

1-> Data Mode


Connected to a MCU

Toggles the LCD pin and gets either 0


5 Pin 5 Read/Write Control Pin between Read/Write or 1.
Operation 0 -> Write Operation

1-> Read Operation


Must be held high to Connected to MCU
6 Pin 6 Enable Control Pin perform Read/Write and always held
Operation high.

In 4-Wire Mode

Only 4 pins (0-3) is


Pins used to send
Data/Command connected to MCU
7 Pin 7-14 Data Bits (0-7) Command or data to the
Pin In 8-Wire Mode
LCD.
All 8 pins(0-7) are
connected to MCU

Normal LED like


8 Pin 15 LED Positive LED Pin operation to illuminate Connected to +5V
the LCD

28 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Normal LED like


operation to illuminate
9 Pin 16 LED Negative LED Pin Connected to ground
the LCD connected
with GND.

Okay, what is this two black circle like things on the back of our LCD?

These black circles consist of an interface IC and its associated components to help us use
this LCD with the MCU. Because our LCD is a 16*2 Dot matrix LCD and so it will have
(16*2=32) 32 characters in total and each character will be made of 5*8 Pixel Dots.  A Single
character with all its Pixels enabled is shown in the below picture.

So Now, we know that each character has (5*8=40) 40 Pixels and for 32 Characters we will
have (32*40) 1280 Pixels. Further, the LCD should also be instructed about the Position of
the Pixels.

29 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

It will be a hectic task to handle everything with the help of MCU, hence an Interface IC
like HD44780 is used, which is mounted on LCD Module itself. The function of this IC is to
get the Commands and Data from the MCU and process them to display meaningful
information onto our LCD Screen.

Let’s discuss the different type of mode and options available in our LCD that has to be
controlled by our Control Pins.

4-bit and 8-bit Mode of LCD:

The LCD can work in two different modes, namely the 4-bit mode and the 8-bit mode. In 4
bit mode we send the data nibble by nibble, first upper nibble and then lower nibble. For
those of you who don’t know what a nibble is: a nibble is a group of four bits, so the lower
four bits (D0-D3) of a byte form the lower nibble while the upper four bits (D4-D7) of a byte
form the higher nibble. This enables us to send 8 bit data.

Whereas in 8 bit mode we can send the 8-bit data directly in one stroke since we use all the 8
data lines.

Now you must have guessed it, Yes 8-bit mode is faster and flawless than 4-bit mode. But the
major drawback is that it needs 8 data lines connected to the microcontroller. This will make
us run out of I/O pins on our MCU, so 4-bit mode is widely used. No control pins are used to
set these modes. It's just the way of programming that change.

Read and Write Mode of LCD:

As said, the LCD itself consists of an Interface IC. The MCU can either read or write to this
interface IC. Most of the times we will be just writing to the IC, since reading will make it
more complex and such scenarios are very rare. Information like position of cursor, status
completion interrupts etc. can be read if required, but it is out of the scope of this tutorial.

The Interface IC present in most of the LCD is HD44780U, in order to program our LCD we
should learn the complete datasheet of the IC. The datasheet is given here.

LCD Commands:

There are some preset commands instructions in LCD, which we need to send to LCD
through some microcontroller. Some important command instructions are given below:

30 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Hex Code Command to LCD Instruction Register

0F LCD ON, cursor ON

01 Clear display screen

02 Return home

04 Decrement cursor (shift cursor to left)

06 Increment cursor (shift cursor to right)

05 Shift display right

07 Shift display left

0E Display ON, cursor blinking

80 Force cursor to beginning of first line

C0 Force cursor to beginning of second line

38 2 lines and 5×7 matrix

83 Cursor line 1 position 3

3C Activate second line

08 Display OFF, cursor OFF

C1 Jump to second line, position 1

OC Display ON, cursor OFF

C1 Jump to second line, position 1

C2 Jump to second line, position 2


 

3.5 IR Sensor Module

31 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

IR Sensor Module

IR Sensor Module Pinout

Pin Configuration

Pin Name Description

VCC Power Supply Input

GND Power Supply Ground

OUT Active High Output

IR Sensor Module Features

 5VDC Operating voltage

 I/O pins are 5V and 3.3V compliant

 Range: Up to 20cm

 Adjustable Sensing range

 Built-in Ambient Light Sensor

 20mA supply current

 Mounting hole

Brief about IR Sensor Module

32 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

The IR sensor module consists mainly of the IR Transmitter and Receiver, Opamp, Variable
Resistor (Trimmer pot), output LED in brief.

IR LED Transmitter

IR LED emits light, in the range of Infrared frequency. IR light is invisible to us as its


wavelength (700nm – 1mm) is much higher than the visible light range. IR LEDs have light
emitting angle of approx. 20-60 degree and range of approx. few centimeters to several feets,
it depends upon the type of IR transmitter and the manufacturer. Some transmitters have the
range in kilometers. IR LED white or transparent in colour, so it can give out amount of
maximum light.

Photodiode Receiver

Photodiode acts as the IR receiver as its conducts when light falls on it. Photodiode is a
semiconductor which has a P-N junction, operated in Reverse Bias, means it start conducting
the current in reverse direction when Light falls on it, and the amount of current flow is
proportional to the amount of Light. This property makes it useful for IR detection.
Photodiode looks like a LED, with a black colour coating on its outer side, Black colour
absorbs the highest amount of light.

LM358 Opamp

33 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

LM358 is an Operational Amplifier (Op-Amp) is used as voltage comparator in the IR


sensor. the comparator will compare the threshold voltage set using the preset (pin2) and the
photodiode’s series resistor  voltage (pin3).

Photodiode’s series resistor voltage drop > Threshold voltage = Opamp output is High

Photodiode’s series resistor voltage drop < Threshold voltage = Opamp output is Low

When Opamp's output is high the LED at the Opamp output terminal turns ON (Indicating
the detection of Object).

Variable Resistor

The variable resistor used here is a preset. It is used to calibrate the distance range  at which
object should be detected.

           

How to Use IR Sensor Module?

The 5 VDC supply input is given to the VCC pin and the supply negative is connected to the
GND terminal of the module. When no object is detected within the range of the IR receiver,
the output LED remains off.

When a object is detected within the range of the IR sensor the LED glows.

34 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Applications

 Obstacle Detection
 Industrial safety devices
 Wheel encoder

 2D-Model

3.6 Relay Module


 We can control high voltage electronic devices using relays. A Relay is actually a switch
which is electrically operated by an electromagnet. The electromagnet is activated with a low
voltage, for example 5 volts from a microcontroller and it pulls a contact to make or break a
high voltage circuit.

HL-52S Relay Module

35 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

As an example for this Arduino Relay Tutorial we will use the HL-52S 2 channel relay
module, which has 2 relays with rating of 10A @ 250 and 125 V AC and 10A @ 30 and 28 V
DC. The high voltage output connector has 3 pins, the middle one is the common pin and as
we can see from the markings one of the two other pins is for normally open connection and
the other one for normally closed connection.

On the other side of the module we have these 2 sets of pins. The first one has 4 pins, a
Ground and a VCC pin for powering the module and 2 input pins In1 and In2. The second set
of pins has 3 pins with a jumper between the JDVcc and the Vcc pin.  With a configuration
like this the electromagnet of the relay is directly powered from the Arduino Board and if
something goes wrong with the relay the microcontroller could get damaged.

36 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

You can get the components from any of the sites below:


 5V Relay Module
 Arduino Board
 Breadboard and Jump Wires
 Cable, Plug, Socket
Circuit Schematic

For better understanding let’s see the circuit schematics of the relay module in this
configuration. So we can see that the 5 volts from our microcontroller connected to the Vcc
pin for activating the relay through the Optocoupler IC are also connected to the JDVcc pin
which powers the electromagnet of the relay. So in this case we got no isolation between the
relay and the microcontroller.

37 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

In order to isolate the microcontroller from the relay, we need to remove the jumper and
connect separate power supply for the electromagnet to the JDVcc and the Ground pin. Now
with this configuration the microcontroller doesn’t have any physical connection with the
relay, it just uses the LED light of the Optocoupler IC to activate the relay.

There is one more thing to be noticed from this circuit schematics. The input pins of the
module work inversely. As we can see the relay will be activated when the input pin will be
LOW because in that way the current will be able to flow from the VCC to the input pin
which is low or ground, and the LED will light up and active the relay. When the input pin

38 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

will be HIGH there will be no current flow, so the LED will not light up and the relay will
not be activated.

3.7 DC Fan ’
A computer fan is any fan inside, or attached to, a computer case used for active cooling. Fans are
used to draw cooler air into the case from the outside, expel warm air from inside, and move air across
a heat sink to cool a particular component. ‘

39 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

40 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Chapter 4

Practical Implementation of Circuit

4.1 Components Required

41 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

For designing Fan Speed Measurement Circuit using IR Sensor & Arduino we need
the following components:
1. Arduino UNO Board
2. 16*2 LCD
3. IR Sensor module
4. Motor
5. Connecting Jumper Wires

4.2 Circuit Diagram

4.3 IR Sensor Module


An infrared sensor is an electronic instrument that is used to sense certain
characteristics of its surroundings by either emitting and/or detecting infrared
radiation. Infrared sensors are also capable of measuring the heat being emitted by an
object and detecting motion.

The wavelength region which ranges from 0.75 to 3µm is known as the near-infrared
region. The region between 3 and 6µm is known as the mid-infrared and infrared
radiation which has a wavelength greater higher than 6µm is known as far-infrared.

4.4 Code

42 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

boolean debounce = false;


int rps = 0;
int rpm = 0;
int sensorValue = 0;

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
}

void loop() {
  int r = rpm_count();
  Serial.println(r);
  lcd.setCursor(0, 0);
  lcd.print("FALAN UNIVERSITY");
  lcd.setCursor(0, 1);
  lcd.print("RPM = ");
  lcd.print(r);
  delay(100);
}

int rpm_count(){
  uint32_t start_time = millis();
while((millis()-start_time) < 1000){
  sensorValue = analogRead(A0);
  while(sensorValue>=200 && (millis()-start_time) < 1000){
    if(debounce){
      debounce = false;
      rps++;
  }
    sensorValue = analogRead(A0);

43 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

    delayMicroseconds(10);
 }
  while(sensorValue<=80 && (millis()-start_time) < 1000){
    debounce = true;
    sensorValue = analogRead(A0);
    delayMicroseconds(1);
 }
}
  rpm = 15*rps;
  rps = 0;
  delayMicroseconds(10);
  return(rpm);
}

44 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Chapter 5

Advantages and Disadvantages

45 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

5.1 Advantages

 Accuracy is high as display is used

 Easy to take reading as little time delay is provided

 Memory is provided for storage of values

 Can compute average deviations

 5.2 Disadvantages
 
 Since the digital tachometer is held in hand, slight variation in its positionchanges its
speed.

 If the speed is varying at every instant then the digital display fluctuatesand makes it
difficult to read the actual speed

 A good reflector is needed.

 Reflection distance should be minimum for good accuracy.

 Direct sunlight may hamper the accuracy.

46 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Chapter 6

Future Development and References

Future Development
47 Department of Physics, Govt Emerson College, Multan
Arduino Based RPM Counter

 People counter.

 Controlling the switching system of a room.

 We use our rpm meter to control the speed of a low volt DC motor. For this we only need to
develop our coding section not the hardware section.

 Can be Implemented using microcontroller so that size gets reduced .i.e. itbecomes
compact.

 Circuit can be modified to get speed in rpm using DAC,ADC & op-amp

Conclusions & Reference

6.1 Conclusions

The Digital Tachometer designed is economical for lab purposes

Overall I consider this project to be a success. The results were actually more promising than
the PIC tachometer...Although, I blame that on both time and experience. Anyway, the
system worked as we designed it and reliably enough that we saw the results we were hoping
for...3000 RPM fans ran at about 3000 RPM and so on. I hope you enjoyed reading this
article and learned something about build your own tachometer with an Arduino!

6.2Reference

[1] Coughling& Driscoll, Operational amplifier & Linear integrated Circuits, 6th edition, Prentice-
Hall India.

[2] Arduino.cc (http://arduino.cc/)

[3] ZulkarnimeSifat, ex-student of AUST,Project Engineer, Bangladesh Army.

[4] Jeremy Blum, Video lectures, (http://www.jeremyblum.com/category/ardui no-tutorials/

[5] S. Ueha and Y. Tomikawa, Ultrasonic Motors: Theory and Applications. Oxford
U.K.: Clarendon, 1993, pp.4-6.
[6] T. Sashida and T. Kenjo, an Introduction to Ultrasonic Motors. Oxford, U.K.:

48 Department of Physics, Govt Emerson College, Multan


Arduino Based RPM Counter

Clarendon, 1993, pp.6-8.


[7] K. Uchino, Piezoelectric Actuators and Ultrasonic Motors. Boston, U.S.A.: Kluwer,
1997, pp. 265-273
[8] A.Iino, K.Suzuki, M.Kasuga, M.Suzuki and T.Yamanaka, "Development of a Self-
Oscillating Ultrasonic Micromotor and Its Application to a Watch", Ultrasonics., vol. 38, pp.
54-59, 2000
[9] B.Koc, A.Dogan. Y.Xu, R.E.Newnham and K.Uchino, "An Ultrasonic Motor Using a
Metal-Ceramic Composite Actuator Torsional Displacement", Jpn. J. Appl. Phys., vol. 37,
pp. 5659-5662, 1998
[10] O.Ohnishi, O.Myohga, T.Uchikawa, M.Tamegai, T.Inoue and S.Takahashi,
"Piezoelectric Ultrasonic Motor Using Longitudinal-Torsional Composite Resonance
Vibration", IEEE Trans. Ultrason., Ferroelect., Freq. Contr., vol. 40, no.6, pp. 6693,
Nov. 1993
[11] M.Aoyagi, Y.Murasawa, T.Ogasawara and Y.Tomikawa, "Experimental
Characteristics of a Bolt-Clamped Short-Cylindrical Torsional Vibrator Using Shear
Mode Piezoceramics Inserted in the Axial Direction", Jpn. J. Appl. Phys., vol. 36, pp.
3126-3129, 1997

49 Department of Physics, Govt Emerson College, Multan

You might also like