0% found this document useful (0 votes)
5 views91 pages

BT - No.-15 Final Major Project (3406) - 1

The document presents a major project report on a Smart Home Control System using Bluetooth, submitted by students of Electronics and Communication Engineering for their Bachelor of Technology degree. It details the design and implementation of a low-cost, flexible, and secure home automation system that utilizes Bluetooth technology to control home appliances via a standalone ARM microcontroller. The report includes acknowledgments, declarations, an abstract, and a comprehensive index outlining the project's objectives, advantages, and applications of home automation systems.

Uploaded by

Naveen Samala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views91 pages

BT - No.-15 Final Major Project (3406) - 1

The document presents a major project report on a Smart Home Control System using Bluetooth, submitted by students of Electronics and Communication Engineering for their Bachelor of Technology degree. It details the design and implementation of a low-cost, flexible, and secure home automation system that utilizes Bluetooth technology to control home appliances via a standalone ARM microcontroller. The report includes acknowledgments, declarations, an abstract, and a comprehensive index outlining the project's objectives, advantages, and applications of home automation systems.

Uploaded by

Naveen Samala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 91

A major project report

on

SMART HOME CONTROL SYSTEM USING BLUETOOTH


submitted in partial fulfillment of the requirement for the award of degree of
BACHELOR OF TECHNOLOGY
in
ELECTRONICS AND COMMUNICATION ENGINEERING

by
S. Naveen (16C41A0441)
S. Prathyusha (16C41A0420)
V. Vamshi Sai (16C41A0419)
S. Krishna (16C41A0430)
T. Dileep Kumar (16C41A0438)

Under the Guidance of


Mr. N. Sukumar
Assistant Professor

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

JAYAMUKHI INSTITUTE OF TECHNOLOGICAL SCIENCES


(Permanently Affiliated to JNTUH, Accredited By NBA, UGC- AUTONOMOUS)
Narsampet, Warangal (R)-506 332(Telangana).
2019-2020

i
JAYAMUKHI INSTITUTE OF TECHNOLOGICAL SCIENCES
(Permanently Affiliated to JNTUH, Accredited By NBA, UGC- AUTONOMOUS)
Narsampet, Warangal (R)-506 332(Telangana).

CERTIFICATE

This is to certify that the Major project report entitled “SMART HOME CONTROL

SYSTEM USING BLUETOOTH ” is bonafide work of students S. Naveen (16C41A0441),

S. Prathyusha (16C41A0420), V. Vamshi Sai (16C41A0419), S. Krishna (16C45A0430),

T. Dileep Kumar (16C41A0438) for the award of the degree of Bachelor of Technology in

Electronics and Communication Engineering during the academic year 2019-2020.

Guide Head of the Dept. Principal


Mr. N. Sukumar Mr. Md. Hameed Pasha Prof. M. Lokanadha Rao

ii
ACKNOWLEDGEMENT

 I write this acknowledgement with great honor, pride and pleasure to pay our gratitude to all
who enabled us either directly or indirectly in reaching this stage.
 I express our immense gratitude to Prof. P. RANGAIAH, Director of Jayamukhi Institute of
Technological Sciences, Narsampet, Warangal, for his constant and gracious guidance
throughout the work.
 I express our immense gratitude to Prof. M. LOKANADHA RAO, Principal, Jayamukhi
Institute of Technological Sciences, Narsampet, Warangal, for his guidance and kind co-
operation.
 I express our gratitude to Mr. G. SATHAIAH, Professor Dean Academics Jayamukhi
Institute of Technological Sciences for his constant motivation and support.
 I would like to thanks to Mr. MD. HAMEED PASHA, Head of the Department of
ELECTRONICS AND COMMUNICATION ENGINEERING for his constant motivation and
support.
 I grateful to our graduate and sincere thanks to Mr. N. SUKUMAR, Guide, Assistant
Professor for his valuable guidance and giving us the opportunity to do our work in a better
manner.
 Last but not least we wish to thank our parents and friends, for their understanding and
cooperation. Without those encouragement and blessings, it would not have been possible to
complete this work.

Yours faithfully

S. Naveen (16C41A0441)
S. Prathyusha (16C41A0420)
V. Vamshi Sai (16C41A0419)
S. Krishna (16C41A0430)
T. Dileep Kumar (16C41A0438)

iii
DECLARATION

I do here by declare that the major project work titled by “SMART HOME

CONTROL SYSTEM USING BLUETOOTH” submitted by us to the Jayamukhi

Autonomous in a partial fulfillment of the requirement for the award of Bachelor of

Technology in Electronics & Communication Engineering is my original work. The

analysis, design and implementation of this project are done by me and my batch mates,

and it has not submitted anywhere else for the award of degree.

S.Naveen (16C41A0441)
V.Vamshi Sai (16C41A0419)
S.Prathyusha (16C41A0420)
S.Krishna (16C41A0430)
T.Dileep Kumar (16C41A0438)

Date: Place:

iv
ABSTRACT

Technology is a never ending process. To be able to design a product using the current
technology that will be beneficial to the lives of others is a huge contribution to the
community. This project presents the design and implementation of a low cost but yet
flexible and secure cell phone based home automation system. The design is based on a
standalone ARM Microcontroller and the home appliances are connected to the input/
output ports of this controller via relays. The communication between the cell phone and
the Controller is wireless i.e. Bluetooth. This system is designed to be low cost and
scalable allowing variety of devices to be controlled with minimum changes to its core.

v
LIST OF FIGURES

Figure no. Name of the figure Page no.

2.4.2 Block diagram 9

3.2 Block diagram of LPC 2148 14

3.3 Pin configuration of LPC 2148 15

3.5.1 Light Emitting Diode 25

3.5.2 Interfacing of micro controller 27

3.5.3 Electrical Transformer 28

3.5.4 A three terminal voltage regulator 30

3.6.1 Bluetooth module HC-05 32

3.6.2 Pin configuration HC-05 33

vi
3.6.3 How to use Bluetooth module 36

3.7.1 Sample hardware installation & source code 38

3.7.2 Pin out & Entering AT command 41

3.7.3 Pin is not presented or not connected 42

5.1 Schematic Diagram 64

vii
ABBREVIATIONS

Symbol Name
ACC Accumulator
B B register
PSW Program status word
SP Stack pointer
DPTR Data pointer 2 bytes
DPL Low byte
DPH High byte
P0 Port0
P1 Port1
P2 Port2
P3 Port3
IP Interrupt priority control
IE Interrupt enable control
TMOD Timer/counter mode control
TCON Timer/counter control
T2CON Timer/counter 2 control
T2MOD Timer/counter mode2 control
TH0 Timer/counter 0high byte
TL0 Timer/counter 0 low byte
TH1 Timer/counter 1 high byte
TL1 Timer/counter 1 low byte
TH2 Timer/counter 2 high byte
TL2 Timer/counter 2 low byte
SCON Serial control
SBUF Serial data buffer
PCON Power control

viii
INDEX

CONTENTS:

CHAPTER-1:
1.1 Introduction to embedded system.…………………………….…1
1.1.1 Examples of embedded system ...………………………….....…2
1.2 Home Automation………..………………………………….…….2
1.2.1 Advantages of home automation systems………………….…...3
1.2.2 Applications of home automation………………………....……3

CHAPTER-2:
2.1 Objective of Problem……………………………………………...4
2.2 Literacy survey...…………………………………………………..4
2.3 Exsisting System…………………………………………………...8
2.4 Proposed System…………………………………………………...9
I. Block diagram……………………………………………….....9
II. Block diagram description…………………………………….10

(a) power supply……………………………………………….10


(b) microcontroller………………………………………….....10
(c) LCD display section…………………………………..……10
(d) Relay……………………………………………………......10
(e) Wi-fi module………………………………………….….....10

CHAPTER-3:
3.1 Hardware components……………………………………………..11
3.1.1 General Description of LPC2148………………………………..11
3.1.2 Features of LPC 2148…………………………………………….13
3 .2 Block Diagram……………………………………………………..14
3.3 Pin configuration…………………………………………………...15
3.4 Pin Description………………………………………………………16
3.5 Light emitting diodes………………………………………….........24
3.6 Bluetooth module overview…………………..……………….........31
3.7 Sample hardware installation and source code……………….......37

ix
CHAPTER-4:
4.1 Software description…………………………………………….....48
4.2 Software components………………………………………….…...55

CHAPTER-5:
5.1 Schematic …………………………………………………………..64
5.2 Schematic description………………………………………….......65
5.3 Advantages of home Automation…………………………………66
5.4 Disadvantages of home Automation………………………………66
5.5 Applications of home Automation………………………………...67

Appendix
Code …………………………………………………………..........68
Conclusion and Future scope.……………………………….........77
References……………………………………………………..........78

x
CHAPTER - 1
INTRODUCTION

1.1 INTRODUCTION TO EMBEDDED SYSTEM:


An embedded system is a special-purpose system in which the computer is
completely encapsulated by or dedicated to the device or system it controls. Unlike a
general-purpose computer, such as a personal computer, an embedded system performs
one or a few predefined tasks, usually with very specific requirements. Since the system
is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost
of the product. Embedded systems are often mass-produced, benefiting from economies
of scale.

Personal Digital Assistants (PDAs) or handheld computers are generally


considered embedded devices because of the nature of their hardware design, even
though they are more expandable in software terms. This line of definition continues to
blur as devices expand. With the introduction of the OQO Model 2 with the Windows XP
operating system and ports such as a

Fig 1.1
USB port — both features usually belong to "general purpose computers", — the
line of nomenclature blurs even more.

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.

1
In terms of complexity embedded systems can range from very simple with a
single microcontroller chip, to very complex with multiple units, peripherals and
networks mounted inside a large chassis or enclosure.

1.1.1 Examples of Embedded Systems:

 Avionics, such as inertial guidance systems, flight control hardware/software and


other integrated systems in aircraft and missiles
 Cellular telephones and telephone switches
 Engine controllers and antilock brake controllers for automobiles
 Home automation products, such as thermostats, air conditioners, sprinklers, and
security monitoring systems
 Handheld calculators
 Handheld computers
 Household appliances, including microwave ovens, washing machines, television
sets, DVD players and recorders
 Medical equipment
 Personal digital assistant
 Videogame consoles
 Computer peripherals such as routers and printers.
 Industrial controllers for remote machine operation.

1.2 Home Automation:


“Home automation” refers to the automatic and electronic control of
household features, activity, and appliances. In simple terms, it means you can easily
control the utilities and features of your home via Wireless Technology to make life
more convenient and secure, and even spend less on household bills. Home automation is
a network of hardware, communication, and electronic interfaces that work to integrate
everyday devices with one another via the Wireless Technology. Each device has sensors
and is we can manage them from your Smartphone or tablet whether you’re at home, or
miles away. This allows you to turn on the lights, lock the front door, or even turn down
the heat, no matter where you are.

2
1.2.1 Advantages of Home automation systems:
In recent years, wireless systems have become more and more common in-home
networking. Also, in home and building automation systems, the use of wireless
technologies gives several advantages that could not be achieved using a wired network
only.
a) Reduced installation costs: First and foremost, installation costs are significantly
reduced since no cabling is necessary. Wired solutions require cabling, where material as
well as the professional laying of cables (e.g. into walls) is expensive.
b) System scalability and easy extension: Deploying a wireless network is especially
advantageous when, due to new or changed requirements, extension of the network is
necessary. In contrast to wired installations, in which cabling extension is tedious. This
makes wireless installations a seminal investment.
c) Aesthetical benefits: Apart from covering a larger area, this attribute helps to full
aesthetical requirements as well. Examples include representative buildings with all-
glass architecture and historical buildings where design or conservatory reasons do not
allow laying of cables.
d) Integration of mobile devices: With wireless networks, associating mobile devices
such as PDAs and Smartphones with the automation system becomes possible
everywhere and at any time, as a device's exact physical location is no longer crucial for
a connection (as long as the device is in reach of the network). For all these reasons,
wireless technology is not only an attractive choice in renovation and refurbishment, but
also for new installations.

1.2.2 Applications of Home Automation


Rebuilding consumer expectations, home automation has been projected to target wide
array applications for the new digital consumer. Some of the areas where consumers can
expect to see home automation led IoT-enabled connectivity are:
 Lighting control
 HVAC
 Lawn/Gardening management
 Smart Home Appliances
 Improved Home safety and security
 Home air quality and water quality monitoring

3
 Natural Language-based voice assistants
 Better Infotainment delivery

 AI-driven digital experiences

4
CHAPTER - 2

2.1 Objective of the Problem:


Home Automation is an upcoming technology that allows us to control hardware devices
through the Wireless Technology and simplify use of Technology. Here we propose to
use Bluetooth in order to control home appliances, those automatics modern homes
through the Wireless Technology (i.e. Bluetooth). The wireless Technology connects
Physical devices, vehicles, buildings, other items-Embedded with electronics, Software,
Sensors, actuators and network connectivity that enable these objects to collect and
exchange data.

2.2 Literacy survey:


There are different Home Automation System with their technology with features,
benefit and limitations they have. “The Figure 1” shows Basic Architecture of Remote
Home Automation.

Device, Things or Machine Central Controller


Sensor

Check
Status

User Interface Controlling

System

Via Ethernet,
Bluetooth, GSM, Wi-Fi

Fig 2.2.1
The Home automation system that uses Wi-Fi technology. System consists of three main
components; web server, which presents system core that controls, and monitors users’
home and hardware interface module (Arduino PCB (ready-made), Wi-Fi shield PCB, 3

5
input alarms PCB, and 3 output actuators PCB.), which provides appropriate interface to
sensors and actuator of home automation system. The System is better from the
scalability and flexibility point of view than the commercially available home automation
systems. The User may use the same technology to login to the server web-based
application. If server is connected to the internet, so remote users can access server web-
based application through the internet using compatible web browser. The application
has been developed based on the android system. An interface card has been developed
to assure communication between the remote user, server, raspberry pi card and the home
Appliances. The application has been installed on an android Smartphone, a web server,
and a raspberry pi card to control the shutter of windows. Android application on a
smartphone issue command to raspberry pi card. An interface card has been realized to
update signals between the actuator sensors and the raspberry pi card. Cloud-based home
appliance monitoring and controlling System. Design and implement a home gateway to
collect metadata from home appliances and send to the cloud-based data server to store
on HDFS (Hadoop Distributed File System), process them using MapReduce and use to
provide a monitoring function to Remote user. It has been implemented with Raspberry
Pi through reading the subject of E-mail and the algorithm. Raspberry Pi proves to be a
powerful, economic and efficient platform for implementing the smart home automation.
Raspberry pi based home automation is better than other home automation methods is
several ways. For example, in home automation through DTMF (dual tone multi-
frequency), the call tariff is a huge disadvantage, which is not the case in their proposed
method. Also, in Web server-based home automation, the design of web server and the
memory space required is ejected by this method, because it simply uses the already
existing web server service provided by G-mail. LEDs were used to indicate the
switching action. System is interactive, efficient and flexible. Shih-Pang Tseng et al.
proposed Smart House Monitor & Manager (SHMM), based on the ZigBee, all sensors
and actuators are connected by a ZigBee wireless network. They designed a simple smart
socket, which can remote control via ZigBee. PC host is used as a data collector and the
motion sensing, all sensing data are transferred to the VM in the cloud. The user can use
the PC or Android phone to monitor or control through the Internet to power-saving of
the house. Arduino microcontroller to receive user commands to execute through an
Ethernet shield. Our house network used together both wireless ZigBee and wired X10
technologies. This system followed smart task scheduling with a heuristic for the
Resource-constrained-scheduling problem (RCPSP). The mobile device can be either

6
wired to the central controller through USB cable or communicates with it wirelessly,
within the scope of the home. Arduino contains the web server application that
communicates through the HTTP protocol with Web-based Android application. The
system is highly flexible and scalable and expandable. The home network which
monitors the appliances and sensors and transmits data to the cloud-based data server
which manages the information and provides services for users by transmitting data and
receiving user commands from mobile application. The proposed system has good
modularity and configurability characteristics with very low power consumption in cost
efficient way. Application developed using the Android platform controlled and
monitored from a remote location using the smart home app and an Arduino Ethernet
based micro web-server. The sensors and actuators/relays are directly interfaced to the
main controller. Proposed design offers are the control of energy management systems
such as lightings, heating, air conditioning, security, fire detection and intrusion detection
with siren and email notifications. Embedded system Raspberry Pi to serve as a
communication gateway between mobile devices and Konnex-Bus (KNX) home
automation systems. Store the information of all actors and sensors within a Smart
Home, instead of using separate profiles. Ensures energy-consumption could be reduced,
compared to a standard desktop computer. Dual tone multi frequency (DTMF) used in
telephone lines. There are three components in the system DTMF receiver and ring
detector, IO interface unit, PC. The PC detects the ringing of the line and then
authenticates the user and use the keypad tones to control the devices as required. An
example of stepper motor control is taken up. This system has the advantage of being
secure and allowing international standardization. This is because the DTMF tones are
the same all over the world. But it suffers from the drawback that the number of
appliances is limited by the number of keys in the keypad. PIC16F887 microcontroller
for home appliances controls with GSM for control of the appliances. It has high
availability, coverage and security but the cost of SMS. AT commands can be sent
through the GSM network to controls the home devices. The system does not does not
have any state information related to the devices and expects the user to keep track of it.
Arduino board is the controller used to control the appliances by using GSM technology.
It uses certain peripheral drivers and relays to achieve this interfacing. The application on
smartphone generates SMS messages based on the user commands and sends it to the
GSM modem attached to the Arduino and control the home appliances. The system has
drawbacks of cost and reliability of SMS. An interface cannot be customized based on

7
devices. It has been designed Arduino board with Bluetooth board were developed for
home automation. Python program is used on the cell phone to provide the user interface.
The Bluetooth board has I/O ports and relays are used for interfacing with the devices
which are to be controlled and monitor. The Bluetooth is password protected to ensure
that the system is secure from intruders. The Bluetooth has a range of 10 to 100m.

Different Home Automation Systems:

 Bluetooth based home automation system using cell phones:

The smart home concept in the system increases the standard of living. In Bluetooth
based home automation system the home appliances are connected to the Arduino BT
board at input output ports using relay. The program of Arduino BT board is based on
high level interactive C language of microcontrollers; the connection is made via
Bluetooth. The password protection is provided so only authorized user is allowed to
access the appliances. The Bluetooth connection is established between Arduino BT
board and phone for wireless communication. The main control system uses wireless
Bluetooth technology to give remote access from PC/laptop or smart phone.

 Zigbee based home automation system using cell phones:

ZigBee is a low-power digital radio having applications like home automation, medical
device data collection, and other low-power low-bandwidth needs, designed for small
scale projects which need wireless connection. To monitor and control the home
appliances the system is designed and implemented using Zigbee. The device
performance is record and store by network coordinators. The message for security
purpose first process by the virtual home algorithm and when it is declared safe it is re-
encrypted and forward to the real network device of the home. Over Zigbee network,
Zigbee controller sent messages to the end. The safety and security of all messages that
are received by the virtual home algorithm. To reduce the expense of the system and the
intrusiveness of respective installation of the system Zigbee communication is helpful.
The microcontroller analysis all signal and convert them into command to understand by
GSM module.
.

8
 Wi-Fi based home automation system using cell phones:
Wi-Fi based home automation system mainly consist three modules, the server, the
hardware interface module, and the software package. Wi-Fi technology is used by
server, and hardware Interface module to communicate with each other. The same
technology uses to login to the server web-based application. The server is connected to
the internet, so remote users can access server web-based application through the internet
using compatible web browser. Software of the latest home automation system is split to
server application software, and Microcontroller (Arduino) firmware. The Arduino
software, built using C language, using IDE comes with the microcontroller itself.
Arduino software is culpable for gathering events from connected sensors, then applies
action to actuators and pre-programmed in the server. Server application software is
culpable of maintaining the whole home automation system, setup, and configuration.

 Home automation using Android ADK:


The devices of home are associate to the ADK and the Connection is established
between the Android device and ADK. The devices of house are link to the input/output
ports of the board and their current situation will have passed to the ADK. The micro
controller board based on the ATmega2560. It has a USB host connection to associate
with Android based phones. The two important features of Android Open Accessory
Protocol are as follows: It has audio output that is from the Android device to the
component and it also support for the component serves as one or more Human Interface
Devices to the Android device.
 GSM Based Home Automation System:
This system presents a completely unique, stand alone, cheap and versatile GSM based
home automation system. This device is connected to a ZigBee Transceiver and it
communicates with
every and each node gift within our home. The GSM Controller facilitate for the
information follow between user and microcontroller. The GSM Controller uses
portable technology to speak. From the portable, command will be sent via SMS to the
Controller that successively interprets the command so activates the specified switch to
regulate the electrical item. As long as there is GSM portable signal coverage, it's
attainable to regulate all electrical things from anyplace within the world. The system is
straightforward to work, and is secure in this solely pre-determined mobile numbers

9
will operate the GSM Controller. The installation of the GSM Controller is
comparatively straight forward and may be tailored for any existing home system.
Management of lights and geyser area unit done via the electrical distribution board.

2.3 Existing Systems:


The IoT systems are of different types based on the user requirements there are many
types of IoT Home Automation Systems exist now-a-days. These systems help the user
to control the home appliances from any places. Which reduces the human effort and
Power consumption in the Home. The ability to control small appliances and lighting
with your fingertips anywhere you are will add safety in your home. You can make sure
appliances are off when its needed to be off and on when its needed to be on. The ability
to lock the door through your phone is one of the greatest benefits of home automation.
This will give you peace of mind knowing that the door is close and not guessing. The
fact that you can be alerted each time someone enters your home also allows you to
monitor who is entering your home at all times, especially when you are not there. The
ability to control everything with your fingertips is very convenient. You never leave the
house without your wallet, keys and your smart phone. With our smart phone always
with us, we can easily monitor our home and control everything with just touch of a
finger. Since we are living in a very fast-paced environment, we don’t even have time to
worry about our home. With home automation, we can save time going back to our
home and make sure everything is order, like if the kids close the door from school or
turn on the lights when you get home. This is the biggest advantage of home automation.
With the ability to control the light, whether dimming or turning on/off on specific time
will saves homeowner a great ton of money. You can save money through household
temperature, with proper automation in window shades and automated thermostat. In
addition, you can save gas, by not driving back home if you forgot to turn off appliances
or lock the door. The Existing IoT systems are very compatible and huge in Size. The
Present Systems are not economical to install in homes. They cost more to get installed in
our homes and the efficiency of the system is not up to the mark.

10
2.4 Proposed system:
I. Block diagram:

LCD

POWER SUPPLY

RELAY 1
MICRO
CONTROLLER
(ARM
LPC2148) RELAY 2

Bluetooth
Module
RELAY 3

RELAY 4

Figure 2.4.2
II. Block Diagram Description:

The Block diagram consists of a Bluetooth Module, a micro controller, an LCD


Display, Relay and power supply, LED. These hardware components will be discussed
briefly as follows:

a) Power Supply:

This section is meant for supplying Power to all the sections mentioned above. It
basically consists of a Transformer to step down the 230V ac to 9V ac followed by
diodes. Here diodes are used to rectify the ac to dc. After rectification the obtained

11
rippled dc is filtered using a capacitor Filter. A positive voltage regulator is used to
regulate the obtained dc voltage.

b) Microcontroller:

This section forms the control unit of the whole project. This section basically
consists of a Microcontroller with its associated circuitry like Crystal with capacitors,
reset circuitry, pull up resistors (if needed) and so on. The Microcontroller forms the
heart of the project because it controls the devices being interfaced and communicates
with the devices according to the program being written.

c) LCD Display Section:

This section is basically meant to show up the status of the project. This project
makes use of Liquid Crystal Display to display / prompt for necessary information

d) Relay:

A relay is an electrically operated switch. Many relays use an electromagnet to


mechanically operate a switch, but other operating principles are also used, such as solid-
state relays. Relays are used where it is necessary to control a circuit by a separate low-
power signal, or where several circuits must be controlled by one signal.

e) Bluetooth Module:

A Bluetooth module is usually a hardware component that provides


a wireless product to work with the computer; or in some cases, the
Bluetooth may be an accessory or peripheral, or a wireless headphone
or other product (such as cell phones can use.)

12
CHAPTER-3

3.1HARDWARE COMPONENTS:

3.1.1 General description of LPC 2148:


The LPC2148 microcontrollers is based on a 32-bit ARM7TDMI-S CPU
with real-time emulation and embedded trace support, that combine microcontrollers
with embedded high-speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide
memory interface and unique accelerator architecture enable 32-bit code execution at the
maximum clock rate. For critical code size applications, the alternative 16-bit Thumb
mode reduces code by more than 30 % with minimal performance penalty.

Due to their tiny size and low power consumption, LPC2141/42/44/46/48 are
ideal for applications where miniaturization is a key requirement, such as access control
and point-of-sale. Serial communications interfaces ranging from a USB 2.0 Full-speed
device, multiple UARTs, SPI, SSP to I2C-bus and on-chip SRAM of 8 kB up to 40 kB,
make these devices very well suited for communication gateways and protocol
converters, soft modems, voice recognition and low end imaging, providing both large
buffer size and high processing power. Various 32-bit timers, single or dual 10-bit ADCs,
10-bit DAC, PWM channels and 45 fast GPIO lines with up to nine edge or level
sensitive external interrupt pins make these microcontrollers suitable for industrial
control and medical systems.

General overview of in system programming (ISP):

In-System Programming (ISP) is a process whereby a blank device mounted to a circuit


board can be programmed with the end-user code without the need to remove the device
from the circuit board. Also, a previously programmed device can be erased and Re
programmed without removal from the circuit board. In order to perform ISP operations
the microcontroller is powered up in a special “ISP mode”. ISP mode allows the
microcontroller to communicate with an external host device through the serial port, such

13
as a PC or terminal. The microcontroller receives commands and data from the host,
erases and reprograms code memory, etc. Once the ISP operations have been completed
the device is reconfigured so that it will operate normally the next time it is either reset or
power removed and reapplied. All of the Philips microcontrollers shown in Table 1 and
Table 2 have a 1 kbyte factory-masked ROM located in the upper 1 kbyte of code
memory space from FC00 to FFFF. This 1 kbyte ROM is in addition to the memory
blocks shown in Table 1 and Table 2. This ROM is referred to as the “Bootrom”. This
Bootrom contains a set of instructions which allows the microcontroller to perform a
number of Flash programming and erasing functions. The Bootrom also provides
communications through the serial port. The use of the Bootrom is key to the concepts of
both ISP and In-Application Programming (IAP). The contents of the bootrom are
provided by Philips and masked into every device. When the device is reset or power
applied, and the EA/ pin is high or at the VPP voltage, the microcontroller will start
executing instructions from either the user code memory space at address 0000h
(“normal mode”) or will execute instructions from the Bootrom (ISP mode).

General Overview of IN APPLICATION PROGRAMMING:

Some applications may have a need to be able to erase and program code memory under
the control fo the application. For example, an application may have a need to store
calibration information or perhaps need to be able to download new code portions. This
ability to erase and program code memory in the end-user application is “In-Application
Programming” (IAP). The Bootrom routines which perform functions on the Flash
memory during ISP mode such as programming, erasing, and reading, are also available
to end-user programs. Thus it is possible for an end-user application to perform
operations on the Flash memory. A common entry point (FFF0h) to these routines has
been provided to simplify interfacing to the end-users application. Functions are
performed by setting up specific registers as required by a specific operation and
performing a call to the common entry point. Like any other subroutine call, after
completion of the function, control will return to the end-user’s code. The Bootrom is
shadowed with the user code memory in the address range from FC00h to FFFFh. This
shadowing is controlled by the ENBOOT bit (AUXR1.5). When set, accesses to internal
code memory in this address range will be from the boot ROM. When cleared, accesses
will be from the user’s code memory. It will be NECESSARY for the end-user’s code to

14
set the ENBOOT bit prior to calling the common entry point for IAP operations, even for
devices with 16 kbyte, 32 kbyte, and 64 kbyte of internal code memory. (ISP operation is
selected by certain hardware conditions and control of the ENBOOT bit is automatic
when ISP mode is activated).

FEATURES OF LPC2148(ARM7) ARCHITECTURE:

Key features:

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


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

15
 Up to 21 external interrupt pins available
 60 MHz maximum CPU clock available from programmable on-chip PLL with
settling
time of 100 ms
 On-chip integrated oscillator operates with an external crystal from 1 MHz to 25
MHz
 Power saving modes include Idle and Power-down
 Individual enable/disable of peripheral functions as well as peripheral clock
scaling for additional power optimization
 Processor wake-up from Power-down mode via external interrupt or BOD
 Single power supply chip with POR and BOD circuits:
CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant I/O
pads.

16
3.2 BLOCK DIAGRAM:

Fig.3.2 Block diagram of LPC 2148

17
3.3 PIN CONFIGURATION:

Fig.3.3 Pin configuration of LPC 2148

18
3.4 Pin Description:

P0.0 to P0.31 I/O Port 0: Port 0 is a 32-bit I/O port with individual direction controls for
each bit. Total of 31 pins of the Port 0 can be used as a general purpose bidirectional
digital I/Os while P0.31 is output only pin. The operation of port 0 pins depends upon the
pin function selected via the pin connect block.

P0.0/TXD0/PWM1:

P0.0 — General purpose input/output digital pin (GPIO)


TXD0 — Transmitter output for UART0
PWM1 — Pulse Width Modulator output 1

P0.1/RXD0/PWM3/EINT0:

P0.1 — General purpose input/output digital pin (GPIO)


RXD0 — Receiver input for UART0
PWM3 — Pulse Width Modulator output 3
EINT0 — External interrupt 0 input

P0.2/SCL0/ CAP0.0:
P0.2 — General purpose input/output digital pin (GPIO)
SCL0 — I2C0 clock input/output, open-drain output (for I2C-bus compliance)
CAP0.0 — Capture input for Timer 0, channel 0
P0.3/SDA0/ MAT0.0/EINT1:
P0.3 — General purpose input/output digital pin (GPIO)
SDA0 — I2C0 data input/output, open-drain output (for I2C-bus compliance)
MAT0.0 — Match output for Timer 0, channel 0
EINT1 — External interrupt 1 input

P0.4/SCK0/ CAP0.1/AD0.6

19
P0.4 — General purpose input/output digital pin (GPIO)
SCK0 — Serial clock for SPI0, SPI clock output from master or input to slave
CAP0.1 — Capture input for Timer 0, channel 0
AD0.6 — ADC 0, input 6.

P0.5/MISO0/ MAT0.1/AD0.7
P0.5 — General purpose input/output digital pin (GPIO)
MISO0 — Master In Slave OUT for SPI0, data input to SPI master or data output from
SPI slave.
MAT0.1 — Match output for Timer 0, channel 1
AD0.7 — ADC 0, input 7

P0.6/MOSI0/ CAP0.2/AD1.0
P0.6 — General purpose input/output digital pin (GPIO)
MOSI0 — Master out Slave In for SPI0, data output from SPI master or data
Input to SPI slave
CAP0.2 — Capture input for Timer 0, channel 2
AD1.0 — ADC 1, input 0, available in LPC2144/46/48 only

P0.7/SSEL0/PWM2/EINT2
P0.7 — General purpose input/output digital pin (GPIO)
SSEL0 — Slave Select for SPI0, selects the SPI interface as a slave
PWM2 — Pulse Width Modulator output 2
EINT2 — External interrupt 2 input

P0.8/TXD1/PWM4/AD1.1
P0.8 — General purpose input/output digital pin (GPIO)
TXD1 — Transmitter output for UART1
PWM4 — Pulse Width Modulator output 4
AD1.1 — ADC 1, input 1, available in LPC2144/46/48 only

P0.9/RXD1/ PWM6/EINT3:
P0.9 — General purpose input/output digital pin (GPIO)
RXD1 — Receiver input for UART1

20
PWM6 — Pulse Width Modulator output 6
EINT3 — External interrupt 3 input

P0.10/RTS1/ CAP1.0/AD1.2:
P0.10 — General purpose input/output digital pin (GPIO)
RTS1 — Request to send output for UART1, LPC2144/46/48 only
CAP1.0 — Capture input for Timer 1, channel 0
AD1.2 — ADC 1, input 2, available in LPC2144/46/48 only

P0.11/CTS1/ CAP1.1/SCL1:
P0.11 — General purpose input/output digital pin (GPIO)
CTS1 — Clear to send input for UART1, available in LPC2144/46/48 only
CAP1.1 — Capture input for Timer 1, channel 1
SCL1 — I2C1 clock input/output, open-drain output (for I2C-bus compliance)

P0.12/DSR1/MAT1.0/AD1.3:
P0.12 — General purpose input/output digital pin (GPIO)
DSR1 — Data Set Ready input for UART1, available in LPC2144/46/48 only
MAT1.0 — Match output for Timer 1, channel 0
AD1.3 — ADC input 3, available in LPC2144/46/48 only

P0.13/DTR1/ MAT1.1/AD1.4:
P0.13 — General purpose input/output digital pin (GPIO)
DTR1 — Data Terminal Ready output for UART1, LPC2144/46/48 only
MAT1.1 — Match output for Timer 1, channel 1
AD1.4 — ADC input 4, available in LPC2144/46/48 only

P0.14/DCD1/EINT1/SDA1:
P0.14 — General purpose input/output digital pin (GPIO)
DCD1 — Data Carrier Detect input for UART1, LPC2144/46/48 only
EINT1 — External interrupt 1 input
SDA1 — I2C1 data input/output, open-drain output (for I2C-bus compliance LOW on
this pin while RESET is LOW forces on-chip boot loader to take over control of the part
after reset

21
P0.15/RI1/ EINT2/AD1.5:
P0.15 — General purpose input/output digital pin (GPIO)
RI1 — Ring Indicator input for UART1, available in LPC2144/46/48 only
EINT2 — External interrupt 2 input
AD1.5 — ADC 1, input 5, available in LPC2144/46/48 only

P0.16/EINT0/MAT0.2/CAP0.2:
P0.16 — General purpose input/output digital pin (GPIO)
EINT0 — External interrupt 0 input
MAT0.2 — Match output for Timer 0, channel 2
CAP0.2 — Capture input for Timer 0, channel 2

P0.17/CAP1.2/ SCK1/MAT1.2:
P0.17 — General purpose input/output digital pin (GPIO)
CAP1.2 — Capture input for Timer 1, channel 2
SCK1 — Serial Clock for SSP, clock output from master or input to slave
MAT1.2 — Match output for Timer 1, channel 2

P0.18/CAP1.3/MISO1/MAT1.3:
P0.18 — General purpose input/output digital pin (GPIO)
CAP1.3 — Capture input for Timer 1, channel 3
MISO1 — Master In Slave Out for SSP, data input to SPI master or data output from
SSP slave
MAT1.3 — Match output for Timer 1, channel 3

P0.19/MAT1.2/MOSI1/CAP1.2:
P0.19 — General purpose input/output digital pin (GPIO)
MAT1.2 — Match output for Timer 1, channel 2
MOSI1 — Master out Slave In for SSP, data output from SSP master or data Input to
SSP slave
CAP1.2 — Capture input for Timer 1, channel 2

P0.20/MAT1.3/SSEL1/EINT3:
P0.20 — General purpose input/output digital pin (GPIO)

22
MAT1.3 — Match output for Timer 1, channel 3
SSEL1 — Slave Select for SSP, selects the SSP interface as a slave
P0.21/PWM5/AD1.6/CAP1.3:
P0.21 — General purpose input/output digital pin (GPIO)
PWM5 — Pulse Width Modulator output 5
AD1.6 — ADC 1, input 6, available in LPC2144/46/48 only
CAP1.3 — Capture input for Timer 1, channel 3

P0.22/AD1.7/CAP0.0/MAT0.0:
P0.22 — General purpose input/output digital pin (GPIO)
AD1.7 — ADC 1, input 7, available in LPC2144/46/48 only
CAP0.0 — Capture input for Timer 0, channel 0
MAT0.0 — Match output for Timer 0, channel 0

P0.23/VBUS:
P0.23 — General purpose input/output digital pin (GPIO)
VBUS — Indicates the presence of USB bus power
This signal must be HIGH for USB reset to occur

P0.25/AD0.4/AOUT:
P0.25 — General purpose input/output digital pin (GPIO)
AD0.4 — ADC 0, input 4
AOUT — DAC output, available in LPC2142/44/46/48 only

P0.28/AD0.1/CAP0.2/MAT0.2:
P0.28 — General purpose input/output digital pin (GPIO)
AD0.1 — ADC 0, input 1
CAP0.2 — Capture input for Timer 0, channel 2
MAT0.2 — Match output for Timer 0, channel 2

P0.29/AD0.2/CAP0.3/MAT0.3:
P0.29 — General purpose input/output digital pin (GPIO)
AD0.2 — ADC 0, input 2
CAP0.3 — Capture input for Timer 0, Channel 3

23
MAT0.3 — Match output for Timer 0, channel 3

P0.30/AD0.3/EINT3/CAP0.0:
P0.30 — General purpose input/output digital pin (GPIO)
AD0.3 — ADC 0, input 3
EINT3 — External interrupt 3 input
CAP0.0 — Capture input for Timer 0, channel 0

P0.31/UP_LED/CONNECT
P0.31 — General purpose output only digital pin (GPO)
UP_LED — USB Good Link LED indicator, it is LOW when device is configured (non-
control endpoints enabled), it is HIGH when the device is not configured or during global
suspend
CONNECT — Signal used to switch an external 1.5 kohms resistor under the
Software control, used with the Soft Connect USB feature
Important: This is a digital output only pin, this pin MUST NOT be externally pulled
LOW when RESET pin is LOW or the JTAG port will be disabled P1.0 to P1.31 I/O
Port 1: Port 1 is a 32-bit bidirectional I/O port with individual direction controls for each
bit, the operation of port 1 pins depends upon the pin function selected via the pin
connect block, pins 0 through 15 of port 1 are not
Available.

P1.16/TRACEPKT0
P1.16 — General purpose input/output digital pin (GPIO)
TRACEPKT0 — Trace Packet, bit 0, standard I/O port with internal pull-up

P1.17/TRACEPKT1
P1.17 — General purpose input/output digital pin (GPIO)
TRACEPKT1 — Trace Packet, bit 1, standard I/O port with internal pull-up

P1.18/TRACEPKT2
P1.18 — General purpose input/output digital pin (GPIO)
TRACEPKT2 — Trace Packet, bit 2, standard I/O port with internal pull-up

24
P1.19/TRACEPKT3
P1.19 — General purpose input/output digital pin (GPIO)
TRACEPKT3 — Trace Packet, bit 3, standard I/O port with internal pull-up

P1.20/TRACESYNC
P1.20 — General purpose input/output digital pin (GPIO)
TRACESYNC — Trace Synchronization, standard I/O port with internal pull-up
Note: LOW on this pin while RESET is LOW enables pins P1.25:16 to operate as Trace
port after reset

P1.21/PIPESTAT0
P1.21 — General purpose input/output digital pin (GPIO)
PIPESTAT0 — Pipeline Status, bit 0, standard I/O port with internal pull-up

P1.22/PIPESTAT1
P1.22 — General purpose input/output digital pin (GPIO)
PIPESTAT1 — Pipeline Status, bit 1, standard I/O port with internal pull-up

P1.23/PIPESTAT2
P1.23 — General purpose input/output digital pin (GPIO)
PIPESTAT2 — Pipeline Status, bit 2, standard I/O port with internal pull-up

P1.24/TRACECLK
P1.24 — General purpose input/output digital pin (GPIO)
TRACECLK — Trace Clock, standard I/O port with internal pull-up

P1.25/EXTIN0
P1.25 — General purpose input/output digital pin (GPIO)
EXTIN0 — External Trigger Input, standard I/O with internal pull-up

P1.26/RTCK
P1.26 — General purpose input/output digital pin (GPIO)

25
RTCK — Returned Test Clock output, extra signal added to the JTAG port, assists
debugger synchronization when processor frequency varies, bidirectional pin with
internal pull-up
Note: LOW on RTCK while RESET is LOW enables pins P1.31:26 to operate a Debug
port after reset

P1.27/TDO
P1.27 — General purpose input/output digital pin (GPIO)
TDO — Test Data out for JTAG interface

P1.28/TDI
P1.28 — General purpose input/output digital pin (GPIO)
TDI — Test Data in for JTAG interface

P1.29/TCK
P1.29 — General purpose input/output digital pin (GPIO)
TCK — Test Clock for JTAG interface

P1.30/TMS
P1.30 — General purpose input/output digital pin (GPIO)
TMS — Test Mode Select for JTAG interface

P1.31/TRST
P1.31 — General purpose input/output digital pin (GPIO)
TRST — Test Reset for JTAG interface

D+: USB bidirectional D+ line


D- : USB bidirectional D- line

RESET External reset input: A LOW on this pin resets the device, causing I/O ports
and peripherals to take on their default states, and processor execution to begin at address
0, TTL with hysteretic, 5 V tolerant

XTAL1: Input to the oscillator circuit and internal clock generator circuits

26
XTAL2: Output from the oscillator amplifier
RTCX1: I Input to the RTC oscillator circuit
RTCX2: Output from the RTC oscillator circuit

VSS: 6, 18, 25, 42, 50 pins are for supply voltage.


Ground: 0 V reference.
VSSA Analog ground: 0 V reference, this should nominally be the same voltage as
VSS, but should be isolated to minimize noise and error

VDD 23, 43, 51 I 3.3 V power supply: This is the power supply voltage for the core and
I/O ports.

VDDA 7 I Analog 3.3 V power supply: This should be nominally the same voltage as
VDD but should be isolated to minimize noise and error, this voltage is only used to
power the on-chip ADC(s) and DAC

VREF ADC reference voltage: This should be nominally less than or equal to the
VDD voltage but should be isolated to minimize noise and error, level on this
Pin is used as a reference for ADC(s) and DAC

VBAT RTC power supply voltage: 3.3 V on this pin supplies the power to the RTC

3.5 LIGHT EMMTTING DIODES:


It is a semiconductor diode having radioactive recombination. It requires a definite
amount of energy to generate an electron-hole pair. The same energy is released when an
electron recombines with a hole. This released energy may result in the emission of
photon and such a recombination. Hear the amount of energy released when the electro
reverts from the conduction band to the valence band appears in the form of radiation.
Alternatively, the released energy may result in a series of phonons causing lattice
vibration. Finally, the released energy may be transferred to another electron. The
recombination radiation may be lie in the infra-red and visible light spectrum. In forward
is peaked around the band gap energy and the phenomenon is called injection
luminescence. I n a junction biased in the avalanche break down region, there results a

27
spectrum of photons carrying much higher energies. Almost White light then gets emitted
from micro-plasma breakdown region in silicon junction
The following are the merits of LEDs over conventional incandescent and other types of
lamps:
1. Low working voltages and currents
2. Less power consumption
3. Very fast action
4. Emission of monochromatic light
5. small size and weight
6. No effect of mechanical vibrations
7. Extremely long life
Typical LED uses a forward voltage of about 2V and current of 5 to 10mA.
GaAs LED produces infra-red light while red, green and orange lights are produced by
gallium arsenide phosphide (GaAs) and gallium phosphide (Gap).

a) Light Emitting Diodes (LEDs):

Example:

Fig 3. 5.1

Circuit symbol:

b) Function:

LEDs emit light when an electric current pass through them.

28
c) Liquid crystal display:

Liquid crystal displays (LCDs) have materials, which combine the properties of both
liquids and crystals. Rather than having a melting point, they have a temperature range
within which the molecules are almost as mobile as they would be in a liquid, but are
grouped together in an ordered form similar to a crystal. An LCD consists of two glass
panels, with the liquid crystal material sand witched in between them. The inner surface
of the glass plates are coated with transparent electrodes which define the character,
symbols or patterns to be displayed polymeric layers are present in between the
electrodes and the liquid crystal, which makes the liquid crystal molecules to maintain a
defined orientation angle. When the LCD is in the off state, light rays are rotated by the
two polarizers and the liquid crystal, such that the light rays come out of the LCD
without any orientation, and hence the LCD appears transparent.
The LCDs used exclusively in watches, calculators and measuring instruments are
the simple seven-segment displays, having a limited amount of numeric data. The
recent advances in technology have resulted in better legibility, more information
displaying capability and a wider temperature range.

d) LCD operation:
In recent years the LCD is finding widespread use replacing LEDs (seven-
segment LEDs or other multi segment LEDs). This is due to the following reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics. This is in contract to LEDs,
which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, there by relieving the CPU of
the task of refreshing the LCD. In the contrast, the LED must be refreshed by the CPU to
keep displaying the data Ease of programming

TABLE 1: Pin description for LCD

Pin Symbol I/O Description

1 Vss -- Ground

29
2 Vcc -- +5V power supply

3 VEE -- Power supply to


control contrast

4 RS I RS=0 to select
command register
RS=1 to select
data register

5 R/W I R/W=0 for write


R/W=1 for read

6 E I/O Enable

7 DB0 I/O The 8-bit data bus

8 DB1 I/O The 8-bit data bus

9 DB2 I/O The 8-bit data bus

10 DB3 I/O The 8-bit data bus

11 DB4 I/O The 8-bit data bus

12 DB5 I/O The 8-bit data bus

13 DB6 I/O The 8-bit data bus

14 DB7 I/O The 8-bit data bus

e) LCD INTERFACING:

Sending commands and data to LCDs with a time delay:

30
Fig 3.5.2: Interfacing of LCD to a micro controller
To send any command to the LCD, make pin RS=0.
For data, make RS=1.Then send a high to low pulse to the E pin to enable the internal
latch of the LCD.

f) Power supply:

The power supply is designed to convert high voltage AC mains electricity to a suitable
low voltage supply for electronic circuits and other devices. A power supply can by
broken down into a series of blocks, each of which performs a particular function. A dc
power supply which maintains the output voltage constant irrespective of ac mains
fluctuations or load variations is known as “Regulated D.C Power Supply”

31
 Transformer:
A transformer is an electrical device which is used to convert electrical power from one
electrical circuit to another without change in frequency.

Transformers convert AC electricity from one voltage to another with little loss of
power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC. Step-up transformers increase in output voltage, step-down
transformers decrease in output voltage. Most power supplies use a step-down
transformer to reduce the dangerously high mains voltage to a safer low voltage. The
input coil is called the primary and the output coil is called the secondary. There is no
electrical connection between the two coils; instead they are linked by an alternating
magnetic field created in the soft-iron core of the transformer. The two lines in the
middle of the circuit symbol represent the core.

Fig 3.5.3: An Electrical Transformer

32
Turns ratio = Vp/ VS = Np/NS
Power Out= Power In
VS X IS=VP X IP
Vp = primary (input) voltage
Np = number of turns on primary coil
Ip = primary (input) current

 RECTIFIER:
A circuit, which is used to convert ac to dc, is known as RECTIFIER. The process of
conversion ac to dc is called “rectification”
TYPES OF RECTIFIERS:
 Half wave Rectifier
 Full wave rectifier
1. Center tap full wave rectifier.
2. Bridge type full bridge rectifier.
i) Half-Wave Rectifier:
A half wave rectifier is a type of rectifier which converts the positive half cycle
(positive current) of the input signal into pulsating DC (Direct Current) output signal.

ii) Full-wave Rectifier:


From the above comparisons we came to know that full wave bridge rectifier as more
advantages than the other two rectifiers. So, in our project we are using full wave bridge
rectifier circuit.
iii) Bridge Rectifier:
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave
rectification. This is a widely used configuration, both with individual diodes wired as
shown and with single component bridges where the diode bridge is wired internally.

A bridge rectifier makes use of four diodes in a bridge arrangement as shown


in fig(a) to achieve full-wave rectification. This is a widely used configuration, both with

individual diodes wired as shown and with single component bridges where the diode
bridge is wired internally.

33
 Filter:

A Filter is a device, which removes the ac component of rectifier output but allows the dc
component to reach the load.
 Capacitor Filter:

We have seen that the ripple content in the rectified output of half wave rectifier is 121%
or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of
ripples is not acceptable for most of the applications. Ripples can be removed by one of
the following methods of filtering:
 Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output
voltages. The maximum current they can pass also rates them. Negative voltage
regulators are available, mainly for use in dual supplies. Most regulators include some
automatic protection from excessive current ('overload protection') and overheating
('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like
power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is
simple to use. You simply connect the positive lead of your unregulated DC power
supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to
the Common pin and then when you turn on the power, you get a 5-volt supply from the
output pin.

Fig: 3.5.4 A Three Terminal Voltage Regulator


 78XX:

34
The Bay Linear LM78XX is integrated linear positive regulator with three
terminals. The LM78XX offer several fixed output voltages making them useful in wide
range of applications. When used as a Zener diode/resistor combination replacement, the
LM78XX usually results in an effective output impedance improvement of two orders of
magnitude, lower quiescent current. The LM78XX is available in the TO-252, TO-220 &
TO-263packages.

l) Features:
• Output Current of 1.5A
• Output Voltage Tolerance of 5%
• Internal thermal overload protection
• Internal Short-Circuit Limited
• No External Component
• Output Voltage 5.0V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, 24V
• Direct Replacement for LM78XX
3.6 Bluetooth Module:

HC-05:

Over view:

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed
for transparent wireless serial connection setup.

Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data
Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses
CSR Blue core 04-External single chip Bluetooth system with CMOS technology and
with AFH(Adaptive Frequency Hopping Feature). It has the footprint as small as
12.7mmx27mm. Hope it will simplify your overall design/development cycle.

35
Fig.3.6.1 Bluetooth module HC-05
Specification:
 Model: HC-05

 Input Voltage: DC 5V

 Communication Method: Serial Communication

 Master and slave mode can be switched

Features:
Hardware Features:

 Typical -80dBm sensitivity


 Up to +4dBm RF transmit power
 Low Power 1.8V Operation ,1.8 to 3.6V I/O
 PIO control
 UART interface with programmable baud rate
 With integrated antenna
 With edge connector

Software Features:

 Default Baud rate: 38400, Data bits:8, Stop bit:1,Parity:No parity, Data control:
has Supported baud rate: 9600,19200,38400,57600,115200,230400,460800.

 Given a rising pulse in PIO0, device will be disconnected.

 Status instruction port PIO1: low-disconnected, high-connected;

36
 PIO10 and PIO11 can be connected to red and blue led separately. When master
and slave are paired, red and blue led blinks 1time/2s in interval, while
disconnected only blue led blinks 2times/s.

 Auto-connect to the last device on power as default.

 Permit pairing device to connect as default.

 Auto-pairing PINCODE:”0000” as default

 Auto-reconnect in 30 min when disconnected as a result of beyond the range of


connection.

Pin Configuration:

Fig 3.6.2 Pin Configuration of HC-05

Pin Pin Name Description


Number

1 Enable / This pin is used to toggle between Data Mode (set low) and
Key AT command mode (set high). By default it is in Data mode

2 Vcc Powers the module. Connect to +5V Supply voltage

3 Ground Ground pin of module, connect to system ground.

37
4 TX – Transmits Serial Data. Everything received via Bluetooth will be
Transmitter given out by this pin as serial data.

5 RX – Receive Serial Data. Every serial data given to this pin will be
Receiver broadcasted via Bluetooth

6 State The state pin is connected to on board LED, it can be used as a


feedback to check if Bluetooth is working properly.

7 LED Indicates the status of Module

 Blink once in 2 sec: Module has entered Command Mode


 Repeated Blinking: Waiting for connection in Data Mode
 Blink twice in 1 sec: Connection successful in Data Mode

8 Button Used to control the Key/Enable pin to toggle between Data and
command Mode

HC-05 Default Settings:

 Default Bluetooth Name: “HC-05”

 Default Password: 1234 or 0000

 Default Communication: Slave

 Default Mode: Data Mode

 Data Mode Baud Rate: 9600, 8, N, 1

38
 Command Mode Baud Rate: 38400, 8, N, 1

 Default firmware: LINVOR

HC-05 Technical Specifications:

 Serial Bluetooth module for Arduino and other microcontrollers


 Operating Voltage: 4V to 6V (Typically +5V)
 Operating Current: 30mA
 Range: <100m
 Works with Serial communication (USART) and TTL compatible
 Follows IEEE 802.15.1 standardized protocol
 Uses Frequency-Hopping Spread spectrum (FHSS)
 Can operate in Master, Slave or Master/Slave mode
 Can be easily interfaced with Laptop or Mobile phones with Bluetooth
 Supported baud rate: 9600,19200,38400,57600,115200,230400,460800.

HC-05 Equivalent Bluetooth Module:

HC-02

Other Bluetooth Modules

HC-04, HC-06, HM-11, ESP32, CSR8645

Where to use HC-05 Bluetooth module

The HC-05 is a very cool module which can add two-way (full-duplex) wireless
functionality to your projects. You can use this module to communicate between two
microcontrollers like Arduino or communicate with any device with Bluetooth
functionality like a Phone or Laptop. There are many android applications that are
already available which makes this process a lot easier. The module communicates with
the help of USART at 9600 baud rate hence it is easy to interface with any
microcontroller that supports USART. We can also configure the default values of the

39
module by using the command mode. So if you looking for a Wireless module that could
transfer data from your computer or mobile phone to microcontroller or vice versa then
this module might be the right choice for you. However do not expect this module to
transfer multimedia like photos or songs; you might have to look into the CSR8645
module for that.

How to Use the HC-05 Bluetooth module

The HC-05 has two operating modes, one is the Data mode in which it can send and
receive data from other Bluetooth devices and the other is the AT Command mode where
the default device settings can be changed. We can operate the device in either of these
two modes by using the key pin as explained in the pin description.

It is very easy to pair the HC-05 module with microcontrollers because it operates using
the Serial Port Protocol (SPP). Simply power the module with +5V and connect the Rx
pin of the module to the Tx of MCU and Tx pin of module to Rx of MCU as shown in
the figure below

Fig 3.6.3 How to use Bluetooth module

During power up the key pin can be grounded to enter into Command mode, if left free it
will by default enter into the data mode. As soon as the module is powered you should be
able to discover the Bluetooth device as “HC-05” then connect with it using the default
password 1234 and start communicating with it. The name password and other default
parameters can be changed by entering into the

Applications

1. Wireless communication between two microcontrollers

40
2. Communicate with Laptop, Desktops and mobile phones

3. Data Logging application

4. Consumer applications

5. Wireless Robots

6. Home Automation

3.7 Sample Hardware Installation and Sample Source Code :

Below is the example of interfacing between Arduino UNO and PC via HC-05
Bluetooth Module. In this example, the communication mode is used.

*Note: For AT mode (use to change the default setting or etc), please refer to this link
Modify The HC-05 Bluetooth Module Defaults Using AT Commands.

Diagram below shows the hardware connection between HC-05 Bluetooth Module and
Arduino UNO. Besides Arduino, it may interface with any microcontroller such as PIC
and etc.

 VCC - Arduino 5V

 GND -Arduino GND

 TXD - Arduino Pin RX

 RXD - Arduino Pin TX

 KEY - Connect to the air for communication mode

41
Fig 3.7.1 Sample hardware installation & source code

Next, please get the sample source code and burn it into Arduino UNO.

After completing hardware and source code installation on Arduino UNO, the next step
is setting up PC site. In order to communicate with Arduino UNO, a Bluetooth device is
needed as well on PC site. We recommend using USB plug in Bluetooth device in PC
site. See below diagram for data transfer between Arduino UNO and PC via Bluetooth
devices.

42
In order to use Bluetooth device in PC site, Bluetooth Device Driver is needed to install
in PC. If your USB Plug in Bluetooth device does not provides driver installation, you
may download this PC Site Bluetooth Software and install it. Plug in your Bluetooth
device to PC during installation and restart PC after installation.

After setting up the Arduino UNO and PC site, now we proceed to next session which
will show communication between Arduino UNO and PC through Bluetooth devices via
communication mode.

3.7.1 AT Command of HC-05:

Having multiple bluetooth modules with the same name can be confusing. Sometimes it
may require to change the default settings like baud rate, or master/slave role of the
module. This guide shows how to enter AT command mode of HC05 bluetooth module
with the help of USB to TTL converter. Alternatively for HC-05, you can use an arduino
board.

43
Requirements:

1.HC-05/HC-06 Bluetooth module with breakout board.

2.USB to TTL converter : I used PL2303HX usb to TTL converter. Any other usb to ttl
converter will do too./Arduino board, Arduino Uno used in this tutorial, other boards
should work to.

3. Arduino IDE/ Tera Term : It can be downloaded from here or if you don't want to
download Arduino then download Tera Term from here.

Step 1: Identifying Your Module:

First thing you need to do is identify your module. It can be either HC05 or HC06. Both
the modules are same in functionality except the pinout. Also HC05 can act as both

44
master and slave whereas HC06 functions only as slave. It's hard to differentiate between
the two only by seeing. One probable way would be checking the back of the breakout
board. If it has "JY-MCU" written on the back, it's probably a HC06. Mine has "ZS-040"
written and it is a HC05. And the HC06 module I tested had a bluetooth sign behind with
three pcb footprints(refer to figure2). To confirm the device identity, you can power up
the module, search for new device on your pc or mobile, and look for HC05 or HC06 on
found device list.

Step 2: Pinout and Entering AT Mode:

Fig 3.7.2 Pin out and entering AT command

Some of the breakout boards have EN pin or even WAKE UP pin instead of KEY pin.
None of them seem to be connected to any pins of module. But that does not matter
because we wouldn't need them anyway.

Once you identified the module, now it's time to enter the AT mode.
Connect the Rx pin of the Bluetooth module to Tx pin of USB to TTL converter, and Tx
pin of Bluetooth to Rx pin of converter. Also connect their ground but don't connect the
Vcc yet. First you'll have to short the key pin with the Vcc. Connect key pin and Vcc
together on breadboard, or any other way. After all other pins are connected; connect Vcc
of bt module to USB to TTL converter's Vcc. Now the led on the module will blink at the

45
interval of 2 seconds. That means it has entered the AT mode. If the led blinks faster than
AT mode was not entered. Disconnect Vcc, check your circuit and try again. If it does
not work then there's a chance that your KEY pin of the module is not really soldered to
the KEY of the main chip, i.e. the 34th pin. You can check that with the help of
multimeter.

If you use an arduino uno, then connect Rx pin of the Bluetooth module to pin 11 of
Arduino Uno(supposedly same for arduino mega), and Tx pin of Bluetooth to pin 10 of
Arduino. Also connect key pin of module to pin 9 of arduino and ground to ground, but
don't connect the Vcc yet. You have to first power up the arduino, and then connect Vcc
just like you did in case of USB to TTL converter.

Step 3: If Key Pin Is Not Present or Not Connected:

Fig 3.7.3 Pin is not presented or not connected

As stated earlier, some models of the breakout board do not have the key pin, instead
they have an EN (enable) pin or WAKE UP pin which may or may not be connected to
any pin just like the STATE pin. In that case you'll have to solder a wire to the 34th pin
of the bt module. I soldered a male header to mine but if you can't solder or don't want to,

46
then you can just hold a wire (the pointy end of a male to male jumper wire would be
convenient ) while connecting the Vcc to 5volt. Once the bt module is in AT mode, you
can release the wire.

Step 4: Setting Up Connection:

47
Once the module is in AT mode, open arduino. Go to tools>serial port>select the com
port your USB to TTL converter is connected to (to find out, go to device manager of
your pc>ports(COM &LPT)) . Now open the serial monitor. The bt module is now
communicating at a baud rate of 38400. So change the baud rate to 38400 at bottom right
corner of the serial monitor. Also change "no line ending " to "both NL & CR" found just
beside the baud rate.

48
If you don't have Arduino IDE, then download Tera term(which is an excellent terminal
emaluator). Open Tera term. A pop up window will open, Select Serial and choose the
com port the usb to ttl converter is connected to. Press ok and a connection will be
established.

Now go to setup>serial port>set the baud rate to 38400. After setting up baud rate go to
setup>terminal>change the newline to CR+LF from the drop down menu. Also check the
local echo box under newline. Now the set up is complete.

If you use arduino (UNO/MEGA) board, then copy paste the following code, which is
just a modification of Software Serial example included in arduino examples.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {

Serial.begin(9600);

pinMode(9,OUTPUT); digitalWrite(9,HIGH);

Serial.println("Enter AT commands:");

mySerial.begin(38400);

void loop()

if (mySerial.available())

49
Serial.write(mySerial.read());

if (Serial.available())

mySerial.write(Serial.read());

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Upload the code to the arduino board, once the code is uploaded, open Serial monitor,
change "no line ending " to "both NL & CR" at the bottom, close it and disconnect
arduino board from usb. Now again reconnect arduino to usb,connect vcc of bluetooth
module to arduino 5volt, and open serial monitor. The led on the module should blink at
the interval of 2 seconds. That means it has entered the AT mode. Now you are ready to
enter AT commands.

Step 5: AT Commands:

Type "AT" (without the quotes) on the serial monitor and press enter. if "OK" appears
then everything is all right and the module is ready to take command. Now you can
change the name of the module, retrieve address or version or even reset to factory
settings. To see the default name, type AT+NAME. The name will be prompted, by

50
default it is HC-05 or JY_MCU or something like that. To change the name just type
AT+NAME=your desired name.

Here is an important note, if the key pin is not high, i.e. not connected to Vcc while
receiving AT commands(if you did not solder the wire and released it after the module
entered AT mode), it will not show the default name even after giving right command.
But you can still change the name by the command mentioned above. To verify if the
name has really changed, search the device from your pc/mobile. The changed name will
appear. To change baud rate, type AT+UART=desired baud rate. Exit by sending
AT+RESET command.

Most useful AT commands are

AT : Ceck the connection.


AT+NAME : See default name
AT+ADDR : see default address
AT+VERSION : See version
AT+UART : See baudrate
AT+ROLE: See role of bt module(1=master/0=slave)
AT+RESET : Reset and exit AT mode
AT+ORGL : Restore factory settings
AT+PSWD: see default password

51
CHAPTER-4

4.1 SOFTWARE DESCRIPTION


Software’s used are:
*KEIL µVision using Embedded C programming
*Express PCB for lay out design
*Express SCH for schematic design
Express PCB
Express PCB is a Circuit Design Software and PCB manufacturing
service. One can learn almost everything you need to know about Express PCB from the
help topics included with the programs given.
Details:
Express PCB, Version 5.6.0
Express SCH
The Express SCH schematic design program is very easy to use. This
software enables the user to draw the Schematics with drag and drop options.
A Quick Start Guide is provided by which the user can learn how to use
it.
Details:
Express SCH, Version 5.6.0
EMBEDDED C:
The programming Language used here in this project is an
Embedded C Language. This Embedded C Language is different from the generic C
language in few things like
a) Data types
b) Access over the architecture addresses.

The Embedded C Programming Language forms the user friendly language with access
over Port addresses, SFR Register addresses etc.
Embedded C Data types:

52
Data Types Size in Bits Data Range/Usage

unsigned char 8-bit 0-255


signed char 8-bit -128 to +127
unsigned int 16-bit 0 to 65535
signed int 16-bit -32,768 to +32,767

Signed char:
 Used to represent the – or + values.
 As a result, we have only 7 bits for the magnitude of the signed number, giving us values
from -128 to +127.

KEIL µVision using Embedded C programming

ABOUT KEIL SOFTWARE:

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

Projects:

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

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

Simulator/Debugger:

The simulator/ debugger in KEIL can perform a very detailed simulation of a


micro controller along with external signals. It is possible to view the precise execution
time of a single assembly instruction, or a single line of C code, all the way up to the
entire application, simply by entering the crystal frequency. A window can be opened for
each peripheral on the device, showing the state of the peripheral. This enables quick
trouble shooting of mis-configured peripherals. Breakpoints may be set on either
assembly instructions or lines of C code, and execution may be stepped through one
instruction or C line at a time. The contents of all the memory areas may be viewed along
with ability to find specific variables. In addition the registers may be viewed allowing a
detailed view of what the microcontroller is doing at any point in time.
The Keil Software 8051 development tools listed below are the programs you
use to compile your C code, assemble your assembler source files, link your program
together, create HEX files, and debug your target program. µVision2 for Windows™
Integrated Development Environment: combines Project Management, Source Code
Editing, and Program Debugging in one powerful environment.
 C51 ANSI Optimizing C Cross Compiler: creates relocatable object modules from
your C source code,
 A51 Macro Assembler: creates relocatable object modules from your 8051
assembler source code,
 BL51 Linker/Locator: combines relocatable object modules created by the compiler

54
and assembler into the final absolute object module,
 LIB51 Library Manager: combines object modules into a library, which may be used
by the linker,
 OH51 Object-HEX Converter: creates Intel HEX files from absolute object modules.

What's New in µVision3?


µVision3 adds many new features to the Editor like Text Templates, Quick Function
Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for
dialog based startup and debugger setup. µVision3 is fully compatible to µVision2 and
can be used in parallel with µVision2.
What is µVision3?
µVision3 is an IDE (Integrated Development Environment) that helps you write,
compile, and debug embedded programs. It encapsulates the following components:

 A project manager.
 A make facility.
 Tool configuration.
 Editor.
 A powerful debugger.
To help you get started, several example programs (located in the \C51\Examples, \
C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided.
 HELLO is a simple program that prints the string "Hello World" using the Serial
Interface.
 MEASURE is a data acquisition system for analog and digital systems.
 TRAFFIC is a traffic light controller with the RTX Tiny operating system.
 SIEVE is the SIEVE Benchmark.
 DHRY is the Dhrystone Benchmark.
 WHETS is the Single-Precision Whetstone Benchmark.
Additional example programs not listed here are provided for each device architecture.
Building an Application in µVision2
To build (compile, assemble, and link) an application in µVision2, you must:
1. Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2).
2. Select Project - Rebuild all target files or Build target.
3. µVision2 compiles, assembles, and links the files in your project

55
Creating Your Own Application in µVision2
To create a new project in µVision2, you must:
1. Select Project - New Project.
2. Select a directory and enter the name of the project file.
3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from
the Device Database™.
4. Create source files to add to the project.
5. Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add
the source files to the project.
6. Select Project - Options and set the tool options. Note when you select the target
device from the Device Database™ all special options are set automatically. You
typically only need to configure the memory map of your target hardware.
Default memory model settings are optimal for most applications.
7. Select Project - Rebuild all target files or Build target.

Debugging an Application in µVision2


To debug an application created using µVision2, you must:
1. Select Debug - Start/Stop Debug Session.
2. Use the Step toolbar buttons to single-step through your program. You may enter
G, main in the Output Window to execute to the main C function.
3. Open the Serial Window using the Serial #1 button on the toolbar.
Debug your program using standard options like Step, Go, Break, and so on.
Starting µVision2 and Creating a Project
µVision2 is a standard Windows application and started by clicking on the program icon.
To create a new project file select from the µVision2 menu
Project – New Project…. This opens a standard Windows dialog that asks you for the
new project file name. We suggest that you use a separate folder for each project. You
can simply use the icon Create New Folder in this dialog to get a new empty folder. Then
select this folder and enter the file name for the new project, i.e. Project1. µVision2
creates a new project file with the name PROJECT1.UV2 which contains a default target
and file group name. You can see these names in the Project

Window – Files.

56
Now use from the menu Project – Select Device for Target and select a CPU for your
project. The Select Device dialog box shows the µVision2 device database. Just select
the micro controller you use. We are using for our examples the Philips 80C51RD+ CPU.
This selection sets necessary tool
options for the 80C51RD+ device and simplifies in this way the tool Configuration
Building Projects and Creating a HEX Files
Typical, the tool settings under Options – Target are all you need to start a new
application. You may translate all source files and line the application with a click on the
Build Target toolbar
icon. When you build an application with syntax errors, µVision2 will display errors and
warning messages in the Output Window – Build page. A double click on a message line
opens the source file on the correct location in a µVision2 editor window. Once you have
successfully generated your application you can start debugging. After you have tested
your application, it is required to create an Intel HEX file to download the software into
an EPROM programmer or simulator. µVision2 creates HEX files with each build
process when Create HEX files under Options for Target – Output is enabled. You may
start your PROM programming utility after the make process when you specify the
program under the option Run User Program #1.

CPU Simulation:
µVision2 simulates up to 16 Mbytes of memory from which areas can be mapped for
read, write, or code execution access. The µVision2 simulator traps reports illegal
memory accesses. In addition to memory mapping, the simulator also provides support
for the Integrated peripherals of the various 8051 derivatives. The on-chip peripherals
of the CPU you have selected are configured from the Device.
Database selection:
you have made when you create your project target. Refer to page 58 for more
Information about selecting a device. You may select and display the on-chip peripheral
components using the Debug menu. You can also change the aspects of each peripheral
using the controls in the dialog boxes.
Start Debugging:
You start the debug mode of µVision2 with the Debug – Start/Stop Debug
Session command. Depending on the Options for Target – Debug Configuration,
µVision2 will load the application program and run the startup code µVision2 saves the

57
editor screen layout and restores the screen layout of the last debug session. If the
program execution stops, µVision2 opens an editor window with the source text or shows
CPU instructions in the disassembly window. The next executable statement is marked
with a yellowarrow. During debugging, most editor features are still available. For
example, you can use the find command or correct program errors. Program source text
of your application is shown in the same windows. The µVision2 debug mode differs
from the edit mode in the following aspects:
_ The “Debug Menu and Debug Commands” described on page 28 are Available. The
additional debug windows are discussed in the following.
_ The project structure or tool parameters cannot be modified. All build Commands are
disabled.

Disassembly Window
The Disassembly window shows your target program as mixed source and assembly
program or just assembly code. A trace history of previously executed instructions may
be displayed with Debug – View Trace Records. To enable the trace history, set Debug –
Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step commands
work on CPU instruction level rather than program source lines. You can select a text
line and set or modify code breakpoints using toolbar buttons or the context menu
commands.

You may use the dialog Debug – Inline Assembly… to modify the CPU instructions.
That allows you to correct mistakes or to make temporary changes to the target program
you are debugging.

4.2 SOFTWARE COMPONENTS:

58
1. Click on the Keil u Vision Icon on Desktop

2. The following fig will appear

3. Click on the Project menu from the title bar

4. Then Click on New Project

––

59
5. Save the Project by typing suitable project name with no extension in u r own
folder sited in either C:\ or D:\

6. Then Click on Save button above.

7. Select the component for u r project. i.e. Atmel……

8. Click on the + Symbol beside of Atmel

60
9. Select AT89C51 as shown below

10. Then Click on “OK”

11. The Following fig will appear

12. Then Click either YES or NO………mostly “NO”

61
13. Now your project is ready to USE

14. Now double click on the Target1, you would get another option “Source
group 1” as shown in next page.

15. Click on the file option from menu bar and select “new”

62
16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.

17. Now start writing program in either in “C” or “ASM”

18. For a program written in Assembly, then save it with extension “.asm” and
for “C” based program save it with extension “ .C”

63
19. Now right click on Source group 1 and click on “Add files to Group Source”

20. Now you will get another window, on which by default “C” files will appear.

21. Now select as per your file extension given while saving the file

22. Click only one time on option “ADD”


.

64
23. Now Press function key F7 to compile. Any error will appear if so happen.

24. If the file contains no error, then press Control+F5 simultaneously.

25. The new window is as follows

26. Then Click “OK”


.

65
27. Now Click on the Peripherals from menu bar, and check your required port as
shown in fig below

28. Drag the port a side and click in the program file.

29. Now keep Pressing function key “F11” slowly and observe.

66
30. You are running your program successfully

CHAPTER-5

5.1 SCHEMATIC:

67
5.2 SCHEMATIC DESCRIPTION:

Firstly, the required operating voltage for Microcontroller LPC2148 is 5V. Hence
the 5V D.C. power supply is needed by the same. This regulated 5V is generated by first
stepping down the 230V to 18V by the step-down transformer.
In the both the Power supplies the step downed ac voltage is being rectified by
the Bridge Rectifier. The diodes used are 1N4007. The rectified ac voltage is now filtered
using a ‘C’ filter. Now the rectified, filtered D.C. voltage is fed to the Voltage Regulator.
This voltage regulator allows us to have a Regulated Voltage. In Power supply given to
Microcontroller 5V is generated using 7805 and in other two power supply 12V is
generated using 7812. The rectified; filtered and regulated voltage is again filtered for
ripples using an electrolytic capacitor 100μF. Now the output from the first section is fed
to 40th pin of AT89S52 microcontroller to supply operating voltage and from other power
supply to circuitry.

The microcontroller LPC2148 with Pull up resistors at Port0 and crystal oscillator
of 11.0592 MHz crystal in conjunction with couple of capacitors is placed at 18 th & 19th
pins of AT89S52 to make it work (execute) properly.
Port 0: P0 is connected to the data pins of the LCD.
Port 2: P2.5, P2.6, P2.7 are connected to control pins of the LCD.
Port 3: 20th is connected to GROUND
40th is connected to Vcc
Rf receiver is connected to pins
Led’s are connected to pins

68
5.3 Advantages of IoT Home Automation:

 Home security: With IoT home automation you are less worried about home
security. You can control the security of your home with your phone. If anything
goes wrong, you may receive notifications on your phone and you may probably
operate you lights or locks through your phone.

 Energy efficiency and savings: You can increase the energy efficiency by
controlling your electrical fixtures through IoT. If you are unsure whether your
child has left lights on before leaving, you can check and control it through your
phone.

 Convenience: This can be considered as one of the main advantages of home


automation using IoT. You have the control of all your devices connected through
IoT. It makes it very convenient for you to have all the devices adjusted just
through your phone. For example, if you forgot to adjust your thermostat in the
morning before you left your house, you can adjust it from your office.

5.4 Disadvantages of IoT Home Automation:

 Compatibility: Currently, there is no international standard of compatibility for


the tagging and monitoring equipment. I believe this disadvantage is the easiest to
overcome. The manufacturing companies of these equipment just need to agree to
a standard, such as Bluetooth, USB, etc. This is nothing new or innovative
needed.
 Complexity: As with all complex systems, there are more opportunities of
failure. With the Internet of Things, failures could sky rocket. For instance, let’s
say that both you and your spouse each get a message saying that your milk has
expired, and both of you stop at a store on your way home, and you both purchase
milk. As a result, you and your spouse have purchased twice the amount that you
both needs. Or maybe a bug in the software ends up automatically ordering a new
ink cartridge for your printer each and every hour for a few days, or at least after
each power failure, when you only need a single replacement.

69
 Privacy/Security: With all of this IoT data being transmitted, the risk of losing
privacy increases. For instance, how well encrypted will the data be kept and
transmitted with? Do you want your neighbors or employers to know what
medications that you are taking or your financial situation?
 Safety: Imagine if a notorious hacker changes your prescription. Or if a store
automatically ships you an equivalent product that you are allergic to, or a flavor
that you do not like, or

a product that is already expired. As a result, safety is ultimately in the hands of


the consumer to verify any and all automation.

5.5 Applications of Bluetooth Home automation:

 Controlled electrical fixtures such as lights and air conditioners


 Simplified garden or lawn management
 HVAC
 Controlled smart home appliances
 Enhanced safety and security at home
 Water and air quality control and monitoring
 Voice based home assistant supporting natural language
 Smart locks and switches

These are a few, but not all the possible applications of home automation using Bluetooth

70
Appendix:

Code:

//https://thingspeak.com/channels/585334
//https://thingspeak.com/channels/585334/charts/2?bgcolor=%23ffffff&color=
%23d62020&dynamic=true&results=60&title=PARCEL-2&type=line&yaxis=value

#include <lpc214x.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include"lcd.h"

#define r1 1<<31
#define r2 1<<30

#define w0a 1<<29


#define w0b 1<<28

#define w1a 1<<27


#define w1b 1<<26

#define ga 1<<25
#define gb 1<<24

char input[12];
char password[4];
char person1[] = "2100884AE201";
char person2[] = "2100887C6EBB";
int total = 0;
char cmd[4] = {0xc0,0xc1,0xc2,0xc3};
char c = 'X';
char rcg;
int h = 0;
int m = 0, count;

int a,num,z;

char Latitude_Buffer[15],Longitude_Buffer[15],Time_Buffer[15],Altitude_Buffer[8];
char iir_val[10];

71
char GGA_String[150];
unsigned int ptl=0;
uint8_t GGA_Comma_Pointers[20];
char GGA[3];
volatile uint16_t GGA_Index, CommaCounter;
bool IsItGGAString= false;

void UART0_init(void)
{
PINSEL0 = PINSEL0 | 0x00000005; /* Enable UART0 Rx0 and Tx0 pins of
UART0 */
U0LCR = 0x83; /* DLAB = 1, 1 stop bit, 8-bit character length */
U0DLM = 0x00; /* For baud rate of 9600 with Pclk = 15MHz */
U0DLL = 0x61; /* We get these values of U0DLL and U0DLM from
formula */
U0LCR = 0x03; /* DLAB = 0 */
U0IER = 0x00000001; /* Enable RDA interrupts */
}

void UART0_TxChar(char ch) /* A function to send a byte on UART0 */


{
U0IER = 0x00000000; /* Disable RDA interrupts */
U0THR = ch;
while( (U0LSR & 0x40) == 0 ); /* Wait till THRE bit becomes 1 which tells
that transmission is completed */
U0IER = 0x00000001; /* Enable RDA interrupts */
}

void UART0_SendString(char* str) /* A function to send string on UART0 */


{
// U0IER = 0x00000000; /* Disable RDA interrupts */
// uint8_t i = 0;
char i;
while( str[i] != '\0' )
{
UART0_TxChar(str[i]);
i++;
}
U0IER = 0x00000001; /* Enable RDA interrupts */
}

72
void UART1_init(void)
{
PINSEL0 = PINSEL0 | 0x00050000; /* Enable UART0 Rx0 and Tx0 pins of
UART0 */
U1LCR = 0x83; /* DLAB = 1, 1 stop bit, 8-bit character length */
U1DLM = 0x00; /* For baud rate of 9600 with Pclk = 15MHz */
U1DLL = 0x61; /* We get these values of U0DLL and U0DLM from
formula */
U1LCR = 0x03; /* DLAB = 0 */
U1IER = 0x00000001; /* Enable RDA interrupts */
}
void UART1_TxChar(char ch) /* A function to send a byte on UART0 */
{
U1IER = 0x00000000; /* Disable RDA interrupts */
U1THR = ch;
while( (U1LSR & 0x40) == 0 ); /* Wait till THRE bit becomes 1 which tells
that transmission is completed */
U1IER = 0x00000001; /* Enable RDA interrupts */
}

char receive()
{
char rx;
c = 'x';
while((U0LSR & 0x01)==0);
rx= U0RBR;
return rx;
}

char receive1()
{
unsigned char rv,rx;
while(!(U1LSR & 0x01));
rx=U1RBR;
return rx;
}

char recv()
{
unsigned char rct;
char r;
do
{
rct=receive();
}
while(rct != '*');
r = receive();

73
int strcmp1(char *a, char *b)
{
int m,x=0;
for(m=0;m<12;m++)
{
if(a[m] == b[m])
{
x = x+1;
}
}
return x;
}
int strcmp2(char *a, char *b)
{
int m,x=0;
for(m=0;m<4;m++)
{
if(a[m] == b[m])
{
x = x+1;
}
}
return x;
}
void conv(unsigned int temp1_value)
{
unsigned char value,d2,d3,d4,val1;
value=temp1_value/10;
d4=temp1_value%10;
val1=value/10;
d3=value%10;
d2=val1%10;

// dlcd(d1+48);
lcd_data(d2+48);
lcd_data(d3+48);
lcd_data(d4+48);
}

void okcheck()
{
unsigned char rct;
do
{
rct=receive();
}
while(rct != 'K');
}

74
void wifiinit()
{
//stringlcd(0x80,"Wifi Initilizing");
lcd_cmd(1);
lcd_string("Wifi Initializing");
UART0_SendString("AT\r\n");
okcheck();
delay(400);
UART0_SendString("AT\r\n");
okcheck();
delay(400);
UART0_SendString("ATE0\r\n");
okcheck();
delay(400);
UART0_SendString("AT+CWMODE=3\r\n");
delay(400);
// txs("AT+CWSAP=\"org_6327\",\"connectnow\",5,0\r\n"); //1st time enable after
disable
// delay(400);
UART0_SendString("AT+CIPMUX=1\r\n");
delay(400);
UART0_SendString("AT+CIPSERVER=1,23\r\n");

/*stringlcd(0x80,"WAITING FOR CONNCT");


stringlcd(0xC0,"org_6327");
*/

lcd_cmd(1);lcd_string("Waiting for Connct");


lcd_cmd(0xc0);
lcd_string("org_6547");
while(receive()!='C');

void lcd_basic()
{
lcd_cmd(0x80);
lcd_string("R1:F"); //3
lcd_cmd(0x8B);
lcd_string("R2:F"); //E

lcd_cmd(0xC0);
lcd_string("W1:C"); //3
lcd_cmd(0xC6);
lcd_string("W2:C"); //9

lcd_cmd(0xCC);

75
lcd_string("G:C"); //E
}
int main()
{
int i;
PINSEL0=0X00000005;
PINSEL2=0X00000000;
IODIR1=0XFFFF0000;
lcd_init();
UART0_init();
UART1_init();
IOCLR1 = w0a | w0b | w1a | w1b | ga | gb;
IOSET1 = r1 | r2;
lcd_cmd(0x85);
lcd_string("Welcome");
delay(3000);
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_string("SMART HOME CONTROL");
lcd_cmd(0xC0);
lcd_string("BY USING WIFI....");
delay(3000);
lcd_cmd(0X01);
lcd_string("wifi init.....");
wifiinit();
delay(3000);
lcd_cmd(0X01);

UART0_SendString("AT+CIPSEND=0,64\r\n");delay(2000);
UART0_SendString("WELCOME TO SMART HOME \r\n");
UART0_SendString("PLZZ GIVE YOUR COMMAND \r\n");

UART0_SendString("*0 - WINDOW1 OPEN \r\n");


UART0_SendString("*1 - WINDOW1 CLOSE \r\n");

UART0_SendString("*2 - WINDOW2 OPEN \r\n");


UART0_SendString("*3 - WINDOW2 CLOSE \r\n");

UART0_SendString("*4 - GATE OPEN \r\n");


UART0_SendString("*5 - GATE CLOSE \r\n");

UART0_SendString("*6 - RELAY1 ON \r\n");


UART0_SendString("*7 - RELAY1 OFF \r\n");

UART0_SendString("*8 - RELAY2 ON \r\n");


UART0_SendString("*9 - RELAY2 OFF \r\n");
lcd_cmd(0x80);
//lcd_string("WAITING FOR COMMAND ");

lcd_basic();

76
while(1)
{
// c = U0RBR;
c = recv();
UART0_SendString("AT+CIPSEND=0,3\r\n");delay(2000);
UART0_TxChar(c);
UART0_SendString("\r\n");
//c = receive();
if(c == '0')
{
c = 'X';
lcd_cmd(0XC3);
lcd_data('O');
IOSET1 = w0a;
IOCLR1 = w0b;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nWINDOW 1 OPEN\r\n");
delay(2000);
IOCLR1 = w0b | w0a;
}
if(c == '1')
{
c = 'X';
lcd_cmd(0XC3);
lcd_data('C');
IOSET1 = w0b;
IOCLR1 = w0a;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nWINDOW 1 CLOSE\r\n");
delay(2000);
IOCLR1 = w0b | w0a;
}
if(c == '2')
{
c = 'X';
lcd_cmd(0XC9);
lcd_data('O');
IOSET1 = w1a;
IOCLR1 = w1b;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nWINDOW 2 OPEN\r\n");
delay(2000);
IOCLR1 = w1b | w1a;
}
if(c == '3')
{
c = 'X';
lcd_cmd(0XC9);
lcd_data('C');
IOSET1 = w1b;

77
IOCLR1 = w1a;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nWINDOW 2 CLOSE\r\n");
delay(2000);
IOCLR1 = w1b | w1a;
}
if(c == '4')
{
c = 'X';
IOSET1 = ga;
IOCLR1 = gb;
lcd_cmd(0XCE);
lcd_data('O');
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nGATE OPEN\r\n");
delay(2000);
IOCLR1 = gb | ga;
}
if(c == '5')
{
c = 'X';
IOSET1 = gb;
IOCLR1 = ga;
lcd_cmd(0XCE);
lcd_data('C');
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nGATE CLOSE\r\n");
delay(2000);
IOCLR1 = gb | ga;
}

if(c == '6')
{
c = 'X';
lcd_cmd(0X83);
lcd_data('N');
IOCLR1 = r1;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nRELAY1 ON\r\n");
delay(2000);
}
if(c == '7')
{
c = 'X';
lcd_cmd(0X83);
lcd_data('F');
IOSET1 = r1;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nRELAY1 OFF\r\n");
delay(2000);

78
}
if(c == '8')
{
c = 'X';
lcd_cmd(0X8E);
lcd_data('N');
IOCLR1 = r2;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nRELAY2 ON\r\n");
delay(2000);
}
if(c == '9')
{
c = 'X';
lcd_cmd(0X8E);
lcd_data('F');
IOSET1 = r2;
UART0_SendString("AT+CIPSEND=0,16\r\n");delay(2000);
UART0_SendString("\r\nRELAY2 OFF\r\n");
delay(2000);
}
}
}

79
Conclusion and Future Scope:

In this project we focused on different process of operating or controlling electrical and


electronic appliances remotely with the help of ARM7. This method of controlling such
applications is referred to as automation. The experimental setup which we designed has
its focal point on controlling different home appliances providing 100% efficiency. Due
to advancement in technology, Wi-Fi network is easily available in all places like home,
Office Building and Industrial Building so proposed wireless network easily controlled
using any Bluetooth. The wiring cost is reduced. Since less wiring is required for the
switches. This also eliminates power consumption inside the building when the loads
were in off conditions. This system is also platform independent allowing any web
browser in any platform to connect HC-05. The system is fully functional through
android application known as “Bluetooth control”. The delay to turn ON is 3 sec and turn
OFF is 2 sec for any load. For future use, the researchers would recommend as:
(i)Reducing the time delay to turn on and off of an appliance
(ii) Adding speech recognition to the system
(iii)using automatic smart phone detection through Wi-fi such that it will operate the
loads automatically when it is in range.
(iv) Expansion of range of Bluetooth such that one can operate in permissible long
distance through smart phone.

80
Research Papers:

[1] The official Bluetooth website from Bluetooth SIG: http://www.bluetooth.com


[2] Neng- Shiang Liang; Li-Chen Fu; Chao-Lin Wu. “An integrated, flexible, and
Internet-based control architecture for home automation system in the internet era”.
Proceedings ICRA `02. IEEE International Conference on Robotics and Automation,
Vol. 2, pp.1101-1106, 2002.
[3] E. Yavuz, B. Hasan, I. Serkan and K. Duygu. “Safe and Secure PIC Based
Remote Control Application for Intelligent Home”. International Journal of
Computer Science and Network Security, Vol. 7, No. 5, May 2007.
[4] B. Koyuncu. “PC remote control of appliances by using telephone lines”. IEEE
Transaction on Consumer Electronics, Vol. 41, Issue 1, pp.201-209, 1995.
[5] S. Schneider, J. Swanson and Peng-Yung Woo. “Remote telephone control
system”. IEEE Transaction on Consumer Electronics, Vol.43, Issue 2, pp.103-111, 1997.

81

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy