Beruflich Dokumente
Kultur Dokumente
PROJECT REPORT
Submitted on
BACHELOR OF TECHNOLOGY
IN
Electronics & Communication Engineering.
Submitted To:
Submitted By:
Abstract
The past decade has seen significant advancement in the field of consumer electronics.
Various intelligent appliances such as cellular phones, air-conditioners, home
security devices, home theatres, etc. are set to realize the concept of a smart home.
They have given rise to a Personal Area Network in home environment, where all
these appliances can be interconnected and monitored using a single controller.
Busy families and individuals with physical limitation represent an attractive market
for home automation and networking. A wireless home network that does not incur
additional costs of wiring would be desirable. Bluetooth technology, which has
emerged in late 1990s, is an ideal solution for this purpose.
Page 2
Table of Content
Chapter
No.
i
ii
iii
iv
vi
vi
viii
Chapter 1.
Chapter 2.
Particulars
Page No.
Declaration
Certificate
Acknowledgment
Abstract
Table of Contents
List of figures
Abbreviations
i
ii
iii
iv
v-vii
viii
ix
Overview of Project
1.1
Introduction
1-3
1-2
1.2
Block diagram
1.3
Project Modules
Hardware Description
2.1
Microcontroller
4-22
4-12
2.1.1
89552
2.1.2
Block Diagram
2.1.3
Features
2.1.4
Pin diagram
2.1.5
Pin description
2.1.6
11
2.1.7
2.1.7
.1
2.1.7
.2
2.1.8
Memory Organization
11
Program Memory
11
Data Memory
12
Watchdog Timer
BLUETOOTH MODULE (HC05):Overview
12
2.2
2.2.1
.
2.2.2
.
2.2.3
2.2.4
.
7-10
13-16
Specifications
14
15
15
Pairing
16
Page 3
2.2.5
.
2.2.6
.
2.3
2.3.1
2.3.2
2.3.3
.
2.3.4
Serial communication
16
Driver IC
ULN2803A Darlington Transistor
Arrays
Simplified Schematics
17-20
17
17
18
Pin diagram
19
2.3.5
19
2.3.6
20
Switches
20
Relay
20
2.5
Connector
21
2.6
Vp812 burner
21
2.7
Power supply
22
2.4.1
Chapter 4.
16
2.4
Chapter 3.
Software
Introduction
23-27
23
3.1
PROTEUS
23
3.2
KEIL
24
3.3
VP812
25
3.4
Android App
4.2
SBUF register
4.2
.1
4.2
.2
26-27
28-32
28
28
28-29
29
SM0, SM1
29
4.3
30
4.4
TI (transmit interrupt)
30
4.5
RI (receive interrupt)
Steps for transmitting and
receiving of character
The steps that 8051 goes through
in transmitting a character via TxD
30
4.6
4.6.1
30-32
30
Page 4
4.6.2.
4.6.3
4.6.4
Chapter 5.
Program
5.1
PROGRAM CODES
5.2
Program detail
31
32
32
33-43
33-43
43
Chapter 6.
Chapter 7.
Problem descriptions
45-46
Chapter 8.
47-48
47
8.2.
Chapter 9.
Disadvantages
44
44
48
Future scope
49
Conclusion
50
References
51
Page 5
List of Figures
Figure
No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Figure Name
Page No.
3
5
6
9
14
15
17
18
19
20
21
22
23
24
25
26
28
29
Page 6
19
20
30
45
General Abbreviation
PLC: Programmable logic controllers.
SCADA: Supervisory control and data acquisition.
I/P: Input
O/P: Output.
T-On: On timer.
T-Off: Off timer.
M: Memory Bits.
Q: Output in program.
MW: Memory words.
NO: Normally open.
NC: Normally closed.
DCS: Distributed Control System.
Page 7
Chapter 1
OVERVIEW OF PROJECT
Page 8
Chapter 1
OVERVIEW OF PROJECT
1.1. INTRODUCTION:
Page 9
Although automation today is not a new thing but most advanced home
automation systems in existence today require a big and expensive
change of infrastructure. We have proposed an automation system that
can control appliances like TVs, Fan, Tube lights from an android mobile
using Bluetooth. In this a low cost secure cell phone based, flexible
automation
system
is
introduced.
Devices
are
connected
to
the
The communication between the cell phone and the microcontroller board
is wireless. Additional devices can be connected into the system with little
modifications. The phone will be Android OS based phone. The switching
circuit will be having microcontroller coding to control the electronics
devices like fans and lights etc. 8-bit microcontroller board based on the
atmel89s52 and the HC-05 Bluetooth module is used. It supports wireless
Page 10
serial communication over Bluetooth. This board has 32 digital input and
output ports.
Page 11
1.3. Project Modules :The project can be better described by dividing it into two categories,
namely,
1. Hardware
2. Software
Page 12
Chapter 2
Hardware Description
Page 13
Chapter 2
Hardware Description
2.1 Microcontroller:-Micro controller is just like a small computer
but the basic difference comes in size and memory. These have CPU, RAM,
ROM, I/O and timers are all on a single chip. It means you dont need any
extra device to make it functional like with a micro-processor. Generally
this microcontroller is used where a specific task is needed to do. So fixed
amount of on-chip ROM, RAM, and number of I/O ports makes them ideal
for a many applications in which cost and space are critical The
microcontroller is used by us in over project is AT89S52.
The
device
is
manufactured
using
Atmels
high-density
nonvolatile memory technology and is compatible with the industrystandard 80C51 instruction set and pin out. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional
nonvolatile memory programmer. By combining a versatile 8-bit CPU with
in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is
a powerful microcontroller which provides a highly-flexible and costeffective solution to many embedded control applications. The AT89S52
provides the following standard features: 8K bytes of Flash, 256 bytes of
RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit
timer/counters, a six-vector two-level interrupt architecture, a full duplex
serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52
is designed with static logic for operation down to zero frequency and
supports two software selectable power saving modes. The Idle Mode
Page 14
stops the CPU while allowing the RAM, timer/counters, serial port, and
interrupt system to continue functioning. The Power-down mode saves the
RAM con-tents but freezes the oscillator, disabling all other chip functions
until the next interrupt or hardware reset. The block diagram is shown
below.
2.1.3. Features
i.
ii.
iii.
iv.
v.
vi.
vii.
viii.
ix.
x.
xi.
xii.
xiii.
Watchdog Timer
xiv.
xv.
Power-off Flag
xvi.
xvii.
xviii.
Page 16
GND:
Pin 20 is the ground.
The 8051 has an on chip oscillator but requires an external clock to run it.
Most often a quartz crystal oscillator is connected to inputs XTAL1 (pin 19)
and XTAL2 (pin 18). The quartz crystal oscillator connected to XTAL1 and
XTAL2 also needs two capacitors of 30 pf value. One side of each capacitor
is connected to the ground. Speed refers to the maximum oscillator
frequency connected to XTAL .When the 8051 is connected to a crystal
oscillator is powered up we can observe the frequency on the XTAL2 pin
using the oscilloscope.
RST:
Pin 9 is the RESET pin. It is an input and is active high. Upon applying a
high pulse to this pin the microcontroller well reset and terminate all
activities. This is often referred to as a power on reset .Activating a power
on reset will cause all values the registers to be lost. It will set program
counter to all 0s.
In order for the RESET input to be effective it must have a minimum
duration of two machine cycles. In other words the high pulse must be
high for a minimum of two machine cycles before it is allowed to go low.
EA:
The 8051 family members such as the 8751/52, 89C51/52 or DS89C4*0 all
come with on chip ROM to store programs. In such cases the EA pin is
connected to Vcc. For family members such as the 8031 and 8032 in which
there is no on chip ROM, code is stored on an external ROM and is fetched
by 8031/32. Therefore for the 8031 the EA pin must be connected to GND
to indicate that the code is stored externally. EA which stands for external
access is pin number 31 in the DIP packages. It is an input pin and must
be connected to either Vcc or GND. In other words it cannot be
unconnected.
PSEN:
This is an output pin. PSEN stands for program store enable. In an 8031
Page 18
based system in which an external ROM holds the program code, this pin is
connected to the OE pin of the ROM.
ALE:
ALE stands for address latch enable. It is an output pin and is active high.
When connecting an 8031 to external memory, port 0 provides both
address and data. In other words the 8031 multiplexes address and data
through port 0 to save pins. The ALE pin is used for de-multiplexing the
address and data by connecting to G pin of the 74LS373 chip.
PORTS 0,1,2,3:
All the ports upon RESET are configured as input, since P0-P3 have value
FFH on them. The following is a summary of features of P0-P3.
PORT 0:
Port 0 is also designated as AD0-AD7 allowing it to be used for both
address and data. When connecting an 8051/31 to an external memory,
port 0 provides both address and data. The 8051 multiplexes address and
data through port 0 to save pins. ALE indicates if p0 has address A0-A7.in
the 8051 based systems where there is no external memory connection
the pins of P0 must be connected externally to 10k-ohm pull-up resistor.
This is due to the fact that P0 is an open drain, unlike P1, P2 and P3. Open
drain is a term used for MOS chips in the same way that open collector is
used for TTL chips. In many systems using the 8751, 89c51 or DS89c4*0
chips we normally connect P0 to pull up resistors.
Port 0 also receives the code bytes during Flash programming and outputs
the code bytes during program verification. External pull-ups are required
during program verification.
Page 19
Port 1:
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1
output buffers can sink/source four TTL inputs. When 1s are written to Port
1 pins, they are pulled high by the internal pull-ups and can be used as
inputs. As inputs, Port 1 pins that are externally being pulled low will
source current (IIL) because of the internal pull-ups. In addition, P1.0 and
P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively,
as shown in the following table. Port 1 also receives the low-order address
bytes during Flash programming and verification.
Port 2
Page 20
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port
2 pins, they are pulled high by the internal pull-ups and can be used as
inputs. As inputs, Port 2 pins that are externally being pulled low will
source current (IIL) because of the internal pull-ups. Port 2 emits the highorder address byte during fetches from external program memory and
during accesses to external data memory that uses 16-bit addresses
(MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups
when emitting 1s. During accesses to external data memory that uses 8bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special
Function Register. Port 2 also receives the high-order address bits and
some control signals during Flash programming and verification.
Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port
3 pins, they are pulled high by the internal pull-ups and can be used as
inputs. As inputs, Port 3 pins that are externally being pulled low will
source current (IIL) because of the pull-ups. Port 3 receives some control
signals for Flash programming and verification. Port 3 also serves the
functions of various special features of the AT89S52, as shown in the
following table.
Page 21
(shown in Table 5- 2) and T2MOD (shown in Table 10-2) for Timer 2. The
register pair (RCAP2H, RCAP2L) is the Capture/Reload registers for Timer 2
in 16-bit capture mode or 16-bit auto-reload mode.
data memory, two banks of 16-bit Data Pointer Registers are provided:
DP0 at SFR address locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in
SFR AUXR1 selects DP0 and DPS = 1 selects DP1. The user should ALWAYS
initialize the DPS bit to the appropriate value before accessing the
respective Data Pointer Register.
The Power Off Flag (POF) is located at bit 4 (PCON.4) in the
PCON SFR. POF is set to 1 during power up. It can be set and rest under
software control and is not affected by reset.
Power off Flag:
The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes
occupy a parallel address space to the Special Function Registers. This
means that the upper 128 bytes have the same addresses as the SFR
space but are physically separate from SFR space.
When an instruction accesses an internal location above address 7FH, the
address mode used in the instruction specifies whether the CPU accesses
the upper 128 bytes of RAM or the SFR space. Instructions which use direct
addressing access the SFR space.
For example, the following direct addressing instruction accesses the SFR
at location 0A0H (which is P2).
MOV 0A0H, #data
Instructions that use indirect addressing access the upper 128 bytes of
RAM. For example, the following indirect addressing instruction, where R0
contains 0A0H, accesses the data byte at address 0A0H, rather than P2
(whose address is 0A0H).
MOV @R0, #data
disable from exiting reset. To enable the WDT, a user must write 01EH and
0E1H in sequence to the WDTRST register (SFR location 0A6H). When the
WDT is enabled, it will increment every machine cycle while the oscillator
is running. The WDT timeout period is dependent on the external clock
frequency. There is no way to disable the WDT except through reset (either
hardware reset or WDT overflow reset). When WDT over-flows, it will drive
an output RESET HIGH pulse at the RST pin.
Device
pairing,
authentication,
encryption
and
architecture
using
the
Bluetooth
profiles.
The
device
2.2.1. Specifications
Hardware features
PIO control.
Software features
Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.
Page 25
PIO9 and PIO8 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.
Page 26
2.2.4. Pairing:
After connect the Bluetooth module, scan for new devices from the
Android phone and you will find the module with the device name HC05, after that, click to connect, if some message appears asking about
Pairing code just put
1234 as default code.
BLUE LED = ACTIVE (Blinking 500ms period inactive connection, change
1seg with active connection)
Page 27
2.2.6. SERIAL COMMUNICATION:To transfer to a device located many meters away, the serial method is
used. The data is sent one bit at a time. Here not 8bit data is send 2 extra
bit are send along with it .this two bit are called start bit and stop bit.
These tow bit are used so synchronization can be done between
transmitter and receiver.
current Darlington
transistor array. The device consists of eight NPN Darlington pairs that
feature high-voltage outputs with common-cathode clamp diodes for
switching inductive loads. The collector-current rating of each Darlington
pair is 500 mA. The Darlington pairs may be connected in parallel for
higher current capability.
Page 28
Page 29
Page 30
Page 31
2.4 Switches:Switches are used for connecting or disconnecting electrical circuit. Many
types of switches are there. Some are operate mechanically or electrically.
Some types are SPST, SPDT, DPST and DPDT in case of switch. SPST
stands for single pole single through, SPDT stands for single pole double
through, DPST stands for double pole single through and DPDT stands for
double pole double through,
In relays points are defines by NO, NC.
NO stand for normally on and NC stands for normally off.
2.4.1 Relay:Relays are electromagnetic switch. Which can be turn on and off by
Appling electrical current. Working voltage is printed on the relay. In this
project we are using 6volt relay. Many relay use an electromagnet to
mechanically operate a switch.
Fig.10. .Relays
2.5 Connector:Page 32
Connectors are used for joining two wires temporally by using connector
big circuit can be divided and after completion they can rejoin. Now a
days every time inverter circuited can be removed out without using de
soldering.
2.6 Vp812 burner:This is the vp812 burner hardware. This is used to burn hex file to the
ATMEL 89s52 microcontroller. This burner we can also burn PIC, AVR
microcontrollers.
Page 33
2.7 Power supply:Samsung charger is used for giving 5v power supply to the circuit. This
charger having power of 700 mA. So circuit can run properly. This
Samsung charger is made of switch mode power supply.
Page 34
Chapter 3
Software
Page 35
Chapter 3
Software
INTRODUCTION: Electronic design automation (EDA or ECAD) is a
category of software tools for designing electronic systems such as
printed circuit boards and integrated circuits. The tools work together in
a design flow that chip designers use to design and analyze entire
semiconductor chips. The various softwares used are:
3.1 PROTEUS:Proteus is software in which we can design the circuit with using hard ware
component. In this software input and output relation is shows in this
software.
can be made in this circuit can be analogies or digital. Hear many testing
device are presented in this like ammeter, voltmeter, oscilloscope etc.
Step to make a new program:1. Click on project on status bar and select new project.
2. Give a name to project.
3. Select new file in file on status bar.
4. Press control + s and give file name with extension name .c.
5. Press option for target look as magic stick present on target 1.
6. Write crystal frequency in MHz
7. Select output and click on create hex file.
The created hex file will found in installation drive of keil.
Page 37
3.3 VP812:Features:
Supports ATMEL series MCU ( 8051 and AVR )
Support Win bond new 8051 MCU, such as
W78E052D/054D/058D/516D.
Support Sync MOS MCU.
Support STC series MCU.
Support PIC series MCU.
Support AVR series MCU from ISP downloading and some AVR MCU
with high voltage programming.
Support 25 series EEPROM/FLASH.
Support NXP (Philips) 8051 MCU
Support common used 29 series Parallel EEPROM 32 pins.
Support common used 39 series Parallel EEPROM 32 pins.
Support common used 49 series Parallel EEPROM 32 pins.
Support TTL flash boot loader.
Use high quality 40 pins IC locker holder.
USB communication supports WinXP /Vista/Win732/64 bits) System.
Support firmware updates.
Supports circuit protection.
Page 38
Software to realize the full potential of ones Mobile handset and its
possibilities.
Android is a comprehensive software stack of mobile devices that includes
an operating system, middleware and key application. This rich source of
software bunch is used in Mobile Technology through its innovation module
of The Android Software Development Kit (SDK).
Applications:
These are the basics of Android applications:
components
(activities,
services,
content
providers,
and
broadcast
receivers)
The manifest file must declare all components in the application and
Page 40
Page 41
Page 42
Page 43
Page 44
Page 45
Page 46
Chapter4
Serial communication in 89s52
Chapter4
Page 47
Serial is a
Page 49
4.3 REN (receive enable):It is a bit-addressable register. When it is high, it allows 8051 to receive
data on RxD pin .If low, the receiver is disable.
4.4 TI (transmit interrupt) :- When 8051 finishes the transfer of 8bit character .It raises TI flag to indicate that it is ready to transfer another
byte .TI bit is raised at the beginning of the stop bit.
Page 50
By checking the TI flag bit, we know whether or not the 8051 is ready to
transfer another byte .It must be noted that TI flag bit is raised by 8051
itself when it finishes data transfer It must be cleared by the
programmer with instruction CLR TI If we write a byte into SBUF before
the TI flag bit is raised, we risk the loss of a portion of the byte being
transferred .The TI bit can be checked by The instruction JNB TI, xx
.Using an interrupt.
register
11.
12.
Page 51
13.
The stop bit is transferred .It is during the transfer of the stop
bit that 8051 raises the TI flag, indicating that the last character was
transmitted
14.
overloading the SBUF .If we write another byte into the SBUF before
TI is raised, the transmitted portion of the previous byte will be lost
15.
After SBUF is loaded with a new byte, the TI flag bit must be
Page 52
Chapter 5
Program
Chapter 5
Program
Page 53
Page 54
}
else
{
mybyte = rx;
}
if(mybyte==0x01)
{
CFL1=CFL1^HIGH;//toggle bit
mybyte=0xff;
old =0xff;
if(IN2==0)
{ //check switch on
com2(); //send status
}
else
{
com1();
}
}
Page 56
else if(mybyte==0x02)
{
CFL2=CFL2^HIGH;
mybyte=0xff;
if(IN==0) {
com2();
}
else
{
com1();
}
}
else if(mybyte==0x03)
{
CFL3=CFL3^HIGH;
mybyte=0xff;
if(CFL3==0) {
com1();
}
Page 57
else
{
com2();
}
}
else if(mybyte==0x04) // check port 1 value
{
SBUF=P2;
while(TI==0); //wait for transmit
TI=0;
}
else if(mybyte==0x05) // check port 1
value
{
if(IN==0)
{ //check switch on
com2(); //send status
}
else
Page 58
{
com1();
}
}
else if(mybyte==0x06) // check port
1 value
{
if(IN2==0)
{ //check switch on
com2(); //send status
}
else
{
com1();
}
}
else
{
com3();
}
}
Page 59
void com3()
{
for (z=0;z<15;z++) {
SBUF=Mess3[z]; //place value in buffer
while(TI==0); //wait for transmit
TI=0;
}
}
void com2()
{
for (z=0;z<8;z++) {
void com1()
{
for (z=0;z<8;z++) {
SBUF=Mess1[z]; //place value in buffer
while(TI==0); //wait for transmit
TI=0;
}
}
void delay(const unsigned int ms)
{
unsigned int x, y;
for(x = 0; x<=ms;x++)
{
for(y=0;y<=1275;y++);
}
}
Page 62
Chapter 6
Circuit diagram
&
Component List
Chapter 6
Page 63
S.No
Component Name
Nos. Required
ULN2003 IC
5V relay
1K Resistor
10
7805 IC
11
9V battery
12
13
1N4007 diode
Page 64
Page 65
Chapter 7
Problem description
Chapter 7
Problem description
Page 66
The various problems & FAQs associated with the project are:
7.1. No manual control to switch on and off or in system
when failed:In that case we can use a two way switch so if automation system
fails than control given to manual. As the manual control provided
unskilled user can perform his routine control. As shown below.
In fig a two way connection with relay is shown. The control act as a
XOR operation mines that output is one when both input are same.
So output is available when positions of both switches are same.
7.2. No confirmation of change of output:To overcome this problem programming can be do so that
controller can compare its previous state. So if state of switch not
changes than controller send an error comes or no change.
7.3. No debugging option:This can be a very good feature of project i.e. you can check that
where problem comes at hardware or in software. So controller
gave all information about communication.
Page 67
7.4. Complex user interface:User interface must be simple so no need to teach the other every
time. But in
7.5. Different key to on and off:In survey it is seen that there are two different key to turn n and
off appliances. But if in programming toggle of bit is done then
more automation can be done in this project.
7.6. Restart power at every new pairing of device:In HV-05 Bluetooth module if a device is parried then this
configuration is save. So at every new device pairing needs restart
of circuit power. This problem can be removed if we use a feature
of HC-05 Bluetooth i.e. key this a pin in
remove all paired detail when this pin high pulses. So connection
of this pin with micro controller can rest the pairing.
7.7. Large change in house wiring:In similar project the automation done by mobile only so all
connection needs to change in wiring and removal of button
connection is needed .So to avoid this circuit is so design as sown
in problem 1 solution.
7.8. Security of hacking control:The Bluetooth connection kept open so other con connect and take
control. so the master user must connect to Bluetooth and removal
of pair info must by master controller by software control.
Page 68
Chapter 8
Advantages
&
Disadvantages
Chapter 8
Advantages & Disadvantages
Page 69
8.1 Advantages
1. Wireless control:By using this project wireless control can be within the hands of user.
3. Status checking :When user doesnt know appliances is on off then user can only
check the status only.
4. Confirmation of changing switch state:When switch is press ten two status will be shown on mobile phone
i.e. old status and new status
2. Connection:Page 70
Chapter 9
FUTURE SCOPE
Page 71
Chapter 9
FUTURE SCOPE
This project can be further developed by integrating it with the internet to
monitor your home while sitting in a remote area. By doing this, one can
keep an eye on his or her home through an internet connected to the
Page 72
users mobile phone or PC or laptop. This will not only improve the security
of your home in this modern day world but will also assist in conservation
of energy like if you left any home appliance switched on by mistake, then
you can check the status of the appliance on the graphical interface made
on your mobile and can switch it off using the internet connectivity.
CONCLUSION
Page 73
&
REFERENCES
CONCLUSION
current
electrical
switches.
Moreover,
implementation
of
wireless
REFERENCES
1. Electronics for you magine June 2013
2. Keil vision IDE, http://www.keil.com/uvision.
Page 75
3. www.vp812.com
4. Serial
Bluetooth
Module,
Tiny
OS
Electronics,
http://www.tinyosshop.com
5. AT89s52
bit
Microcontroller,
ATMEL
Corporations,
http://www.atmel.com3.
6. The
official
Bluetooth
website
from
Bluetooth
SIG:
http://www.bluetooth.com
Page 76