Vous êtes sur la page 1sur 86

ABSTRACT

The main aim of this project is to present a conceptual model of a microprocessor based
variable electronic speed governor that can be implemented to control the speed of any
vehicle depending on the local speed limit. The circuit is cost effective, efficient and easy
to implement on already existing vehicles. Every city, town or a village, can be marked and
divided into individual zones. The division depends upon the area under which the
business, residential, and industrial regions come. The central business district being a very
busy traffic zone demands the least speed limit, with the residential and industrial zones
having lesser traffic densities, the speed limits will vary accordingly.

Any city or town can be divided into physical zones which are classified according to
different speed ranges. A transmitter is placed at all exit and entry points of the interface of
any two zones that transmits a message signal at carrier frequency, indicating the upper
limit value of the zones’ speed range into which the vehicle is entering at that moment, to
the receiver which gives the message as an input to a preprogrammed ARM 7
Microprocessor embedded within the automobile which compares the speed of the vehicle
measured by a sensor at the maximum allowable speed and automatically regulates the
speed of the vehicle. The speed of the vehicle can be varied by varying the “duty cycle” of
the pulse input. The entire system is a low cost variable electronic speed governor, small in
size and easy to assemble onto an existing vehicle without disturbing its present
arrangement.

The output of project would be that speed of vehicle is reduced by 25% in zone1 and 50%
in zone 2.

1
Chapter-1
OVERVIEW OF THE PROJECT
The main aim of this project is to present a conceptual model of a microprocessor based
variable electronic speed governor that can be implemented to control the speed of any
vehicle depending on the local speed limit. The circuit is cost effective, efficient and easy
to implement on already existing vehicles.
The entire project is divided into three sections:
1. Input section
2. Control section
3. Output section

Input section:

The input section consists of aRFID module and non-contact type tachometer. This
Tachometer uses Non-contact IR Tachometer for measuring the speed of the shaft. This
circuit sends signal HIGH or LOW pulses to the processor.

Processing section:

In this section we use arm 7 microprocessor for processing the input. We have three
separate programs each for zone detection,speed calculation, speed display on LCD, error
detection and error correction via servo motor.

Output section:

The output is given to change the throttle valve position. This is done with the help
of a servo motor which is in turn connected to the valve. The arm7 calculates the error and
sends the appropriate error correction signal to the servo motor. Then the servo motor
rotates and in turn rotates the throttle valve thereby gear transmission system.

2
Fig 1.1BLOCK DIAGRAM OF THE PROJECT

1.1 Components used in the project:

1.ARM 7 micro processor


2.ATMEGA 8 micro controller
3.16x2 LCD display
4.RF Receiver and Transmitter
5.Variable DC motors
6.12v DC power supply
7.L293d motor driver IC

3
Chapter -2
LITERATURE REVIEW
The development of project was started with background study or literature review about
other system that related to road safety. This is done by find out the journal, articles and
books that relate with this project.Here are some previously used technologies related to
road safety.

Firstly most School Zone signs should have flashing lights, especially in hot zones, can
have these flashing lights as well because some drivers do not pay attention if there are no
flashing lights. The speed limit in hot zones should be reduced, especially if they keep
occurring so reducing the speed limit from 60km to 50km or even 40km if need be can be
an option.

Secondly, more sensory input needs to occur to get driver’s attention like a loud warning
bell or beeping noise and a loud recorded voice on speakers before entering a certain area
or hot zone, for example ‘You are about to enter a hot zone, please reduce speed
immediately, maintain control of the vehicle and secure seat belts’.

Thirdly, more speed humps in certain areas and hot zones. This works well in general, and
for those who disobey the speed humps, it can be annoying and cause possible damage to a
car.

After understood all the related concepts, innovation of previous system is designed. Then,
the circuit of zone section and vehicle is designed. After all the designing process is done,
the circuit design is tested on test board.. After the test is satisfied, the circuit is fabricated.
Lastly, the prototype is tested and measured.

4
Chapter-3

ARM PROCESSOR

3.1 ARM Processor

ARM stands for Advanced RISC Machines. It is a 32 bit processor core, used for high end
application. It is widely used in Advanced Robotic Applications.

Fig: 3.1ARM Processor

3.1.1 History and Development

 ARM was developed atAcron Computers ltd of Cambridge, England between 1983 and
1985.
 RISC concept was introduced in 1980 at Stanford and Berkley.
 ARM ltd was found in 1990.
 ARM cores are licensed to partners so as to develop and fabricate new microcontrollers
around same processor cores.

5
3.1.2 Key Features

1. 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.


2. 8 Kb to 40 Kb of on-chip static RAM and 32 Kb to 512 Kb of on-chip flash memory.
128-bit wide interface/accelerator enables high-speed 60 MHz operation.
3. In-System Programming/In-Application Programming (ISP/IAP) via on-chip boot loader
software. Single flash sector or full chip erase in 400 ms and programming of 256 bytes in
1 ms
4. Embedded ICERT and Embedded Trace interfaces offer real-time debugging with the on-
chip Real Monitor software and high-speed tracing of instruction execution.
5. USB 2.0 Full-speed compliant device controller with 2 Kb of endpoint RAM.
In addition, the LPC2146/48 provides 8 Kb of on-chip RAM accessible to USB by DMA.
6. One or two (LPC2141/42 vs. LPC2144/46/48) 10-bit ADCs provide a total of 6/14
Analog inputs, with conversion times as low as 2.44 µs per channel.
7. Single 10-bit DAC provides variable analog output (LPC2142/44/46/48 only).
8. Two 32-bit timers/external event counters (with four capture and four compare channels
each), PWM unit (six outputs) and watchdog.
9. Low power Real-Time Clock (RTC) with independent power and 32 kHz clock input.
10. Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400 Kbit/s),
SPI and SSP with buffering and variable data length capabilities.
11. Vectored Interrupt Controller (VIC) with configurable priorities and vector addresses.
12. Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.
13. Up to 21 external interrupt pins available.
14. 60 MHz maximum CPU clock available from programmable on-chip PLL with settling
time of 100 µs.

6
15. On-chip integrated oscillator operates with an external crystal from 1 MHz to 25 MHz.

Fig: 3.2 LPC2144/46/48 pinning

7
Fig: 3.3 Block diagram of ARM 7

8
3.1.3Architectute

3.1.3.1 Core Data path

Architecture is characterized by Data path and control path.

• Data path is organized in such a way that, operands are not fetched directly from memory
locations. Data items are placed in register files. No data processing takes place in memory
locations.
• Instructions typically use 3 registers. 2 source registers and 1 destination register.
• Barrel Shifter preprocesses data, before it enters ALU.
• Barrel Shifter is basically a combinational logic circuit, which can shift data to left or right
by arbitrary number of position in same cycle.
• Increment or Decrement logic can update register content for sequential access.

3.1.3.2 Pipeline

• In ARM 7, a 3 stage pipeline is used. A 3 stage pipeline is the simplest form of pipeline
that does not suffer from the problems such as read before write.
• In a pipeline, when one instruction is executed, second instruction is decoded and third
instruction will be fetched.
• This is executed in a single cycle.

3.1.3.3 Register Bank

• ARM 7 uses load and store Architecture.


• Data has to be moved from memory location to a central set of registers.
• Data processing is done and is stored back into memory.
• Register bank contains, general purpose registers to hold either data or address.
• It is a bank of 16 user registers R0-R15 and 2 status registers.
• Each of these registers is 32 bit wide.

9
3.1.3.4 Data Registers- R0-R15

• R0-R12 - General purpose registers


• R13-R15 - Special function registers of which,
R13 - Stack Pointer, refers to entry pointer of Stack.
R14 - Link register, return address is put to this when ever a subroutine is called.
R15 - Program counter

Depending upon application R13 and R14 can also be used as GPR. But not commonly
used.

Fig: 3.4 Data Registers- R0-R15

In addition there are 2 status registers

 CPSR - Current program status register, status of current execution is stored. CPSR
contains a number of flags which report and control the operation of ARM7 CPU.
 SPSR - Saved program status register, includes status of program as well as processor.

10
3.1.3.5 Vectored Interrupt Controller

The Vectored interrupt controller takes 32 interrupt request inputs and


programmable assigns them into 3 categories, FIQ, vectored IRQ, and non-vectored IRQ.
The programmable assignment scheme means that priorities of interrupts from the various
peripherals can be dynamically assigned and adjusted.

3.1.3.6 Features

1. ARM Prime cell™ vectored interrupt controller


2. 32 interrupt request inputs
3. 16 vectored IRQ interrupts
4. 16 priority levels dynamically assigned to interrupt requests
5. Software interrupt generation.

3.1.3.7 Description

1. Fast Interrupt request have the highest priority. If more than one request is assigned to FIQ,
the VIC ORs the requests to produce the FIQ signal to the ARM processor.
2. The fastest possible FIQ latency is achieved when only one request is classified as FIQ,
because then the FIQ service routine can simply start dealing with that device.
3. But if more than one request is assigned to the FIQ class, the FIQ service routine can read
a word from the VIC that identifies which FIQ source(s) is (are) requesting an interrupt.
4. Vectored IRQs have the middle priority, but only 16 of the 32 requests can be assigned to
this category.
5. Any of the 32 requests can be assigned to any of the 16 vectored IRQ slots, among which
slot 0 has the highest priority and slot 15 has the lowest.
6. Non-vectored IRQs have the lowest priority.
7. The victors the requests from all the vectored and non-vectored IRQs to produce the
i. IRQ signal to the ARM processor. The IRQ service routine can start by reading a register
from the VIC and jumping there. If any of the vectored IRQs are requesting, the VIC
provides the address of the highest-priority requesting IRQs service routine, otherwise it
ii. Provides the address of a default routine that is shared by all the non-vectored IRQs.

11
8. The default routine can read another VIC register to see what IRQs are active.
9. All registers in the VIC are word registers. Byte and halfword reads and write are not
supported.
10. Additional information on the Vectored Interrupt Controller is available in the ARM
i. PrimeCell™ Vectored Interrupt Controller (PL190) documentation.

3.2. ARM 7 LPC 2148 DEVELOPMENT BOARD

Fig:3.5. Arm 7 LPC 2148 development board

12
Increasingly, embedded systems developers and system-on-chip designers select specific
microprocessor cores and a family of tools, libraries, and off-the-shelf components to
quickly develop new microprocessor-based products and applications. ARM is one of the
major options available for embedded system developer.

Over the last few years, the ARM architecture has become the most pervasive 32-bit
architecture in the world, with wide range of ICs available from various IC
manufacturers. ARM processors are embedded in products ranging from cell/mobile
phones to automotive braking systems. A worldwide community of ARM partners and
third-party vendors has developed among semiconductor and product design companies,
including hardware engineers, system designers, and software developers.

ARM7 is one of the widely used micro-controller family in embedded system application.
This section is humble effort for explaining basic features of ARM-7.

ARM is a family of instruction set architectures for computer processors based on a


reduced instruction set computing (RISC) architecture developed by British company
ARM Holdings.

A RISC-based computer design approach means ARM processors require significantly


fewer transistors than typical processors in average computers. This approach reduces
costs, heat and power use. These are desirable traits for light, portable, battery-powered
devices—including smartphones, laptops, tablet and notepad computers), and
other embedded systems. A simpler design facilitates more efficient multi-core CPUs and
higher core counts at lower cost, providing higher processing power and improved energy
efficiency for servers and supercomputers.

STARTING WITH LPC2148

LPC2148 is the widely used IC from ARM-7 family. It is manufactured by Philips and it
is pre-loaded with many inbuilt peripherals making it more efficient and a reliable option
for the beginners as well as high end application developer.

13
• 8 to 40 kB of on-chip static RAM and 32 to 512 kB of on-chip flash program
memory.128 bit wide interface/accelerator enables high speed 60 MHz operation.

• In-System/In-Application Programming (ISP/IAP) via on-chip boot-loader software.


Single flash sector or full chip erase in 400 ms and programming of 256 bytes in 1ms.

• Embedded ICE RT and Embedded Trace interfaces offer real-time debugging with the
on-chip Real Monitor software and high speed tracing of instruction execution.

• USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM. In
addition, the LPC2146/8 provides 8 kB of on-chip RAM accessible to USB by DMA.

• One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a total of
6/14analog inputs, with conversion times as low as 2.44 us per channel.

• Single 10-bit D/A converter provides variable analog output.

• Two 32-bit timers/external event counters (with four capture and four compare channels
each), PWM unit (six outputs) and watchdog.

• Low power real-time clock with independent power and dedicated 32 kHz clock input.

• Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus(400 kbit/s),
SPI and SSP with buffering and variable data length capabilities.

• Vectored interrupt controller with configurable priorities and vector addresses.

• Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.

• Up to nine edge or level sensitive external interrupt pins available.

• On-chip integrated oscillator operates with an external crystal in range from 1 MHz to30
MHz and with an external oscillator up to 50 MHz.

• Power saving modes include Idle and Power-down.

14
• Individual enable/disable of peripheral functions as well as peripheral clock scaling for
additional power optimization.

• Processor wake-up from Power-down mode via external interrupt, USB, Brown-Out
Detect (BOD) or Real-Time Clock (RTC).

FIRST STEP- HARDWARE REQUIREMENT

Here is the pin configuration of LPC 2148.

Now let us start with the hardware requirement of LPC2148.

15
LPC2148 need minimum below listed hardware to work properly.

1. Power Supply

2. Crystal Oscillator

3. Reset Circuit

4. RTC crystal oscillator

5. UART

1. Power Supply

LPC2148 works on 3.3 V power supply. LM 117 can be used for generating 3.3 V supply.
However, basic peripherals like LCD, ULN 2003 (Motor Driver IC) etc. works on 5V. So
AC mains supply is converted into 5V using below mentioned circuit and after that LM
117 is used to convert 5V into 3.3V.

Transformer:It is used to step down 230V AC to 9V AC supply and provides isolation


between power grids and circuit.

Rectifier: It is used to convert AC supply into DC.

16
Filter:It is used to reduce ripple factor of DC output available from rectifier end.

Regulator:It is used to regulate DC supply output.

Circuit for this is as shown below.

Here, Regulator IC 7805 is used to provide fix 5V dc supply. Now we can use LM 117 for
generating 3.3V supply from 5V using below circuit.

2. Reset Circuit

Reset button is essential in a system to avoid programming pitfalls and sometimes to


manually bring back the system to the initialization mode. Circuit diagram for reset is as
shown below. MCP 130T is a special IC used for providing stable RESET signal to LPC
2148.

17
3. Oscillator Circuit

Oscillations, the heartbeat, are provided using a crystal and are necessary for the system to
work.

18
The value of capacitors C20 & C21 depends upon the frequency of crystal Y3. General
circuit and its equivalent circuit is as shown below.

We can also use external oscillator for providing system clock. Circuit for this application
is as given below.

19
4. RTC Oscillator Circuit
It provides clock for RTC operation.

5. UART

LPC 2148 has inbuilt ISP which means we can program it within the system using serial
communication on COM0. It has also COM1 for serial communication. MAX 232/233 IC
must be used for voltage logic conversion. Related connections are as given below.

A Universal asynchronous receiver/transmitter, abbreviated UART is a piece of


computer hardware that translates data between parallel and serial forms. The universal
designation indicates that the data format and transmission speeds are configurable. The
electric signalling levels and methods (such as differential signalling etc.) are handled by a
driver circuit external to the UART. A UART is usually an individual (or part of an)

20
integrated circuit used for serial communications over a computer or peripheral device
serial port. UARTs are now commonly included in microcontrollers.

3.2.1 Universal Asynchronous Receiver/Transmitter 0

Features

 16 byte receive and transmit FIFOs


 Register locations conform to ‘550 industry standard
 Receiver FIFO trigger points at 1, 4, 8, and 14 bytes
 Built-in fractional baud rate generator with auto bauding capabilities.
 Mechanism that enables software and hardware flow control implementation

3.2.2 Universal Asynchronous Receiver/Transmitter 1

Features

• UART1 is identical to UART0, with the addition of a modem interface.


• 16 byte receive and transmit FIFOs
• Register locations conform to ‘550 industry standard
• Receiver FIFO trigger points at 1, 4, 8, and 14 bytes
• Built-in fractional baud rate generator with auto building capabilities.
• Mechanism that enables software and hardware flow control implementation
• Standard modem interface signals included with flow control (auto-CTS/RTS) fully
supported in hardware (LPC2144/6/8 only).

3.3 Analog-To-Digital Converter (ADC)

Basic clocking for the A/D converters is provided by the VPB clock. A
programmable divider is included in each converter, to scale this clock to the 4.5 MHz
(max) clock needed by the successive approximation process.

21
Features

• 10 bit successive approximation analog to digital converter (one in LPC2141/2 and two in
LPC2144/6/8).
• Input multiplexing among 6 or 8 pins (ADC0 and ADC1).
• Power-down mode.
• Burst conversion mode for single or multiple inputs.
• Optional conversion on transition on input pin or Timer Match signal.
• Global Start command for both converters (LPC2144/6/8 only).

3.3.1 Operation

3.3.1.1 Hardware-Triggered Conversion

If the BURST bit in the ADCR is 0 and the START field contains 010-111, the
ADC will start a conversion when a transition occurs on a selected pin or timer match
signal. The choices include conversion on a specified edge of any of 4 Match signals, or
conversion on a specified edge of either of 2 Capture/Match pins. The pin state from the
selected pad or the selected Match signal, XO Red with ADCR bit 27, is used in the edge
detection logic.

3.3.1.2 Real Time Clock

Features

 Measures the passage of time to maintain a calendar and clock.


 Ultra Low Power design to support battery powered systems
 Provides seconds, minutes, hours, day of month, month, year, day of week, and day of year
 Dedicated 32 kHz oscillator or programmable prescaler from VPB clock.
 Dedicated power supply pin can be connected to a battery or to the main 3.3 V

22
3.3.2 Description

On, and optionally when it is off. It uses little power in Power-down mode. On the
LPC2141/2/4/6/8, the RTC can be clocked by a separate 32.768 KHz oscillator, or by a
programmable pre scale divider based on the VPB clock. Also, the RTC is powered by it’s,
which can be connected to a battery or to the same 3.3 V supply used by the rest of the
device.

Fig: 3.6 Architecture of Real Time Clock

3.3.3 Register Description

The RTC includes a number of registers. The address space is split into four
sections by functionality. The first eight addresses are the miscellaneous register group.
The second set of eight locations are the time counter group. The third set of eight
locations contain the alarm register group. The remaining registers control the reference
clock divider.

23
Chapter-4

INTRODUCTION TO ARDUINO

4.1. ARDUINO:

Arduino is a tool for making computers that can sense and control more of the
physical world than your desktop computer. It's an open-source physical computing
platform based on a simple microcontroller board, and a development environment for
writing software for the board.
Arduino can be used to develop interactive objects, taking inputs from a variety of
switches or sensors, and controlling a variety of lights, motors, and other physical outputs.
Arduino projects can be stand-alone, or they can communicate with software running on
your computer (e.g. Flash, Processing, MaxMSP). The boards can be assembled by hand or
purchased preassembled.
The Arduino programming language is an implementation of Wiring, a similar physical
computing platform, which is based on the Processing multimedia programming
environment.

4.2. ABOUT ARDUINO:


There are many other microcontrollers and microcontroller platforms available for
physical computing. PIC, Raspberry Pi, 8051, and many others offer similar functionality.
All of these tools take the messy details of microcontroller programming and wrap it up in
an easy-to-use package. Arduino also simplifies the process of working with
microcontrollers, but it offers some advantage for teachers, students, and interested
amateurs over other systems.

• Inexpensive -Arduino boards are relatively inexpensive compared to other microcontroller


platforms. The least expensive version of the Arduino module can be assembled by hand.
• Cross-platform - The Arduino software runs on Windows, Macintosh OSX, and Linux
operating systems. Most microcontroller systems are limited to Windows.
• Simple, clear programming environment - The Arduino programming environment is
easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as

24
well. For teachers, it's conveniently based on the Processing programming environment, so
students learning to program in that environment will be familiar with the look and feel of
Arduino.
• Open source and extensible software- The Arduino software is published as open source
tools, available for extension by experienced programmers. The language can be expanded
through C++ libraries, and people wanting to understand the technical details can make the
leap from Arduino to the AVR C programming language on which it's based. Similarly,
you can add AVR-C code directly into your Arduino programs if you want to.
• Open source and extensible hardware - The Arduino is based on
Atmel's ATMEGA8 and ATMEGA168microcontrollers. The plans for the modules are
published under a Creative Commons license, so experienced circuit designers can make
their own version of the module, extending it and improving it. Even relatively
inexperienced users can build the breadboard version of the module in order to understand
how it works and save money.

ARDUINO IMAGE:

Fig.4.1. Image of Arduino

25
4.3 ARDUINO LIBRARY:

Arduino library is a library which consists of various commands and syntaxes of various
functions used to implement our desired program.

4.3.1. ARDUINO COMMANDS for LCD programming:

1. setup():

The setup() function is called when a sketch starts. Use it to initialize variables, pin modes,
start using libraries, etc. The setup function will only run once, after each powerup or reset
of the Arduino board.

2. pinmode():

Configures the specified pin to behave either as an input or anoutput.As of Arduino 1.0.1,
it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP.
Additionally, the INPUT mode explicitly disables the internal pullups.

Syn ta x:

pinMode(pin, mode)

Par a met e rs :

pin: the number of the pin whose mode you wish to set
mode: INPUT, OUTPUT, or INPUT_PULLUP.

Re t ur ns :

None

26
3. digitalWrite()

De s cr i pti on

Writes a HIGH or a LOW value to a digital pin.


If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the
corresponding value: 5V for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable
an internal 20K pull up resistor. Writing LOW will disable the pullup. The pullup resistor
is enough to light an LED dimly, so if LEDs appear to work, but very dimly, this is a likely
cause. The remedy is to set the pin to an output with the pinMode() function.

Syn ta x:

digitalWrite(pin, value)

Par a met e rs

pin: the pin number


value: HIGH or LOW

Re t ur ns

none

4. digitalRead():

De s cr i pti on

Reads the value from a specified digital pin, either HIGH or LOW.

Syn ta x:

digitalRead(pin)

Par a met e rs :

pin: the number of the digital pin you want to read (int)

27
Re t ur ns

HIGH or LOW

4. delay()

De s cr i pti on

Pauses the program for the amount of time (in milliseconds) specified as parameter.

Syn ta x

delay(ms)

Par a met e rs

ms: the number of milliseconds to pause (unsigned long)

Re t ur ns

Nothing

4.4.ATMEGA 8 MICROCONTROLLER
Atmega 8 is a high performance, low power Atmel AVR 8-bit microcontroller generally
used along with arduino boot-loader in automatic controlled products and devices. It is
available in 28-pin DIP and TQFP.

4.4.1 Features of Atmega 8

• Memory: It has 8 Kb of Flash program memory (10,000 Write/Erase cycles durability),


512 Bytes of EEPROM (100,000 Write/Erase Cycles). 1Kbyte Internal SRAM
• I/O Ports: 23 I/O line can be obtained from three ports; namely Port B, Port C and Port D.
• SPI (Serial Peripheral interface): ATmega8 holds three communication devices integrated.
One of them is Serial Peripheral Interface. Four pins are assigned to Atmega8 to
implement this scheme of communication.
• USART: One of the most powerful communication solutions is USART and ATmega8
supports both synchronous and asynchronous data transfer schemes. It has three pins

28
assigned for that. In many projects, this module is extensively used for PC-Micro
controller communication.
• Analog Comparator: A comparator module is integrated in the IC that provides comparison
facility between two voltages connected to the two inputs of the Analog comparator via
External pins attached to the micro controller.
• Analog to Digital Converter: Inbuilt analog to digital converter can convert an analog input
signal into digital data of 10bit resolution. For most of the low end application, this much
resolution is enough.
• 32 × 8 General Purpose Working Registers are available.

Pin diagram

Fig. 4.2 Pin Diagram of Atmega 8 Micro Controller

29
Pin Description

VCC

Digital supply voltage. Magnitude of the voltage range between 4.5 to 5.5 V for the
ATmega8 and 2.7 to 5.5 V for ATmega8L.

GND
Ground. Zero reference digital voltage supply.

PORTB (PB7.. PB0)


PORTB is a port I / O two-way (bidirectional) 8-bit with internal pull-up resistor can be
selected. This port output buffers have symmetrical characteristics when used as a source
or sink. When used as an input, the pull-pin low externally will emit a current if the pull-up
resistor is activated it. PORTB pins will be in the condition of the tri-state when RESET is
active, although the clock is not running.

PORTC (PC5.. PC0)


PORTC is a port I / O two-way (bidirectional) 7-bit with internal pull-up resistor can be
selected. This port output buffers have symmetrical characteristics when used as a source
or sink. When used as an input, the pull-pin low externally will emit a current if the pull-up
resistor is activated it. PORTC pins will be in the condition of the tri-state when RESET is
active, although the clock is not running.

PC6/RESET
If RSTDISBL Fuse programmed, PC6 then serves as a pin I / O but with different
characteristics. PC0 to PC5. If Fuse RSTDISBL not programmed, then serves as input
Reset PC6. LOW signal on this pin with a minimum width of 1.5 microseconds will bring
the microcontroller into reset condition, although the clock is not running.

PORTD (PD7.. PD0)


PORTD is a port I / O two-way (bidirectional) 8-bit with internal pull-up resistor can be
selected. This port output buffers have symmetrical characteristics when used as a source

30
or sink. When used as an input, the pull-pin low externally will emit a current if the pull-up
resistor is activated it. PORTD pins will be in the condition of the tri-state when RESET is
active, although the clock is not running.

RESET
Reset input pin. LOW signal on this pin with a minimum width of 1.5 microseconds will
bring the microcontroller into reset condition, although the clock is not running. Signal
with a width of less than 1.5 microseconds does not guarantee a Reset condition.

AVCC
AVCC is the supply voltage pin for the ADC, PC3 .. PC0, and ADC7 .. ADC6. This pin
should be connected to VCC, even if the ADC is not used. If the ADC is used, AVCC
should be connected to VCC through a low-pass filter to reduce noise.

Aref
Analog Reference pin for the ADC.

ADC7 .. ADC6
ADC analog input. There is only on ATmega8 with TQFP and QFP packages / MLF.

Programming an Atmega 8 using and arduino board

Place your Atmega chip into the Arduino board with the divot of the chip facing outward.
Set the jumper to an external power supply and connect a 12V power brick (your board
needs to be externally powered when using the AVR ISP mkII but is not needed with the
AVR tiny ISP). Then, attach the 6-pin female plug of your AVR programmer to the 6 male
header ICSP pins with the plastic nub of the ribbon cable head facing inward.

31
Fig.4.3 Arduino Board

Fig. 4.4 Arduino Pin Mappnig

32
CHAPTER-5
RADIO FREQUENCY IDENTIFICATION

5.1.INTRODUCTION

RFID is not a new technology and has passed through many decades of use in military,
airline, library, security, healthcare,sports, animal farms and other areas. Industries use
RFID forvarious applications such as personal/vehicle access control,departmental store
security, equipment tracking, baggage, fast-food establishments, logistics, etc. The
enhancement in RFIDtechnology has brought advantages that are related to
resourceoptimization, increased efficiency within business processes,and enhanced
customer care, overall improvements in businessoperations and healthcare.

RFID stands for Radio Frequency Identification and is aterm that describes a system of
identification. RFID is based on storing and remotely retrieving information or data as it
consists of RFID tag, RFID reader and backend Database. RFID tags store unique
identification information of objects and communicate the tags so as toallow remote
retrieval of their ID. RFID technology depends on the communication between the RFID
tags and RFID readers. The range of the reader is dependent upon its operational
frequency. Usually the readers have their own software running on their ROM and also,
communicate with other software to manipulate these unique identified tags. Basically, the
application which manipulates tag deduction information for the end user, communicates
with the RFID reader to get the tag information through antennas. Many researchers have
addressed issues that are related to RFID reliability and capability. RFID is continuing to
become popular because it increases efficiency and provides better service to stakeholder.
RFID technology has been realized as a performance differentiator for a variety of
commercial applications, but its capability is yet to be fully utilized.
5.2. RFID EVOLUTION

RFID technology has passed through many phases overthe last few decades. The
technology has been used in tracking delivery of goods, in courier services and in baggage

33
handling. Other applications includes automatic toll payments, departmental access control
in large buildings, personal and vehicle control in a particular area, security of items which
shouldn’t leave the area, equipment tracking in engineering firms, etc.

Figure 5.1 shows RFID evolution over the past few decades.

The first RFID application was the "Identification Friend or Foe" system (IFF) and it was
used by the British in the Second World War. Transponders were placed into fighter planes
andtanks, and reading units could query them to decide whether to attack. Successors of
this technology are stillused in armies around the world.The first commercial RFID
application was the "Electronic Article Surveillance" (EAS). It was developed inthe
seventies as a theft prevention system. It was based on tags that can store a single bit. That
bit was readwhen the customer left the store and the system would sound alarm when the
bit was not unset. In theend-seventies RFID tags made its way into the agriculture for
example for animal tagging.In the eighties RFID technology got a boost when Norway and
several US states decided to uses RFID for toll collection on roads. In addition to toll

34
collection the following decade brought a vast number ofnew applications, such as ski
passes, gasoline cards, money cards, etc.In 1999 the MIT was founded. Its task was to
develop a global standard for item-leveltagging. The Auto-ID was closed in 2003 after
completing the work on the Electronic Product Code (EPC).At the same time the newly
founded continues the work.The probably first paper related to RFID technology was the
landmark paper by Harry Stockman,"Communication by Means of Reflected Power" in
October 1948. The first patent on RFID was issued in1973 for a passive radio transponder
with memory.

5.3. RFID System Working


Most RFID systems consist of tags that are attached to the objects to be identified. Each
tag has its own “readonly”or “rewrite” internal memory depending on the type and
application. Typical configuration of this memory is to store product information, such as
an object’s unique ID manufactured date etc. The RFID reader generates magnetic fields
that enable the RFID system to locate objects (via the tags) that are within its range. The
high-frequency electromagnetic energy and query signal generated by the reader triggers
the tags to reply to the query. The query frequency could be up to 50 times per second. As
a result communication between the main components of the system i.e. tags and reader is
established. As a result large quantities of data are generated. Supply chain industries
control this problem by using filters that are routed to the backend information systems. In
other words, in order to control this problem, software such as Savant is used. This
software acts as a buffer between the Information Technology and RFID reader .Several
protocols manage the communication processbetween the reader and tag. These protocols
(ISO 15693and ISO 18000-3 for HF or the ISO 18000-6, and EPC for UHF) begin the
identification process when the reader is switched on. These protocol works on selected
frequency bands (e.g. 860 – 915 MHz for UHF or 13.56MHz for HF). If the reader is on
and the tag arrives in the reader fields, then it automatically wakes-up and decodes the
signal and replies to the reader by modulating thereader’s field. All the tags in the reader
range may reply at the same time, in this case the reader must detect signal collision
(indication of multiple tags). Signal collision is resolved by applying anti-collision
algorithm which enables the reader to sort tags and select/handleeach tag based on the

35
frequency
requency range (between 50 tags to 200 tags) and the protocol
ol used. In this connection the
reader can perform certain operations on the tags such as reading the tag’s identifier
identifi
number and writing data into a tag.
tag

Fig 5.2 A typical RFID System

The reader performs these


thes operations one by one on each tag. A typical RFID system
s work
cycle can be seen in figure 5.2.

5.4. Components of an RFID System

The RFID system consists of various components which are integrated


grated in a manner
manne defined
in the above section.
section.This allows the RFID system
tem to deduct the objects (tag) and perform
various operations
ions on it. The integration of RFID components enables
nables the implementation
of an RFID
ID solution. The RFID system consists of following five components (as shown in
Figure 5.3):

36
 Tag (attached with an object, unique identification).
 Antenna (tag detector, creates magnetic field).
 Reader (receiver of tag information, manipulator).
 Communication infrastructure (enable reader/RFID to work through IT infrastructure).

Fig. 5.3 Components of an RFID System


5.5. Tags:

Tags contain microchips that store the uniqueidentification (ID) of each object. The ID is a
serialnumber stored in the RFID memory. The chip is made up of integrated circuit and
embedded in a silicon chip.RFID memory chip can be permanent or changeabledepending
on the read/write characteristics. Read-onlyand rewrite circuits are different as read-only
tag containsfixed data and cannot be changed without re-programelectronically. On the
other hand, re-write tags can beprogrammed through the reader at any time without
anylimit. RFID tags can be different sizes and shapes depending on the application and the
environment atwhich it will be used. A variety of materials areintegrated on these tags. For
example, in the case of thecredit cards, small plastic pieces are stuck on variousobjects,

37
and the labels. Labels are also embedded in avariety of objects such as documents,
cloths,manufacturingmaterials etc.

.
Fig.5.4 Variety of RFID tags (various shape & sizes)

RFID tags can also be classified by their capabilitiessuch as read and write data.

Fig. 5.5 RFID tags classifications

There are three types of tags: the passive, semi-activeand active. Semi-active tags have a
combination of activeand passive tags characteristics. So, mainly two types oftags (active
38
and passive) are being used by industry and most of the RFID system. The
essentialcharacteristics of RFID tags are their function to theRFID system. This is based on
their range, frequency,memory, security, type of data and other characteristics.
These characteristics are core for RFID performance anddiffer in usefulness/support to the
RFID system operations. While considering thesecharacteristics, figure 5.6 compares the
active and passivetags.

Fig.5.6 RFID active and passive tags comparison

5.5.1. Tag Frequencies

The range of the RFID tags depends on their frequency.This frequency determines the
resistance to interferenceand other performance attributes. The use/selectionof RFID tag
depends on the application; differentfrequencies are used on different RFID tags. EPC
global and International Standards Organization (ISO) are the major organizations working
to developinternational standards for RFID technologies in theUHF band. These two
organizations are still evolvingand are not fully compatible with each other. Inorder to
avoid the use of different radio frequenciesstandards, most of the international
communities areobligated to comply with the InternationalTelecommunication Union
(ITU) standards.

39
Thefollowing are the commonly used frequencies:
 Microwave :
Works on 2.45 GHz, it has good reader rate even faster than UHF tags. Althoughat this
frequency the reading rate results are notthe same on wet surfaces and near metals,
thefrequency produce better results in applicationssuch as vehicle tracking (in and out
withbarriers), with approximately 1 meter of tags read range.
 Ultra High Frequency:
Works within a range of 860-930 MHz, it can identify large numbers oftags at one time
with quick multiple read rate at agiven time. So, it has a considerable goodreading speed. It
has the same limitation asMicrowave when is applied on wet surface andnear metal.
However, it is faster than highfrequency data transfer with a reading range of 3 meters.
 High Frequency:
Works on 13.56MHz and has less than one meter reading range but isinexpensive and
useful for access control, itemsidentifications on sales points etc, as it can implanted inside
thin things such as paper.
 Low Frequency:
Works on 125 kHz, it has approximately half a meter reading range andmostly used for
short reading range applicationssuch as shops, manufacturing factories, inventory.

5.6. RFID Reader:

RFID reader works as a central place for the RFIDsystem. It reads tags data through the
RFID antennas at a certain frequency. Basically, the reader is anelectronic apparatus which
produce and accept a radio signals. The antennas contains an attached reader,the reader
translates the tags radio signals throughantenna, depending on the tags capacity.
Thereaders consist of a build-in anti-collision schemes and asingle reader can operate on
multiple frequencies. As a result, these readers are expected to collect or write dataonto tag
(in case) and pass to computer systems. For thispurpose readers can be connected using
RS-232, RS-485, USB cable as a wired options (called serial readers) andconnect to the
computer system. Also can use Wi-Fi aswireless options which also known as network

40
readers. Readers are electronic devices which can beused as standalone or be integrated
with other devicesand the following components/hardware into it.

Fig.5.7. RF reader module

5.7. Advantages & Disadvantages of RFID System

Advantages:
 High speed
 Multipurpose and many
 format
 Reduce man-power
 High accuracy
 Complex duplication
 Multiple reading (tags)

Disadvantages:
 Interference
 High cost
 signal problem

41
Chapter-6

LCD DISPLAY
6.1. DEFINITION
LCD (Liquid Crystal Display) screen is an electronic display module and has a wide range
of applications. A 16x2 LCD display is very basic module and is very commonly used in
various devices and circuits. These modules are preferred over seven segments and other
multi segment LEDs.

6.2. ABOUT LCD


The reasons being:
1. LCDs are economical.
2. Easily programmable.
3. Have no limitation of displaying special & even custom characters (unlike in
sevensegments), animations and soon.

6.3. 16x2 Display


A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
Command and Data.
The command register stores the command instructions given to the LCD. A command is
an instruction given to LCD to do a predefined task like initializing it, clearing its screen,
setting the cursor position, controlling display etc. The data register stores the data to be
displayed on the LCD. The data is the ASCII value of the character to be displayed on the
LCD. Click to learn more about internal structure of a LCD.

42
Fig 6.1 pin diagram of LCD

Pin No Function Name


1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
4 Selects command register when low; and data register when high Register Select
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-

Table 6.1 pin description of LCD

43
Chapter-7
INTRODUCTION TO DC MOTOR
7.1 Electric DC Motor
An electric motor is a device which converts electrical energy to mechanical
energy. A DC motor relies on the fact that, like magnet poles repel and unlike magnetic
poles attract each other. A coil of wire with a current running through it generates a
electromagnetic field aligned with the center of the coil. By switching the current on or off
in a coil its magnet field can be switched on or off or by switching the direction of the
current in the coil the direction of the generated magnetic field can be switched 180°.

A simple DC motor typically has a stationary set of magnets in the stator and an
armature with a series of two or more windings of wire wrapped in insulated stack slots
around iron pole pieces (called stack teeth) with the ends of the wires terminating on a
commutator. The armature includes the mounting bearings that keep it in the center of the
motor and the power shaft of the motor and the commutator connections.

The commutator allows each armature coil to be activated in turn. The current in
the coil is typically supplied via two brushes that make moving contact with the
commutator. Now, some brushless DC motors have electronics that switch the DC current
to each coil on and off and have no brushes to wear out or create sparks.

Fig 7.1 working of DC motor

In real life, though, DC motors will always have more than two poles (three is a very
common number). In particular, this avoids "dead spots" in the commutator. You can
imagine how with our example two-pole motor, if the rotor is exactly at the middle of its
rotation (perfectly aligned with the field magnets), it will get "stuck" there. Meanwhile,

44
with a two-pole motor, there is a moment where the commutator shorts out the power
supply (i.e., both brushes touch both commutator contacts simultaneously). This would be
bad for the power supply, waste energy, and damage motor components as well. Yet
another disadvantage of such a simple motor is that it would exhibit a high amount of
torque "ripple" (the amount of torque it could produce is cyclic with the position of the
rotor).

Fig 7.2. A Simple DC Motor

7.2.Features

 100 RPM 12V DC motors with Gearbox


 3000 RPM base motor
 6mm shaft diameter with internal hole
 125 gm weight
 Same size motor available in various rpm
 No-load current = 60 mA (Max), Load current = 300 mA(Max)

7.3. Motor Construction

7.3.1 Rotor
In an electric motor the moving part is the rotor which turns the shaft to deliver the
mechanical power. The rotor usually has conductors laid into it which carry currents that
interact with the magnetic field of the stator to generate the forces that turn the shaft.
However, some rotors carry permanent magnets, and the stator holds the conductors.

45
7.3.2 Stator

The stationary part is the stator, usually has either windings or permanent magnets. The
stator is the stationary part of the motor’s electromagnetic circuit. The stator core is made
up of many thin metal sheets, called laminations. Laminations are used to reduce energy
loses that would result if a solid core were used.

7.3.3.Air gap
In between the rotor and stator is the air gap. The air gap has important effects, and is
generally as small as possible, as a large gap has a strong negative effect on the
performance of an electric motor.

7.3.4.Winding
Windings are wires that are laid in coils, usually wrapped around a laminated soft
iron magnetic core so as to form magnetic poles when energized with current.

Electric machines come in two basic magnet field pole configurations: salient-
pole machine and nonsalient-pole machine. In the salient-pole machine the pole's magnetic
field is produced by a winding wound around the pole below the pole face. In
the nonsalient-pole, or distributed field, or round-rotor, machine, the winding is distributed
in pole face slots. A shaded-pole motor has a winding around part of the pole that delays
the phase of the magnetic field for that pole.Some motors have conductors which consist of
thicker metal, such as bars or sheets of metal, usually copper, although sometimes
aluminum is used. These are usually powered by electromagnetic induction.

7.3.5 Commutator

Fig.7.3 Commutator

46
A commutator is a mechanism used to switch the input of certain AC and DC
machines consisting of slip ring segments insulated from each other and from the electric
motor's shaft. The motor's armature current is supplied through the stationary brushes in
contact with the revolving commutator, which causes required current reversal and applies
power to the machine in an optimal manner as the rotor rotates from pole to pole. In
absence of such current reversal, the motor would brake to a stop. In light of significant
advances in the past few decades due to improved technologies in electronic controller,
sensorless control, induction motor, and permanent magnet motor fields,
electromechanically commutated motors are increasingly being displaced by externally
commutated induction and permanent magnet motors.

7.4 DC Servo Motor

A servomotor is a rotary actuator that allows for precise control of angular


position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for
position feedback. It also requires a relatively sophisticated controller, often a dedicated
module designed specifically for use with servomotors.

Servomotors are not a different class of motor, on the basis of fundamental operating
principle, but use servomechanism to achieve closed loop control with a generic open loop
motor. In other words, a servomotor is just a regular motor with a sensor installed,
typically to measure angular position during operation.

As the name suggests, a servomotor is a servomechanism. More specifically, it is a closed-


loop servomechanism that uses position feedback to control its motion and final position.
The input to its control is some signal, either analogue or digital, representing the position
commanded for the output shaft.

47
Fig. 7.4 A Servo Motor

The motor is paired with some type of encoder to provide position and speed
feedback. In the simplest case, only the position is measured. The measured position of the
output is compared to the command position, the external input to the controller. If the
output position differs from that required, an error signal is generated which then causes
the motor to rotate in either direction, as needed to bring the output shaft to the appropriate
position. As the positions approach, the error signal reduces to zero and the motor stops.

The very simplest servomotors use position-only sensing via


a potentiometer and bang-bang control of their motor; the motor always rotates at full
speed (or is stopped). This type of servomotor is not widely used in industrial motion
control, but it forms the basis of the simple and cheap servos used for radio-controlled
models.

More sophisticated servomotors measure both the position and also the speed of the
output shaft. They may also control the speed of their motor, rather than always running at
full speed. Both of these enhancements, usually in combination with a PID
control algorithm, allow the servomotor to be brought to its commanded position more
quickly and more precisely, with less overshooting.

48
Chapter-8
L293 DRIVER IC
8.1.Dual H-bridge Motor Driver – L293D IC
Generally, even the simplest robot requires a motor to rotate a wheel or performs particular
action.Since motors require more current then the microcontroller pin can typically
generate, you need some type of a switch (Transistors, MOSFET, Relay etc.,) which can
accept a small current, amplify it and generate a larger current, which further drives a
motor. This entire process is done by what is known as a motor driver.

Motor driver is basically a current amplifier which takes a low-current signal from the
microcontroller and gives out a proportionally higher current signal which can control and
drive a motor. In most cases, a transistor can act as a switch and perform this task which
drives the motor in a single direction.

Turning a motor ON and OFF requires only one switch to control a single motor in a single
direction. What if you want your motor to reverse its direction? The simple answer is to
reverse its polarity. This can be achieved by using four switches that are arranged in an
intelligent manner such that the circuit not only drives the motor, but also controls its
direction. Out of many, one of the most common and clever design is an H-bridge circuit
where transistors are arranged in a shape that resembles the English alphabet "H".
As you can see in the image, the circuit has four switches A, B, C
and D. Turning these switches ON and OFF can drive a motor in
different ways.

Turning on Switches A and D makes the motor rotate clockwise


Turning on Switches B and C makes the motor rotate anti-clockwise
Turning on Switches A and B will stop the motor (Brakes)
Turning off all the switches gives the motor a free wheel drive

Fig 8.1. Circuit Diagram of H-bridge

49
8.2. L293D IC:
L293D is a typical Motor driver or Motor Driver IC which allows DC motor to drive on
either direction. L293D is a 16-pin IC which can control a set of two DC motors
simultaneously in any direction, forward and reverse with just 4 microcontroller pins
(without enable pin being considered)

8.2.1. Features of L293D:


• Supply voltage can be as large as 36 Volts. This means you do not have to worry much
about voltage regulation.
• L293D has an enable facility which helps you enable the IC output pins. If an enable pin is
set to logic high, then state of the inputs match the state of the outputs. If you pull this low,
then the outputs will be turned off regardless of the input states]
• The datasheet also mentions an "over temperature protection" built into the IC. This means
an internal sensor senses its internal temperature and stops driving the motors if the
temperature crosses a set point
• Another major feature of L293D is its internal clamp diodes. This fly-back diode helps
protect the driver IC from voltage spikes that occur when the motor coil is turned on and
off (mostly when turned off)
• Output current capability is limited to 600mA per channel with peak output current limited
to 1.2A (non-repetitive). This means you cannot drive bigger motors with this IC.
However, most small motors used in hobby robotics should work.
• This integrated circuit not only drives DC motors, but can also be used to drive relay
solenoids, stepper motors etc.

Fig 8.2 PCB of H-bridge

50
Fig 8.3.Pin Diagram of L293 and IC

8.2.2 L293D Connections:


There are 16 pins sticking out of this IC and we have to understand the functionality of
each pin before implementing this in a circuit

• Pin1 and Pin9 are "Enable" pins. They should be connected to +5V for the drivers to
function. If they pulled low (GND), then the outputs will be turned off regardless of the
input states, stopping the motors. If you have two spare pins in your microcontroller,
connect these pins to the microcontroller, or just connect them to regulated positive 5
Volts.
• Pin4, Pin5, Pin12 and Pin13 are ground pins which should ideally be connected to
microcontroller's ground.
• Pin2, Pin7, Pin10 and Pin15 are logic input pins. These are control pins which should be
connected to microcontroller pins. Pin2 and Pin7 control the first motor (left); Pin10 and
Pin15 control the second motor(right).
• Pin3, Pin6, Pin11, and Pin14 are output pins. Tie Pin3 and Pin6 to the first motor, Pin11
and Pin14 to second motor
• Pin16 powers the IC and it should be connected to regulated +5Volts
• Pin8 powers the two motors and should be connected to positive lead of a secondary
battery. As per the datasheet, supply voltage can be as high as 36 Volts.

51
Suppose you need to control the left motor which is connected to Pin3 and Pin6 .As
mentioned above, we require three pins to control this motor - Pin1, Pin2 and Pin7. Here is
the truth table representing the functionality of this motor driver.

Fig 8.4. Interface of motor with L293

52
CHAPTER-9

TACHOMETER

9.1. Definition:

A tachometer is nothing but a simple electronic digital transducer. Normally, it is used for
measuring the speed of a rotating shaft. The number of revolutions per minute (rpm) is
valuable information for understanding any rotational system. For example, you can also
measure the speed of fans you use.

9.2. SELECTION OF TACHOMETER

 Accuracy

 Precision

 Range

 Acquisition Time

 Contact type / Non-Contact type

 Portable / Fixed

 Digital / Analog

 Cost

9.3. Types of Tachometers

Analog Tachometer

 Has a needle and dial type of interface

 No provision for storage of readings

 Cannot compute average, deviation, etc.

53
Digital Tachometer

 Has a LCD or LED readout

 Memory is provided for storage

9.4. ARDUINO TACHOMETER CONSTRUCTION:

A tachometer is a useful tool for counting the RPM (rotations per minute) of a wheel or
basically anything that spins. The way we built a tachometer is using a transmitter and
receiver. When the link between them is broken, you know that something is spinning and
can execute some code that calculates the current RPM of whatever is spinning to break
the transmitter/receiver link.

9.4.1. OVERVIEW OF WORKING OF THIS TACHOMETER:


The purpose to choose this tachometer is we get a single input, single output system.
The input will come in the form of a signal state change from high (+5v) to low (+0v)
which will occur when the IR break-beam is interrupted and the Arduino will then
increment an internal counter. As time goes on, additional processing and calculation will
occur as interrupts are trigger and the LCD will output the calculated RPM.
To create the IR break-beam, we used an IR LED with a low value resistor so that it
shines very bright. The receiver will be a phototransistor which biases 'on' whenever the IR
LED's light is detected. A computer fan will be placed between the IR link and turned on
so as to continuously generate an interrupt through some additional transistor logic
circuitry. For output, the Arduino LCD interface will be used so that we can output the
final RPM value to the LCD.

9.4.2. PARTS :

The various parts we used for construction of tachometer are described below:

1.ArduinoUno

54
2.16x2LCD
3.Breadboard
4.5kohm Trimpot
5.Jumper Wire
6.SIPs
7.2x 2n2222 NPN Transistors
8.Infrared LED
9.Phototransistor
10. 10 ohm Resistor
11.100 kilo ohm Resistor
12.15 kilo ohm Resistor
13.Computer Fan
14.Servo motor

9.4.3 PART DETAILS:

The parts used in this project are all listed out above, but the more interesting and
necessary parts are listed out below with a little more detail to describe their function.

ARDUINO UNO:
This is the Arduino board that we will be using to process the IR break-beam pulses
that tell us when the CPU fan has moved. The Arduino will use these pulses along with a
timer to figure out what the current RPM of the fan is.

16x2 LCD:
After the Arduino has figured out what the current RPM is, it will be displayed on
this LCD so that it's obvious to the user.
5 KILO OHM TRIMPOT:
This trimpot will be used for setting the contrast of the 16x2 LCD. It's gives an analog
output varying from +5v to 0, which the LCD translates to a brightness setting.

55
IR EMITTER DIODE AND PHOTO TRANSISTOR:
The photo transistor turns on whenever intense Infrared light shines on it. So
whenever the IR LED is on and shining, it keeps the phototransistor biased 'on',
'on' but if the
IR LED is blocked, by...for example a fan blade, the phototransistor is biased 'off'.
2n2222 NPN Transistors:
Transistors
These transistors will mainly be used as level shifters to ensure the pulses output
from the IR break-beam
beam to the Arduino come in the form of +0v to +5v and nothing in
in-
between.
Schematic overview of the Tachometer:

Fig 9.1. circuit diagram tachometer

The break-beam
beam circuit's signal goes to the digital input on the Arduino. This will interrupt
the Arduino so it can count that a pulse has just been registered and the tachometer is
reading data.
56
CHAPTER-10
INTERFACING

10.1. DEFINITION

An interface is the point of interaction with software, or computer hardware, or


with peripheral devices such as a computer monitor or a keyboard. Some computer
interfaces such as a touchscreen can send and receive data, while others such as a mouse or
microphone, can only send data.

10.2. Interface Between 16x2 LCD And Arduino:

Parts used in interfacing:


1.Arduino UNO
2.16x2 LCD
3.Breadboard
4.5kΩ Trimpot
5.Jumper Wire
6.SIPs
Parts List Details:
Luckily the list of parts for this project is very short. The main components are the
16x2 LCD and the Arduino UNO
Arduino UNO:
This is the bare bones and basic CPLD dev board that I developed a few years ago.
The core components are the CPLD, power circuitry and programming circuitry. The
additions from the previous cpld analog to digital converter project were left on the board
since we'll be using them in this project.

57
Fig 10.1 Arduino UNO

16x2 LCD:
This is the 128 Macrocell CPLD that we'll be using to output the digital PWM
signal to control the 10 LED bar fading-in and fading out.

Fig 10.2 16x2 LCD display

5kΩTrimpot:
We will use this LED bar to output both the exact 8-bit value that is converted from
analog to digital. A resistor network will be connected up to the LED bar to limit the
amount of current flowing through.

58
Fig 10.3 Trimpot

Breadboard:
Since the cplddev board is built on protoboard, we need to use sockets, SIPs and
wire wrap to connect everything together.

Fig 10.4 breaboard

SIPs:
SIPs are used to hold all the ICs in place and to make a large connection for the
motors on top of the board. Additionally SIPs are perfect for wire wrapping everything
together.

59
Schematic Overview:

Since this is purely an output system, we only need to look at the straight forward
interface from Arduino UNO to LCD. As you can see below, the connections are mostly
pin to pin with no funny business.

Fig 10.5 interface circuit

Schematic Specifics:
16x2 LCD Interface
3 control pins and 8 data pins are connected from the Arduino to the LCD. These
are what will tell the LCD what to do and when.

Trimpot Contrast Control


The contrast control uses an analog voltage to tell the LCD how dark or bright the
contrast should be. Using a trimpot here allows for easy adjusting.

60
Program for Static LCD Display:

#include <LiquidCrystal.h>
LiquidCrystallcd(7, 8, 9, 10, 11, 12); //Initialize LCD
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Current RPM:");
}
void loop()
{
while(1){
//Slow Down The LCD
delay(400);
//Clear The Bottom Row
lcd.setCursor(0, 1);
lcd.print(" ");
//Update The Rpm Count
lcd.setCursor(0, 1);
lcd.print(rpm);
}

61
10.3.Interface between tachometer and Arduino:

Parts:

1.Arduino UNO
2.16x2 LCD
3.Breadboard
4.5kΩ Trimpot
5.Jumper Wire
6.SIPs
7.2x 2n2222 NPN Transistor
8.Infrared LED
9.Phototransistor
10.10Ω Resistor
11.100kΩ Resistor
12.15kΩ or 16kΩ Resistor
13.Computer Fan

Parts List Details:


The parts used in this project are all listed out above, but the more interesting and
necessary parts are listed out below with a little more detail to describe their function.

IR Emitter Diode and Phototransistor


The photo transistor turns on whenever intense Infrared light shines on it. So
whenever the IR LED is on and shining, it keeps the phototransistor biased 'on', but if the
IR LED is blocked, by...for example a CPU fan blade, the phototransistor is biased 'off'.

Fig 10.6 IR transmitter

62
Fig 10.7 IR receiver

2n2222 NPN Transistors:


These transistors will mainly be used as level shifters to ensure the pulses output
from the IR break-beam to the Arduino come in the form of +0v to +5v and nothing in-
between.

Fig 10.8 Transistor

Schematic Overview:
The circuit diagram for this project is a little more complicated.The LCD interface
is simplified to have only 2 control lines and 4 data lines. Then the tachometer IR break-
beam circuit is added on the side to make things a little more complex.

63
Fig 10.9 LCD display circuit

Schematic Specific:
16x2 LCD Interface
2 control pins and 4 data pins are connected from the Arduino to the LCD. These
are what will tell the LCD what to do and when.

IR Break-Beam Circuit
The break-beam circuit's signal goes to the digital input pin #2 on the Arduino. This
will interrupt the Arduino so it can count that a pulse has just been registered and the
tachometer is reading data.

64
Hardware circuit after interfacing:

The program for rpm count:

volatile float time = 0;


volatile float time_last = 0;
volatileintrpm_array[5] = {0,0,0,0,0};
void setup()
{
//Digital Pin 2 Set As An Interrupt
attachInterrupt(0, fan_interrupt, FALLING);
}
void loop()
{
int rpm = 0;
if(time > 0)
{
//5 Sample Moving Average To Smooth Out The Data
rpm_array[0] = rpm_array[1];

65
rpm_array[1] = rpm_array[2];
rpm_array[2] = rpm_array[3];
rpm_array[3] = rpm_array[4];
rpm_array[4] = 60*(1000000/(time*8));
//Last 5 Average RPM Counts Eqauls....
rpm = (rpm_array[0] + rpm_array[1] + rpm_array[2] + rpm_array[3] + rpm_array[4]) / 5;
}
voidfan_interrupt()
{
time = (micros() - time_last);
time_last = micros();
}

66
CHAPTER-11

SOFTWARE REQIUREMENTS
Software Tools used :
1. Keil Software
2. Arduino IDE
3. Fritzing

In this work Keil software used for c programming for automation of the vehicle.
Program is used to send the message form zonal section to vehicle section. Therefore the
microcontroller activated and controlled the speed of the vehicle.

11.1 About Keil Software

It is possible to create the source files in a text editor such as Notepad, run the
Compiler on each C source file, specifying a list of controls, run the Assembler on each
Assembler source file, specifying another list of controls, run either the Library Manager
or Linker (again specifying a list of controls) and finally running the Object-HEX
Converter to convert the Linker output file to an Intel Hex File. Once that has been
completed the Hex File can be downloaded to the target hardware and debugged.
Alternatively KEIL can be used to create source files; automatically compile, link and
covert using options set with an easy to use user interface and finally simulate or perform
debugging on the hardware with access to C variables and memory. Unless you have to use
the tolls on the command line, the choice is clear. KEIL Greatly simplifies the process of
creating and testing an embedded application.

11.1.1. Keil in Projects

The user of KEIL centers on “projects”. A project is a list of all the source files
required to build a single application, all the tool options which specify exactly how to
build the application, and – if required – how the application should be simulated. A
project contains enough information to take a set of source files and generate exactly the

67
binary code required for the application. Because of the high degree of flexibility required
from the tools, there are many options that can be set to configure the tools to operate in a
specific manner. It would be tedious to have to set these options up every time the
application is being built; therefore they are stored in a project file. Loading the project file
into KEIL informs KEIL which source files are required, where they are, and how to
configure the tools in the correct way. KEIL can then execute each tool with the correct
options. It is also possible to create new projects in KEIL. Source files are added to the
project and the tool options are set as required. The project can then be saved to preserve
the settings.

11.1.2 Simulator/Debugger

The simulator/ debugger in KEIL can perform a very detailed simulation of a micro
controller along with external signals. It is possible to view the precise execution time of a
single assembly instruction, or a single line of C code, all the way up to the entire
application, simply by entering the crystal frequency. A window can be opened for each
peripheral on the device, showing the state of the peripheral. This enables quick trouble
shooting of mis-configured peripherals. Breakpoints may be set on either assembly
instructions or lines of C code, and execution may be stepped through one instruction or C
line at a time. The contents of all the memory areas may be viewed along with ability to
find specific variables. In addition the registers may be viewed allowing a detailed view of
what the microcontroller is doing at any point in time. The vehicle section and zone section
programs are given in appendix.

11.2. Arduino IDE:

The Arduino integrated development environment (IDE) is a cross-platform application


written in Java, and is derived from the IDE for the Processing programming language and
the Wiring projects. It is designed to introduce programming to artists and other
newcomers unfamiliar with software development. It includes a code editor with features
such as syntax highlighting, brace matching, and automatic indentation, and is also capable

68
of compiling and uploading programs to the board with a single click. A program or code
written for Arduino is called a "sketch".

Writing Sketches
Software written using Arduino are called sketches. These sketches are written in
the text editor. Sketches are saved with the file extension .ino. It has features for
cutting/pasting and for searching/replacing text. The message area gives feedback while
saving and exporting and also displays errors. The console displays text output by the
Arduino environment including complete error messages and other information. The
bottom right-hand corner of the window displays the current board and serial port. The
toolbar buttons allow you to verify and upload programs, create, open, and save sketches,
and open the serial monitor.
Arduino programs are written in C or C++. The Arduino IDE comes with
a software library called "Wiring" from the original Wiring project, which makes many
common input/output operations much easier. Users only need define two functions to
make a runnable cyclic executive program:

• setup(): a function run once at the start of a program that can initialize settings
• loop(): a function called repeatedly until the board powers off.

Serial Monitor:

The tool called ‘serial monitor’ helps one to view the data coming from the arduino
board using the in-built serial monitoring interface. It is the most effective communication
method available with a microcontroller. The serial port of the microcontroller provides the
easiest way by which the user and the microcontroller can write their data in the same
medium and both can read each other’s data. When the serial port of the microcontroller is
connected to the PC and the incoming and outgoing data is monitored using software and
displayed in a window, it forms the simplest text user interface (TUI) setup for the
microcontroller. Serial communication is a very useful debugging tool in the code
development process.

69
Fig 11.1.Sketch of Arduino

11.3 Fritzing:

Fritzing is the sophisticated new electronics application with the funny name. It is a
powerful tool for making schematics, prototyping circuits, and designing printed circuit
boards. This software allows the designer / artist / researcher / hobbyist to document their
Arduino-based
based prototype and create a PCB layout for manufacturing.

Three Views

Fritzing can show your project in three views. The default is the Breadboard view

Breadboard View:

Breadboard
oard view is a brilliant simulation that comes with a giant library of parts organized
by brand name and model, so you can drag and drop your exact parts into your diagram. If
the parts you want are not in the library, then you can use the Parts Designer tto create
them.

70
Schematic View:

Studying the schematics is a great way to learn to read them. Reading the schematics is
essential to hack electronics because schematics are product documentation and they tell
you everything about the hardware.

71
The Printed
ed Circuit Board (PCB) view:

The breadboard view is a main feature of this software. It helps in designing the PCB for
the prototype created in the above steps. The final design can then be exported for
manufacturing of the PCB. It also has a great auto routing
routing feature which helps beginners in
designing.

Fig 11.2 The Printed Circuit Board (PCB) view

Any change you make in any of these views is automatically updated in the other views.

72
RESULT AND DISCUSSIONS

The output of the project was achieved successfully. The vehicle as received signals very
efficiently from RFID tags and transmitted them to the RFID Reader. Finally the ARM 7
processor on processing those signals, delivered the output to motor in efficient way.
Hence the speed of the vehicle is reduced by 25% in zone1 and by 50% in zone2.

73
FUTURESCOPE

Further development of the project can be done in two ways:


A. Anti-lock Braking System (Modified):
One drawback of proposed method is that
,it consumes some time to reduce the vehicle speed from higher to lower.To overcome this
problem ,a modified version of anti-lock braking system has to be employed which applies
the continuous cycles of pulses,letting the wheels lock and unlock until vehicle reaches
desired speed.

B. Use of Fuzzy Logic:


The input variables used are season, timing of the day,density of traffic and
uncertainities.based on set of fuzzy rules written and the membership funtions made ,these
four variables are fuzzified and output is determined to set the maximumspeed of vehicle
which removes some of limitations coming in proposed project.

74
CONCLUSION

The Integration of RFID Technology with Electronic Governors for speed limiting was
achieved successfully.
.
The implementation of this system into every automobile will solve the problems of traffic
congestion, loss life in everyday road accidents and property damage and will also
supplementing law enforcement agencies in high speed pursuits.

Initial trials of the model can be first implemented for heavy diesel vehicles of public and
private institutions like schools, colleges, mass transport buses. The results will naturally
help to enforce the system to all vehicles.

75
REFERENCES

1. Telaprolu, Microcontroller based automation of variable electronic speed governor,


Vehicular Electronics and Safety (ICVES), 2009

2. Sushant R. Burje, Prof. S.A. Kulkarni and N.B. Dhande, Design and Development of
Microcontroller Based Electronic Speed Governor for Automotive Engine, International
Journal of Engineering and Science ,Vol. 1, Issue 5 (October 2012), PP 26-33

3. R.S. Khurmi, J.K. Gupta, Theory of machines, S-Chand, 2005

4. Micheal Margolis, Arduino Cookbook, SPD, 2012

5. A.K. Sawhney, Puneet Sawhney, A Course In Electrical And Electronic Measurements


And Instrumentation, Dhanpat Rai Publications, 2012

6. David Seal, ARMv7-M Architecture Reference Manual, Addison-Wesley, Second


Edition, ISBN-13: 978-0201737196

76
APPENDIX-1
PROGRAM FOR STATIC LCD DISPLAY AND RPM COUNT
#include <LiquidCrystal.h>
LiquidCrystallcd(7, 8, 9, 10, 11, 12); //Initialize LCD
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Current RPM:");
}
void loop()
{
while(1){
//Slow Down The LCD
delay(400);
//Clear The Bottom Row
lcd.setCursor(0, 1);
lcd.print(" ");
//Update The Rpm Count
lcd.setCursor(0, 1);
lcd.print(rpm);
}
volatile float time = 0;

volatile float time_last = 0;

volatileintrpm_array[5] = {0,0,0,0,0};

void setup()

77
{

//Digital Pin 2 Set As An Interrupt

attachInterrupt(0, fan_interrupt, FALLING);

void loop()

int rpm = 0;

if(time > 0)

//5 Sample Moving Average To Smooth Out The Data

rpm_array[0] = rpm_array[1];

rpm_array[1] = rpm_array[2];

rpm_array[2] = rpm_array[3];

rpm_array[3] = rpm_array[4];

rpm_array[4] = 60*(1000000/(time*8));

//Last 5 Average RPM Counts Eqauls....

rpm = (rpm_array[0] + rpm_array[1] + rpm_array[2] + rpm_array[3] + rpm_array[4]) / 5;

voidfan_interrupt()

time = (micros() - time_last);

time_last = micros();

78
APPENDIX-2
/*
Target: SPEED CONTROL ROBOT
*/
// Hedar Files
#include <lpc214x.h>
#include "MAD/DELAY.H"
#include "MAD/LCD.H"
#include "MAD/UART.H"
// Port Variables
#define PLOCK 0x00000400
#define PWMPRESCALE 60 //60 PCLK cycles to increment TC by 1 i.e 1 Micro-second
// Function Declarations
void initPWM(void);
void initClocks(void);
void setupPLL0(void);
void feedSeq(void);
void connectPLL0(void);
#define EN1 0x00000004
unsigned char temp[15];
unsigned inti=0;
void serial(void) __irq
{
temp[i]=uart1_rx();
i++;
VICVectAddr= 0x00000000;
}

79
void uart1_interrupt(void)
{

VICVectCntl0 = 0x20|7;
VICVectAddr0 = (unsigned) serial;
VICIntEnable = 0x00000080;
U1IER = 0x01;
}
// Main Function
int main(void)
{
//initClocks(); //Initialize CPU and Peripheral Clocks @ 60Mhz
initPWM(); //Initialize PWM

lcd_init();
lcd_cmd(0x85);
lcd_string("WELCOME");
delay(1000);
uart1_init();
delay(1000);
uart1_interrupt();
delay(1000);
lcd_cmd(1);
lcd_string("PORT OPENED");
delay(1000);
lcd_cmd(1);
lcd_string("RUNNING AT");
lcd_cmd(0xC0);

80
lcd_string(" NORMAL SPEED");
i=0;
IODIR0|=EN1;
//Also by default all pins are configured as Inputs after MCU Reset.
card1:

IOSET0|=EN1;
PWMMR1 = 10000;
PWMMR2 = 5000;
PWMMR3 = 0;
PWMMR5 = 10000; //T-ON=25% , Hence 25% Bright
PWMLER = ((1<<1)|(1<<2)|(1<<3)|(1<<5)); //Update Latch Enable bit for
PWMMR1
if(i==0)
goto card1;
while(i<12);
temp[i]='\0';
lcd_cmd(0xC0);
lcd_string(temp);
delay(5000);
lcd_cmd(1);
lcd_string("SCHOOL ZONE");
delay(5000);
lcd_cmd(1);
lcd_string("RUNNING AT ");
lcd_cmd(0xC0);
lcd_string("75% DUTY CYCLE");
i=0;

81
card2:
IOSET0|=EN1;
PWMMR1 = 7500;
PWMMR2 = 7500;
PWMMR3 = 0;
PWMMR5 = 10000; //T-ON=25% , Hence 25% Bright
PWMLER = ((1<<1)|(1<<2)|(1<<3)|(1<<5)); //Update Latch Enable bit for
PWMMR1
//return 0; //normally this wont execute ever

if(i==0)
goto card2;
while(i<12);
temp[i]='\0';
lcd_cmd(1);
lcd_string(temp);
delay(5000);
lcd_cmd(1);
lcd_string("SCHOOL ZONE");
lcd_cmd(0xC0);
lcd_string(" CROSSED");
delay(5000);
i=0;
next1:
IOSET0|=EN1;
PWMMR1 = 10000;
PWMMR2 = 5000;
PWMMR3 = 0;
PWMMR5 = 10000; //T-ON=25% , Hence 25% Bright
82
PWMLER = ((1<<1)|(1<<2)|(1<<3)|(1<<5)); //Update Latch Enable bit for
PWMMR1
if(i==0)
goto next1;
while(i<12);
temp[i]='\0';
lcd_cmd(1);
lcd_string(temp);
delay(5000);
lcd_cmd(1);
lcd_string("HOSPITAL ZONE");
delay(5000);
lcd_cmd(1);
lcd_string("RUNNING AT ");
lcd_cmd(0xC0);
lcd_string("50% DUTY CYCLE");
i=0;

card3:
IOSET0|=EN1;
PWMMR1 = 5000;
PWMMR2 = 5000;
PWMMR3 = 0;
PWMMR5 = 10000; //T-ON=25% , Hence 25% Bright
PWMLER = ((1<<1)|(1<<2)|(1<<3)|(1<<5)); //Update Latch Enable bit for
PWMMR1
//return 0; //normally this wont execute ever

if(i==0)

83
goto card3;
while(i<12);
temp[i]='\0';
lcd_cmd(1);
lcd_string(temp);
delay(5000);
lcd_cmd(1);
lcd_string("HOSPITAL ZONE");
lcd_cmd(0xC0);
lcd_string(" CROSSED");
delay(5000);
i=0;
next2:
IOSET0|=EN1;
PWMMR1 = 10000;
PWMMR2 = 5000;
PWMMR3 = 0;
PWMMR5 = 10000; //T-ON=25% , Hence 25% Bright
PWMLER = ((1<<1)|(1<<2)|(1<<3)|(1<<5)); //Update Latch Enable bit for
PWMMR1
goto next2;
}

void initPWM(void)
{
PINSEL0 = 0x0005800A; // Select PWM1, PWM2, PWM3 output for Pin0.0
PINSEL1 = 0x00000400; // Select PWM5 output for Pin0.0
PWMPCR = 0x0; //Select Single Edge PWM - by default its single Edged so this
line can be removed

84
PWMPR = PWMPRESCALE-1; // 1 micro-second resolution
PWMMR0 = 10000; // 10ms period duration
PWMMR1 = 2500; // 2.5ms - pulse duration i.e width (Brigtness level)
PWMMR2 = 2500;
PWMMR3 = 2500;
PWMMR5 = 2500;
PWMMCR = (1<<1); // Reset PWMTC on PWMMR0 match
PWMLER = ((1<<1)|(1<<2)|(1<<3)|(1<<5))| (1<<0); // update MR0 and MR1
PWMPCR = (1<<9)|(1<<10)|(1<<11)|(1<<13); // enable PWM output
PWMTCR = (1<<1) ; //Reset PWM TC & PR
//Now , the final moment - enable everything
PWMTCR = (1<<0) | (1<<3); // enable counters and PWM Mode
//PWM Generation goes active now - LED must be 25% Bright after boot!!
//Now you can get the PWM output at Pin P0.0, P0.1, P0.7, P0.21!
}

void initClocks(void)
{
setupPLL0();
feedSeq(); //sequence for locking PLL to desired freq.
connectPLL0();
feedSeq(); //sequence for connecting the PLL as system clock

//SysClock is now ticking @ 60Mhz!

VPBDIV = 0x01; // PCLK is same as CCLK i.e 60Mhz


//Using PLL settings as shown in : http://www.ocfreaks.com/lpc214x-pll-tutorial-for-
cpu-and-peripheral-clock/
//PLL0 Now configured!
85
}
//---------PLL Related Functions :---------------
void setupPLL0(void)
{
//Note : Assuming 12Mhz Xtal is connected to LPC2148.

PLL0CON = 0x01; // PPLE=1 & PPLC=0 so it will be enabled


// but not connected after FEED sequence
PLL0CFG = 0x24; // set the multipler to 5 (i.e actually 4)
// i.e 12x5 = 60 Mhz (M - 1 = 4)!!!
// Set P=2 since we want FCCO in range!!!
// So , Assign PSEL =01 in PLL0CFG as per the table.
}
void feedSeq(void)
{
PLL0FEED = 0xAA;
PLL0FEED = 0x55;
}

void connectPLL0(void)
{
// check whether PLL has locked on to the desired freq by reading the lock bit
// in the PPL0STAT register
while( !( PLL0STAT & PLOCK ));
// now enable(again) and connect
PLL0CON = 0x03;
}

86