Você está na página 1de 42

MICROCONTROLLER BASED GESTURE VOCALISER

A documentation on major project work Phase II

Submitted in the partial fulfilment of the requirements for

the award of the degree of

BACHELOR OF TECHNOLOGY
in
ELECTRONICS AND COMMUNICATION ENGINEERING
by

Susheel Reddy Pingili B15EC049


Rishitha Vemula B15EC007
Vikas Allam B15EC023
Shanthan Reddy Chinthalapani B14EC042
Under the guidance of
Dr. G. RAGHOTHAM REDDY
Professor & HOD, Department of ECE.

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING KAKATIYA


INSTITUTE OF TECHNOLOGY & SCIENCE, WARANGAL
(An Autonomous Institute under Kakatiya University, Warangal)
WARANGAL – 506015
2018-2019

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.

Project Guide Head of the Department

Dr. G. RAGHOTHAM REDDY Dr. G. RAGHOTHAM REDDY


Professor & Head, Professor & Head,
Dept. of ECE, Dept. of ECE,
KITS, Warangal. KITS, Warangal.

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.

SUSHEEL REDDY PINGILI


Roll No. B15EC049

RISHITHA VEMULA
Roll No. B15EC007

VIKAS ALLAM
Roll No. B15EC023

SHANTHAN REDDY CHINTHALAPANI


Roll No. B14EC042

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.

Susheel Reddy Pingili


Rishitha Vemula
Vikas Allam
Shanthan Reddy chinthalapani

4
INDEX

1.Introduction……………………….................................................................. 7

2.Literature Review……………………….…………………………………... 8

3.Objectives of the project……………………….…………………………... 9

4.Embedded Systems…………………………………………………………. 10

4.1. Description 10

4.2. Need for embedded systems 11

4.3. Applications 11

5.Hardware description………………………………………………………. 12

5.1. Introduction 12

5.2. Microcontroller 13

5.3. Programmable IC 16

5.4. Pin Diagram 18

5.5. Special microcontroller feature 18

5.6. Memory organization 18

5.7. Stack 18

5.8.I/O Ports 20

5.9. Clock generator 23

5.10. Special features of CPU 24

5.11. Reset 24

5.12. MCLR 25

5.13. Interrupts 25

5.14. Applications of Microcontroller 26

5.15. Micro Electro Mechanical System 27

5.16. Working of MEMS 29

5
5.17. LED indicator 31

6.Software description………………………………………………………… 32

6.1. Compilation and simulation steps 32

6.2. Dumping steps 39

7.Microcontroller code………………………………………………………… 41

8.Status of the project…………………………………………………………. 42

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.

The control system consists of MEMS accelerometer sensor and microcontroller.


Microcontroller collects data from the sensor and announces appropriate announcement for that data
(gesture movement). The announcement is given by the microcontroller through the voice circuit
interfaced to it. To perform this intelligent task, Microcontroller is loaded with an intelligent program
written in embedded ‘C’ language.

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.

2. Usage of MEMS sensor for gesture-based operations.

3. Voice based announcement of predefined basic needs

9
4: EMBEDDED SYSTEMS

Description:

An embedded system is a computer system designed to perform one or a few dedicated


functions often with real-time computing constraints. It is embedded as part of a complete device
often including hardware and mechanical parts. By contrast, a general-purpose computer, such as
a personal computer (PC), is designed to be flexible and to meet a wide range of end-user needs.
Embedded systems control many devices in common use today.

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.

Need For Embedded Systems:

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:

At home we use a number of embedded systems which include microwave oven,


remote control, vcd players, dvd players, camera etc….

2. Office automation:

We use systems like fax machine, modem, printer etc.

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:

FIG 5.1: Block diagram of Microcontroller based Gesture Vocalizer.

12
The main blocks of this project are:

1. Regulated Power Supply


2. MEMS accelerometer.
3. Micro Controller
4. Voice circuit.
5. Crystal Oscillator.
6. Reset.
7. LED indicators

5.2 Micro controller

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:

● CPU (Central Processing Unit or the microprocessor)


● EEPROM / EPROM / PROM / ROM (Read Only Memory for the program code)
● RAM (Random, Access Memory for the program code)
● I /O (Input / Output) devices (serial, parallel, ADC, DAC etc.)
● Timers
● Interrupt controller
● Embedded Controller
● ADC
● Calculator
● PWM function generator

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.

5.3 PROGRAMMABLE INTEGRATED CIRCUIT (PIC)

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:

1. Base-line: 12-bit Instruction Word length


2. Mid-Range: 14-bit Instruction Word length
3. High-End: 16-bit Instruction Word length

5.3.1 PIC MICROCONTROLLER ARCHITECTURE

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

PIC use Harvard architecture and a RISC instruction set.

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.

5.3.2 PIC16F72 MICROCONTROLLER

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.

5.3.3 PIC16F72 DEVICE INCLUDED

5.3.3.1 HIGH PERFOTMANCE RISC CPU

● Only 35 single word instructions to learn


● All single cycle instructions except for program branches, which are two-cycle
● Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle
● 2K x 14 words of Program Memory, 128 x 8 bytes of Data Memory (RAM)
● Pin out compatible to PIC16C72/72A and PIC16F872
● Interrupt capability
● Eight-level deep hardware stack
● Direct, Indirect and Relative Addressing modes

5.3.3.2 PERIPHERAL FEATURES

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)

5.3.3.3 CMOS TECHNOLOGY

● Low power, high speed CMOS FLASH technology


● Fully static design
● Wide operating voltage range: 2.0V to 5.5V
● Industrial temperature range
● Low power consumption:
o - < 0.6 mA typical @ 3V, 4 MHz
o 20 μA typical @ 3V, 32 kHz
o < 1 μA typical standby current

5.4 PIN DIAGRAM

Figure 5.3: Pin Configuration of PIC16F72.

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

● 1,000 erase/write cycle FLASH program memory typical


● Power-on Reset (POR), Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
● Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation
● Programmable code protection
● Power saving SLEEP mode
● Selectable oscillator options
● In-Circuit Serial Programming™ (ICSP™) via 2 pins
● Processor read access to program memory

5.6 MEMORY ORGANIZATION

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).

5.8 I/O PORTS

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.

5.8.2 PORTB AND THE TRISB REGISTER

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

5.9 Clock generator - oscillator

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

PIC16Fcan work with four different configurations of an oscillator

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.

Oscillator and capacitors can be packed in


joint case with three pins. Such element is
called ceramic resonator and is
represented in charts like the one below.

Center pins of the element is the ground,


while end pins are connected with OSC1
and OSC2 pins on the microcontroller.
When designing a device, the rule is to
place an oscillator nearer a
microcontroller, so as to avoid any
interference on lines on which
microcontroller is receiving a clock.

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.

5.10 SPECIAL FEATURES OF THE CPU

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

The PIC16F72 differentiates between various kinds of RESET:

● Power-on Reset (POR)


● MCLR Reset during normal operation
● MCLR Reset during SLEEP
● WDT Reset (during normal operation)
● WDT Wake-up (during SLEEP)
● Brown-out Reset (BOR)

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.

5.14 APPLICATION OF MICROCONTROLLER

● 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

The MMA7260Q is 3-axis accelerometer. An accelerometer measures acceleration (change in speed)


of anything that it's mounted on. Single axis accelerometers measure acceleration in only one
direction. Dual-axis accelerometers are the most common measure acceleration in two directions,
perpendicular to each other. Three-axis accelerometers measure acceleration in three directions.

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:

Working of MMA7260Q sensor:

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:

1. Dimensions: 0.8" x 0.55" x 0.11" (without header pins)


2. Operating voltage: 3.3-16 V
3. Supply current: 1.35 mA
4. Output format: 3 analog voltages (one signal for each axis)
5. Output voltage range: 0-Vcc (0-3.3 V for VIN > 3.3 V)
6. Sensitivity range: ±1.5g, 2g, 4g, or 6g (selectable using pins GS1 and GS2; default is ±6g)
7. Weight without header pins: 0.03 oz (0.85 g)
8. Included components

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.

5.17 LED INDICATOR


A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in
many devices, and are increasingly used for lighting. Introduced as a practical electronic component
in 1962, early LEDs emitted low-intensity red light, but modern versions are available across the
visible, ultraviolet and infrared wavelengths, with very high brightness

Fig 5.6.a: Parts of a LED

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

Fig 5.6.b: Electrical Symbol & Polarities of LED

31
6: SOFTWARE DESCRIPTION

This project is implemented using following software’s:


● PIC C compiler - for compilation part
● Proteus 7 (Embedded C) – for simulation part

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//

6.1 Compilation and simulation steps:

For PIC microcontroller, PIC C compiler is used for compilation. The compilation
steps are as follows:

● Open PIC C compiler.


● You will be prompted to choose a name for the new project, so create a separate folder where
all the files of your project will be stored, choose a name and click save.
● Click Project, New, and something the box named 'Text1' is where your code should be
written later.
● Now you have to click 'File, Save as' and choose a file name for your source code ending with
the letter '.c'. You can name as 'project.c' for example and click save. Then you have to add
this file to your project work.
● You can then start to write the source code in the window titled 'project.c' then before testing
your source code; you have to compile your source code, and correct eventual syntax errors.
● By clicking on compile option .hex file is generated automatically.
● This is how we compile a program for checking errors and hence the compiled program is
saved in the file where we initiated the program.
After compilation, next step is simulation. Here first circuit is designed in Express PCB using
Proteus 7 software and then simulation takes place followed by dumping. The simulation steps are as
follows:
● Open Proteus 7 and click on IS1S6.
● Now it displays PCB where circuit is designed using microcontroller. To design circuit
components are required. So click on component option.
Now click on letter ’p’, then under that select PIC16F73 ,other components related to the project and
click OK. The PIC 16F73 will be called your “'Target device”, which is the final destination
of your source code.
6.2 Dumping steps:
The steps involved in dumping the program edited in proteus 7 to microcontroller are
shown below:
1. Initially before connecting the program dumper to the microcontroller kit the window is
appeared as shown below.
33
Fig 6.1: Picture of program dumper window

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.

Fig 6.6: Picture after program dumped into the microcontroller

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);
}

9: STATUS OF THE PROJECT

The project has been initiated. The following components have been successfully completed:

1. Desing of the code for the Microcontroller.

2. Dumping of code into the Microcontroller.


41
3.Basic Software Requirements.

Following components need to be completed.

1. Desing of the voice circuit.

2 .Desing of the mems module.

3. Interfacing of the different module .

Time plan Scheduled For the project:

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