You are on page 1of 52

Chapter 1

Introduction

Its the age of modernization. The era where everything comes under the notion The smaller, The
better. The general trend as we see in development of technology is that, the size of electronics
products have been reducing with time. This means that in time to come , we might witness the
big sized products of today to reduce to the size of an small notebook.
Major advancement in electronics is done by replacing the cables and wires as far as possible in
the entire system. Such an application has resulted microwave technologies and radio
technologies to enter into the system. One sub-genre of these technologies is Bluetooth.
Bluetooth is a proprietary open wireless technology standard for exchanging data over short
distances from fixed and mobile devices, creating personal area networks (PANs) with high
levels of security.
The Advent of Bluetooth technology has made a revolution in electronic industry. With this,
many wireless products have been available in market that has flocked masses to the market for
these products.
There are many advantages of using Bluetooth wireless technology. The most important is the
fact that any two devices can be connected with each other without the use of any cables or
wires. Added to that, is that using Bluetooth devices is very safe and also convenient. Presently,
Bluetooth devices are coming very inexpensive and hence attracting many customers. The Fact
that it eliminates the use of wires for communication, we can move our equipment anywhere we
want and can still retain the transmission.
What we intend to do in our project is that we will use Bluetooth technology to manage and
control devices. The devices can range from anything be it indoor or outdoors. We will manage
devices placed at remote locations and a remote in our hand to control the working of these
devices without having moving up to the device.
We also intend to use a touch screen remote as an integral part of our project so as to enhance the
flexibility of the remote control. As we know that, touch screen devices are much easier to use
and very much attractive, this part of our project will give it a unique dimension. Since the
project is open to the type and number of device it can control, it will serve has a single unit to
8

integrate Bluetooth technology with the input via a touch screen.

1.1 KEY FEATURES:


Bluetooth Communication
Operated wirelessly
Touch Screen Remote Input
Compact size

Chapter 2
Hardware

10

2.1 Hardware Components Used:


AT89S52 MICROCONTROLLER
BLUETOOTH MODULES ( Tx Rx )
4 WIRE RESISTIVE TOUCH-SCREEN
16 x 2 LCD MATRIX
ANALOG DIGITAL CONVERTER : 0848

11

2.2 MICROCONTROLLER:
[1]

Microcontroller, as the name suggests, are small controllers. They are like single chip

computers that are often embedded into other systems to function as processing/controlling unit.
For example, the remote control you are using probably has microcontrollers inside that do
decoding and other controlling functions. They are also used in automobiles, washing machines,
microwave ovens, toys ... etc, where automation is needed.
2.2.1 Description
The 8051 family of microcontrollers is based on an architecture which is highly optimized for
embedded control systems. It is used in a wide variety of applications from military equipment
to automobiles to the keyboard.SecondonlytotheMotorola68HC11in eight bit processors sales,
the 8051 family of microcontrollers is available in a wide array of variations from
manufacturers such as Intel, Philips, and Siemens. These manufacturers have added numerous
features and peripherals to the 8051 such as I2C interfaces, analog to digital converters,
watchdog timers, and pulse width modulated outputs. Variations of the 8051 with clock speeds
up to 40MHz and voltage requirements down to 1.5 volts are available. This wide range of
parts based on core makes the 8051 family an excellent choice as the base architecture for a
company's entire line of products since it can perform many functions and developers will only
have to learn this one platform.

The AT89S52 is a low-power, high-performance CMOS8-bit microcontroller r with 8K bytes


of in-system programmable Flash memory. The device is manufactured using Atmels highdensity non volatile memory technology and is compatible with the industry- standard 80C51
instructions and pin out. The on-chip Flash allows the program memory to be reprogrammed
in-system or by a conventional non volatile memory programmer. By combining a versatile 8bit CPU within-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a
powerful microcontroller which provides a highly-flexible and cost- effective solution to
many embedded control applications. In addition, the AT89S52 is designed with static logic for
operation down to zero frequency and supports two software selectable power saving modes.
12

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 the RAM con-tents but
freezes the oscillator, disabling all other chip functions until the next interrupt or hardware
reset.

2.2.2 Features
The basic architecture of AT89S52consistsof the following features:

CompatiblewithMCS-51Products

8KBytesofIn-SystemProgrammable(ISP)Flash Memory

4.0Vto 5.5VOperatingRange

FullyStaticOperation:0Hzto33MHz

256x8-bitInternalRAM

32ProgrammableI/O Lines

Three16-bitTimer/Counters

Eight Interrupt Sources

Full Duplex UART Serial Channel

Low-power Idle and Power-down Modes

13

Interrupt Recovery from Power-down Mode

Watchdog Timer

Fast Programming Time

Flexible ISP Programming (Byte and Page Mode)

[2]Fig.

14

2.1 Pin diagram of AT89S52

2.2.4 Block Diagram

15

[3]Fig.

[4]Figure

16

2.2 Block diagram of the microcontroller

2.3: Microcontroller and its different subunits

2.2.5 Pin Description

Port0:Port0isan8-bitopendrainbidirectionalI/Oport.Asanoutputport,eachpin
cansinkeightTTLinputs.When1s arewrittentoport0 pins, the pins can be used as highimpedance inputs.Port0 can also be configured to be the multiplexed low-order
address/ data bus during accesses to external program and data memory. In this mode,
P0 has internal pull-ups.

Port1:Port1is an 8-bit bidirectional I/O port with internal pull-ups. The Port1 output
buffers can sink / source four TTL inputs. When1s are written to Port1 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port
1 pins that are externally being pulled low will source current (IIL) because of the
internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter
2 external count input (P1.0/T2) and the timer/counter2 trigger input(P1.1/T2EX),
respectively, as shown in the following table.

Port2: Port2 is an 8-bit bidirectional I/O port with internal pull-ups.ThePort2 output
buffers can sink/ source four TTL inputs.When1s are written to Port2 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port
Pins that are externally being pulled low will source current(IIL) because of the internal
pull-ups. Port 2emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that use16- bit addresses
(MOVX@ DPTR). In this application, Port2 uses strong internal pull- ups when
emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX
@ RI), Port 2emits the contents of the P2 Special Function register.

Port3:Port3 is an 8-bit bidirectional I/O port with internal pull-ups.ThePort3 output


buffers can sink/source four TTL inputs. When 1s are written to Port3 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port3 pins that

17

are externally being pulled low will source current(IIL) because of the pull-ups. Port3
receives some control signals for Flash programming an verification. Port3 also serves
the functions of various special features of the AT89S52,as shown in the following
table.

18

2.3 Bluetooth
[5]Bluetooth

is a proprietary open wireless technology standard for exchanging data over short

distances (using short wavelength radio transmissions) from fixed and mobile devices,
creating personal area networks (PANs) with high levels of security. Created by telecoms
vendor Ericsson in 1994, it was originally conceived as a wireless alternative to RS-232 data
cables. It can connect several devices, overcoming problems of synchronization.
Bluetooth is managed by the Bluetooth Special Interest Group, which has more than 14,000
member companies in the areas of telecommunication, computing, networking, and consumer
electronics. The SIG oversees the development of the specification, manages the qualification
program, and protects the trademarks. To be marketed as a Bluetooth device, it must
be qualified to standards defined by the SIG. A network of patents are required to implement the
technology and are only licensed to those qualifying devices; thus the protocol, whilst open, may
be regarded as proprietary.
Implementation
Bluetooth uses a radio technology called frequency-hopping spread spectrum, which chops up
the data being sent and transmits chunks of it on up to 79 bands (1 MHz each; centered from
2402 to 2480 MHz) in the range 2,400-2,483.5 MHz (allowing for guard bands). This range is in
the globally unlicensed Industrial, Scientific and Medical (ISM) 2.4 GHz short-range radio
frequency band.
Originally Gaussian frequency-shift keying (GFSK) modulation was the only modulation scheme
available; subsequently, since the introduction of Bluetooth 2.0+EDR, /4-DQPSK and 8DPSK
modulation may also be used between compatible devices. Devices functioning with GFSK are
said to be operating in basic rate (BR) mode where an instantaneous data rate of 1 Mbit/s is
possible. The term Enhanced Data Rate (EDR) is used to describe /4-DPSK and 8DPSK
schemes, each giving 2 and 3 Mbit/s respectively. The combination of these (BR and EDR)
modes in Bluetooth radio technology is classified as a "BR/EDR radio".

19

Bluetooth is a packet-based protocol with a master-slave structure. One master may


communicate with up to 7 slaves in a pico net; all devices share the master's clock. Packet
exchange is based on the basic clock, defined by the master, which ticks at 312.5 s intervals.
Two clock ticks make up a slot of 625 s; two slots make up a slot pair of 1250 s. In the simple
case of single-slot packets the master transmits in even slots and receives in odd slots; the slave,
conversely, receives in even slots and transmits in odd slots. Packets may be 1, 3 or 5 slots long
but in all cases the master transmit will begin in even slots and the slave transmit in odd slots.

[6]Fig

2.4BlueTooth Tranciever

2.3.1 Communication and Connection


A master Bluetooth device can communicate with up to seven devices in a piconet. (An ad-hoc
computer network using Bluetooth technology) The devices can switch roles, by agreement, and
the slave can become the master at any time.

20

At any given time, data can be transferred between the master and one other device (except for
the little-used broadcast mode). The master chooses which slave device to address; typically, it
switches rapidly from one device to another in a round-robin fashion.
The Bluetooth Core Specification provides for the connection of two or more piconets to form
a scatternet, in which certain devices serve as bridges, simultaneously playing the master role in
one piconet and the slave role in another.
Many USB Bluetooth adapters or "dongles" are available, some of which also include
an IrDA adapter. Older (pre-2003) Bluetooth dongles, however, have limited capabilities,
offering only the Bluetooth Enumerator and a less-powerful Bluetooth Radio incarnation. Such
devices can link computers with Bluetooth with a distance of 100 meters, but they do not offer as
many services as modern adapters do.

[7]Fig

21

2.5BlueTooth Tranciever

2.4 Resistive Touch Screen


[8]Resistive

touch screens are touch-sensitive computer displays composed of two flexible sheets

coated with a resistive material and separated by an air gap or microdots. When contact is made
to the surface of the touch screen, the two sheets are pressed together. On these two sheets there
are horizontal and vertical lines that when pushed together, register the precise location of the
touch. Because the touch screen senses input from contact with nearly any object (finger,
stylus/pen, palm) resistive touch screens are a type of "passive" technology.
For example, during operation of a four-wire touch screen, a uniform, unidirectional voltage
gradient is applied to the first sheet. When the two sheets are pressed together, the second sheet
measures the voltage as distance along the first sheet, providing the X coordinate. When this
contact coordinate has been acquired, the uniform voltage gradient is applied to the second sheet
to ascertain the Y coordinate. These operations occur within a few milliseconds, registering the
exact touch location as contact is made.
Resistive touch screens typically have high resolution (4096 x 4096 DPI or higher), providing
accurate touch control. Because the touch screen responds to pressure on its surface, contact can
be made with a finger or any other pointing device.
Resistive touch screen technology works well with almost any stylus-like object. In some
circumstances, this is more desirable than a capacitive touch screen, which has to be operated
with a capacitive pointer, such as a bare finger. The costs are relatively low when compared with
active touch screen technologies] Resistive touch screen technology can be made to
support multi-touch input.
Due to the nature of passive touch screen design, when "inking" (taking handwritten notes with a
stylus), the user cannot press a large hand down on the screen while writing. This is the tradeoff
between having a dedicated implement (stylus) versus the ability to use one's fingers as a stylus.
A few modern tablets recognize both fingers and a stylus, and avoid this problem by deactivating
recognition for non-stylus input when the stylus makes contact.

22

For people who must grip the active portion of the screen or must set their entire hand down on
the screen, alternative touch screen technologies are available, such as active touch screen in
which only the stylus creates input and touches from the hand are rejected. However, there are
now newer touch screen technologies which allow the use of multi-touch without the
aforementioned vectoring issues

[9]Fig

2.64-Wire Touch Screen

2.3.1 Theory of operation - analog resistive touch screens


Usually a resistive touch screen consists of at least three layers: A flexible membrane made from
PET film is suspended over a rigid substrate made from glass or acryl (see Figure 2-1). Both
surfaces are coated with a transparent conductive film like ITO (Indium tin oxide). The
conductive ITO layers are kept apart by an insulting spacer along the edges, and by spacer dots
on the inner surface of the two ITO layers. In this way there will be no electrical connection
unless pressure is applied to the top sheet (PET film).

4-wire touch screens use a single pair of electrodes (Bus bars) on each ITO layer The bus bars
in the top sheet and substrate are perpendicular to each other. The bus bars are connected to the
touch screen controller through a 4-wire flex cable. The 4 wires are referred as X+ (left), X23

(right), Y+ (top) and Y- (bottom). An advantage of the 4-wire touch screens is that it is possible
to determine the touch pressure by measuring the contact resistance (R Touch) between the two
ITO layers.

R Touch decreases as the touch pressure (or the size of the depressed area) increases. This
characteristic can be useful in applications in which it is not only required to detect where the
pressure is applied, but also the type of pressure (area and force).

8091A-AVR-07/07 AVR341

Electrodes in 4- and 5- wire touch screens.5-wire touch screens have circular electrodes. Since
all of them reside in the substrate ITO there is a need for linearization pattern (conductive) to
make an applied voltage gradient uniform.
4 wires connect to the electrodes these are referred to as UL (Upper Left), UR (Upper Right), LL
(Lower Left), LR (Lower Right). The fifth wire is used for sensing the electrode voltage and is
referred to as the sense wire. The sense wire is embedded in the top sheet. The advantage of
the 5-wire touch screen type is that the ITO coating on the top sheet is not required to be perfect.
This means that physical wearing of the 5-wire touch screens is less critical than for 4-wire touch
screens.

24

2.5 LCD(Liquid Crystal Display)


[10]Frequently,

an 8051 program must interact with the outside world using input and output

devices that communicate directly with a human being. One of the most common devices
attached to an 8051 is an LCD display. Some of the most common LCDs connected to the 8051
are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per
line by 2 lines, respectively.
Fortunately, a very popular standard exists which allows us to communicate with the vast
majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U,
which refers to the controller chip which receives data from an external source (in this case, the
8051) and communicates directly with the LCD.
2.5.1 44780 BACKGROUND
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 is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit
data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the
data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines
plus the 8 lines for the data bus).
The three control lines are referred to as EN, RS, and RW.
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 (0) and then set
the other two control lines and/or put data on the data bus. When the other lines are completely
ready, bring EN high (1) and wait for the minimum amount of time required by the LCD
datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a
command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1),
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.
25

The RW line is the "Read/Write" control line. When RW is low (0), the information on the data
bus is being written to the LCD. When RW is high (1), the program is effectively querying (or
reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are
write commands--so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the
user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4,
DB5, DB6, and DB7.
As we've mentioned, the LCD requires either 8 or 11 I/O lines to communicate with. For the sake
of this tutorial, we are going to use an 8-bit data bus--so we'll be using 11 of the 8051's I/O pins
to interface with the LCD.
Let's draw a sample pseudo-schematic of how the LCD will be connected to the 8051.

[11]Fig

2.7LCD-Microcontroller Interfacing

As you can see, we've established a 1-to-1 relation between a pin on the 8051 and a line on the
44780 LCD. Thus as we write our assembly program to access the LCD, we are going to equate
constants to the 8051 ports so that we can refer to the lines by their 44780 name as opposed to
P0.1, P0.2, etc. Let's go ahead and write our initial equates:

26

DB0

EQU

P1.0

DB1

EQU

P1.1

DB2

EQU

P1.2

DB3

EQU

P1.3

DB4

EQU

P1.4

DB5

EQU

P1.5

DB6

EQU

P1.6

DB7

EQU

P1.7

EN

EQU

P3.7

RS

EQU

P3.6

RW

EQU

P3.5

DATA EQU P1
Having established the above equates, we may now refer to our I/O lines by their 44780 name.
For example, to set the RW line high (1), we can execute the following instruction:
SETB RW
2.5.2 HANDLING THE EN CONTROL LINE
As we mentioned above, the EN line is used to tell the LCD that you are ready for it to execute
an instruction that you've prepared on the data bus and on the other control lines. Note that the
EN line must be raised/lowered before/after each instruction sent to the LCD regardless of
whether that instruction is read or write, text or instruction. In short, you must always manipulate
EN when communicating with the LCD. EN is the LCD's way of knowing that you are talking to
it. If you don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines.
Thus, before we interact in any way with the LCD we will always bring the EN line low with the
following instruction:
CLR EN
And once we've finished setting up our instruction with the other control lines and data bus lines,
we'll always bring this line high:
SETB EN
The line must be left high for the amount of time required by the LCD as specified in its
datasheet. This is normally on the order of about 250 nanoseconds, but check the datasheet. In
the case of a typical 8051 running at 12 MHz, an instruction requires 1.08 microseconds to
execute so the EN line can be brought low the very next instruction. However, faster
27

microcontrollers (such as the DS89C420 which executes an instruction in 90 nanoseconds given


an 11.0592 MHz crystal) will require a number of NOPs to create a delay while EN is held high.
The number of NOPs that must be inserted depends on the microcontroller you are using and the
crystal you have selected.
The instruction is executed by the LCD at the moment the EN line is brought low with a final
CLR EN instruction.
Programming Tip: The LCD interprets and executes our command at the instant the EN line is
brought low. If you never bring EN low, your instruction will never be executed. Additionally,
when you bring EN low and the LCD executes your instruction, it requires a certain amount of
time to execute the command. The time it requires to execute an instruction depends on the
instruction and the speed of the crystal which is attached to the 44780's oscillator input.
2.5.3 CHECKING THE BUSY STATUS OF THE LCD
As previously mentioned, it takes a certain amount of time for each instruction to be executed by
the LCD. The delay varies depending on the frequency of the crystal attached to the oscillator
input of the 44780 as well as the instruction which is being executed.
While it is possible to write code that waits for a specific amount of time to allow the LCD to
execute instructions, this method of "waiting" is not very flexible. If the crystal frequency is
changed, the software will need to be modified. Additionally, if the LCD itself is changed for
another LCD which, although 44780 compatible, requires more time to perform its operations,
the program will not work until it is properly modified.
A more robust method of programming is to use the "Get LCD Status" command to determine
whether the LCD is still busy executing the last instruction received.
The "Get LCD Status" command will return to us two tidbits of information; the information that
is useful to us right now is found in DB7. In summary, when we issue the "Get LCD Status"
command the LCD will immediately raise DB7 if it's still busy executing a command or lower
DB7 to indicate that the LCD is no longer occupied. Thus our program can query the LCD until

28

DB7 goes low, indicating the LCD is no longer busy. At that point we are free to continue and
send the next command.
2.6 RELAYS
There are a variety of devices which are classed as output devices and are therefore commonly
called Actuators. Actuators convert an electrical signal into a corresponding physical quantity
such as movement, force, sound etc. Actuators can also be considered as either Binary or
Continuous devices based upon the number of stable states their output has. For example, A relay
is a Binary Actuator as it has two stable states, latched and unlatched while a motor is a
Continuous Actuator. The most common types of actuators or output devices are Relays, Lights,
Motors and Loudspeakers and in this tutorial we will look at a Electromechanical Relays and
Solid State Relays.
2.6.1 Basic Operation

[12]Fig

2.8 Relay

We have two sets of electrically conductive contacts. One pair which are classed as Normally
Open, (NO) or make contacts and another set which are classed as Normally Closed, (NC) or
break contacts. These terms "Normally Open, Normally Closed" or "Make and Break Contacts"
refer to the state of the electrical contacts when the relay coil is "de-energized", i.e, no supply
voltage connected to the coil. An example of this arrangement is given below.
29

The relays contacts are electrically conductive pieces of metal which touch together completing a
circuit and allow the circuit current to flow, just like a switch. When the contacts are open the
resistance between the contacts is very high in the Mega-Ohms, producing an open circuit and no
circuit current flows. When the contacts are closed the contact resistance should be zero a short
circuit, but this is not the case. All relay contacts have a certain amount of "contact resistance"
when they are closed and this is called the "On-Resistance". With a new relay and contacts this
on-resistance will be very small, generally less than 0.2's because the tips are new and clean.
For example, if the contacts are passing a load current of say 10A, then the voltage drop across
the contacts using Ohms Law is 0.2 x 10 = 2 volts. As the contact tips begin to wear, and if they
are not properly protected from high inductive or capacitive loads, they will start to show signs
of arcing damage as the circuit current still wants to flow as the contacts open. This arcing or
sparking will cause the contact resistance of the tips to increase as the contact tips become
damaged. If allowed to continue the contact tips may become so burnt and damaged to the point
were they are physically closed but do not pass any or very little current.

2.6.2 Relay Contact Types


As well as the standard descriptions of Normally Open, (NO) and Normally Closed, (NC) used
to describe how the relays contacts are connected, relay contact arrangements can also be classed
by their actions. Electromechanical relays are made up of one or more individual switches with
each "switch" being referred to as a Pole. Each one of these switches or poles can be connected
or "thrown" together by energizing the relays coil and this gives rise to the description of the
contact types as:

SPST - Single Pole Single Throw

SPDT - Single Pole Double Throw


30

DPST - Double Pole Single Throw

DPDT - Double Pole Double Throw

2.7 Working of the Hardware


1.

Master Module
On Power on, the Bluetooth module is configured to be in command mode and
automatically connects to the Slave module via the Bluetooth link. The commands are

issued stored in the Microcontroller.


On being connected the L.C.D. shows Connected and a blue LED blinks for 5 times.
The Four wire Resistive touch-screen is interfaced with Microcontroller via Analog to
Digital Converter 0848 (A.D.C.). When an area on the screen is pressed, the
corresponding voltage values are fed to the ADC which converts them into 8 bit digital

data.
The 8-bit digital data is fed to a Port of Microcontroller. The Microcontroller decodes the
data and sends a corresponding data serially to the Bluetooth device connected at Pin 11

and 12.
This data is transmitted to the slave module and accordingly it responds.

31

32

2. Working of Slave Module


On Power On, the Slave Bluetooth module is configured to be in command mode and
connects to the master Bluetooth module upon receiving commands from the

Microcontroller.
After being connected, it receives data from the Master Module, which sends it to

Microcontroller via UART.


The controller decodes the data and then it performs the required action based on the

Data received.
If the data Sent is 1 0 , then Electric Bulb connected via Relay at Pin 3.6 will glow.
If the data Sent is 0 1 , then Electric Bulb connected via Relay at Pin 3.7 will glow.
If the data Sent is 0 0 , then both the Electric Bulbs will not glow.
The function of Relay is to switch the power supply from AC Mains to the Electric bulb.

3.

33

34

Chapter 3
Software

35

[13]Connecting

hardware according to the circuit diagram doesnt work really. You need to

program the components accordingly so as to work according to the algorithm you have designed
in order to make the project work properly as required. Following is the description of software
used.
3.1 Cx51 Compiler
The C programming language is a general-purpose programming language that provides code
efficiency, elements of structured programming, and a rich set of operators. C is not a big
language and is not designed for any one particular area of application. Its generality combined
with its absence of restrictions, makes C a convenient and effective programming solution for a
wide variety of software tasks. Many applications can be solved more easily and efficiently with
C than with other more specialized languages.
The Cx51 Optimizing C Compiler is a complete implementation of the American National
Standards Institute (ANSI) standard for the C language. The Cx51 Compiler is not a universal C
compiler adapted for the 8051 target. It is a ground-up implementation, dedicated to generating
extremely fast and compact code for the 8051 microprocessor. The Cx51 Compiler provides you
with the flexibility of programming in C and the code efficiency and speed of assembly
language.
Since the Cx51 Compiler is a cross compiler, some aspects of the C programming language and
standard libraries are altered or enhanced to address the peculiarities of an embedded target
processor.
The Keil C51 C Compiler for the 8051 microcontroller is the most popular 8051 C compiler in
the world. It provides more features than any other 8051 C compiler available today.
The C51 Compiler allows you to write 8051 microcontroller applications in C that, once
compiled, have the efficiency and speed of assembly language. Language extensions in the C51
Compiler give you full access to all resources of the 8051.

36

The C51 Compiler translates C source files into relocatable object modules which contain full
symbolic information for debugging with the Vision Debugger or an in-circuit emulator. In
addition to the object file, the compiler generates a listing file which may optionally include
symbol table and cross reference information.
3.1.1 Features

Nine basic data types, including 32-bit IEEE floating-point,

Flexible variable allocation with bit, data, b data, I data, x data, and p data memory
types,

Interrupt functions may be written in C,

Full use of the 8051 register banks,

Complete symbol and type information for source-level debugging,

Use of AJMP and ACALL instructions,

Bit-addressable data objects,

Built-in interface for the RTX51 Real-Time Kernel,

Support for dual data pointers on Atmel, AMD, Cypress, Dallas Semiconductor,
Infineon, Philips, and Triscend microcontrollers,

Support for the Philips 8xC750, 8xC751, and 8xC752 limited instruction sets,

Support for the Infineon 80C517 arithmetic unit.

The 8051 Family is one of the fastest growing Microcontroller Architectures. More than 500
device variants from various silicon vendors are available today. New extended 8051 devices,
like the Philips 80C51MX architecture, are dedicated for large applications with several
megabytes of code and data space.
For optimum support of these different 8051 variants, Keil provides several development tools
that are listed in the table below. A new output file format (OMF2) allows direct support of up to
16MB code and data space. The CX51 Compiler is a variant of the C51 compiler that is designed
for the new Philips 80C51MX architecture.
37

38

3.2 KEILSOFTWARE

Keil Micro Vision is an integrated development environment used to create software to be run on
embedded systems(like a microcontroller).It allows for such software to be written either in
assembly or C programming languages and for that software to be simulated on a computer be
fore being loaded on to the microcontroller.

3.2.1 Vision3
Vision3is an IDE (Integrated Development Environment)that helps write, compile, and
debug embedded programs. It encapsulates the following components:

A project manager.
A make facility.
Tool configuration.
Editor.

A powerful debugger.

39

Chapter 4
List of
References

40

[1]

Muhammad Ali Mazidi , Janice Gillispie Mazidi, Rolin D. Mckinlay.


Second edition, THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEM
Chapter 2: The 8051 Microcontrollers, Page Number: 19 25
Chapter 9 : Using Timers
Chapter 10 : Serial port programming
Chapter 12 : LCD programming
Chapter 13 : Using ADC 0848 and its programming

[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10
]
[11
]
[12
]
[13
]

http://www.ikalogic.com/tut_8051_1_.php
http://microcontroller51.blogspot.com/2010/08/microcontrollers.html
http://www.mikroe.com/eng/chapters/view/14/chapter-1-world-of-microcontrollers/
http://www.nskelectronics.in/files/aubtm-20_v12.pdf
http://www.8051projects.info/forum/tags/interface%20bluetooth%20with
%208051%20microcontroller.html
http://www.afiata.com/search/bluetooth+transmitter+circuit
http://www.nskelectronics.in/touch_screen.html
http://www.nskelectronics.in/_ds_touch_screen.html
http://www.multyremotes.com/lcd-interfacing.htm
http://knol.google.com/k/interfacing-an-lcd-to-8051-microcontroller-lcd-programming
http://www.classictruckshop.com/clubs/earlyburbs/projects/bosch/relay.htm
http://www.keil.com/appnotes

41

Chapter 5
Limitations
&
Future

42

Limitations
The Range of Bluetooth Transmitter Receiver is limited.
The number of devices that can be connected and controlled cannot exceed 30
Touch Screen is sensitive and susceptible to get damaged easily.

Future Scope
A fully functional touch screen operated system can be built that would be able to control
any number of devices.
The range of the device can be enhanced.
Voice controlled system can also be incorporated in the already existing mechanism.

43

Appendix

44

Annexure: A
Block Diagram

45

46

Annexure: B
Schematic

47

48

49

50

Annexure: C
Source Code

51

#include <REGX51.H>
sbit REL1=P1^0;
sbit REL2=P1^1;
unsigned char x1,k;
unsigned int i,j;
void data_tx(unsigned char);
unsigned char data_rx(unsigned char);
unsigned char buff[6];
unsigned char buff2[28];
unsigned char slave_1[]={'L','L','L'};
unsigned char
slave_2[]={13,10,'A','T','+','B','D','I','S','C','M','O','D','E',
'=','3',',','0',13,10};
unsigned char slave_ok[]={'@','@','@'};
void delay(int x)
{
unsigned int i,j;
for(i=0;i<=255;i++)
for(j=0;j<=x;j++);
}
/************************** SLAVE PROGRAMMING
**************************/
void main()
{
P1=0x00;
delay(1000);
TMOD=0x20;
//
Timer 1 , Mode 2 : 8 bit Auto Reload
TH1=0xfd;
// Baud Rate = 9600
TL1=0xfd;
SCON=0x50;
//
Serial 8 bit , REN Enabled
TR1=1;
while(1)
{
REP:for(i=0;i<3;i++)
// Transmitting 'LLL' to Module
{
data_tx(slave_1[i]);
}
for(j=0;j<6;j++)
// Receiving OK from Module
{
buff[j]=data_rx(x1);
}
if(buff[0]==13&&buff[1]==10&&buff[2]=='O'&&buff[3]=='K'&&buff[4]=
52

=13&&buff[5]==10)
received
{
/* LED1=0;
delay(100);
LED1=1;
LED2=0;
delay(100);
LED2=1;
LED3=0;
delay(100);
LED3=1; */

//

Checking for OK

REP2: for(i=0;i<20;i++)
{
// Transmitting 'AT+BDISCMODE=3,0' to Module
data_tx(slave_2[i]);
}
for(j=0;j<6;j++)
// Checking for OK received
{
buff[j]=data_rx(x1);
}
if(buff[0]==13&&buff[1]==10&&buff[2]=='O'&&buff[3]=='K'&&buff[4]=
=13&&buff[5]==10)
// Checking for OK
received
{
delay(1000);
for(j=0;j<28;j++)
// Receiving CONNECTED notification
{
buff2[j]=data_rx(x1);
}
REP3: if(buff2[0]==13&&buff2[1]==10)
Checking for OK received
{
for(i=0;i<3;i++)
// Transmitting '@@@' to MASTER for
Confirmation
{
//

data_tx(slave_ok[i]);
}
while(1)
53

{
k=data_rx(x1);
if(k=='Q')
{
REL2=0;
REL1=1;
}
else if(k=='R')
{
REL1=0;
REL2=1;
}
else if(k=='S')
{
REL1=1;
REL2=1;
}
else
{
REL1=0;
REL2=0;
}
}
}
else

goto REP3;

}
else goto REP2;
}
else
goto REP;
}
}
/****************************************************/
void data_tx(unsigned char x)
{
54

SBUF=x;
while(TI==0);
TI=0;
}
/****************************************************/
unsigned char data_rx(unsigned char y)
{
while(RI==0);
y=SBUF;
RI=0;
return(y);
}

55

Annexure: D
Flow Chart

56

Start
Power On

Transmitting LLL to Master Module

Wait till OK is received

Received OK?
YE
NO

Light the LEDs as Confirmation

Transmitting @@@ to Master


Module

Received Connection
Confirmation?

YE
If Data Received = Q

YES
RELAY1=1
RELAY2=0

NO
YES
If Data Received = R

RELAY1=1
RELAY2=1

NO
NO

If Data Received = S

YES
RELAY1=0
RELAY2=1

EXIT

57

Annexure: E
Data Sheets

58

You might also like