Arduino Based RPM Counter
Arduino Based RPM Counter
Multan
Supervisor:
Shafqat Hayyat
Department of Physics
Govt Emerson College, Multan
2016-2020
Arduino Based RPM Counter
Department of Physics,
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.
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
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.
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
Chapter-5
5.2) Limitations………………………………………………,..……………………..52
5.4) Conclusion……………………………………………………………………………..52
5.5)Bibliography……………………………………………………………………………54
Chapter 1
Introduction
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.
Chapter 2
Literature Review
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.
Chapter 3
Hardware Components
Following is the list of components that are necessary to build the assembly the project.
Voltage Regulator
Resistors
IR Sensor
LED
Potentiometer – 10kΩ
DC Fan
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.
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.
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).
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.
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.
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).
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.
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
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.
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.
Arduino UNO
Developer Arduino
Manufacturer Many
CPU Microchip AVR (8-bit)
Memory SRAM
Storage Flash, EEPROM
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
Background
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
Pins
Arduino UNO
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),
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.
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.[
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.
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.
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.
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/
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
In 4-Wire Mode
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.
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.
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.
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:
02 Return home
IR Sensor Module
Pin Configuration
Range: Up to 20cm
Mounting hole
The IR sensor module consists mainly of the IR Transmitter and Receiver, Opamp, Variable
Resistor (Trimmer pot), output LED in brief.
IR LED Transmitter
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
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.
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.
Applications
Obstacle Detection
Industrial safety devices
Wheel encoder
2D-Model
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.
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.
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
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. ‘
Chapter 4
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
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
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
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);
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);
}
Chapter 5
5.1 Advantages
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
Chapter 6
Future Development
47 Department of Physics, Govt Emerson College, Multan
Arduino Based RPM Counter
People counter.
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
6.1 Conclusions
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.
[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.: