Вы находитесь на странице: 1из 52

A

SUMMER TRAINING REPORT


ON

Embedded System & Design


Under the guidance of
MR. NAVEEN
CEO, EMTECH FOUNDATION,NEW DELHI

SUBMITTED IN
PARTIAL FULFILLMENT OF THE REQUIREMENT FOR THE AWARD OF
DEGREE
OF
BACHELOR OF TECHNOLOGY

Submitted to :-

Submitted by:-

Mr Nitin Sharma(Associate Professor, ECE)

Ashish (1510168)

Department of Electronics and Communication Engineering


N.C. College Of Engineering, Israna (Panipat)
(An Autonomous Institute Permanently affiliated to Kurukshetra University, Kurukshetra)

ACKNOWLEDGEMENT
I want to express my sincere gratitude and thanks to Mr. Nitin Sharma (H.O.D., ECE Department), N.
C. College of Engineering, Israna (Panipat) for granting me permission for my industrial training in
the field of Embedded Systems. I express my sincere thanks to Mr. Naveen, CEO, EMTECH
Foundation for his cooperative attitude and consistent guidance, due to which I was able to complete my
training successfully. Finally, I pay my regards and gratitude to the team members and technicians of N.
C. College of Engineering, Israna (Panipat) and EMTECH Foundation, New Delhi for their
valuable help, support and guidance.

INDEX
Content

Page no.

Chapter 1
1.1 EMTECH Foundation

1.2 Technological Workshop

1.3 Topics on which institute provides training

1.3.1

Embedded System Design

1.3.2

Mobile Robotics Design

1.3.3

PCB Designing

1.3.4

CFP (Career Foundation Program)

1.3.5

STEP (Summer Training & Essence Program)

1.3.6

WRAP (Winter Rapid Action Program)

Chapter2
2.1 Basics of Embedded Systems

2.2 Concept of Embedded Systems in C

2.2.1 C is Common in Embedded Systems

10

2.2.2 C Languages Used in Embedded Systems

10

2.2.3 How C Programs are Created and Installed on Embedded Systems

10

2.2.4 Common Embedded Systems that Use C

10

2.2.5 Standards for Embedded System Programming in C

11

2.3 Advantages of Embedded C in the programming

11

2.4 MPLAB IDE

12

2.5 MICROCONTROLLER (PIC16F887A)

13

2.5.1 Pin Description

13

2.5.2 Features

14

2.6 Conclusion

16
3

CHAPTER-3
3.1 Block Diagram

17

3.1.1

Reset Circuit

17

3.1.2

Power Supply

18

3.1.3

Oscillator circuit

19

3.1.4

Liquid Crystal Display

19

3.2 CIRCUIT DIAGRAM

19

3.3 COMPONENTS USED

21

3.6 CODING

28

3.7 APPLICATIONS

48

CHAPTER-4
4.1 Conclusion

49

4.2 Future Work

49

REFRENCES

50

CHAPTER-1
1.1 EMTECH Foundation
EMTECH Foundation is an ISO certified Embedded Systems/ Microcontroller Training and
Consultancy Company, powered by a passion to provide the best of services in the industry. Being in IT
business for a couple of years, today it is a leading solution provider for embedded system designs across
the globe. With the enthusiastic team of highly skilled engineers, it is headquartered in New Delhi, the
capital of India. It is serving to a large number of professionals. It offers solutions to corporate clients,
train budding engineers and recruit skilled professionals. For a corporate client, it converts ideas to
technological realities, and for a professional, it converts dreams to realities. For an engineer seeking
professional degree, it helps them to attain guaranteed success by offering support and guidance.
EMTECH Foundation has been able to make a name for itself in a short span of time because of its
commitment to ensure customer satisfaction by rewarding quality work in all spheres.

1.2 Technological Workshop


In todays competitive electronics market scenario, India too holds a market value but as compared to
other countries, she still needs a lot to be done to prove its potential in electronics (R&D) domain too.
EMTECH Foundation came up with a little initiative to provide its young and budding engineers a
platform where they can learn, experiment and express their ability to solve different problems related to
her growing economy. So, it offers different courses time to time and organizes different workshops for
such engineering students and engineers. Be a part of such activity and be proud to feel the technology is
in your hand.

PCB Designing: The connections on the PCB should be identical to the circuit diagram, but
while the circuit diagram is arranged to be readable, the PCB layout is arranged to be functional,
so there is rarely any visible correlation between the circuit diagram and the layout. PCB layout
can be performed manually (using CAD) or in combination with an auto router.

Robotics: For many people, it is a machine that imitates a human-like the androids in Star Wars,
Terminator and Star Trek: The Next Generation. However these robots capture our imagination,

such robots still only inhabit Science Fiction. People still haven't been able to give a robot enough
common reliably interact with a dynamic world.

1.3 Topics on which institute provides training


EMTECH Foundation offers dedicated electronic system and hardware design courses to help students
accelerate the process of product development in industrial and practical applications. This is a
concentrated practical course intended for people who want to learn how to build up electronics projects
with analog and digital circuits.
1.3.1 Embedded System Design
The training program is based on micro chip range 8-bit microcontroller. The training is intended to bring
together the technology and education in the field of Embedded System Design. It is widely recognized
that the embedded system Domain is a multidisciplinary one, requiring a large variety of skills from
electrical, electronics to software engineering. The industrial application based on control and signal
processing theory, electronics, computer engineering and science, telecommunications, automobile,
defense, aerospace domains etc. The training program is based on Microchip Mid range (PIC16Fxxxx)
8-bit Microcontroller. Microchip Technology Inc., USA is worlds #1 company in 8-bit microcontroller.

Fig.1.1 an embedded system


1.3.2

Mobile Robotics Design

This training is the one of its kind robotics intended to facilitate students, professionals and hobbyists
with a concrete platform for their foray into the exciting world of robotics and artificial intelligence. The
training includes basic concepts of electrical, electronics, mechanical and computer engineering, with an

elaborate learning manual, and detailed projects that will enable users to gain valuable insights into these
disciplines. The programming is based on Microchip High range (PIC18Fxxxx) 8-bit Microcontroller.
1.3.3

PCB Designing

The connections on the PCB should be identical to the circuit diagram, but while the circuit diagram is
arranged to be readable, the PCB layout is arranged to be functional, so there is rarely any visible
correlation between the circuit diagram and the layout. PCB layout can be performed manually
(using CAD) or in combination with an Auto router. The best results are usually still achieved using at
least some manual routing - simply because the design engineer has a far better judgment of how to
arrange circuitry. Surprisingly, many auto routed boards are often completely illogical in their track
routing - the program has optimized the connections, and sacrificed any small amount of order that may
have been put in place by manual routing.

Fig.1.2 PCB Board

1.3.4

CFP (Career Foundation Program)

Career Foundation Program (CFP) in Embedded Systems Design is a job oriented full time training
program for engineering graduates. It has been designed and formed by industry experts to groom young
engineers to meet the requirements of the todays industry.
1.3.5

STEP (Summer Training & Essence Program)

As per AICTE norms, summer training is a part of curriculum for all engineering students of 2nd/3rd
year. The objective of training curriculum gets them the understanding of engineering fundamentals and
experiencing of its happening at industry level. STEP is a professionally designed training program to
fulfill the need with achieving utmost satisfaction of being an ENGINEER, among others.
7

1.3.6

WRAP (Winter Rapid Action Program)

The WRAP is a 15 days training meant for final year engineering students. This program offers best
approach towards embedded system and project design. The program comes with good reasons to
upgrade skills of engineering students for latest trends in the industry with utilization.

1.4 Why I chose embedded systems for training?


An embedded system is a computer system designed for specific control functions within a larger system,
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. Physically, embedded systems range from portable devices
such as digital watches and MP3 players, to large stationary installations like traffic, factory controllers,
or

the

systems

controlling nuclear

power

plants.

Complexity

varies

from

low,

with

single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a
large chassis or enclosure. Embedded systems are designed to do some specific task, rather than be a
general-purpose computer for multiple tasks. Some also have real-time performance constraints that must
be met, for reasons such as safety and usability. Others may have low or no performance requirements,
allowing the system hardware to be simplified to reduce costs.

CHAPTER-2
2.1 Basics of Embedded Systems
An embedded system is a combination of computer hardware and software, either fixed in capability or
programmable, that is specifically designed for a particular function within a time constraint.
An embedded system is a computer system designed for specific control functions within a larger system,
often with real-time computing constraints. It is embedded as a 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 contain processing cores that are typically either microcontrollers or digital signal
processors (DSP). The key characteristic, however, is being dedicated to handle a particular task. Since
the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size
and cost of the product and increase the reliability and performance. Some embedded systems are massproduced, benefiting from economies of scale.
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. Industrial machines,
automobiles, medical equipments, cameras, household appliances, airplanes, vending machines and toys
are among possible hosts of an embedded system.
Embedded systems that are programmable are provided with programming interfaces, and embedded
systems programming is a specialized occupation. Certain operating systems or language platforms are
tailored for the embedded market, such as Embedded Java and Windows XP Embedded.
2.2 Concept of Embedded Systems in C
An embedded system is a system that connects the preprogrammed software on a controlled embedded in
the computer hardware. The software is installed on the controller, the brains of the electronic device.
Each embedded system is used for one specific function. A complex device like a smart phone may have
embedded devices that can control several functions. However, embedded systems are not as complex or
9

programmable as a personal computer. C is one of the most commonly used programming languages in
embedded devices. Embedded systems are used to control electronic devices such as DVD players, cell
phones, watches and medical devices. Video cards and network switches are embedded systems used in
computer peripherals. The cruise control and anti-lock brakes in a car are also embedded systems.
Embedded systems are cheaper than complex processors due to their simplicity and frequent mass
production. Software written in a language like C is used to control the mechanical devices within the
embedded system.
2.2.1 C is Common in Embedded Systems
C is one of the most commonly used software languages used on embedded device controllers. One
reason is because it is one of the few software languages that operates on both 8 bit controllers and 64 bit
PCs, meaning that many computer programmers can write C software for both personal computers and
embedded devices. The C language can also use very simple commands to control the device, freeing up
the limited memory of the device to hold many commands or parameters. C can be written for both
microcontrollers and digital signal processors.
2.2.2 C Languages Used in Embedded Systems
C and C++ are the most frequently used languages in the creation of embedded systems. Embedded
systems are rarely programmed using the C++ because embedded systems rarely have the memory space
for the complex programming used in C++. It is occasionally used on embedded Linux systems.
2.2.3 How C Programs are Created and Installed on Embedded Systems
Code is written in C on a programmers PC. Code is run through a compiler on the programmers PC to
create a software program. The embedded system software may be run through a simulator on the
programmers computer. The software program is copied onto the controller using a programmer. The
controller is then tested on a test bed to ensure that it works properly.
2.2.4 Common Embedded Systems that Use C
Bluetooth devices are programmed in C. PIC microcontrollers such as those used in web cameras are
frequently programmed in C. PIC microcontrollers programmed in C have also been used in LED (Light
Emitting Diodes) devices and LCD (Liquid Crystal Display) monitors. USB devices are embedded
devices frequently coded in C.

10

2.2.5 Standards for Embedded System Programming in C


The American National Standards Institute (ANSI) has written standards for the C programming
language. The International Standards Organization wrote standard ISO/IEC 9899 for the C programming
language. The Motor Industry Software Reliability Association has created a proprietary set of standards
for programming in C for embedded devices in automobiles.
2.3 Advantages of Embedded C in the programming
Programming in C makes the embedded systems more reliable. C code written for a specific micro
controller can easily be transferred to systems using different micro controllers of different vendors
without little or no modification. It can be reused, easy to maintain and easy to debug and extend.
The advantages of C are

Of higher level languages, C is the closest to assembly languages.

Most micro controllers have available C compilers.

Writing in C, simplifies code development for large projects.

It is easier and less time consuming to write in C language than an assembly language.

C is easier to modify and update.

Code available in function libraries can be used.

C code is portable to other micro controllers with little or no change.

Assembly is the fastest, however, it is difficult to find or train assembly experts. Then if a new
processor is required, a start over is required!

C is mid-level, lots of good C programmers are available, C compilers are available. C can be
used on 8-, 16-, 32-, and 64-bits processors.

2.4 MPLAB IDE

11

An embedded system is typically a design making use of the power of a small microcontroller, like the
Microchip PICmicro MCU or dsPIC Digital Signal Controller (DSCs). These microcontrollers combine a
microprocessor unit (like the CPU in a desktop PC) with some additional circuits called peripherals,
plus some additional circuits on the same chip to make a small control module requiring few other
external devices. This single device can then be embedded into other electronic and mechanical devices
for low-cost digital control.
MPLAB IDE (Integrated Development Environment) is used for editing, compiling codes as well as
simulating them using an inbuilt simulator. It is a software program that runs on a PC to develop
applications for Microchip microcontrollers. It is called an Integrated Development Environment, or IDE,
because it provides a single integrated environment to develop code for embedded microcontrollers.
The following steps are followed to program the PIC16F877A

Setting up a new project


(1) Selecting the device
(2) Setting up Language Tools
(3) Naming the project
(4) Adding Required files to the Project

Editing & Compiling the Code


(1) Viewing Windows
(2) Checking the Configuration Bits
(3) Locating the main code area
(4) Locating the variable definition area
(5) Locating the ISR (Interrupt Service Routine)
(6) Building the code

Testing the code using the Simulator


12

(1) Selecting the debugger(simulator)


(2) Viewing the watch window
(3) Selecting the registers for a watch
(4) Checking the program sequence

Feeding the program in the micro controller

2.5 MICROCONTROLLER (PIC16F887A)


It is an 8-bit microcontroller. PIC here stands for Peripheral Interface Controller. The letter f in the name
of the microcontroller stands for flash memory. This microcontroller has 256 data RAM, a 20KB of onchip ROM for the program, three timers and 32 pins for I/O ports all on a single chip. The PIC families
include 10xxx, 12xxx, 14xxx, 16xxx, 17xxx and 18xxx. They are all 8-bit processors, meaning that the
CPU can work on only 8-bits of data at a time. It has Harvard architecture.
2.5.1 Pin Description

MCLR/VPP - Master Clear (input) or programming voltage (output).Master Clear (reset) input.
This pin is an active low reset to the device. VPP is programming voltage input.

Fig.3.2 pin diagram


13

PORTA- It is a bi-directional I/O port. It has only 5 pins.

PORTB- It is a bi-directional I/O port. PORTB can be software programmed for internal weak
pull-up on all inputs.

PORTC- It is a bi-directional I/O port. It has 8 pins.

PORTD- It is a bi-directional I/O port or parallel slave port when interfacing to a microprocessor
bus.

PORTE- It is a bi-directional I/O port. It has only 3 pins.

VSS- Ground reference for logic and I/O pins.

VDD- Positive supply for logic and I/O pins.

OSC1/CLK1- It is oscillator crystal input or external clock source input. CLK1 is external clock
source input and is always associated with pin function OSC1.

OSC2/CLKOUT- It is oscillator crystal output. It is connected to crystal or resonator in crystal


oscillator mode. In RC mode, OSC2 pin outputs CLKO, which has the frequency of OSC1 and
denotes the instruction cycle rate.

2.5.2 Features
High Performance 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

Up to 8K x 14 words of FLASH Program Memory

Up to 368 x 8 bytes of Data Memory (RAM)

Up to 256 x 8 bytes of EEPROM Data Memory


14

Pinout compatible to other 28-pin or 40/44-pinr

Harvard Architecture

Instruction pipelining

Peripheral Features

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

Special Microcontroller Features

100,000 erase/write cycle Enhanced FLASH program memory typical

1,000,000 erase/write cycle Data EEPROM memory typical

Data EEPROM Retention > 40 years

Self-reprogrammable under software control

Single supply 5V In-Circuit Serial Programming

Programmable code protection

Power saving SLEEP mode

Selectable oscillator option

CMOS Technology

Low power, high speed FLASH/EEPROM technology

Fully static design


15

Wide operating voltage range (2.0V to 5.5V)

Commercial and Industrial temperature ranges

Low power consumption

2.6 Conclusion
An embedded system is a combination of computer hardware and software, either fixed in capability or
programmable. C remains a very popular language for micro-controller developers due to the code
efficiency and reduced overhead and development time. C offers low-level control and is considered
more readable than assembly. Many free C compilers are available for a wide variety of development
platforms. The compilers are a part of an IDEs with ICD support, breakpoints, single-stepping and an
assembly window. The performance of C compilers has improved considerably in recent years, and they
are claimed to be more or less as good as assembly, depending on who you ask. Most tools now offer
options for customizing the compiler optimization. Additionally, using C increases portability, since C
code can be compiled for different types of processors.

16

CHAPTER-3
3.1 BLOCK DIAGRAM

fig.3.1 block diagram of ultrasonic distance measurement

The block diagram of security system contains the following:


3.1.1

Reset Circuit

It is MCLR - Master Clear Reset at Pin number 1. If PIC reads 0V at MCLR pin, it will reset the program, so if the
MCLR pin is not connected with 5V, PIC will remain reset and the program will not execute. The MCLR pin can
be connected directly with 5V (series with resistor likes picture below) but you will unable to reset if your system
goes wrong. So, a switch is used. But simply a switch between the 5V and the reset pin cannot be added. So a Pull
up Resistor is used. The correct way to add up a switch in order to create the logic condition is shown below.
When the switch is not pushed, current will flow trough 10K resistor and MCLR Pin. As a result, MCLR Pin will
receive 5V and PIC will read it as logic 1. But when switch is pushed, current will flow through 10K resistor,
switch and directly to ground. There is no voltage will receive at MCLR Pin. This gives logic 0 at MCLR Pin.

17

fig.3.2 reset circuit

3.1.1

Power Supply

18

The supply pin of PIC16F877A IC is the most important. The ideal voltage for PIC16F887A is 5V

fig.3.3 power supply connection


(Direct Current). It should not be higher than 5.5V because it is going to blow up. It also should not be
less then 2V because it not going to operate. There are various types of supply such as battery and DC
adapter which can be used. The problem is, if a battery is used, it is hard to find a normal battery in 5V.
But 3 normal 1.5V batteries can be connected in series. It will not be efficient enough. So a 9V battery
can is used but it needs to be stepped down to 5V.So a voltage regulator LM7805 is used. The two
numbers at the end of the part number is 05 which means it will step down the larger input voltage to 5V.
Using LM7805 is not only limited to battery supply source but a rectifier circuit is also needed.

3.1.2

Oscillator circuit

There are two pins named as OSC1 and OSC2. You can connect the crystal oscillator from various frequencies.
Pulse generated from the oscillator will some time have noise. To reduce the noise, two capacitors in Pico farad
values are needed. The value of capacitor depends on the speed of oscillator that is used. Here a crystal oscillator at
4MHz is used for its efficient operation.

19

3.1.3

Liquid Crystal Display

The LCD is used to display some message or data. There are two types of LCD graphical and character.
Graphical LCD are used to display some image or message. This consists of small crystal pixels. And
character LCD is used to display symbol, character and numbers. The character LCD takes the ASCII
values as input. The diagram shows the 16X2 LCD which means 16 columns and 2 rows to display
character and data. The IC used for the LCD is HD44780. This IC consist of the 8 bit processor and 2
RAMS, i.e. 1 DDRAM( data display RAM) and CGRAM(character generator RAM ).

3.2 CIRCUIT DIAGRAM


The technique of distance measurement in air includes continuous wave and pulse echo technique. In the
pulse echo method, a burst of pulses is sent through the transmission medium and is reflected by an
object kept at specified distance. The time taken for the pulse to propagate from transmitter to receiver is
proportional to the distance of object. For contact less measurement of distance, the device has to rely on
the target to reflect the pulse back to itself. The target needs to have a proper orientation that is it needs to
be perpendicular to the direction of propagation of the pulses. The amplitude of the received signal gets
significantly attenuated and is a function of nature of the medium and the distance between the
transmitter and target. The pulse echo or time-of-flight method of range measurement is subject to high
levels of signal attenuation when used in an air medium, thus limiting its distance range.

20

C2
C3
RV1

LCD1

1k

LM016L

D0
D1
D2
D3
D4
D5
D6
D7
7
8
9
10
11
12
13
14

RS
RW
E
4
5
6

1
2
3

VSS
VDD
VEE

68%

R1
10k

C1
1uF

22pF

X1
CRYSTAL

22pF

U1
1
2
3
4
5
6
7
14
13
33
34
35
36
37
38
39
40

10k R11
10k 10k
10kR10

RE3/MCLR/VPP

RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RA0/AN0/ULPW U/C12IN0RC2/P1A/CCP1
RA1/AN1/C12IN1RC3/SCK/SCL
RA2/AN2/VREF-/CVREF/C2IN+ RC4/SDI/SDA
RA3/AN3/VREF+/C1IN+
RC5/SDO
RA4/T0CKI/C1OUT
RC6/TX/CK
RA5/AN4/SS/C2OUT
RC7/RX/DT
RA6/OSC2/CLKOUT
RA7/OSC1/CLKIN
RD0
RD1
RB0/AN12/INT
RD2
RB1/AN10/C12IN3RD3
RB2/AN8
RD4
RB3/AN9/PGM/C12IN2RD5/P1B
RB4/AN11
RD6/P1C
RB5/AN13/T1G
RD7/P1D
RB6/ICSPCLK
RB7/ICSPDAT
RE0/AN5
RE1/AN6
RE2/AN7

15
16
17
18
23
24
25
26
19
20
21
22
27
28
29
30
8
9
10

D1
LED-RED

PIC16F887

D2

R13
R12

LED-RED

fig.3.4 circuit diagram


Firstly the power supply is given to the circuit through a battery which is 5V.the oscillator circuit is
employed to give clock pulses to the controller.
Here,the password is fed through a 4x4 matrix keypad.
An lcd is used to display the indications of entering the password and incorrect password etc.
If the wrong password is entered.the system blocks and doesnt take anymore input.
Also a buzzer starts ringing if the incorrect password is fed to the controller.

3.3 COMPONENTS USED

21

Resistor: A resistor is a passive two-terminal electrical component that implements electrical


resistance as a circuit element. The current through a resistor is in direct proportion to the voltage
across the resistor's terminals. This relationship is represented by Ohm's law:

where I is the current through the conductor in units of amperes, V is the potential difference
measured across the conductor in units of volts, and R is the resistance of the conductor in units of
ohms.
The ratio of the voltage applied across a resistor's terminals to the intensity of current in the
circuit is called its resistance, and this can be assumed to be a constant (independent of the
voltage) for ordinary resistors working within their ratings.
Resistors are common elements of electrical networks and electronic circuits and are ubiquitous in
electronic equipment. Practical resistors can be made of various compounds and films, as well as
resistance wire (wire made of a high-resistivity alloy, such as nickel-chrome). Resistors are also
implemented within integrated circuits, particularly analog devices, and can also be integrated
into hybrid and printed circuits.

fig.3.5 resistor
The ohm (symbol: ) is the SI unit of electrical resistance, named after Georg Simon Ohm. An
ohm is equivalent to a volt per ampere. Since resistors are specified and manufactured over a very
large range of values, the derived units of milliohm (1 m = 10 3 ), Kohm (1 k = 103 ), and
mega ohm (1 M = 106 ) are also in common usage.
22

Capacitor: A capacitor (formerly known as condenser) is a passive two-terminal-electrical


component used to store energy in an electric field. The forms of practical capacitors vary widely,
but all contain at least two electrical conductor separated by dielectric (insulator). Capacitors used
as parts of electrical systems, for example, consist of metal foil separated by a layer of insulating
film.
When there is a potential difference (voltage) across the conductors, a static electrical field
develops across the dielectric, causing positive charge to collect on one plate and negative charge
on the other plate. Energy is stored in the electrostatic field. An ideal capacitor is characterized by
a single constant value, capacitance measured in farads. This is the ratio of the electric charge on
each conductor to the potential difference between them.
The capacitance is greatest when there is a narrow separation between large areas of conductor
hence capacitor conductors are often called "plates," referring to an early means of construction.
In practice, the dielectric between the plates passes a small amount of leakage current and also has
an electric field strength limit, resulting in breakdown voltage while the conductors and leads
introduce an undesired inductance and resistance.

fig.3.6 different types of capacitors

Diode: In electronics, a diode is a type of two-terminal electric component with a nonlinear


current voltage characteristic. A semiconductor diode, the most common type today, is a
crystalline piece of semiconductor material connected to two electrical terminals a vacuum tube

23

diode (now rarely used except in some high-power technologies) is a vacuum tube with two
electrodes a plate and a cathode.
The most common function of a diode is to allow an electric current to pass in one direction
(called the diode's forward direction), while blocking current in the opposite direction (the reverse
direction). Thus, the diode can be thought of as an electronic version of a check value. This
unidirectional behavior is called rectification and is used to convert electric current to direct
current, and to extract modulation from radio signals in radio receivers.
However, diodes can have more complicated behavior than this simple onoff action.
Semiconductor diodes do not begin conducting electricity until a certain threshold voltage is
present in the forward direction (a state in which the diode is said to be forward biased). The
voltage drop across a forward biased diode varies only a little with the current, and is a function
of temperature; this effect can be used as a temperature sensor or voltage reference.
Semiconductor diodes have nonlinear electrical characteristics, which can be tailored by varying
the construction of their PN junction. These are exploited in special purpose diodes that perform
many different functions. For example, diodes are used to regulate voltage (zener diodes) to
protect circuits from high voltage surges to electronically tune radio and TV receivers (varactor
diodes)

to generate radio frequency oscillations and to produce light (light emitting diodes)

Tunnel diodes exhibit negative resistance which makes them useful in some types of circuits.
Diodes were the first semiconductor electronic device. The first semiconductor diodes, called
cats whisker diodes developed around 1906, were made of mineral crystals such as galena
Today most diodes are made of silicon , but other semiconductors such as are germanium
sometimes used.

fig. 3.7 diode

24

LED: A light-emitting diode (LED) is a semiconductor light source. Leds are used as indicator
lamps in many devices and are increasingly used for other 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.
When a light-emitting diodes is forward biased (switched on), electrons are able to recombine
with electron 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. Leds are often small in area (less than
1 mm2), and integrated optical components may be used to shape its radiation pattern. Leds
present many advantages over incandescent light sources including lower energy consumption,
longer lifetime.

fig. 3.8 LEDs

Voltage Regulator 7805: In electronics, a linear regulator is a voltage regulator based on an


active device operating in its "linear region" (in contrast, a switching regulator is based on a
transistor forced to act as an on/off switch) or passive devices like zener diodes operated in their
breakdown region. The regulating device is made to act like a variable resister \continuously
adjusting a voltage divider network to maintain a constant output voltage. It is very inefficient
compared to a switch mode power supply since it sheds the difference voltage by dissipating heat.

25

Fixe three-terminal linear regulators are commonly available to generate fixed voltages of plus 3
V, and plus or minus 5 V, 6V, 9 V, 12 V, or 15 V when the load is less than 1.5 amperes.
The "78 xx" series (7805, 7812, etc.) regulate positive voltages while the 79xx series (7905, 7912,
etc.) regulate negative voltages. Often, the last two digits of the device number are the output
voltage; e.g., a 7805 is a +5 V regulator, while a 7915 is a -15 V regulator. There are variants on
the 78xx series ICs, such as 78L and 78S, some of which can supply up to 1.5 Amps. Adjusting
fixed regulators several ways are used to make fixed IC regulators adjustable. A zener diode or
resistor is added between the IC's ground terminal and ground. Resistors are acceptable where
ground current is constant, but are ill-suited to regulators with varying ground current. Switching
in different zeners, diodes or resistors can be used to obtain stepwise adjustment.

fig. 3.9 a voltage regulator

Microcontroller (PIC16F887A): It is an 8-bit microcontroller. PIC here stands for


Peripheral Interface Controller. The letter f in the name of the microcontroller stands for flash
memory. This microcontroller has 256 data RAM, a 20KB of on-chip ROM for the program,
three timers and 32 pins for I/O ports all on a single chip. The PIC families include 10xxx, 12xxx,
14xxx, 16xxx, 17xxx and 18xxx. They are all 8-bit processors, meaning that the CPU can work
on only 8-bits of data at a time.

26

fig.3.10 pic16f887
There are 5 ports in the pic microcontroller named port A, B, C, D and E. Port A has 5 pins, Port
B,C & D has 8 pins and Port E has 3 pins. Pin 1 is for reset circuit. Pin 13 and 14 is for the
oscillatory circuit that produces the desirable frequency. Pins 11 and 32 are for the ground and
Pins 12 and 31 is used for the Vcc.

LCD: The LCD is used to display some message or data. There are two types of LCD graphical

fig.3.11 LCD
and character. Graphical LCD are used to display some image or message. This consists of
smallcrystal pixels. And character LCD is used to display symbol, character and numbers. The
character LCD takes the ASCII values as input. The diagram shows the 16X2 LCD which means 16
columns and 2 rows to display character and data. The IC used for the LCD is HD44780. This IC
27

consist of the 8 bit processor and 2 RAMS, i.e. 1 DDRAM( data display RAM) and
CGRAM(character generator RAM ).
The 16x2 LCD used here has 16 pins out of which 8 pins are data lines, they are directly connected to
the controller. The third pin is connected to the potentiometer for the brightness. Three pins 1, 5 and
16 are connected to ground. Pins 2 and 15 are connected to power supply.

The rest of the two

pins are EN and RS. EN stands for Enable which latches (accepts) the data or the command given to
the LCD and RS stands for Register Select. It is used for selecting command or data registers.

Crystal Oscillator: A crystal oscillator is an electronic oscillator circuit that uses the
mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with
a very precise frequency. This frequency is commonly used to keep track of time (as in quartz
wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize
frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator
used is the quartz crystal, so oscillator circuits designed around them became known as "crystal
oscillators."

fig.3.12 crystal oscillator


Quartz crystals are manufactured
for frequencies from a few tens
of kilohertz to tens of megahertz.
More than two billion crystals are
manufactured annually. Most are
used for consumer devices such as wristwatches, clocks, radios, computers, and cell phones. Quartz
crystals are also found inside test and measurement equipment, such as counters, signal generators,
and oscilloscopes. Crystals can be manufactured for oscillation over a wide range of frequencies, from a
few kilohertz up to several hundred megahertz. Many applications call for a crystal oscillator frequency

28

conveniently related to some other desired frequency, so hundreds of standard crystal frequencies are
made in large quantities and stocked by electronics distributors.

Switch: It is a momentary or non-latching switch which causes a temporary change in the state
of an electrical circuit only while the switch is physically actuated. An automatic mechanism (a
spring) returns the switch to its default position immediately afterwards, restoring the initial
circuit condition. There are two types:
A push to make switch allows electricity to flow between its two contacts when held in. When the
button is released, the circuit is broken.
A push to break switch does the opposite, i.e., when the button is not pressed, electricity can flow,
but when it is pressed the circuit is broken.

fig.3.13 an electronic switch

3.6 CODING
#include <pic.h>
#define LCD PORTB
#define RS RD6
#define EN RD7
int lnum,a,b,c,d,e,f,i=0,p=0,p3=0;
char arr4[]={"ENTER PASSWORD "};
char arr1[4]={"1234"};
char check[4]={"1355"};
char arr[4]={0};
char arrs[4]={0};
29

char arr2[]={"CORRECT PASSWORD"};


char arr3[]={"INCORRECT PASSWD"};
char arr5[]={"ENTER NEW PA$$ "};
char arr6[]={"password based "};
char arr8[]={"security system "};
int p1;
char arrt[]={"pswd reset

"};

char key[]={"enter key"};


char key1[]={"wrong key"};

void delay(unsigned long m)


{
while(m--);
}
void command()
{
RS=0;
EN=1;
delay(10);
EN=0;
delay(100);
}

void data()
{
RS=1;
EN=1;
30

delay(10);
EN=0;
delay(100);
}

void reset()
{
p3=p1=0;
LCD=0X01;
command();
LCD=0X80;
command();
for(int v=0;v<9;v++)
{
PORTB=key[v];
data();
}
LCD=0Xc0;
command();
while(p3<4)
{

RC0=1;
RC1=0;
RC2=0;
RC3=0;

31

if(RC4==1)
{
while(RC4==1);
PORTB='*';
data();
arrs[p3]='1';
p3++;
}
if(RC5==1)

{while(RC5==1);
PORTB='*';
data();
arrs[p3]='2';
p3++;
}
if(RC6==1)

{while(RC6==1);
PORTB='*';
data();
arrs[p3]='3';
p3++;
}
if(RC7==1)
{
while(RC7==1);
32

PORTB='*';
data();
arrs[p3]='4';
p3++;
}
RC0=0;
RC1=1;
RC2=0;
RC3=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';
data();
arrs[p3]='5';
p3++;
}
if(RC5==1)
{while(RC5==1);
PORTB='*';
data();
arrs[p3]='6';
p3++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
33

arrs[p3]='7';
p3++;
}
if(RC7==1)
{while(RC7==1);
PORTB='*';
data();
arrs[p3]='8';
p3++;
}

RC2=1;
RC0=RC1=RC3=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';

data();
arrs[p3]='9';
p3++;
}
if(RC5==1)
{while(RC5==1);
PORTB='*';
data();
arrs[p3]='A';
p3++;
34

}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
arrs[p3]='B';
p3++;
}
if(RC7==1)
{while(RC7==1);
PORTB='*';
data();
arrs[p3]='C';
p3++;
}
RC3=1;
RC1=RC0=RC2=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';

data();
arrs[p3]='D';
p3++;
}
if(RC5==1)
{while(RC5==1);
35

PORTB='*';
data();
arrs[p3]='E';
p3++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
arrs[p3]='M';
p3++;
}
}

if(arrs[0]==check[0]&&arrs[1]==check[1]&&arrs[2]==check[2]&&arrs[3]==check[3])
{
PORTB=0X01;
command();
PORTB=0X80;
command();
for(int t=0;t<14;t++)
{

LCD=arr5[t];
data();
}
36

LCD=0XC0;
command();
while(p1<4)
{

RC0=1;
RC1=0;
RC2=0;
RC3=0;
if(RC4==1)
{
while(RC4==1);
PORTB='*';
data();
arr1[p1]='1';
p1++;
}
if(RC5==1)
{while(RC5==1);
PORTB='*';
data();
arr1[p1]='2';
p1++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
37

data();
arr1[p1]='3';
p1++;
}
if(RC7==1)
{
while(RC7==1);
PORTB='*';
data();
arr1[p1]='4';
p1++;
}
RC0=0;
RC1=1;
RC2=0;
RC3=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';
data();
arr1[p1]='5';
p1++;
}
if(RC5==1)
{while(RC5==1);
PORTB='*';
data();
38

arr1[p1]='6';
p1++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
arr1[p1]='7';
p1++;
}
if(RC7==1)
{while(RC7==1);
PORTB='*';
data();
arr1[p1]='8';
p1++;
}
RC2=1;
RC0=RC1=RC3=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';
data();
arr1[p1]='9';
p1++;
}
if(RC5==1)
39

{while(RC5==1);
PORTB='*';
data();
arr1[p1]='A';
p1++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
arr1[p1]='B';
p1++;
}
}
LCD=0X01;
command();
LCD=0X80;
command();
for(int o=0;o<16;o++)
{
LCD=arrt[o];
data();
}
LCD=0X01;
command();
LCD=0X80;
command();
40

for(int r=0;r<16;r++)
{
LCD=arr4[r];
data();
}
LCD=0Xc0;
command();
}
else
{
LCD=0X01;
command();
LCD=0X80;
command();
for(int x=0;x<9;x++)
{
PORTB=key1[x];
data();
}
delay(20000);
LCD=0X01;
command();
LCD=0X80;
command();
for(int r=0;r<16;r++)
{
LCD=arr4[r];
41

data();
}
LCD=0Xc0;
command();
}
}
void main()
{
ANSELH=0X00;
TRISC=0XF0;
TRISD=0X00;
PORTD=0X00;
TRISB=0X00;
LCD=0X38;
command();
LCD=0X01;
command();
LCD=0X0E;
command();
LCD=0X80;
command();

RD0=RD1=RD2=0;

for(int h=0;h<16;h++)
{
PORTB=arr6[h];
42

data();
delay(100);
}
LCD=0Xc0;
command();
for(int j=0;j<16;j++)
{
PORTB=arr8[j];
data();
delay(100);
}
delay(20000);
LCD=0X01;
command();
LCD=0X80;
command();
RD2=1;
while(1)
{
p=0;
LCD=0X80;
command();
for(int k=0;k<16;k++)
{
PORTB=arr4[k];
data();
}
43

LCD=0XC0;
command();
while(p<4)
{
RC0=1;
RC1=0;
RC2=0;
RC3=0;
if(RC4==1)
{
while(RC4==1);
PORTB='*';
data();
arr[p]='1';
p++;
}
if(RC5==1)
{while(RC5==1);
PORTB='*';
data();
arr[p]='2';
p++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
44

arr[p]='3';
p++;
}
if(RC7==1)
{
while(RC7==1);
PORTB='*';
data();
arr[p]='4';
p++;
}
RC0=0;
RC1=1;
RC2=0;
RC3=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';
data();
arr[p]='5';
p++;
}
if(RC5==1)
{while(RC5==1);
PORTB='*';
data();
arr[p]='6';
45

p++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
arr[p]='7';
p++;
}
if(RC7==1)
{while(RC7==1);
PORTB='*';
data();
arr[p]='8';
p++;
}
RC2=1;
RC0=RC1=RC3=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';
data();
arr[p]='9';
p++;
}
if(RC5==1)
{while(RC5==1);
46

PORTB='*';
data();
arr[p]='A';
p++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
arr[p]='B';
p++;
}
if(RC7==1)
{while(RC7==1);
PORTB='*';
data();
arr[p]='C';
p++;
}
RC3=1;
RC1=RC0=RC2=0;
if(RC4==1)
{while(RC4==1);
PORTB='*';
data();
arr[p]='D';
p++;
47

}
if(RC5==1)
{while(RC5==1);
PORTB='*';
data();
arr[p]='E';
p++;
}
if(RC6==1)
{while(RC6==1);
PORTB='*';
data();
arr[p]='M';
p++;
}
if(RC7==1)
{
while(RC7==1);
reset();
}
}
if(arr1[0]==arr[0]&&arr1[1]==arr[1]&&arr1[2]==arr[2]&&arr1[3]==arr[3])
{
RD0=1;
LCD=0X01;
command();
LCD=0X80;
48

command();
for(i=0;i<16;i++)
{
LCD=arr2[i];
data();
}
delay(20000);
RD0=0;
//break;
}
else
{
LCD=0X01;
command();
LCD=0X80;
command();
RD1=RD2=1;
for(i=0;i<16;i++)
{
LCD=arr3[i];
data();
}
delay(20000);
RD1=RD2=0;
//break;
}
}
49

3.7 APPLICATIONS
Banking
Home security
Confidential documents
Safe locking system
Radioactive labs

CHAPTER-4

4.1 Conclusion
The microcontroller with LCD makes it user friendly and can be embedded in a single unit. The circuit
has been implemented on bread board and tested for its.

4.2 Future Work


50

The project did well in performing its desired task. however, we can make the password entry remotely to
make the project more reliable.

51

REFERENCES

Microchips manual on PIC16f887A

Pic microcontroller and Embedded systems by Muhammad Ali Mazidi, Pearson International

www.google.co.in

www.migatron.com

en.wikipedia.org

www.Elecfreaks.com

52

Вам также может понравиться