Professional Documents
Culture Documents
BACHELOR OF TECHNOLOGY
in
ELECTRONICS AND COMMUNICATION ENGINEERING
by
1
KAKATIYA INSTITUTE OF TECHNOLOGY AND SCIENCE, WARANGAL
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
CERTIFICATE
This is to certify that the project work entitled “MICROCONTROLLER BASED
GESTURE VOCALISER” is the bonafide project work phase I carried out by Susheel Reddy
Pingili, Rishitha Vemula, Vikas Allam and Shanthan Reddy Chinthalapani bearing Roll.Nos.
B15EC049, B15EC007, B15EC023 and B14EC042 respectively, in partial fulfilment of the
requirements for the award of degree of the Bachelor of Technology from Kakatiya Institute of
Technology and Science, Warangal during the academic year 2017-2018.
2
DECLARATION
We declare that the work presented in this project report is original and has been carried out
in the Department of Electronics & Communication Engineering, Kakatiya Institute of Technology
and Science, Warangal, Telangana, and to best of our knowledge it has been not submitted elsewhere
for any degree.
RISHITHA VEMULA
Roll No. B15EC007
VIKAS ALLAM
Roll No. B15EC023
3
ACKNOWLEDGEMENT
We express our deepest sense of gratitude and indebtedness to our project guide
Dr.G.Ragotham reddy, Professor & Head , Dept. of ECE, KITS, Warangal for having been a
source of consistent inspiration, precious guidance and generous assistance during project work.
We deem it as a privilege to have worked under his able guidance. Without his close monitoring and
valuable suggestions this work wouldn’t have taken this shape. We feel that this help is not
substitutable and unforgettable.
We are thankful to B. Tech Project work Convener, Smt. S. P. Girija, Associate Professor,
Dept. of ECE, KITSW, Project work Coordinators Syed Zaheeruddin, Assistant Professor, B.
Narsimha, Assistant Professor and P. Chiranjeevi, Assistant Professor, Dept. of ECE, KITSW for
timely conduction of seminars.
We are profoundly thankful to Dr. G. Raghotham Reddy, Professor & Head, Dept. of ECE
for his constant support and encouragement.
We express our sincere thanks to Dr. K. Ashoka Reddy, Principal, KITS, Warangal, for his
kind gesture and support.
We are indebted to the Management of Kakatiya Institute of Technology and Science,
Warangal, for providing the necessary infrastructure and good academic environment in an endeavour
to complete the project and special thanks for providing Department Library of ECE and Digital
Library to access IEEE papers.
We would like to acknowledge the faculty and non-teaching staff of Electronics and
Communication Engineering Department. We are thankful to Ch.jagadeesh, Lab Assistant, DC Lab
for his help and cooperation during our project work.
4
INDEX
1.Introduction……………………….................................................................. 7
2.Literature Review……………………….…………………………………... 8
4.Embedded Systems…………………………………………………………. 10
4.1. Description 10
4.3. Applications 11
5.Hardware description………………………………………………………. 12
5.1. Introduction 12
5.2. Microcontroller 13
5.3. Programmable IC 16
5.7. Stack 18
5.8.I/O Ports 20
5.11. Reset 24
5.12. MCLR 25
5.13. Interrupts 25
5
5.17. LED indicator 31
6.Software description………………………………………………………… 32
7.Microcontroller code………………………………………………………… 41
6
1: INTRODUCTION
The project aims in designing a system which helps the paralyzed people to express their basic
needs. This system makes use of gestures of body parts to announce their basic needs like food, water,
etc..,. MEMS (Micro Electro-Mechanical Systems) accelerometer sensor is placed on any movable
part of the body of the paralyzed and he need to move that part in different directions to announce
different needs.
MEMS is a Micro Electro Mechanical Sensor which is a highly sensitive sensor and capable of
detecting the tilt. This sensor finds the tilt and makes use of the accelerometer to open or close the
door depending on tilt. For example, if the tilt is to the right side then the door opens or if the tilt is to
the left side then the door closes.
7
2. LITERATURE REVIEW
[1] V. Padmanabhan, M. Sornalatha “Hand gesture recognition and voice conversion system for
dumb people”, IJSER, volume 5, May-2014.
[2] Atu-Ur-Rahman, Salman Afghani ,Muhammad Akmal, Raheel Yousaf “Microcontroller and
sensor based gesture vocalizer” ,ISPRA’08,University of Cambridge,Feb-2008.
[3] K.Gunasekaran , R.Manikandan “Sign language to speech translation system using PIC
microcontroller”.
8
3. OBJECTIVES OF THE PROJECT
1. To help the paralyzed, to express their basic needs through simple gesture movement.
9
4: EMBEDDED SYSTEMS
Description:
Embedded systems are controlled by one or more main processing cores that are typically
either microcontrollers or digital signal processors (DSP). The key characteristic, however, is
being dedicated to handle a particular task, which may require very powerful processors. For
example, air traffic control systems may usefully be viewed as embedded, even though they
involve mainframe computers and dedicated regional and national networks between airports and
radar sites. (Each radar probably includes one or more embedded systems of its own.
Physically embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems
controlling nuclear power plants. Complexity varies from low, with a single microcontroller
chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or
enclosure.
In general, "embedded system" is not a strictly definable term, as most systems have
some element of extensibility or programmability. For example, handheld computers share some
elements with embedded systems such as the operating systems and microprocessors which
power them, but they allow different applications to be loaded and peripherals to be connected.
Moreover, even systems which don't expose programmability as a primary feature generally need
to support software updates. On a continuum from "general purpose" to "embedded", large
application systems will have subcomponents at most points even if the system as a whole is
"designed to perform one or a few dedicated functions", and is thus appropriate to call
"embedded".
10
Labeled parts include microprocessor (4), RAM (6), flash memory (7).Embedded
systems programming is not like normal PC programming. In many ways, programming for an
embedded system is like programming PC 15 years ago. The hardware for the system is usually
chosen to make the device as cheap as possible. Spending an extra dollar a unit in order to make
things easier to program can cost millions. Hiring a programmer for an extra month is cheap in
comparison. This means the programmer must make do with slow processors and low memory,
while at the same time battling a need for efficiency not seen in most PC applications. Below is a
list of issues specific to the embedded field.
The uses of embedded systems are virtually limitless, because every day new products
are introduced to the market that utilizes embedded computers in novel ways. In recent years,
hardware such as microprocessors, microcontrollers, and FPGA chips have become much
cheaper. So when implementing a new form of control, it's wiser to just buy the generic chip and
write your own custom software for it. Producing a custom-made chip to handle a particular task
or set of tasks costs far more time and money. From an implementation viewpoint, there is a
major difference between a computer and an embedded system. Embedded systems are often
required to provide Real-Time response. The main elements that make embedded systems unique
are its reliability and ease in debugging.
Applications:
1.Consumer applications:
2. Office automation:
3. Industrial automation:
Today a lot of industries are using embedded systems for process control. In
industries we design the embedded systems to perform a specific operation like monitoring
temperature, pressure,humidity ,voltage, current etc.., and basing on these monitored levels we
do control other devices, we can send information to a centralized monitoring station.
11
5 : HARDWARE DESCRIPTION
5.1 Introduction:
In this chapter the block diagram of the project and design aspect of independent
modules are considered. Block diagram is shown in fig: 5.1:
12
The main blocks of this project are:
Microcontroller is a Microcomputer in a single Chip. That means that a microcontroller chip includes
a microprocessor (CPU) as well as some often used peripherals. A controller is used to control some
process or aspect of the environment. A typical microcontroller application is the monitoring a house.
As the temperature rises, the controller causes the windows to open. If the temperature goes above a
certain threshold, the air conditioner is activated.
As the process of miniaturization continued, all of the components needed for a controller were built
right onto one chip. A one chip computer or microcontroller was born. A microcontroller is a highly
integrated chip, which includes, on one chip, all or most of the parts needed for a controller. The
microcontroller could be called a “one-chip-solution”. It typically includes:
Simply an embedded controller is a controller that is embedded in a greater system. You could say
that an embedded controller is controller (or computer that is embedded into some device for some
purpose other than to provide general purpose computing like a PC.
In addition to control applications such as the above home monitoring system, microcontrollers are
frequently found in embedded applications. Among many uses that we can find one or more
microcontrollers appliances (microwave oven, refrigerators, television and VCRs, stereos),
automobiles (engine control, diagnostic, climate control), environmental control (greenhouse, factory,
home), instrumentation, aerospace, power electronic controlling and thousands of other uses.
13
A special application that microcontrollers are well suited for is data logging. Stick one of these
chips out in the middle of a paddy field or up in a balloon, and monitor and record environmental
parameters (temperature, humidity, rain, etc.). Small size, low power consumption, and
flexibility make these devices ideal for unattended data monitoring and recoding.
Depending on the power and features that are needed, one might choose a 4 bit, 16 bit, or 32 bit
microcontroller. In addition, some specialized versions are available which include features
specific for communications, keyboard handling, signal processing, video processing, and other
tasks.
PIC controllers are a family of small RISC controllers used in embedded applications. PIC controllers
are produced by the company "Microchip”. Literature can be obtained from the Microchip web site.
The growth of the 8-bit MCU market share is a testament to the PIC micro MCUs ability to meet the
needs of many. This growth has made the PIC micro architecture one of the top three architectures
available in the general market today. This growth was fueled by the Microchip vision of the benefits
of a low cost OTP solution. Some of the benefits for the customer include:
PIC micro devices are grouped by the size of their Instruction Word. The three current PIC micro
families are:
The high performance of the PIC micro TM devices can be attributed to a number of architectural
features commonly found in RISC microprocessors:
● Harvard architecture
● Long Word Instructions
● Single Word Instructions .Single Cycle Instructions .Instruction Pipelining
● Reduced Instruction Set
● Register File Architecture
● Orthogonal (Symmetric) Instructions
14
Harvard Architecture
Harvard architecture has the program memory and data memory as separate memories and is accessed
from separate buses. This improves bandwidth over traditional von Neumann architecture in which
program and data are fetched from the same memory using the same bus. To execute an instruction, a
von Neumann machine must make one or more (generally more) accesses across the 8-bit bus to fetch
the instruction. Then data may need to be fetched, operated on, and possibly written. As can be seen
from this description, that bus can be extremely busy. While with a Harvard architecture, the
instruction is fetched in a single instruction cycle (all 14-bits). While the program memory is being
accessed, the data memory is on an independent bus and can be read and written. These separated
buses allow one instruction to execute while the next instruction is fetched.
The PIC16F72 belongs to the Mid-Range family of the PIC micro devices. A block diagram of the
device is shown in Figure 3.2. The program memory contains 2K words, which translate to 2048
instructions, since each 14-bit program memory word is the same width as each device instruction.
The data memory (RAM) contains 128 bytes. There are 22 I/O pins that are user configurable on a
pin-to-pin basis. Some pins are multiplexed with other device functions. These functions include:
● External interrupt
● Change on PORTB interrupt
● Timer0 clock input
● Timer1 clock/oscillator
● Capture/Compare/PWM
● A/D converter
● SPI/I2C
15
Figure 5.2: PIC16F72 Architecture.
16
● High Sink/Source Current: 25 mA
● Timer0: 8-bit timer/counter with 8-bit prescaler
● Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via external
crystal/clock
● Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
● Capture, Compare, PWM (CCP) module
o Capture is 16-bit, max. resolution is 12.5 ns
o Compare is 16-bit, max. resolution is 200 ns
o PWM max. resolution is 10-bit
● 8-bit, 5-channel analog-to-digital converter
● Synchronous Serial Port (SSP) with SPI™ (Master/Slave) and I2C™ (Slave)
● Brown-out detection circuitry for Brown-out Reset (BOR)
17
Pins on PIC16F72 microcontroller have the following meaning:
There are 28 pins on PIC16F72. Most of them can be used as an IO pin. Others are already for
specific functions. These are the pin functions.
1. MCLR – to reset the PIC
2. RA0 – port A pin 0
3. RA1 – port A pin 1
4. RA2 – port A pin 2
5. RA3 – port A pin 3
6. RA4 – port A pin 4
7. RA5 – port A pin 5
8. VSS – ground
9. OSC1 – connect to oscillator
10. OSC2 – connect to oscillator
11. RC0 – port C pin 0 VDD – power supply
12. RC1 – port C pin 1
13. RC2 – port C pin 2
14. RC3 – port C pin 3
15. RC4 - port C pin 4
16. RC5 - port C pin 5
17. RC6 - port C pin 6
18. RC7 - port C pin 7
19. VSS - ground
20. VDD – power supply
21. RB0 - port B pin 0
22. RB1 - port B pin 1
23. RB2 - port B pin 2
24. RB3 - port B pin 3
25. RB4 - port B pin 4
26. RB5 - port B pin 5
27. RB6 - port B pin 6
28. RB7 - port B pin 7
By utilizing all of this pin so many applications can be done such as:
1. LCD – connect to Port B pin.
2. LED – connect to any pin declared as output.
3. Relay and Motor - connect to any pin declared as output.
4. External EEPROM – connect to I2C interface pin – RC3 and RC4 (SCL and SDA)
5. LDR, Potentiometer and sensor – connect to analogue input pin such as RA0.
6. GSM modem dial up modem – connect to RC6 and RC7 – the serial communication interface
using RS232 protocol.
18
5.5 SPECIAL MICROCONTROLLER FEATURES
There are two memory blocks in the PIC16F72 device. These are the program memory and the data
memory. Each block has separate buses so that concurrent access can occur. Program memory can be
read internally by the user code. The data memory can further be broken down into the general
purpose RAM and the Special Function Registers (SFRs). The SFRs control the “core”. The SFRs
used to control the peripheral modules.
PIC16F72 devices have a 13-bit program counter capable of addressing a 8K x 14 program memory
space. The address range for this program memory is 0000h - 07FFh. Accessing a location above the
physically implemented address will cause a wraparound. The RESET Vector is at 0000h and the
Interrupt Vector is at 0004h.
The Data Memory is partitioned into multiple banks that contain the General Purpose Registers and
the Special Function Registers. Bits RP1 (STATUS<6>) and RP0 (STATUS<5>) are the bank select
bits. Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are reserved for the
Special Function Registers. Above the Special Function Registers are General Purpose Registers,
implemented as static RAM. All implemented banks contain SFRs. Some “high use” SFRs from one
bank may be mirrored in another bank, for code reduction and quicker access (e.g., the STATUS
register is in Banks 0 - 3).
5.7 STACK
The stack allows a combination of up to eight program calls and interrupts to occur. The stack
contains the return address from this branch in program execution. Mid-range devices have an 8-level
deep x 13-bit wide hardware stack. The stack space is not part of either program or data space and the
stack pointer is not readable or writable. The PC is PUSH’d onto the stack when a CALL instruction
is executed, or an interrupt causes a branch. The stack is POP’d in the event of a RETURN, RETLW
or a RETFIE instruction execution. PCLATH is not modified when the stack is PUSH’d or POP’d.
After the stack has been PUSH’d eight times, the ninth push overwrites the value that was stored from
the first push. The tenth push overwrites the second push (and so on).
Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on
the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O
pin.
19
5.8.1 PORTA AND THE TRISA REGISTER
PORTA is a 6-bit wide, bi-directional port. The corresponding data direction register is TRISA.
Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the
corresponding output driver in a Hi-Impedance mode). Clearing a TRISA bit (= 0) will make the
corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin).
Reading the PORTA register, reads the status of the pins, whereas writing to it will write to the port
latch. All write operations are read-modify-write operations. Therefore, a write to a port implies that
the port pins are read, this value is modified and then written to the port data latch. Pin RA4 is
multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. The RA4/T0CKI pin
is a Schmitt Trigger input and an open drain output. All other RA port pins have TTL input levels and
full CMOS output drivers. Other PORTA pins are multiplexed with analog inputs and analog VREF
input. The operation of each pin is selected by clearing/setting the control bits in the ADCON1
register (A/D Control Register1). The TRISA register controls the direction of the RA pins, even
when they are being used as analog inputs. The user must ensure the bits in the TRISA register are
maintained set when using them as analog inputs.
PORTB is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISB.
Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input (i.e., put the
corresponding output driver in a Hi-Impedance mode). Clearing a TRISB bit (= 0) will make the
corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin).
Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups.
This is performed by clearing bit RBPU (OPTION<7>). The weak pull-up is automatically turned off
when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset.
Four of PORTB’s pins, RB7:RB4, have an interrupt-on change feature. Only pins configured as inputs
can cause this interrupt to occur (i.e., any RB7:RB4 pin configured as an output is excluded from the
interrupt on change comparison). The input pins (of RB7:RB4) are compared with the old value
latched on the last read of PORTB. The “mismatch” outputs of RB7:RB4 are OR’d together to
generate the RB Port Change Interrupt with flag bit RBIF (INTCON<0>). This interrupt can wake the
device from SLEEP. The user, in the Interrupt Service Routine, can clear the interrupt in the following
manner:
● Any read or write of PORTB. This will end the mismatch condition.
● Clear flag bit RBIF.
A mismatch condition will continue to set flag bit RBIF. Reading PORTB will end the mismatch
condition and allow flag bit RBIF to be cleared. The interrupt-on-change feature is recommended for
wake-up on key depression operation and operations where PORTB is only used for the interrupt-on-
change feature. Polling of PORTB is not recommended while using the interrupt-on-change feature.
This interrupt-on-mismatch feature, together with software configurable pull-ups on these four pins,
allow easy interface to a keypad and make it possible for wake-up on key depression. Refer to the
Embedded Control Handbook, “Implementing Wake-Up on Key Stroke” (AN552). RB0/INT is an
external interrupt input pin and is configured using the INTEDG bit (OPTION<6>).
20
5.8.3 PORTC AND THE TRISC REGISTER
TRISC. Setting a TRISC bit (= 1) will make the corresponding PORTC pin an input (i.e., put the
corresponding output driver in a Hi-Impedance mode). Clearing a TRISC bit (= 0) will PORTC is an
8-bit wide, bi-directional port. The corresponding data direction register is make the corresponding
PORTC pin an output (i.e., put the contents of the output latch on the selected pin). PORTC is
multiplexed with several peripheral functions. PORTC pins have Schmitt Trigger input buffers. When
enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin. Some
peripherals override the TRIS bit to make a pin an output, while other peripherals override the TRIS
bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled,
read-modify write instructions (BSF, BCF, XORWF) with TRISC as destination should be avoided.
The user should refer to the corresponding peripheral section for the correct TRIS bit settings.
The Timer0 module timer/counter has the following features:
● 8-bit timer/counter
● Readable and writable
● 8-bit software programmable prescaler
● Internal or external clock select
● Interrupt on overflow from FFh to 00h
● Edge select for external clock
Oscillator circuit is used for providing a microcontroller with a clock. Clock is needed so that
microcontroller could execute a program or program instructions.
Types of oscillators
Since configurations with crystal oscillator and resistor-capacitor (RC) are the ones that are used most
frequently, these are the only ones we will mention here. Microcontroller type with a crystal oscillator
has in its designation XT, and a microcontroller with resistor-capacitor pair has a designation RC.
This is important because you need to mention the type of oscillator when buying a microcontroller.
XT Oscillator
21
Crystal oscillator is kept in metal housing
with two pins where you have written
down the frequency at which crystal
oscillates. One ceramic capacitor of 30pF
whose other end is connected to the
ground needs to be connected with each
pin.
RC Oscillator
In applications where great time precision is not necessary, RC oscillator offers additional
savings during purchase. Resonant frequency of RC oscillator depends on supply voltage rate,
resistance R, capacity C and working temperature. It should be mentioned here that resonant
frequency is also influenced by normal variations in process parameters, by tolerance of external R
and C components, etc.
22
Above diagram shows how RC oscillator is connected with PIC16F84. With value of resistor R being
below 2.2k, oscillator can become unstable, or it can even stop the oscillation. With very high value of
R (ex.1M) oscillator becomes very sensitive to noise and humidity. It is recommended that value of
resistor R should be between 3 and 100k. Even though oscillator will work without an external
capacitor (C=0pF), capacitor above 20pF should still be used for noise and stability. No matter which
oscillator is being used, in order to get a clock that microcontroller works up on, a clock of the
oscillator must be divided by 4. Oscillator clock divided by 4 can also be obtained on
OSC2/CLKOUT pin, and can be used for testing or synchronizing other logical circuits.
Following a supply, oscillator starts oscillating. Oscillation at first has an unstable period and
amplitude, but after some period of time it becomes stabilized.
23
To prevent such inaccurate clock from influencing microcontroller's performance, we need to keep the
microcontroller in reset state during stabilization of oscillator's clock. Diagram above shows a typical
shape of a signal which microcontroller gets from the quartz oscillator.
RC Oscillator
In applications where great time precision is not necessary, RC oscillator offers additional savings
during purchase. Resonant frequency of RC oscillator depends on supply voltage rate, resistance R,
capacity C and working temperature. It should be mentioned here that resonant frequency is also
influenced by normal variations in process parameters, by tolerance of external R and C components,
etc
In order to prevent from bringing a logical zero to MCLR pin accidentally (line above it means that
reset is activated by a logical zero), MCLR has to be connected via resistor to the positive supply
pole. Resistor should be between 5 and 10K. This kind of re sistor whose function is to keep a certain
line on a logical one as a preventive, is called a pull up.
These devices have a host of features intended to maximize system reliability, minimize cost through
elimination of external components, provide power saving Operating modes and offer code
protection:
● Oscillator Selection
● RESET
o Power-on Reset (POR)
o Power-up Timer (PWRT)
o Oscillator Start-up Timer (OST)
o Brown-out Reset (BOR)
● Interrupts
24
● Watchdog Timer (WDT)
● SLEEP
● Code Protection
● ID Locations
● In-Circuit Serial Programming
These devices have a Watchdog Timer, which can be enabled or disabled using a configuration bit. It
runs off its own RC oscillator for added reliability. There are two timers that offer necessary delays on
power-up. One is the Oscillator Start-up Timer (OST), intended to keep the chip in RESET until the
crystal oscillator is stable. The other is the Power-up Timer (PWRT), which provides a fixed delay of
72 ms (nominal) on power-up only. It is designed to keep the part in RESET while the power supply
stabilizes, and is enabled or disabled using a configuration bit. With these two timers on-chip, most
applications need no external RESET circuitry. SLEEP mode is designed to offer a very low current
Power-down mode. The user can wake-up from SLEEP through external RESET, Watchdog Timer
Wake-up, or through an interrupt. Several oscillator options are also made available to allow the part
to fit the application. The RC oscillator option saves system cost while the LP crystal option saves
power. Configuration bits are used to select the desired oscillator mode.
5.11 RESET
Some registers are not affected in any RESET condition. Their status is unknown on POR and
unchanged in any other RESET. Most other registers are reset to a “RESET state” on Power-on Reset
(POR), on the MCLR and WDT Reset, on MCLR Reset during SLEEP, and Brown-out Reset (BOR).
They are not affected by a WDT Wake-up, which is viewed as the resumption of normal operation.
The TO and PD bits are set or cleared differently in different RESET situations. These bits are used in
software to determine the nature of the RESET.
5.12 MCLR
PIC16F72 device has a noise filter in the MCLR Reset path. The filter will detect and ignore small
pulses. It should be noted that a WDT Reset does not drive MCLR pin low. The behavior of the ESD
protection on the MCLR pin has been altered from previous devices of this family. Voltages applied
to the pin that exceed its specification can result in both MCLR and excessive current beyond the
device specification during the ESD event. For this reason, Microchip recommends that the MCLR
pin no longer be tied directly to VDD.
25
5.13 INTERRUPTS
The PIC16F72 has up to eight sources of interrupt. The interrupt control register (INTCON) records
individual interrupt requests in flag bits. It also has individual and global interrupt enable bits. A
global interrupt enable bit, GIE (INTCON<7>) enables (if set) all unmasked interrupts, or disables (if
cleared) all interrupts. When bit GIE is enabled, and an interrupt’s flag bit and mask bit are set, the
interrupt will vector immediately. Individual interrupts can be disabled through their corresponding
enable bits in various registers. Individual interrupt bits are set, regardless of the status of the GIE bit.
The GIE bit is cleared on RESET. The “return from interrupt” instruction, RETFIE, exits the interrupt
routine, as well as sets the GIE bit, which re-enables interrupts. The RB0/INT pin interrupt, the RB
port change interrupt and the TMR0 overflow interrupt flags are contained in the INTCON register.
The peripheral interrupt flags are contained in the Special Function Register, PIR1. The corresponding
interrupt enable bits are contained in Special Function Register, PIE1, and the peripheral interrupt
enable bit is contained in Special Function Register INTCON. When an interrupt is serviced, the GIE
bit is cleared to disable any further interrupt, the return address is pushed onto the stack, and the PC is
loaded with 0004h. Once in the Interrupt Service Routine, the source(s) of the interrupt can be
determined by polling the interrupt flag bits. The interrupt flag bit(s) must be cleared in software
before re-enabling interrupts to avoid recursive interrupts. For external interrupt events, such as the
INT pin or PORTB change interrupts, the interrupt latency will be three or four instruction cycles.
The exact latency depends when the interrupt event occurs, relative to the current Q cycle. The latency
is the same for one or two cycle instructions. Individual interrupt flag bits are set, regardless of the
status of their corresponding mask bit, PEIE bit, or the GIE bit.
● Building control
o Access control
o Temperature sensing
o lighting
o If re detection
● Industrial control
o Process control
● Instrumentation
o Industrial instrumentation
● Metering
o Handheld metering systems
● Motor speed control
o AC motor control
o DC motors
o Steppers
● Automotive
o LIN slave nodes
o Body and convenience electronics
26
5.15 MICRO-ELECTRO MECHANICAL SYSTEM
Accelerometers are very handy for measuring the orientation of an object relative to the earth, because
gravity causes all objects to accelerate towards the earth. A two-axis accelerometer can be used to
measure how level an object is.
(This would be a good place to fill in equations to calculate a body's angle from the X and Y
accelerations on the body).
With a three-axis accelerometer, you can measure an object's acceleration in every direction.
This three-axis accelerometer is essentially a carrier board or breakout board for Freescale’s
MMA7260QT MEMS (micro-electro-mechanical systems) accelerometer
27
5.16 WORKING OF MEMS:
The schematic for the 3-axis accelerometer is shown below. The device can be powered directly
through the Vcc/3.3 V pin using a supply that is within the MMA7260QT’s acceptable power supply
range of 2.2 V to 3.6 V. Alternatively, the board can be powered by higher voltages, up to 16 V, using
the VIN pin, which connects to a low-dropout 3.3 V regulator. In this configuration, the Vcc/3.3 V pin
can serve as an output to be used as a reference voltage or power source for other low-power devices
(up to around 50 mA, depending on the input voltage).
The sensitivity selection pins GS1 and GS2 are pulled up to the Vcc line, making the default
sensitivity 6g; these pins can be pulled low by a microcontroller or through jumpers. For 5 V
microcontroller applications, the lines should not be driven high. Instead, the microcontroller I/O pin
can emulate an open-drain or open-collector output by alternating between low output and high-
impedance (input) states. Put another way, if you are using a 5 V microcontroller, you should make
your sensitivity selection I/O lines inputs and rely upon the internal pull-ups on the GS1 and GS2
lines if you want them to be high. It is always safe for you to drive these lines low.
28
Each of the three outputs is an RC-filtered analog voltage that ranges from 0 to Vcc. For 5 V
applications, the outputs will range from 0 to 3.3 V. The 3.3 V output can be used as a reference for
analog-to-digital converters to gain full resolution samples. Otherwise, your conversions will be
limited to 66% of the full range (e.g. an 8-bit ADC will yield numbers from 0 to 168).
Specifications:
29
Applications:
Accelerometers are real workhorses in the sensor world because they can sense such a wide range of
motion. They're used in the latest Apple Power books (and other laptops) to detect when the
computer's suddenly moved or tipped, so the hard drive can be locked up during movement. They're
used in cameras, to control image stabilization functions. They're used in pedometers, gait meters, and
other exercise and physical therapy devices. They're used in gaming controls to generate tilt data.
They're used in automobiles, to control airbag release when there's a sudden stop. There are countless
other applications for them.
Working:
30
The LED is based on the semiconductor diode. When a diode is forward biased
(switched on), electrons are able to recombine with holes within the device, releasing energy in
the form of photons. This effect is called electroluminescence and the color of the light
(corresponding to the energy of the photon) is determined by the energy gap of the
semiconductor. The compact size of LEDs has allowed new text and video displays and sensors
to be developed, while their high switching rates are useful in advanced communications
technology. The electrical symbol and polarities of led are shown in fig: 5.6.b
31
6: SOFTWARE DESCRIPTION
PIC Compiler:
PIC compiler is software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which is to be
dumped into the microcontroller for further processing. PIC compiler also supports C language code.
It’s important that you know C language for microcontroller which is commonly
known as Embedded C. As we are going to use PIC Compiler, hence we also call it PIC C. The PCB,
PCM, and PCH are separate compilers. PCB is for 12-bit opcodes, PCM is for 14-bitopcodes, and
PCH is for 16-bit opcode PIC microcontrollers. Due to many similarities, all three compilers are
covered in this reference manual. Features and limitations that apply to only specific microcontrollers
are indicated within. These compilers are specifically designed to meet the unique needs of the PIC
microcontroller. This allows developers to quickly design applications software in a more readable,
high-level language. When compared to a more traditional C compiler, PCB, PCM, and PCH have
some limitations. As an example of the limitations, function recursion is not allowed.
This is due to the fact that the PIC has no stack to push variables onto, and also
because of the way the compilers optimize the code. The compilers can efficiently implement normal
C constructs, input/output operations, and bit twiddling operations. All normal C data types are
supported along with pointers to constant arrays, fixed point decimal, and arrays of bits.
PIC C is not much different from a normal C program. If you know assembly, writing
a C program is not a crisis. In PIC, we will have a main function, in which all your application
specific work will be defined. In case of embedded C, you do not have any operating system running
in there. So you have to make sure that your program or main file should never exit. This can be done
with the help of simple while (1) or for (;;) loop as they are going to run infinitely.
We have to add header file for controller you are using, otherwise you will not be able
to access registers related to peripherals.
32
#include <16F73.h> // header file for PIC 16F73//
For PIC microcontroller, PIC C compiler is used for compilation. The compilation
steps are as follows:
2. Select Tools option and click on Check Communication for establishing a connection as shown
in below window
34
Fig 6.2: Picture of checking communications before dumping program into microcontroller
3. After connecting the dumper properly to the microcontroller kit the window is appeared as shown
below.
35
Fig 6.3: Picture after connecting the dumper to microcontroller
4. Again by selecting the Tools option and clicking on Check Communication the microcontroller
gets recognized by the dumper and hence the window is as shown below.
36
Fig 6.4: Picture of dumper recognition to microcontroller
5. Import the program which is ‘.hex’ file from the saved location by selecting File option and
clicking on ‘Import Hex’ as shown in below window.
37
Fig 6.5: Picture of program importing into the microcontroller
6. After clicking on ‘Import Hex’ option we need to browse the location of our program and click the
‘prog.hex’ and click on ‘open’ for dumping the program into the microcontroller.
38
7. After the successful dumping of program the window is as shown below.
7: MICROCONTROLLER CODE
Program Code:
39
Theprogram codewhichisdumpedinthemicrocontrollerofourprojectisshownbelow.
#include<16f72.h>
#include<apr33A3.h>
#use delay(clock=20000000)
bytech=0;
voidmain()
{
unsignedintfinal;
output_high(PIN_C2);
delay_ms(1000);
output_low(PIN_C2);
delay_ms(1000);
output_high(PIN_C2);
delay_ms(1000);
output_low(PIN_C2);
delay_ms(1000);
play_voice(1);
delay_ms(2000);
while(1)
{
set_adc_channel(0);
delay_us(100);
final=Read_ADC();
if(final==0)
{
output_high(pin_C3);
if(!input(pin_C0))
{
play_voice(2);
}
}
elseif(final==1)
{
output_high(pin_C4);
if(!input(pin_C0))
{
play_voice(3);
}
}
elseif(final==2)
{
output_high(pin_C5);
if(!input(pin_C0))
{
play_voice(4);
}
}
elseif(final==3)
{
40
output_high(pin_C6);
if(!input(pin_C0))
{
play_voice(5);
}
}
elseif(final==4)
{
output_high(pin_C7);
if(!input(pin_C0))
{
play_voice(6);
}
}
delay_ms(500);
output_low(pin_C4);
}
The project has been initiated. The following components have been successfully completed:
First phase of the project has been successfully completed in the first semester. The
Second phase of the project, is to be completed in the VIII Semester.
42