Sie sind auf Seite 1von 79

Advanced College of Engineering and Management

Kupondole, Lalitpur
(Affiliated to Tribhuvan University)

A Final Year Project Report


on
“REMOTE SENSING AND CONTROL FOR HI-FI HOME”
[CODE NO.: EG777EX]

BY

Basu Dev Aryal(bdv555@hotmail.com) Exam Roll No: 16204


Mohan Nepal(zenithismine@hotmail.com) Exam Roll No: 16212
Saroj Adhikari(sh_saroj@hotmail.com) Exam Roll No: 16228
Suvas Koirala(suvas_24@hotmail.com) Exam Roll No: 16232

A FINAL YEAR PROJECT WORK SUBMITTED TO THE


DEPARTMENT OF COMPUTER AND ELECTRONICS ENGINEERING
FOR THE PARTIAL FULFILLMENT OF THE REQUIREMENT FOR
THE DEGREE OF THE BACHELOR’S IN ELECTRONICS AND
COMMUNICATION ENGINEERING

Lalitpur, Nepal
March, 2009
Advanced College of Engineering and Management
Kupondole, Lalitpur
(Affiliated to Tribhuvan University)

A Final Year Project Report


on
“REMOTE SENSING AND CONTROL FOR HI-FI HOME”
[CODE NO.: EG777EX]

Being a project submitted in partial fulfilment of the requirements for the


degree of Bachelor’s Degree in Electronics and Communication Engineering.

In the
Department of Computer and Electronics Engineering
Advanced College of Engineering and Management

BY
Basu Dev Aryal (bdv555@hotmail.com) Exam Roll No: 16204
Mohan Nepal (zenithismine@hotmail.com) Exam Roll No: 16212
Saroj Adhikari (sh_saroj@hotmail.com) Exam Roll No: 16228
Suvas Koirala (suvas_24@hotmail.com) Exam Roll No: 16232

Lalitpur,Nepal
March, 2009
Approval Letter

The undersigned certify that they have read and recommended to the Department of Computer
and Electronics Engineering, final year project work entitled, Remote Sensing and Control for
Hi-Fi Home, submitted by Mr. Basu Dev Aryal, Mr. Mohan Nepal, Mr. Saroj Adhikari and Mr.
Suvas Koirala in partial fulfillment of requirement for the degree of Bachelor in Electronics
Engineering.

--------------------------------
Er. Binod Chandra Shrestha
Project Co-Ordinator
Department of Computer and Electronics Engineering
ACEM, Lalitpur
Project Supervisor
CERTIFICATE

We have pleasure in forwarding the project of Basu Dev Aryal, Mohan Nepal, Saroj Adhikari,
Suvas Koirala entitled “Remote Sensing and Control for Hi-Fi Home” for the completion of
Bachelor of Engineering in Electronics and Communication of this institute.

Basu Dev Aryal, Mohan Nepal, Saroj Adhikari, Suvas Koirala have completed the project work
for the full prescribed period under the curriculum, and the project embodied the result of their
investigations conducted during the period they worked as a full time student of this department.

---------------------------------- -------------------------
Er. Binod Chandra Shrestha Er. Sharad Ghimire
Project Co-ordinator Asst. Professor
ACEM M.Sc. Program Co-Ordinator
Project Supervisor IOE, Pulchok Campus
External Examiner

-------------------------------------
Er. Dhaneshwar Sah
Deputy Head of Department
Department of Computer and
Electronics Engineering, ACEM


Acknowledgement

First of all we would like to express our sincere thanks to the Department of Computer
and Electronics Engineering, ACEM, for providing us the environment to carry out our
projects smoothly.
We would like to record our appreciation to our D.H.O.D. Er. Dhaneshwor Sah, for his
valuable encouragement throughout the project. His efforts created an environment and
infrastructure to our project.
We express our gratitude to our project Supervisor Er. Binod Chandra Shrestha who
seriously helped us from the very beginning and managed his precious time, suggestions
and continuous effort to support us. We are extremely obliged to record our heartfelt
thanks to Er. Barun Koirala for his valuable support and priceless help and guidance.
We extend our sincere thanks to I.O.E which has given us the opportunity to do this
project which will help us enhance our career.
We would like thank Er. Amit Kumar Tamang and Er. Kiran Sharma for cooperating
us in various ways.
We are also thankful to all the teachers and staffs of our college for their support and help
in various sectors.
Last but not the least, we would like to appreciate all of our classmates for their
encouragement, help and co-operation during project works.

Basu Dev Aryal


Mohan Nepal
Saroj Adhikari
Suvas Koirala

iii

Abstract

Our project entitled “Remote Sensing and Control for Hi-Fi Home” is designed
especially to meet the requirements of those who are willing to control their home
appliances through a hand held remote device that is portable within the periphery of the
house. It is designed in such a way that provides the effective and secure system of
control providing the information about the status of the house periodically. The title
Remote Sensing is to focus on the reception of the remote status using RF and Control is
done through the same transceiver. A Hi-Fi home is well equipped with modern
electronics appliances with high level of security. It also has the facility of controlling the
available appliances through the portable remote control device. We have chosen Hi-Fi
home as our application field because it is the major demand in the present time. If we
will be able to implement it successfully then we will be proceeding towards the
industrial applications. Just to modularize the project work, we have taken the three
different types of input parameters. One is we have controlled the door locking and
unlocking system with open and close facility. Next one is to sense the room temperature
and perform the necessary actions including the detection of abnormal temperature due to
fire and thus alerts us through alarming. The next sensor detects the light intensity and
provides the automatic light switching facility. The data is converted to corresponding
digital values by Analog to Digital Converter so that it could be analyzed effectively in
the Micro Controller Unit (MCU). The transmission and reception of the encrypted data
is carried out through the RF module RF12B which supports dual communication with
operating frequency of 868 MHz. We have adopted Advanced Encryption Standard
(AES) to encrypt and decrypt the data for secure communication. This data is now
analyzed by Microcontroller, AT89C52 and the appropriate control signal is fed to the
remote device that controls the appliances. The portable remote device consists of keypad
that facilitates the manual control of the appliances. The microcontroller programming is
carried out in C programming language and is compiled by SDCC to convert the program
to hex file required for the microcontroller. This hex file is then written to the
microcontroller through the burner and this machine language serves as a brain to control
the whole system.

ŝǀ

List of Figures

S.N. Figures Name Page No.


01 Block diagram of Remote section 06
02 Block diagram of Control section 06
03 Basic Block Diagram of Microcontroller 09
04 AT89C52 IC pin description 13
05 Internal block diagram of NE555 Timer IC 16
06 Connection diagram of 555 timer IC 17
07 Pin diagram of 555 timer IC 18
08 Light activated relay 18
09 Relay Driving Circuit 20
10 Pin description of TIP 122 21
11 Equivalent circuit of TIP 122 21
12 Pin diagram of TSOP 22
13 Reverse Biasing of diode 23
14 Circuit Diagram of Remote Section 24
15 Circuit Diagram of Control Section 25
16 Flow chart of remote section 28
17 Flow chart of Control section 29
18 Flow chart of AES process 30
19 Graphical representation of AddRoundKey 33
20 Graphical representation of ShiftRows 34
21 Wave form of serial data unit 40
22 Null Modem Cinnection 40
23 Snap shot of simulation circuit to test the code in Proteus 42
ISIS professional
24 PCB design circuit for Remote Section 43
25 PCB design circuit for Control Section 43
26 RF12B Transceiver pin description 53



27 Structure of 2X16 LCD 59
28 Physical structure of Keypad 64
29 Flowchart for keypad programming 65
30 Snapshots 67




TABLE OF CONTENTS

Title Page Number


Approval i
Certificate ii
Acknowledgements iii
Abstract iv
List of figures v

1. Introduction 1
1.1 Background 1
1.2 Problem Statement 2
1.3 Objectives 2
2. Literature Review 3
2.1 Previous works 3
2.2 Related Theory 4
2.2.1 Radio Frequency 4
2.2.2 Advanced Encryption Standard 4
3. Description of Project 6
3.1 System Architecture 6
3.1.1 Sensors 7
3.1.2 ADC 7
3.1.3 Display 7
3.1.4 Wireless Module 8
3.1.5 Keypad 8
3.2 Description of Components 8
3.2.1 8051 Microcontroller 8
3.2.2 555 Timer IC 15
3.2.3 LM 35 17
3.2.4 Light Dependent Resistor 18
3.2.5 LCD 19
3.2.6 RF Module 19
3.2.7 Relay 19
3.2.8 TIP 122 21
3.2.9 IR Light Emitting Diode 21
3.2.10 IR Receiver 22
3.2.11 Diode 23
3.3 Circuit Explanation 24
3.3.1 Circuit Diagram 24
3.3.2 Remote Section 26
3.3.3 Control Section 27
3.4 Flow Chart 28
3.4.1 Remote section 28
3.4.2 Control section 29
3.4.3 AES Encryption process 30
3.5 Serial Communication 39
3.6 Software & Equipments 41
3.6.1 Proteus 6 Professional 41
3.6.2 MCU programming in C 44
3.6.3 SDCC Compiler 45
3.6.4 Oscilloscope 46
3.6.5 Digital Multimeter 47
4. Epilogue 48
4.1 Problem faced 48
4.2 Limitations 49
4.3 Future Enhancements 49
4.4 Conclusion 50
Bibliography and References 51
Appendix A: Transceiver Module RF12B 52
Appendix B: Analog to Digital Converter 55
Appendix C: Liquid Crystal Display 58
Appendix D: Keypad interfacing with MCU 63
Appendix E: Costing 66
Appendix F: Snapshots 67

   



1. Introduction
1.1 Background
The development in the field of science and technology occurred so rapid that even
the developing countries are not being able to implement it completely. It is so
because the newer technologies overcome the older one. The main point to be
considered here is the level of human desire i.e. they are unsatisfied to any luxury
they acquire. After the industrial development, world directed towards the information
age with the development of computer during 1950s. The invention of ICs in 1980s
led the electronics world to the peak by its compact size weight, cost with increased
quality and reliability. With the launching of communication satellite in 1962, the
world converted into the global village.

With the development of electronics devices and communication medium, we are


being able not only to use the final products in our daily life but also this has become
challenging sector for us to study about the existing technology and create our own
idea to assist the technological society. But the production of such electronics goods is
not simple as we use it. It involves the detail study of nature, waves, flow of energy,
study of available materials, various experiences and expertise of the past and their
modification as per the requirement. It takes a lot of time, effort and perhaps lifelong
dedication of many individuals.

To dedicate an individual in technological field, almost all countries have their own
sort of education and curriculum pattern. We, the final year students of Bachelor in
Electronics and Communication Engineering, have also tried our best to implement
the knowledge we acquired during our course period to assist this technological world
through the final year project entitled “Remote Sensing and Control for Hi-Fi Home”.
This is a microcontroller based project with emerging wireless and data security
system. It is designed to facilitate the high level people to assist their luxury through
the control of each and every home appliance from any place they desire with the high
level of security. Different input sensors are used to sense the existing conditions of
the appliances and P89V51RD2 is used as MCU. The system consists of RF wireless
modules for the data transmission from the remote control device to the application
device and vice versa.




   



1.2 Problem Statement


People in this 21st century are living busy as well as luxurious life. In one hand, we
are using the modern appliances of science and technology but on the other hand, we
are being lazier and we demand more added facilities. People also demand the state of
fast and ease in access and the level of security of the system. Though there are some
of the devices that are designed to partially fulfill the requirements of the present
situation, they have not been an effective one. Some of the devices are designed with
IR system of data transfer which is limited to control over very short distance and
should also be in line of sight between two communicating terminals. Some of the
devices used security systems just in locking and unlocking the pairing or bonding of
the devices where the unauthorized person can easily get access to the data during
data transmission. Also the wireless communication performed was only simplex type
which could not fulfill the requirement. Some other home appliances control
approaches were carried out through PC which had data wired data transfer
mechanism. So, considering all of the existing problems, we have come up with our
design. Our design consists of data transfer through RF modules which is capable to
transfer data to long distance and moreover the use of Advances Encryption System
facilitates the secure way of data communication. So we are more hopeful that our
project will fulfill the present demand with high degree of precision.

1.3 Objectives:
The main objectives of our project are as follows:

¾ To perform the duplex communication between two wireless devices


¾ To sense the existing status of the remote devices and obtain information in
the display
¾ To control the remotely operated devices using control signals
¾ To take corrective action automatically as per requirement
¾ To prevent the data from any type of tapping or attacks




   



2. Literature Review
2.1 Previous works
Nothing is perfect in this world. So, the development in the field of science and
technology never goes to the saturation limit. Being an engineer, our contribution
should also be dedicated in the field of technology. Thus, with the knowledge we gain
during our 4 year course and studying the existing situation, we came up with our
project entitled “Remote Sensing and Control for Hi-Fi Home”. Several other
projects related partially with our projects helped us get idea that assisted us to create
more features in our project.

We came to study the reports from our seniors to know about the attempts made in the
past. We came across the report “Room Automation using IR” which used the
control of home appliances through Infra Ray (IR). It was capable to control the
devices within few meters and the necessary condition is that both the transmitter and
the receiver should follow line of sight principle. We came across next report entitled
“Long Range Remote Control” which used transmission of control signals though
radio frequency wave but no any data security system was adopted. It was the project
without using MCU. We came across the report “Wireless Ultrasound Flood
Monitoring System” which also used RF wave and somewhat used security systems
using password facility. But only simplex communication was possible and data
communication system was not secure. Next we came across a project work entitled
“Wireless PC to PC communication Using IR Modulation” which was limited to
the text files only. It used data transfer in asynchronous mode to transfer text files
from one PC to another. It used IR modulation and demodulation techniques and the
data transfer rate was limited up to maximum rate of 2400bps. The text file was
transferred on polling basis rather than the in interrupt basis. “Device Control Using
IR” was also a project in which 555 timer was used in modulating the ASCII value
pulses and decoding those pulses to perform specified action depending upon the
characters sent at the same rate of 2400 bps.

Thus, we became ready to overcome all the challenges that project faced and create
the project work with more features, more accurate values, and longer range of
operation. The use of various types of sensors with the feedback control system has
made our project more effective. The duplex communication system with data




   



encryption and decryption made more secure and reliable communication method.
The availability of automatic sensing and control has made the project carrying out
some level of intelligence. The facility of LCD display which displays each and every
information regarding the normal operations and changes occurred in the system has
made the project more friendly and effective.

2.2 Related Theory


2.2.1 Radio frequency (RF)

It is a frequency or rate of oscillation within the range of about 3 Hz to 300 GHz. This
range corresponds to frequency of alternating current electrical signals used to
produce and detect radio waves. Since most of this range is beyond the vibration rate
that most mechanical systems can respond to, RF usually refers to oscillations in
electrical circuits. Electrical currents that oscillate at RF have special properties not
shared by direct current signals. One such property is the ease with which they can
ionize air to create a conductive path through air. This property is exploited by 'high
frequency' units used in electric arc welding. Another special property is an
electromagnetic force that drives the RF current to the surface of conductors, known
as the skin effect. Another property is the ability to appear to flow through paths that
contain insulating material, like the dielectric insulator of a capacitor. The degree of
effect of these properties depends on the frequency of the signals.

2.2.2 Advanced Encryption Standard

The Advanced Encryption Standard, in the following referenced as AES, is the winner
of the contest, held in 1997 by the US Government, after the Data Encryption
Standard was found too weak because of its small key size and the technological
advancements in processor power. Fifteen candidates were accepted in 1998 and
based on public comments the pool was reduced to five finalists in 1999. In October
2000, one of these five algorithms was selected as the forthcoming standard: a slightly
modified version of the Rijndael. The Rijndael, whose name is based on the names of
its two Belgian inventors, Joan Daemen and Vincent Rijmen, is a Block cipher, which
means that it works on fixed-length group of bits, which are called blocks. It takes an
input block of a certain size, usually 128, and produces a corresponding output block
of the same size. The transformation requires a second input, which is the secret key.




   



It is important to know that the secret key can be of any size (depending on the cipher
used) and that AES uses three different key sizes: 128, 192 and 256 bits. To encrypt
messages longer than the block size, a mode of operation is chosen, which I will
explain at the very end of this tutorial, after the implementation of AES. While AES
supports only block sizes of 128 bits and key sizes of 128, 192 and 256 bits, the
original Rijndael supports key and block sizes in any multiple of 32, with a minimum
of 128 and a maximum of 256 bits.




   



3. Description of Project
3.1 System Architecture

The system consists of the two separate devices namely Remote Section and Control
Section, connected wirelessly through Radio Frequency as the transmitting medium.
A pair of RF modules is used as a bridge to communicate between these two devices.
Figure below shows Block Diagram of the two sections.



   



We have used both the remote and control devices for two way communication, so
both the sections operate as transceiver. But the module is able to communicate only
half duplex communication with the baud rate of 9600 bps.

3.1.1 Sensors

The various sensors like temperature sensor (LM35), light sensor(LDR) and IR
sensors are have been used in our project.

Temperature Sensor

LM35 is commonly used temperature sensor. It outputs the Centigrade temperature to


corresponding voltage level. The change in voltage level is 10mV per degree
Centigrade.

Light Sensor

Light Dependent Resistor (LDR) is used as a simple light sensor. The commercially
available LDR has varying resistance ranging from about 5KŸ to 100KŸ. So, another
variable resistor of 100KŸ is used in series with LDR to obtain the required voltage
drop across the LDR so that we can easily analyze the change in intensity of light.

IR Sensor

It is a sensor using infra ray which is emitted by IR led and the supply to the IR led is
given through output of astable multivibrator. 555 timer IC is used to generate the
pulse of 38KHZ and TSOP of same frequency is used as IR receiver.

3.1.2 ADC

It facilitates us upto eight multiplexed inputs and the selection of each input can be
carried out through the selector pins. The output of ADC is always eight bit digital
data which is fed to the microcontroller for further processing.

3.1.3 Display

A 2*16 character display LCD is used to display the message regarding the status of
the home as well as the command given from the control section. The display system
is managed in such a way that the user can obtain the information periodically.




   



3.1.4 Wireless Module

Wireless module is used to achieve the wireless communication between the remote
section and the control section. It facilitates user providing the portable remote control
device which the user can carry with him and operates within the range that the
wireless module supports.

3.1.5 Keypad

The Keypad used in our project is Hex Keypad. It consists of keys of 4*4 matrix
where each four terminals of row are connected to one port of microcontroller and
that of column are connected to the next port of the microcontroller.

3.2 Description of Components


3.2.1 8051 Microcontroller

Introduction to Microcontroller

A microcontroller is an integrated chip that is often part of an embedded system. The


microcontroller includes a CPU, RAM, ROM, I/O ports, and timers like a standard
computer, but because they are designed to execute only a single specific task to
control a single system, they are much smaller and simplified so that they can include
all the functions required on a single chip. Microcontrollers are sometimes called an
embedded microcontroller, which just means that they are part of an embedded
system that is, one part of a larger device or system. A microcontroller differs from a
microprocessor, which is a general-purpose chip that is used to create a multi-function
computer or device and requires multiple chips to handle various tasks. A
microcontroller is meant to be more self-contained and independent, and functions as
a tiny dedicated computer.

The great advantage of microcontrollers, as opposed to using larger microprocessors,


is that the parts-count and design costs of the item being controlled can be kept to a
minimum. They are typically designed using CMOS (complementary metal oxide
semiconductor) technology, an efficient fabrication technique that uses less power and
is more immune to power spikes than other techniques. There are also multiple
architectures used, but the predominant architecture is CISC (Complex Instruction Set




   



Computer), which allows the microcontroller to contain multiple control instructions


that can be executed with a single macro instruction. Some use a RISC (Reduced
Instruction Set Computer) architecture, which implements fewer instructions, but
delivers greater simplicity and lower power consumption. Early controllers were
typically built from logic components and were usually quite large. Later,
microprocessors were used, and controllers were able to fit onto a circuit board.
Microcontrollers now place all of the needed components onto a single chip. Because
they control a single function, some complex devices contain multiple
microprocessors. Microcontrollers have become common in many areas, and can be
found in home appliances, computer equipment, and instrumentation. They are often
used in automobiles, and have many industrial uses as well, and have become a
central part of industrial robotics. Because they are usually used to control a single
process and execute simple instructions, microcontrollers do not require significant
processing power.

The automotive market has been a major driver of microcontrollers, many of which
have been developed for automotive applications. Because automotive
microcontrollers have to withstand harsh environmental conditions, they must be
highly reliable and durable. Nonetheless, automotive microcontrollers, like their
counterparts, are very inexpensive and are able to deliver powerful features that
would otherwise be impossible, or too costly to implement.

Fig 3.1 Basic Block Diagram of Microcontroller





   



Comparison of Microcontroller and Microprocessor

The microprocessor contains no RAM, ROM and Input/Output ports on the chip
itself. On the other hand microcontroller has CPU, RAM and ROM, input/output
ports, timer, interrupts and serial ports on a single chip.

Furthermore, microprocessor instruction sets are processing intensive, implying they


have powerful addressing modes with instruction sets catering to operations on large
volumes of data. On the other hand, microcontroller has instruction sets catering to
the control of inputs and outputs. The interface too many inputs and outputs uses
single bit. Microcontroller has instructions to set and clear individual bits and perform
other bit oriented operations such as logically ANDing, ORing and XORing bits
jumping if a bit is set or clear and so on. This powerful feature is rarely present on
microprocessor which is usually designed to operate on bytes or larger units of data.

8051 Microcontroller

Microcontrollers are designed in a single chip, which typically includes a


microprocessor, certain byte of R/W memory, from 1K to 2K bytes of ROM, and
several signal lines to connect I/O lines. They are used in such functions as
controlling appliances and traffic lights. We have used ATMEL 89C52
microcontroller in our project. Some features are summarized below:

• 8-Bit CPU Optimized for Control Applications


• Extensive Boolean Processing Capabilities (Single-Bit Logic)
• On-Chip Flash Program Memory
• On-Chip Data RAM
• Bidirectional and Individually Addressable I/O Lines
• Multiple 16-Bit Timer/Counters
• Full Duplex UART
• Multiple Source/Vector/Priority Interrupt Structure
• On-Chip Clock Oscillator
• On-chip EEPROM (AT89S series)
• SPI Serial Bus Interface (AT89S Series)
• Watchdog Timer (AT89S Series)

 


   



Microcontroller can perform various operations and computations on the data. It


consists of the arithmetic and the logic unit, I/O unit, control unit and other various
components. The 8051 is the most popular microcontroller used today. Many
derivative microcontrollers have been developed which are based on and compatible
with the 8051.To program an 8051 requires an important skill for one who plans to
develop product that will take advantage of microcontrollers. One of the 8051 based
microcontrollers is the most popular and widely used chip named as AT89C51. But
because of the higher size of ROM as well as RAM needed in our project, we have
used AT89C52, which consists of 8KB of ROM and 256 bytes of RAM. The 8051 is
an 8-bit machine. Its memory is organized in bytes and practically all its instructions
deal with byte quantities. It uses an accumulator as the primary register for instruction
results. Other operands can be accessed using one of the four different addressing
modes available:

• Register implicit
• Direct
• Indirect or immediate
Operands reside in one of the five memory spaces of the 8051. The five memory
spaces of the 8051 are:
• Program memory
• External Data Memory
• Internal data Memory
• Special Function Registers
• Bit Memory

The AT89C52 microcontroller includes 4k Bytes of In-System reprogrammable Flash


memory. Also 256*8-bit Internal RAM with 32 programmable I/O Lines. It consists
of two 16-bit Timer/Counters and six Interrupt Sources. The AT89C51 is a low
power, high performance CMOS 8-bit micro-computer with 8K bytes of flash
programmable and erasable read only memory. The on-chip Flash allows the program
memory to be reprogrammed in-system or by conventional nonvolatile memory
programmer. By combining a versatile 8-bit CPU with flash on a monolithic chip, the
Atmel AT89C52 is a powerful microcontroller, which provides a highly flexible and
cost effective solution to many embedded control applications. The AT89C52
provides the following standard features timer/counter, five vector interrupt




   



architecture with two levels, full duplex serial port, on-chip oscillator and clock
circuitry. In addition, the AT89C52 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port and
interrupt system to continue functioning. The Power-down mode saves RAM contents
but freezes the oscillator disabling all other chip functions until the next hardware
reset.

Features of AT89C52:
• 8K bytes of In-system reprogrammable Flash Memory.
• Endurance: 1,000 Write/Erase cycles
• Fully static operation: 0 Hz to 24 MHz.
• Three level program memory lock.
• 32 programmable I/O lines
• 128x 8-Bit Timer/counters.
• Six Interrupt Sources.
• Programmable Serial Channel.
• Low power Idle and Power Down Modes.

Pin Description:
Vcc
Supply voltage
Gnd
Ground
Port 0
Port 0 is an 8-bit open-drain bi-directional I/O port. So, it requires external pull up
resisters when used as simple I/O port. It is also designed as AD0-AD7 i.e. it can be
used for both address and data bus. When ALE = 0, it acts as data bus D0 –D7, but
when ALE = 1, it acts as address bus A0-A7. In our system, we have used Port 0 as
the data bus for the LCD.




   



Figure 3.3: AT89C52 IC pin description

Port 1 / Port 2
Port 1 / Port 2 both are an 8-bit bi-directional I/O port with internal pull-ups. Port 1 /
Port 2 both acts as simple I/O when 8051 used with no external memory connection.
But, with the system with external memory connection, Port 2 acts as higher order
address bus along with the Port 0 to provide the 16-bits address for the external
memory. Port 1 is dedicated for the keypad while in case of Port 2, pin 2.1 used to
enable the 555 timer, pin 2.2 used to enable/disable the latch in the circuit, pin2.7, 2.6
& 2.5 used for the control signaling of the LCD.

Port 3
Port 3 is also an 8-bit bi-directional 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 internal pull-ups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current because of the internal pull ups.
Port 3 also serves the function of various special features of the AT89C52 as listed
below; Port 3 also receives some control signals for Flash programming and
verification. Port 3 also serves the functions of various special features of the
AT89C52 as listed below:




   



Port pin Alternate functions

P 3.0 RXD (serial input port)


P 3.1 TXD (serial transmit port)
P 3.2 INT0 (external interrupt 0)
P 3.3 INT1 (external interrupt 1)
P 3.4 T0 (timer 0 external input)
P 3.5 T1 (timer 1 external input)
P 3.6 WR (external data memory write strobe)
P 3.7 RD (external data memory read strobe)
Table 3.1: Port 3 Alternate function table

ALE/PROG
ALE (address latch enable) is an output pin and is active high, while connecting to an
external memory.

RST
RESET pin (i.e. pin 9) is an input pin and active high (normally low) where the high
pulse must last for minimum of the two machine cycles before it goes to low. Upon
application of the high pulse, the MCU will be reset such that all the values of its
register will reset and program counter will be set to 0s.Infact, it is also referred to as
reset interrupt among the six interrupts available in 8051 MCU.

PSEN
“Program store Enable” is read strobe to external program memory. When the
AT89C52 is executing code from external program memory, PSEN is activated twice
each machine cycle, except that two PSEN activations are skipped during each access
to external data memory.

EA/VPP
External Access Enable, EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH.
This pin also receives the 12-volt programming enable voltage during Flash
programming for two parts that require 12-volt VPP.




   



XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.

XTAL2
Output from the inverting oscillator amplifier.

Oscillator Characteristics
XTAL l and XTAL2 are the input and output, respectively, of an inverting amplifier,
which can be configured for use as an on-chip oscillator. Either a quartz crystal or
ceramic resonator may be used. To drive the device from an external clock source
XTAL2 should he left unconnected while XTALl is driven. There are no requirements
on the duty cycle or me external clock signal, since the input to the internal clocking
circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage
high and low time specifications must be observed.

3.2.2 555 Timer IC

The NE 555 timer is a TTL digital logic circuit that is used in the controller circuit to
produce a periodic square wave signal. The period and duty cycle of the square signal
are determined by the resistor and capacitor connected to the timer. A square wave
with a 50% duty cycle is desired. In order to obtain exactly a 50% duty cycle from
timer two resistor of identical value are required.

A timer is device that can be used in verities of application such as

• Precision timing
• Sequential timing
• Time delay generator
• Pulse generator




   



Figure below shows the internal block diagram of NE555 timer IC

Fig (a): - Internal block diagram of NE555 Timer IC.

The designed formula for the frequency of the pulses in astable mode of operation is,

F=1.44/ (R1+2*R2)*C
The high and low time of each pulse can be calculated as
High time=0.69*(R1+R2)*C
Low time=0.69*R2*C
The duty cycle of the wave form, usually expressed as a percentage and is given by
Duty cycle = (High time)/ (Pulse period time)
Figure below shows the astable mode of operation of NE555 timer IC.




   



Fig: Connection diagram of 555 timer IC

3.2.3 LM 35

The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35
thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the
user is not required to subtract a large constant voltage from its output to obtain
convenient Centigrade scaling. The LM35 does not require any external calibration or
trimming to provide typical accuracies of ±¼°C at room temperature and ±¾°C over a
full -55 to +150°C temperature range. Low cost is assured by trimming and
calibration at the wafer level. The LM35's low output impedance, linear output, and
precise inherent calibration make interfacing to readout or control circuitry especially
easy. It can be used with single power supplies, or with plus and minus supplies. As it
draws only 60 µA from its supply, it has very low self-heating, less than 0.1°C in still
air. The LM35 is rated to operate over a -55° to +150°C temperature range, while the
LM35C is rated for a -40° to +110°C range (-10° with improved accuracy). The
LM35 series is available packaged in hermetic TO-46 transistor packages, while the
LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor
package. The LM35D is also available in an 8-lead surface mount small outline
package and a plastic TO-220 package.




   

   



Fig: - Pin diagram of 555 timer IC

3.2.4 Light Dependent Resistor

It is a light activated resistor whose resistance varies with the intensity of light. The
property of varying resistance may be in two modes. We have used the resistor with
resistance inversely proportional to the intensity of light i.e. when the light falls on the
LDR, its resistance decrease
decreases.
s. This varying resistance is then used to obtain the
t
varying potential difference across the resistor and
an is used to turn on the transistor to
obtain the logic level required for further processing.
process

LDR can be used in two modes namely light activated mode and dark activated mode.
The connection diagram for these modes is shown in the figure below:

 

   



3.2.5 LCD

The LCD used in our project is a 16*2 matrix type LCD which means it consists of 2
columns of display each supporting of 16 characters. It is used for displaying the
information both in the fixed control module as well as the portable remote device. It
displays the information regarding the present status of the house periodically and the
certain changes that occurred in the system. It is used instead of the LED display
because just by the LED identification, the message won’t seem friendly to all users
so couldn’t be effective method. So, the provision of the LCD display provides clear
information regarding the room condition. For further information, see Appendix C

3.2.6 RF Modules

We used RF12B as transceiver module to transmit and receive the data through RF
wave. It is a single chip, low power, multi-channel FSK transceiver designed for use
in applications requiring FCC or ETSI conformance for unlicensed use. The RF12B
transceiver produces a flexible, low cost, and highly integrated solution that does not
require production alignments. The chip is a complete analog RF and baseband
transceiver including a multi-band PLL synthesizer with PA, LNA, I/Q down
converter mixers, baseband filters and amplifiers, and an I/Q demodulator. All
required RF functions are integrated. Only an external crystal and bypass filtering are
needed for operation. It works on the signal ranges from 433/868/915 MHz. The SPI
interface is used to communicate with the microcontroller for the various parameter
settings like baud rate, clock rate, modes, carrier frequency etc. The RF modules are
shown in the figure 3.17 below. For further information, see Appendix A

3.2.7 Relay

Relays are electromechanical devices/components which allow a low-power circuit


switch a relatively high current on and off, or to control signals that must be
electrically isolated from the controlling circuit itself. Newcomers to electronics
sometimes want to use a relay for this type of application, but are unsure about the
details of doing so. To make a relay operate, we have to pass a suitable, pull-in, and
holding current (DC) through its energizing coil. And generally relay coils are
designed to operate from a particular supply voltage, often 12V or 5V, in the case of
many of the small relays used for electronics work. In each case the coil has a





   

   



resistance which will draw the right pull-in


pull in and holding currents when it is connected
to that supply voltage.
age. So the basic idea is to choose a relay with a coil designed to
operate
rate from the supply voltage we are using for our control circuit (and with contacts
capable
able of switching the currents we want to control), and then provide
ovide a suitable
relay driver circuit
uit so that our low-power circuitry can control the
he current through the
relay coil. Typically this will be somewhere
somewhere between 25mA and 70mA. Often our
relay driver can be very simple, using little more than an NPN or PNP transistor to
control the coil current.
nt. All our low-power
power circuitry has to do is provide enough base
current to turn the transistor on and off, as shown in the diagram below.

Fig: Relay Driving Circuit

In A, NPN transistor Q1 (say a BC547 or BC548 or TIP


TIP 122 for high current driving
circuit) is being used to control a relay (RLY1) with
with a 12V coil, operating from a
+12V supply. Series base resistor R1 is used to set the base current for Q1, so that the
transistor is driven into saturation (fully turned on) when the relay is to be energ
energized.
That way, the transistor will have minimal voltage drop, and hence dissipate very
little power.

The simple
mple transistor driver circuit is very low in cost, and is generally fine for
driving most relays. However there may be occasions, such as when our control

 

   



circuit is based on CMOS logic (obtained from the microcontroller), where the base
current needed by these circuits is a bit too high.

3.2.8 TIP 122

TIP 122 (TIP 120/121) is a Darlington pair transistor with higher VCBO and VCEO
(100VDC). A Darlington pair is used to amplify weak signal so that they can be
clearly detected by another circuit or a computer/microcontroller.

Darlington pair current gain,

ȕ = ȕ1* ȕ2

Figure below shows the configuration and equivalent circuit of TIP 122.

Fig (a): - pin description of TIP 122 Fig (b): - Equivalent circuit of TIP 122

3.2.9 IR Light Emitting Diode

A light-emitting diode (LED) is a semiconductor device that emits visible light when
an electric current passes through it. The light is not particularly bright, but in most
LEDs it is monochromatic, occurring at a single wavelength .The output from an LED




   



can range from red (700nm)to blue-violet(400nm).Some LEDs emit infrared energy
(830nm or longer); such a device is known as an infrared-emitting diode(IRED).

Benefits of LEDs and IREDs, compared with incandescent and fluorescent


illuminating devices include:

• Low power requirement


• High efficiency
• Long life

Every semiconductor has a different energy gap. The wavelength that describes the
color of the radiated light depends upon the magnitude of the energy gap. It is given
by the relation

Ȝ = h*c/E
where,
h=Plank’s constant
c=Velocity of light
E=Band gap energy

3.2.10. IR Receiver (TSOP)

The basic principle of photo detection is that when the light falls on the detector
surface it absorbs it; the photon energy is transferred to its electron some of which
gain enough energy to escape from the cathode forming a complete current path.
There are various types of photo detectors like phototransistor, semiconductor,
phototransistors etc. Special receiver modules tuned for particular frequency receive
the modulated infrared signal. We have employed receiver module TSOP for 38 KHz.

Pinning: 1 = OUT, 2 = GND, 3 = VS




   

   



Features
• Very low supply current
• Photo detector and preamplifier in one package
• Internal filter for PCM frequency
• Improved shielding against EMI
• Supply voltage: 2.5 V to 5.5 V
• Improved immunity against ambient light
• Insensitive to supply voltage ripple and noise

3.2.11 Diode

The diodes are also used as protection against negative


negative voltage at the power supply of
circuit in reverse bias mode. The diode used in our project is 1N4007. The connection
diagram for reverse biased mode is shown in figure below.

Fig: - Reverse Biasing of diode



   

   



3.3 Circuit Explanation

3.3.1 Circuit Diagram

Fig: Circuit Diagram of Remote Section



   

   



Fig: Circuit Diagram of Control Section



   



3.3.2 Remote section:

Consist of MCU unit, ADC, Display unit, sensor input and load control unit.

MCU Unit:

The MCU unit consist of a microcontroller unit P89V51RD2BN, is an 8 bit, 64kb of


flash and 1024 byte of RAM memory. The data input to it is encoded and transmitted
to control side for further analysis as a feedback of the system. Another function of
this unit is to implement the command from the control side that is given as a
response of data transmitted from remote side. It identifies the command from the
control and controls the load in Hi-Fi Home.
The input signals are taken through the ADC from the port 1. The port 0 is used to
transfer the data to the LCD to display the local information and control information
from the control side. P2.0, P2.1, and P2.2 are used for the control signals (rs, en and
rw) to the LCD. P3.0 and P3.1 are used as usual in serial communication (Rx and Tx).
P3.3 through P3.7 are used to control the load in The Hi-Fi Home. P2.2 through P2.7
are used as control lines to the ADC. Pin no. 30 is used as ADC clock line from where
we obtained 1.8 MHz (1/6th of crystal frequency; for 11.0592 MHz of crystal it is 1.8
MHz) of signal and is called ALE signal.
As usual biasing arrangement of MCU, Pin no. 9 is used for reset the MCU, pin no.
40 Vcc, pin no. 20 Gnd and pin no. 18 and 19 for clock frequency for MCU.

Display Unit:

For display the local information as well as the control information in the remote side.
The control information is given from the control side. Here we have used 16*2 LCD
to display the information. The pin detail of the 16*2 LCD is given in appendix.

Load control unit:

The control signal from the MCU is used to drive the relay through Darlington pair
transistor TIP 122. TIP 122 is a high current and high VCBO, VCEO (100VDC).

Sensor input section:

The sensor used in our project is temperature, light and IR sensors.




   



The temperature sensor gives the temperature of the Home to the ADC. Depending
upon the temperature the user determines whether heater or fan ON. Here we used the
temperature sensor LM35 which is linear with degree centigrade.
The light sensor determines the intensity of the room in the Home. Depending upon
the intensity user decides to turn ON the light or OFF the light.
To determine the status of the door whether it is open or closed, IR sensor is used. It
sends the status of the door to the MCU unit. The user decides to the action.

3.2.3 Control Section

The control section has a major function of controlling the load in the remote section.
It consists of keypad, display and MCU unit.

Display unit:

The display unit is same as that of remote section.

MCU Unit:

As in the remote section the same microcontroller is used in MCU unit. It decodes the
information from the control side and send to the LCD. Also the control information
from the keypad is displayed in the LCD as well as it is encoded to transmit to control
side. P1.0 through P1.3 are used as the columns of keypad and P3.4 through P3.7 are
used as the rows of keypad. P3.0 and P3.1 are used as Rx and Tx for serial
communication. Port 0 is used for transmitting display data to the LCD. P2.0, P2.1and
P2.2 are used as control lines to LCD.

Keypad:

For identification of the key pressed firstly all the columns are high and rows are
made low. Once the key is pressed the value of columns is read and the pressed
column is determined. After that one row is made high and column is read. Check
whether the current row is pressed or not. If not go to next row otherwise read the key
value from the look up table. The keypad detail is given in the appendix.




   



3.4 Flow Chart

3.4.1 Remote section

Start

Any command
from control? Read ADC data
No

Encrypt the data

Yes
Decrypt the command
Send data to serial port

Send to o/p port Display in LCD

 
Fig: - Flow chart of remote section

The remote section operates on interrupt basis. When any control command is
detected in the serial line, the control automatically call the decryption function.
Analyzing the detected command it controls the load. In the other time it continuously
observes the data in the input line from the ADC. Encrypt it and send it to the serial
line. At the same time it displays the message in the local LCD screen. All the input
sensors are connected to ADC. So by selecting the multiplex input of the ADC
through the microcontroller we can obtain the sensor data directly. Further the
obtained data are processed and used to encrypt, which is sent through the serial line
of microcontroller.

 


   



3.4.2 Control section

Start

Any data from


remote?
Yes

No

Input from keypad Decrypt the data

Encrypt the key input

Send to serial port Display to LCD

 
Fig: - Flow chart of Control section

In the control section, user analyzes the received data. So the program
control always monitors the data input whether received or not.
Whenever the data is received it decrypts the data and display in the LCD
display. Another function is to take the command through the keypad. It
is done upon interrupt basis. Whenever it detects interrupt in the interrupt
line it automatically jumps to keypad function to input the command data.
Now the data is encrypted and sends through the serial line to the remote
area.





   



3.4.3 Flow chart of AES Encryption process

 Start

Input text

AddRoundkey operation
Count =0

SubByte operation

Count++
ShiftRow operation

MixColumns operation

AddRoundkey operation

Is Count < 9? No

Yes
SubByte operation

ShiftRow operation

AddRoundkey operation

o/p encrypted text

Stop

Figure: - Flow chart of AES process

 


   



Description of the Advanced Encryption Standard algorithm

AES is an iterated block cipher with a fixed block size of 128 and a variable key
length. The different transformations operate on the intermediate results, called state.
The state is a rectangular array of bytes and since the block size is 128 bits, which is
16 bytes, the rectangular array is of dimensions 4x4. (In the Rijndael version with
variable block size, the row size is fixed to four and the number of columns vary. The
number of columns is the block size divided by 32 and denoted Nb). The cipher key
is similarly pictured as a rectangular array with four rows. The number of columns of
the cipher key, denoted Nk, is equal to the key length divided by 32.

A state:
-----------------------------
| a0,0 | a0,1 | a0,2 | a0,3 |
| a1,0 | a1,1 | a1,2 | a1,3 |
| a2,0 | a2,1 | a2,2 | a2,3 |
| a3,0 | a3,1 | a3,2 | a3,3 |
-----------------------------
A key:
-----------------------------
| k0,0 | k0,1 | k0,2 | k0,3 |
| k1,0 | k1,1 | k1,2 | k1,3 |
| k2,0 | k2,1 | k2,2 | k2,3 |
| k3,0 | k3,1 | k3,2 | k3,3 |
-----------------------------

It is very important to know that the cipher input bytes are mapped onto the the state
bytes in the order a0,0, a1,0, a2,0, a3,0, a0,1, a1,1, a2,1, a3,1 ... and the bytes of the
cipher key are mapped onto the array in the order k0,0, k1,0, k2,0, k3,0, k0,1, k1,1,
k2,1, k3,1 ... At the end of the cipher operation, the cipher output is extracted from the
state by taking the state bytes in the same order. AES uses a variable number of
rounds, which are fixed: A key of size 128 has 10 rounds. A key of size 192 has 12
rounds. A key of size 256 has 14 rounds. During each round, the following operations
are applied on the state:




   



1. SubBytes: every byte in the state is replaced by another one, using the Rijndael
S-Box
2. ShiftRow: every row in the 4x4 array is shifted a certain amount to the left
3. MixColumn: a linear transformation on the columns of the state
4. AddRoundKey: each byte of the state is combined with a round key, which is a
different key for each round and derived from the Rijndael key schedule

In the final round, the MixColumn operation is omitted. The algorithm looks like the
following (pseudo-C):
AES(state, CipherKey)
{
KeyExpansion(CipherKey, ExpandedKey);
AddRoundKey(state, ExpandedKey);
for (i = 1; i < Nr; i++)
{
Round(state, ExpandedKey + Nb*i);
}
FinalRound(state, ExpandedKey + Nb * Nr);
}

Observations:

The cipher key is expanded into a larger key, which is later used for the actual
operations.
The roundKey is added to the state before starting the with loop
The FinalRound() is the same as Round(), apart from missing the MixColumns()
operation. During each round, another part of the ExpandedKey is used for the
operations. The ExpandedKey shall ALWAYS be derived from the Cipher Key and
never be specified directly.
AES operations: SubBytes, ShiftRow, MixColumn and AddRoundKey




   



The AddRoundKey operation:

In this operation, a Round Key is applied to the state by a simple bitwise XOR. The
RoundKey is derived from the Cipher Key by the means of the key schedule. The
Round Key length is equal to the block key length (=16 bytes).
----------------------------- ----------------------------- ---------------------------------------------------------
| a0,0 | a0,1 | a0,2 | a0,3 | | k0,0 | k0,1 | k0,2 | k0,3 | | b0,0 | b0,1 | b0,2 | b0,3 |
| a1,0 | a1,1 | a1,2 | a1,3 | XOR | k2,0 | k2,1 | k2,2 | k2,3 | = | b2,0 | b2,1 | b2,2 | b2,3 |
| a2,0 | a2,1 | a2,2 | a2,3 | | k1,0 | k1,1 | k1,2 | k1,3 | | b1,0 | b1,1 | b1,2 | b1,3 |
| a3,0 | a3,1 | a3,2 | a3,3 | | k3,0 | k3,1 | k3,2 | k3,3 | | b3,0 | b3,1 | b3,2 | b3,3 |
----------------------------- ----------------------------- ---------------------------------------------------------

where: b(i,j) = a(i,j) XOR k(i,j)


A graphical representation of this operation can be seen below:

The ShiftRow operation:

In this operation, each row of the state is cyclically shifted to the left, depending on
the row index.
The 1st row is shifted 0 positions to the left.
The 2nd row is shifted 1 positions to the left.




   

   



The 3rd row is shifted 2 positions to the left.


The 4th row is shifted 3 positions to the left.

----------------------------- -----------------------------------
-----
| a0,0 | a0,1 | a0,2 | a0,3 | | a0,0 | a0,1 | a0,2 | a0,3 |
| a1,0 | a1,1 | a1,2 | a1,3 | -> | a1,1 | a0,2 | a1,3 | a1,0 |
| a2,0 | a2,1 | a2,2 | a2,3 | | a2,2 | a2,3 | a2,0 | a2,1 |
| a3,0 | a3,1 | a3,2 | a3,3 | | a3,3 | a3,0 | a3,1 | a3,2 |
----------------------------- -----------------------------------
-----------------------------

A graphical representation of this operation can be found below:

Please note that the inverse of ShiftRow is the same cyclically shift but this time to the
right. It will be needed later for decoding.

The SubBytes operation:

The SubBytes operation is a non-linear


non linear byte substitution, operating on each byte of the
state independently. The substitution table (S-Box)
(S is invertible and is constructed by
the composition of two transformations:
1. Take the multiplicative inverse in Rijndael's finite field
2. Apply an affine transformation which is documented in the Rijndael
documentation.
Since the S-Box
Box is independent of any input, pre-calculated
pre calculated forms are used, if enough
memoryy (256 bytes for one S-Box)
S Box) is available. Each byte of the state is then
substituted by the value in the S-Box
S Box whose index corresponds to the value in the
state:



   



a(i,j) = SBox[a(i,j)]

Please note that the inverse of SubBytes is the same operation, using the inversed S-
Box, which is also precalculated.

The MixColumn operation:

I will keep this section very short since it involves a lot of very advance mathematical
calculations in the Rijndael's finite field. All you have to know is that it corresponds to
the matrix multiplication with:
2 3 1 1
1 2 3 1
1 1 2 3
3 1 1 2
and that the addition and multiplication operations are a little different from the
normal ones.

The Rijndael Key Schedule:

The Key Schedule is responsible for expanding a short key into a larger key, whose
parts are used during the different iterations. Each key size is expanded to a different
size:

An 128 bit key is expanded to an 176 byte key.


An 192 bit key is expanded to an 208 byte key.
An 256 bit key is expanded to an 240 byte key.

There is a relation between the cipher key size, the number of rounds and the
ExpandedKey size. For an 128-bit key, there is one initial AddRoundKey operation
plus there are 10 rounds and each round needs a new 16 byte key, therefor we require
10+1 RoundKeys of 16 byte, which equals 176 byte. The same logic can be applied to
the two other cipher key sizes. The general formula is that:
ExpandedKeySize = (nbrRounds+1) * BlockSize




   



The Key Schedule is made up of iterations of the Key schedule core, which works on
4-byte words. The core uses a certain number of operations, which are explained here:

Rotate:

The 4-byte word is cyclically shifted 1 byte to the left:


--------------------- ---------------------
| 1d | 2c | 3a | 4f | -> | 2c | 3a | 4f | 1d |
--------------------- ---------------------

Rcon:

Just note that the Rcon values can be pre-calculated, which results in a simple
substitution (a table lookup) in a fixed Rcon table (again, Rcon can also be calculated
on-the-fly if memory is a design constraint.)

S-Box:

The Key Schedule uses the same S-Box substitution as the main algorithm body.
The Key Schedule Core:
Now that we know what the operations are, let me show you the key schedule core (in
pseudo-C):
keyScheduleCore(word)
{
Rotate(word);
SBoxSubstitution(word);
word[0] = word[0] XOR RCON[i];
}
In the above code, word has a size of 4 bytes and i is the iteration counter from the
Key Schedule.




   



The Key Expansion:

First, let me show you the keyExpansion function as you can find it in the Rijndael
documentation (there are 2 version, one for key size 128, 192 and one for key size
256):

KeyExpansion(byte Key[4*Nk] word W[Nb*(Nr+1)])


{
for(i = 0; i < Nk; i++)
W[i] = (Key[4*i],Key[4*i+1],Key[4*i+2],Key[4*i+3]);
for(i = Nk; i < Nb * (Nr + 1); i++)
{
temp = W[i - 1];
if (i % Nk == 0)
temp = SubByte(RotByte(temp)) ^ Rcon[i / Nk];
W[i] = W[i - Nk] ^ temp;
}
}
• Nk is the number of columns in the cipher key (128-bit -> 4, 192-bit -> 5, 256-
bit -> 6)
• W is of type "word", which is 4-bytes
Let us try to explain this in an easier understandable way:
1. The first n bytes of the expanded key are simply the cipher key (n = the size of
the encryption key)
2. The Rcon value i is set to 1
3. Until we have enough bytes of expanded key, we do the following to generate
n more bytes of expanded key (please note once again that "n" is used here,
this varies depending on the key size)
a. we do the following to generate four bytes
¾ we use a temporary 4-byte word called t
¾ we assign the previous 4 bytes to t
¾ we perform the key schedule core on t, with i as rcon value
¾ we increment i




   



¾ we XOR t with the 4-byte word n bytes before in the


expandedKey (where n is once either either 16,24 or 32 bytes)
b. we do the following x times to generate the next x*4 bytes of the
expandedKey (x = 3 for n=16,32 and x = 5 for n=24)
¾ we assign the previous 4-byte word to t
¾ we XOR t with the 4-byte word n bytes before in the expandedKey
(where n is once either either 16,24 or 32 bytes)
c. if n = 32 (and ONLY then), we do the following to generate 4 more bytes
¾ we assign the previous 4-byte word to t
¾ We run each of the four bytes in t through Rijndael's S-box
¾ we XOR t with the 4-byte word 32 bytes before in the
expandedKey
d. if n = 32 (and ONLY then), 4. we do the following three times to generate
twelve more bytes
¾ we assign the previous 4-byte word to t
¾ we XOR t with the 4-byte word 32 bytes before in the
expandedKey
4. We now have our expandedKey
5. for n=16, we generate: 4 + 3*4 bytes = 16 bytes per iteration
6. for n=24, we generate: 4 + 5*4 bytes = 24 bytes per iteration
7. for n=32, we generate: 4 + 3*4 + 4 + 3*4 = 32 bytes per iteration

The implementation of the key schedule is pretty straight forward, but since there is a
lot of code repetition, it is possible to optimize the loop slightly and use the modulo
operator to check when the additional operations have to be made.

AES Decryption

If you managed to understand and implement everything up to this point, you


shouldn't have any problems getting the decryption to work either. Basically, we
inverse the whole encryption and apply all the operations backwards.
As the key schedule stays the same, the only operations we need to implement are the
inversed subBytes, shiftRows and mixColumns, while addRoundKey stays the same.

 


   



3.5 Serial Communication

The data I/O of the PC depend upon the Microprocessor Architecture. It can employ
Memory Mapped I/O or I/O Mapped I/ O. In I/O Mapped I/O, the devices are
identified with the separate I/O address. The maximum numbers of devices in this
approach that can be well addressed depends upon the number of data bits in the
Microprocessor Architecture Design. For example 8 bit architecture in 8085 can
address up to 256 devices using this approach. The data transfer for this approach is
faster than the Memory Mapped I/O because there is no need to go to memory address
to fetch operands time and again. However, the number of devices that can be
addressed is limited and small range than the Memory mapped I/O. The instructions
such as IN and OUT are used. In Memory Mapped I/O, the devices are treated like the
memory locations. The addressability of I/O devices is much high and is determined
by the number of Bits in the Address Bus. The memory instructions such as LDA,
STA, LDAX, STAX, are used for data I/O in such approach.

Here in our project, we have used serial data transfer in asynchronous mode.
Asynchronous mode is often used in data communication between PC and the
peripherals because of higher speed of the processor than the peripheral devices in
general. The synchronous data transfer takes place bitwise or character wise. The start
bit, stop bit, parity bit are used for baud rates that is fixed to be same at the both
transmitting side and receiving side. UART such as Motorola’s MC6850 is used for
asynchronous data communication.

In serial data transfer, a single line is used to transfer a bit at a time. This technique is
slower than parallel data transfer however highly economical. It is used for long
distance communication such as in internet. Most of the time serial data
communication is of interest. The signal high is indicated by MARK and the signal
low level is called SPACE.





   



Fig: -wave form of serial data unit.

Serial Communication in MCU:

In Microcontroller there is one inbuilt chip called USART (Universal Synchronous


Asynchronous Receiver and Transmitter) that facilitates both the synchronous and
asynchronous data communication. The TXD (pin 11) and RXD (pin 10) of
AT89C51/AT 89C52 microcontroller are used for the serial communication purpose.
In this project we have implemented serial communication in polling mode rather than
in interrupt mode since we don’t need high speed of operation and we didn't have to
mind for the CPU Utilization Factor. The PC side VB interface is used for fixing the
data rate (asynchronous) half duplex communication. There is the provision of setting
the values of auto mode and manual mode tracking. The data is wirelessly transmitted
by the RF Transmitter at the site and received at the monitoring system by the RF
receiver and finally to the PC via serial Port. The communication type is a null
modem type of communication as shown in figure.

MCU 1 MCU 2

  

 

  

  

  

Fig: - Null Modem Connection

 

   



3.6 Software & Equipments

This section is intended to give some basic introduction and useful information about
the software and tools that we employed in to develop our system.

3.6.1 Proteus 6 Professional

Many CAD users dismiss schematic capture as a necessary evil in the process of
creating PCB layout but Proteus 6 Professional has always disputed this point of view.
With PCB layout now offering automation of both component placement and track
routing, getting the design into the computer can often be the most time consuming
element of the exercise. And if you use circuit simulation to develop your ideas, you
are going to spend even more time working on the schematic.

ISIS has been created with this in mind. It has evolved over twelve year research and
development and has been proven by thousands of users worldwide. The strength of
its architecture has allowed us to integrate first conventional graph based simulation
and now – with PROTEUS VSM - interactive circuit simulation into the design
environment. For the first time ever it is possible to draw a complete circuit for a
micro-controller based system and then test it interactively, all from within the same
piece of software. Meanwhile, ISIS retains a host of features aimed at the PCB
designer, so that the same design can be exported for production with ARES or other
PCB layout software. The Proteus Professional v 6.9, Lab Center Electronics 1990-
2005, has been used for the simulation and PCB layout designed purpose in our
system. And this software proved to be the most comprehensive tool for testing many
microcontroller based circuitry with MCU coding, of course and it has also helped to
give professional look to our circuit.

Proteus used in Simulation

We have used the Proteus ISIS professional to carry out the simulation of our design
and checking the correctness of the coding done in C language. The library of the ISIS
was rich in the commercially available ICs, which proved to be fruitful for us to check
the output of circuit at various conditions and to check the feasibility of any new
components to be added in the systems. During the simulation of our system, ISIS had




   



been very useful to test the code from the very beginning. As the Proteus ISIS
professional don’t have simulation facility for RF transmission, we have carried the
wired communication procedure to verify the coding. Figure below shows the
simulation of the system displaying the temperature:

Figure: Snap shot of simulation circuit to test the code in Proteus ISIS professional




   



Proteus used in PCB design:

We have used the Proteus ARES professional for the PCB design. The design of PCB
was employed manually rather than using the self routing tool ELECTRA available in
ARES.

Fig: - PCB design circuit for Remote Section

Fig: - PCB design circuit for Control Section




   



3.6.2 MCU Programming in C

The programming of MCU is done in Assembly language, C language etc. Among


then we have chosen C language programming instead of Assembly language
programming due to the various reasons as explained followings:

When compliers complies the code written in C language to produce Hex files that
loaded into the ROM of MCU. The size of HEX file is larger with respect to the Hex
file produced by the program written in assembly language. As MCU has limited on
chip ROM, for example AT89C51 MCU has only 4KB of ROM. Moreover, memory
can only be extended up to 64KB as address bus used is of 16 bits. Hence, the size of
HEX file produced by the complier is the major issue while writing the code in MCU.

Assembly language Vs C language

In spite of the problem explained above while doing the MCU programming in C
language, we chose C language because the assembly language is tedious and time
consuming while the C language is much easier and less time consuming to write
program. Furthermore, program in C sis easier to modify, update and more
importantly to debug. C language also allows us to use codes available in function
libraries.

C data types for MCU

This sections attempts to review some of the widely used C data types in MCU. The
section explain how the proper use of C data types is carried out, such that the
programmer would be able to produce small size of HEX file as much as possible.

Unsigned char:

The unsigned char is an 8 bit data types that takes the value in the range of 0-255 (00-
FFH). It is most widely used data types for MCU. By default, C compilers assume as
signed char if we don’t put keyword unsigned in front of char. it is also used for the
ASCII character as genuinely used in C language.




   



Signed char:

It is also an 8 bit data type using D7 among (D7-D0) of 1 byte data to represent the
‘+’ or ‘-‘ sign of the magnitude, such that there are only 7 bits for the magnitude of
signed numbers giving range of (-128 to 127). This data types is used where the sign
of the magnitude becomes vital.

Unsigned int:

When the values of variables exceed 256 then the unsigned int comes into play. This
is 16 bits data type giving the range of 0 – 65535 (0000 – FFFFH), it occupies 2 bytes
of RAM space of MCU. Hence, misuse of this data type will result in unnecessary
increase in size of HEX file.

Signed int:

It uses D15 bit of (D15 – D0) data to represent sign as described in case of signed
char, giving the magnitude range of (-32,768 to +32767) Finally, it can be concluded
that when the variables are declared during programming the MCU in C language,
• The programmer should drag his/her attention to the size of the data types & its
intention of use.
• There should not be unnecessary declaration of variables, i.e. no redundant
declaration or optimum use of the declared variable. If one takes care of the above
mentioned point then s/he will be able to mitigate the size of HEX files effectively.

3.6.3 SDCC compiler

SDCC (Small Device C Compiler) is free open source, retarget table; optimizing
ANSIC compiler by Sandeep Dutta designed for 8 bit Microprocessors. The current
version targets Intel MCS51 based Microprocessors (8031, 8032, 8051, 8052, etc.),
Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and Zilog Z80 based
MCUs. It can be retargeted for other microprocessors, support for Microchip PIC,
Atmel AVR is under development. SDCC has extensive language extensions suitable
for utilizing various microcontrollers and underlying hardware effectively. The
Supported data-types are: bool, char, short, int ,long, float




   



Compiling in SDCC

For single source file 8051 projects the process is very simple. Compile your
programs with the following command "sdcc sourcefile.c". This will compile,
assemble and link your source file. Output files are as follows: sourcefile.asm,
sourcefile.lst, sourcefile.rst, sourcefile.sym, sourcefile.rel or sourcefile.o,
sourcefile.map, sourcefile.mem, sourcefile.ihx, sourcefile.adb, sourcefile.cdb,
sourcefile.-(no extension).

Post processing the Intel Hex file

In most cases this won’t be needed but the Intel Hex file which is generated by SDCC
might include lines of varying length and the addresses within the file are not
guaranteed to be strictly ascending. If your tool chain or a boot loader does not like
this you can use the tool packihx which is part of the SDCC distribution: packihx
sourcefile.ihx >sourcefile.hex. Now the Sourcefile.hex is loaded in the ROM of
MCU using the software EZ Downloader v4.1.

3.6.4 0scilloscope

An oscilloscope (sometimes abbreviated CRO, for cathode-ray oscilloscope, or


commonly just scope or O-scope) is a type of electronic test equipment that allows
signal voltages to be viewed, usually as a two-dimensional graph of one or more
electrical potential differences (vertical axis) plotted as a function of time or of some
other voltage (horizontal axis). One of the most frequent uses of scopes is
troubleshooting malfunctioning electronic equipment. One of the advantages of a
scope is that it can graphically show signals: where a voltmeter may show a totally
unexpected voltage, a scope may reveal that the circuit is oscillating. In other cases
the precise shape of a pulse is important. In a piece of electronic equipment, for
example, the connections between stages (e.g. electronic mixers, electronic
oscillators, amplifiers) may be 'probed' for the expected signal, using the scope as a
simple signal tracer. If the expected signal is absent or incorrect, some preceding
stage of the electronics is not operating correctly. Since most failures occur because of
a single faulty component, each measurement can prove that half of the stages of a
complex piece of equipment either work, or probably did not cause the fault.




   



Once the faulty stage is found, further probing can usually tell a skilled technician
exactly which component has failed. Once the component is replaced, the unit can be
restored to service, or at least the next fault can be isolated.

Another use is for software engineers who must program electronics. Often a scope is
the only way to see if the software is running the electronics properly. Another use is
to check newly designed circuitry. Very often a newly designed circuit will
misbehave because of design errors, bad voltage levels, electrical noise etc. Digital
electronics usually operate from a clock, so a dual-trace scope which shows both the
clock signal and a test signal dependent upon the clock is useful. "Storage scopes" are
helpful for "capturing" rare electronic events that cause defective operation.

3.6.5 Digital multimeter

Digital multimeter usually employ an electronic circuit that acts as an integrator,


linearly ramping output voltage when input voltage is constant (this can be easily
realized with an opamp). The dual-slope integrator method applies a known reference
voltage to the integrator for a fixed time to ramp the integrator's output voltage up,
then the unknown voltage is applied to ramp it back down, and the time to ramp
output voltage down to zero is recorded (realized in an ADC implementation). The
unknown voltage being measured is the product of the voltage reference and the
ramp-up time divided by the ramp-down time. The voltage reference must remain
constant during the ramp-up time, which may be difficult due to supply voltage and
temperature variations.




   



4. Epilogue

4.1 Problem faced

Nothing is perfect in this world. So this completely implies to our activities as well.
During the project activities, we faced different problems even from simpler to more
complex. Some of the problems are described below:

Problem in Hardware

As hard to theoritize any concept, much harder is to realize the system with electronic
component. The commercially available ICs and other components don’t operate with
expected reliability. The simplicity in the circuitry seems that it is a single day work
to complete the project. But after starting, one will experience what obstacles might
one face in the course of making a system synchronizing hardware and software. It is
simple to realize the circuitry module wise rather than to realize the whole circuit. But
assembling and working on the whole circuit would cause a lot of problems.

We first tried to connect the circuit in the bread board. So, we faced a lot of problem.
The serious problem caused due to the loose connection and difficult to find the fault.
We could not obtain the output so we plan to design PCB directly. After PCB design
was completed and all the components were assembled, we took only some hours to
make it work.

Next problem we faced is due to power supply fault. We were completely dependent
on the regulated power supply that we have in the electronics lab. Before we had not
faced such problems but after our final circuit was ready and during our testing, we
found that the regulated power supply had supplied larger current due to which some
microcontrollers get damaged during switching.

Our work was delayed due to the unavailability of power supply facility. We suffered
a lot due to load shedding. This directly affects us during software and hardware
works as both works need power supply. College supported us to some extent by
providing the alternative source. The unavailability of all the components in time is
the second major problem to us to start the work in time.

 


   



Problems in Software:

We got problems to initiate the simulation as well as interfacing the components as


this type of works was our first approach. We used ISIS Professional for simulation of
our project and ARES Professional to design PCB. As both of these application
programs were new to us, we took a lot of time to be familiar with this software. The
logical failure as well as debugging was another challenging job for us. Moreover, the
simulation software which we were using had some of the components incompatible
with the available hardware in the market. This problem was major during keypad
interfacing as well as using ADC. We were also compelled to modify some of our
plan. The successful performance of the RF based devices is always the challenging
task for us. So, data transmission and reception through the RF module is also
difficult task for us.

4.2 Limitations

Even a perfect device available in the market has its limitation. Similarly, our project
has also passed through some of the limitations. Due to the short range of RF module,
it could not control the devices from very far distance. The type of communication
carried out through the module is also half duplex and of slow speed supporting the
maximum baud rate of 9600. Because of the unavailability of the free ports in the
microcontroller, we used only few inputs which may be insufficient to precisely
define the Hi-Fi Home. We could solve this problem using multiplexing system if we
had sufficient time.

4.3 Future Enhancements

Our project is just the approach to control the remote devices wirelessly with higher
precision. So, this application field covers wide range. The further enhancement could
be the fruitful in the industrial sectors as well those sectors consisting of risky works
like as in mining and chemical works.
The recommendation for the future enhancements in the project can be:
¾ To control the devices with long range capability
¾ To use the system as secure local area data communication





   



4.4 Conclusion

The designed system has overcome the normal control devices using the
IR system and also normal code locking system which has less or no any
secure system of control. The system was designed that could take the various
inputs required for home security as well as normal operation and could transfer to the
remotely device wirelessly. The remote is capable of controlling the devices within
the periphery of the house. The data security has also been carried out successfully.
So, the project is proposed for the application.

 


   



Bibliography and References

a. Second Edition, First Edition 2006, 8051 Microcontroller and Embedded


Systems, S.K. Kataria and Sons
b. Douglas V. Hall, Second edition 1999, Microprocessor and Interfacing,
Programming and Hardware, Tata McGraw-Hill,New Delhi..
c. Chhabra, 2nd Edition Principle of communication,
d. Project Reports of Seniors
e. http://fp.gladman.plus.com/cryptography technology.(06/09/2008)
f. http://en.wikipedia.org/wiki/Advanced_Encryption_ Standard(06/09/2008)
g. http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf..(11/09/2008)
h. www.8051.com(11/09/2008)
i. http://www.hoperf.com (03/10/2008)
j. www.national.com(03 10 2008)




   



APPENDIX A

Transceiver Module RF12B

Hope’s RF12B is a single chip, low power, multi-channel FSK transceiver designed
for use in applications requiring FCC or ETSI conformance for unlicensed use in the
433, 868 and 915 MHz bands. The RF12B transceiver produces a flexible, low cost,
and highly integrated solution that does not require production alignments. The chip is
a complete analog RF and baseband transceiver including a multi-band PLL
synthesizer with PA, LNA, I/Q down converter mixers, baseband filters and
amplifiers, and an I/Q demodulator. All required RF functions are integrated. Only an
external crystal and bypass filtering are needed for operation.

The RF12B features a completely integrated PLL for easy RF design, and its rapid
settling time allows for fast frequency-hopping, bypassing multi-path fading and
interference to achieve robust wireless links. The PLL’s high resolution allows the
usage of multiple channels in any of the bands. The receiver baseband bandwidth
(BW) is programmable to accommodate various deviation, data rate and crystal
tolerance requirements. The transceiver employs the Zero-IF approach with I/Q
demodulation. Consequently, no external components (except crystal and decoupling)
are needed in most applications.

The RF12B dramatically reduces the load on the microcontroller with the integrated
digital data processing features: data filtering, clock recovery, data pattern
recognition, integrated FIFO and TX data register. The automatic frequency control
(AFC) feature allows the use of a low accuracy (low cost) crystal. To minimize the
system cost, the RF12B can provide a clock signal for the microcontroller, avoiding
the need for two crystals.





   



Fig: - RF12B Transceiver pin description

Features

¾ Fully integrated (low BOM, easy design-in)


¾ No alignment required in production
¾ Fast-settling, programmable, high-resolution PLL synthesizer
¾ Fast frequency-hopping capability
¾ High bit rate (up to 115.2 kbps in digital mode and 256 kbps in analog
mode)
¾ Direct differential antenna input/output
¾ Integrated power amplifier
¾ Programmable TX frequency deviation (15 to 240 kHz)
¾ Programmable RX baseband bandwidth (67 to 400 kHz)
¾ Analog and digital RSSI outputs
¾ Automatic frequency control (AFC)
¾ Data quality detection (DQD)
¾ Internal data filtering and clock recovery
¾ RX synchronous pattern recognition
¾ SPI compatible serial control interface
¾ Clock and reset signals for microcontroller
¾ 16 bit RX Data FIFO
¾ Two 8 bit TX data registers
¾ Low power duty cycle mode




   



¾ Standard 10 MHz crystal reference


¾ Wake-up timer
¾ 2.2 to 3.8 V supply voltage
¾ Low power consumption
¾ Low standby current (0.3 ȝA)
¾ Supports very short packets (down to 3 bytes)
¾ Excellent temperature stability of the RF parameters

Typical Applications

¾ Remote control
¾ Home security and alarm
¾ Wireless keyboard/mouse and other PC peripherals
¾ Toy controls
¾ Remote keyless entry
¾ Tire pressure monitoring
¾ Telemetry
¾ Personal/patient data logging
¾ Remote automatic meter reading






   



APPENDIX B

Analog to Digital Converter

An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device which


converts continuous signals to discrete digital numbers. The reverse operation is
performed by a digital-to-analog converter (DAC). Typically, an ADC is an electronic
device that converts an input analog voltage (or current) to a digital number.
However, some non-electronic or only partially electronic devices, such as rotary
encoders, can also be considered ADCs. The digital output may use different coding
schemes, such as binary, Gray code or two's complement binary.

Resolution

The resolution of the converter indicates the number of discrete values it can produce
over the range of analog values. The values are usually stored electronically in binary
form, so the resolution is usually expressed in bits. In consequence, the number of
discrete values available, or "levels", is usually a power of two. For example, an ADC
with a resolution of 8 bits can encode an analog input to one in 256 different levels,
since 28 = 256. The values can represent the ranges from 0 to 255 (i.e. unsigned
integer) or from -128 to 127 (i.e. signed integer), depending on the application.

Resolution can also be defined electrically, and expressed in volts. The voltage
resolution of an ADC is equal to its overall voltage measurement range divided by the
number of discrete intervals as in the formula:

Where: Q is resolution in volts per step (volts per output code),


EFSR is the full scale voltage range = VRefHi − VRefLo,
M is the ADC's resolution in bits, and
N is the number of intervals, given by the number of available levels
(output codes), which is: N = 2M




   



Most ADCs are of a type known as linear, although analog-to-digital conversion is an


inherently non-linear process (since the mapping of a continuous space to a discrete
space is a piecewise-constant and therefore non-linear operation). The term linear as
used here means that the range of the input values that map to each output value has a
linear relationship with the output value, i.e., that the output value k is used for the
range of input values from
m(k + b)

to
m(k + 1 + b),

where m and b are constants. Here b is typically 0 or −0.5. When b = 0, the ADC is
referred to as mid-rise, and when b = −0.5 it is referred to as mid-tread.

Non-linear ADCs

If the probability density function of a signal being digitized is uniform, then the
signal-to-noise ratio relative to the quantization noise is the best possible. Because of
this, it's usual to pass the signal through its cumulative distribution function (CDF)
before the quantization. This is good because the regions that are more important get
quantized with a better resolution. In the dequantization process, the inverse CDF is
needed.

This is the same principle behind the companders used in some tape-recorders and
other communication systems, and is related to entropy maximization. (Never confuse
companders with compressors!)

For example, a voice signal has a Laplacian distribution. This means that the region
around the lowest levels, near 0, carries more information than the regions with higher
amplitudes. Because of this, logarithmic ADCs are very common in voice
communication systems to increase the dynamic range of the representable values
while retaining fine-granular fidelity in the low-amplitude region. An eight-bit a-law
or the ȝ-law logarithmic ADC covers the wide dynamic range and has a high
resolution in the critical low-amplitude region, that would otherwise require a 12-bit
linear ADC.




   



Accuracy

An ADC has several sources of errors. Quantization error and (assuming the ADC is
intended to be linear) non-linearity is intrinsic to any analog-to-digital conversion.
There is also a so-called aperture error which is due to a clock jitter and is revealed
when digitizing a time-variant signal (not a constant value). These errors are
measured in a unit called the LSB, which is an abbreviation for least significant bit. In
the above example of an eight-bit ADC, an error of one LSB is 1/256 of the full signal
range, or about 0.4%.

Quantization error

Quantization error is due to the finite resolution of the ADC, and is an unavoidable
imperfection in all types of ADC. The magnitude of the quantization error at the
sampling instant is between zero and half of one LSB. In the general case, the original
signal is much larger than one LSB. When this happens, the quantization error is not
correlated with the signal, and has a uniform distribution. Its RMS value is the standard

deviation of this distribution, given by .




   



APPENDIX C

Liquid Crystal Display (LCD)

The liquid crystal display (LCD) is passive display equipment. This means it doesn’t
emit light; instead, it uses the ambient light in the environment. By manipulating this
light, it displays required text using very little power. This has made LCDs preferred
technology whenever low power consumption and compact size is critical hence; it is
suitable for use in battery-powered electronic devices. It is a thin, flat display device
made up of any number of color or monochrome pixels arrayed in front of a light
source or reflector. Each pixel of an LCD consists of a layer of liquid crystal
molecules aligned between two transparent electrodes, and two polarizing filters, the
axes of polarity of which are perpendicular to each other. With no liquid crystal
between the polarizing filters, light passing through one filter would be blocked by the
other. The surfaces of the electrodes that are in contact with the liquid crystal material
are treated so as to align the liquid crystal molecules in a particular direction. Before
applying an electric field, the orientation of the liquid crystal molecules is determined
by the alignment at the surfaces. In a twisted nematic device (the most common liquid
crystal device), the surface alignment directions at the two electrodes are
perpendicular, and so the molecules arrange themselves in a helical structure, or twist.
Because the liquid crystal material is birefringent (i.e. light of different polarizations
travels at different speeds through the material), light passing through one polarizing
filter is rotated by the liquid crystal helix as it passes through the liquid crystal layer,
allowing it to pass through the second polarized filter. Half of the light is absorbed by
the first polarizing filter, but otherwise the entire assembly is transparent. When a
voltage is applied across the electrodes, a torque acts to align the liquid crystal
molecules parallel to the electric field, distorting the helical structure. This reduces the
rotation of the polarization of the incident light, and the device appears gray. If the
applied voltage is large enough, the liquid crystal molecules are completely untwisted
and the polarization of the incident light is not rotated at all as it passes through the
liquid crystal layer. This light will then be polarized perpendicular to the second filter,
and thus be completely blocked and the pixel will appear black. By controlling the
voltage applied across the liquid crystal layer in each pixel, light can be allowed to

 


   



pass through in varying amounts, correspondingly illuminating the pixel. LCD


provides a useful interface for the user, debugging an application or just giving it a
"professional" look. The most common type of LCD controller provides a relatively
simple interface between a processor and an LCD. Using this interface is often not
attempted by inexperienced designers and programmers because it is difficult to find
good documentation on the interface, initializing the interface can be a problem and
the displays themselves are expensive. The 2 lines x 16 character LCD modules are
available from a wide range of manufacturers and should all be compatible with the
HD44780. The diagram below shows the pin numbers for these devices. When
viewed from the front, the left pin is pin 14 and the right pin is pin 1.

Figure A.1:- Structure of 2X16 LCD

44780 standards:

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the
data bus. The user may select whether the LCD will require a total of 11 data lines (3
control lines plus 8 lines for the data bus). The three control lines are referred to as
EN, RS and RW.

EN:
The EN line is called “Enable”. This control line is used to tell the LCD that you are
sending it data. To send data to the LCD, your program should make sure this line is





   



low and then set the other two control lines and/or put data on the data bus. When
other lines are completely ready, set EN high and wait for the minimum amount of
time as specified in the data sheet and end by bringing it back to low again.

RS:

The RS line is the “Register Select” line. When RS is low, the data is to be treated as
a command or special instruction. When RS is high the data being sent is text data,
which should be displayed on the screen. For example, to display the letter “T” on the
screen you would set RS high.

RW:

The RW line is the “Read/Write” control line. When RW is low, the information on
the data bus is being written on the LCD. When RW is high, the program is
effectively querying or reading the LCD. Only one instruction is a read command. All
others are write commands so RW will almost always be low.

D0 – D7:

The 8-bit data pins, D0 – D7, are used to send information to the LCD or read the
contents of the LCD’s internal registers. To display letters and numbers, we send
ASCII codes for the letters A – Z, a – z and numbers 0 – 9 to these pins while making
RS = 1. There are also instruction command codes that can be sent to the LCD to clear
the display or force the cursor to the home position or blink the cursor. Table A below
lists the instruction command codes. We also use RS = 0 to check the busy flag bit to
see if the LCD is ready to receive information. The busy flag is D7 and can be read
when R/W = 1 and RS = 0, as follows: if R/W = 1, RS = 0. When D7 = 1(busy flag
=1), the LCD is busy taking care of internal operations and will not accept any new
information. When D7 = 0, the LCD is ready to receive new information. It is always
recommended to check the busy flag before writing any data to the LCD.

 


   



Table A.1: LCD Command Codes

Code (Hex) Command to LCD Instruction Register

1 Clear display screen


2 Return Home
4 Decrement Cursor(shift cursor to left)
6 Increment Cursor(shift cursor to right)
5 Shift Display right
7 Shift Display left
8 Display off, cursor off
A Display off, cursor on
C Display on, cursor off
E Display on, cursor blinking
F Display on, cursor blinking
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift the entire display to the right
80 Force cursor to beginning of first line
C0 Force cursor to beginning of second line
38 2 lines and 5 X 7 matrix

Features:

¾ Clear Easy to Read Digits


¾ Low Power Consumption
¾ Works with ICL7106 or equivalent
¾ PCB Mounting




   



Display applications:

¾ Television and digital television


¾ Liquid crystal display television (LCD TV)
¾ LCD projector
¾ Computer monitor
¾ Aircraft Instrumentation displays
¾ HD44780 Character LCD a widely accepted protocol for small LCD displays 




   



APPENDIX D

Keypad Interfacing with MCU

This section describes the basic circuit of 4 X 4 matrix keypad using push to on
switches and the basic algorithm to interface the keypad with MCU. The circuit of
figure C.1 shows the 4x4 matrix keypad connected to a single port. The rows are
connected to an output port (upper nibble of the port) and the columns are connected
to input port (lower nibble of the port). If no key has been pressed, reading the input
port will yield 1s for all columns since they are all connected to high (Vcc). If all the
rows are grounded and a key is pressed, one of the columns will have 0 since the key
pressed provides the path to ground. It is the function of the MCU to scan the keypad
continuously to detect and identify the key pressed. The process described as below:
The process is proceeding with grounding rows and reading the columns. To detect a
pressed key, the MCU grounds all rows by providing 0 to the output latch, that it
reads the columns. If the data read from the columns is D3 – D0 = 1111, no key has
been pressed and the process continues until a key press is detected. However, if one
of the column bits has a zero, this means that a key press has occurred. For example,
if D3 – D0 = 1101, this means that a key in the D1 column has been pressed. After a
key press is detected, the MCU will go through the process of identifying the key.
Starting with the top row, the MCU grounds it by providing a low to row D0 only:
then it reads the columns. If the data read is all 1s, no key in that row is activated and
the process is moved to the next row. It grounds the next row, read the columns, and
checks for any zero. This process continues until the row is identified. After
identification of the row in which the key has been pressed, the next task is to find out
which column the pressed key belongs to. This should be easy since the MCU knows
at any time which row and column are being accessed.




   



Fig: - Physical structure of Keypad




   



The entire process has also been described in flowchart below:



  


  


!"
#


 #$%
 
&'   
   


!"
 !"  

 #%(% No $%*


' /* '


 Yes
.* /*-/(%*
 )* +,-


!"  --+"

( ,

#%(%
 '
 
 


#

Figure: - Flowchart for keypad programming




   



APPENDIX E

Costing

List of Components Quantity Unit Price(Rs.) Total Cost(Rs.)

Microcontroller(AT89C52) 2 200 400

LCD 2 1,000 2,000

RF Module 1 pair 1,650 1,650

LEDs 10 5 50

Crystal Oscillator 2 50 100

Resistors 2 pack 50 100

Capacitors 1 pack 50 50

IR Receiver(TSOP) 2 35 70

IR LED 2 10 20

Timer IC (NE555) 1 30 30

IC Base 5 10 50

LDR 1 15 15

LM35 1 90 90

ADC(0808) 1 800 800

Ceramic capacitor 10 5 50

Relays 5 40 200

Transistor 5 35 105

Model house 1 1000 1,000

Miscellaneous -- -- 3,000

Total cost 9,080




   



APPENDIX F
Snapshots

Fig: - RF module

Fig: - Remote Section




   



Fig: - Control Section

 


Das könnte Ihnen auch gefallen