Professional Documents
Culture Documents
CONTENTS
1. Introduction
2. Functional Block Diagram
3. Functional Description
4. Introduction to AT 89C51
5. Hardware
5.1 Power Supply
5.2 L C D
5.3 ASK Tx and Rx
5.4 MATRIX keypad
5.5 Relay Driver Circuit Using ULN 2003
6. Software
6.1 Flow Chart
6.2 Program
INTRODUCTION
INTRODUCTION:
The main motivation behind bringing our project entitled
MICROCONTROLLER
BASED
INSTRUMENT
IDENTIFICATION AND DETECTION is the careless nature of the
human beings after the work is done. We know that it is the human
tendency to misplace the things after the work is done rather than placing
them in predefined order so that we can get it easily whenever it is
required again. If not placed in order difficulty arises while searching. In
the case of a small firm or laboratory searching is not a problem but for
the case of big laboratory searching kills lot of time which is not good.
This project enables to find the misplaced thing without actually wasting
lot of time.
INPUT KEY
BOARD 4*4
MATRIX
Relay,s
And
Driver
MICRO
CONTROLLER
89C51
SEPROM
LCD 16*2
Receiver:-
ASK Rx
MICRO
CONTROLLER
89C51
BUZZER
ASK Tx
Functional Description:
INTRODUCTION
TO AT 89C51
8951/8051 MICROCONTROLLER:
Computer in its simplest from needs at least three basic blocks: the
central processing unit (CPU). Input-output (I/O) and memory
(RAM/ROM). The integrated from of CPU is the microprocessor. As the
use of microprocessors in control applications increased, development of
microcontroller unit or MCU took shape, wherein CPU, I/O and some
limited memory on a single, chip was fabricated. Intention was to reduce
the chip count as much as possible. There are many types of
microcontrollers currently in the market, out of which the 8031. Family
from Intel, and second soured by many others, have gained immense
popularity.
INTRODUCTION
Looking back into the history of microcomputers, one would at first come
across the development of microprocessor, I.e.., the processing element,
and later on the peripheral devices. The three basic element the CPU,
I/O devices and memory- have developed in distinct direction. While the
CPU has been the proprietary item, the memory devices fall into generalpurpose category and the I/O devices may be grouped somewhere inbetween. The control applications of microprocessors have different
requirements, both hardware-wise as well as software-wise. Whereas
microprocessor has just sufficient number of on-chip devices to act as the
CPU, a number of other auxiliary devices are needed to get a working
microcontroller. integration of I/O and memory with the CPU on a single
chip ushered in the era of development of a new class of devices, i.e...,
the single chip microcontrollers. Now only one device was needed to run
an independent control application. The 8048 from Intel, Z80 from Zilog,
6805 and 6811 from Motorola represent a few of the members of this
large family. The 8048 from Intel became popular due to its use in the
keyboard of the IBM PC.
The family of second generation microcontrollers from Intel, the 8051
and other related devices, has brought about a new revolution in this field.
While the early microcontrollers had only limited memory and existent
serial I/O capability, the 8051 provides for 4k PROM/ROM, 128 byte
RAM and 32 I/O lines. It also includes a universal asynchronous receivetransmit (UART) device, two 16-bit timer/counter and elaborate Interrupt
logic. Lack of multiply and divide instructions, has also been taken care
of in the 8051. Thus the 8051 may be called nearly equivalent of the
following devices on a single chip:
8085 + 8255 + 8251 + 8253 + 2764 + 2764 + 6116
(Microprocessor) (PPI) (USART) (TIMER) (EPROM) (RAM)
In short, the 8051 has the following on-chip facilities:
4k ROM (EPROM on 8751)
128 byte RAM
USRT
32 Input-output port lines
TWO 16-bit timer/ count
Six interrupt sources and
On-chip clock oscillator and power on- reset circuitry.
The other members of this family, such as 8053, have one extra
timer/counter, 8k ROM/EPROM and 256 byte RAM, while 8031and
8032 are corresponding ROM-less versions of 8052,respectivily. All these
are also available in CMOS versions. The 8051 family includes a large
numbers of members from many manufacturers, some of which are listed
below.
8051 with 4k ROM and its
8751 with 4k EPROM
8031 ROM-less version.
8052 with 8k ROM, one additional counter/timer and 256-bit RAM; its
other version (8052h) comes with
built-in BASIC interpreter.
8032 & 8752 are ROM + I/O (80C31) Along with pulse width modulator.
80C592 With 8-channel A/D converter, by Philips.
AT 89C51 CMOS device with EPROM (100 times programmable), by
ATMEL.
SALIENT FEATURES
The 8051 can be configured to bypass the internal 4k RAM and run
solely with external program memory. For this its external access ( ) pin
31 has to be grounded, which makes it equivalent to 8031. The program
store enable (PSEN) signal acts as read pulse for program memory. The
data memory is external only and a separate RD* signal is available for
reading its contents.
Use of external memory requires that three of its 8-bit ports (out of four)
are configured to provide data/address multiplexed bus, Hi address bus
and control signals related to external memory use. The RXD and TXD
ports of UART also appear on pins 10 and 11 of 8051 and 8031,
respectively. One 8-bit port, which is bit addressable and extremely useful
for control applications, still remains free for use.
The UART utilizes one of the internal timers for generation of baud rate.
The crystal used for generation of CPU clock has therefore to be chosen
carefully. The 3.579MHz crystal; available abundantly, can provide a
baud rate of 1200.
The 256-byte address space is utilized by the internal RAM and special
function registers (SFRs)array which is separate from external RAM
space of 64k. the 00-7f space is occupied by the RAM and the 80-FF
space by the SFRs. The 128-byte internal RAM has been utilized in the
following fashion:
00-1F: Used for four banks of eight registers of 8-bit each. The four
banks may be selected by soft ware any time during the program.
INSTRUCTION SET
Moving Data
Mnemonic
Operation
MOV A, #n
MOV A, Rr
MOV Rr, A
MOV Rr, #n
MOV DPTR, #nn
Mnemonic
MOV A, #OF1h
register
Operation
Move the immediate data byte F1h to the A
MOV A, RO
Copy the data in register RO to register A
MOV DPTR, #0ABCDh Move the immediate data bytes ABCDh to the DPTR
MOV R5, A
Copy the data in register A to register R5
MOV R3, # 1 Ch
Move the immediate data byte 1Ch to register R3
CAUTION
It is impossible to have immediate data as a destination.
All number must star with a decimal number (0-9), or the assumes the number is a
label.
Register-to-register moves using the register addressing mode occur between register
A and RO to R7.
LOGICAL OPERATIONS
Mnemonic Operation
RL
Rotate a byte to the left; the Most Significant Bit (MSB) becomes the Least
Significant Bit (LSB)
RLC
Rotate a byte and the carry bit left; the carry becomes the LSB, the MSB
becomes the carry
RR
Rotate a byte to the right; the LSB becomes the MSB
RRC
Rotate a byte carry to the right; the LSB becomes the carry, and the carry the
MSB
SWAP Exchange the low and high nibbles in a byte
CAUTION
If the direct address destination is one of the port SFRs, the data latched in the SFR,
not the pin data is used.
No flags are affected unless the the direct address is the PSW.
Only internal RAM or SFRs may be logically manipulated.
Mnemonic
INC destination
Operation
Increment destination by 1
DEC destination
ADD/ADDC destination, source
SUBB destination, source
MUL AB
of register B
Decrement destination by 1
Add source to destination with/with carry flag
Multiply the contents of register A and B
Divide the contents of register A by the contents
DA A
CAUTION
Operation
Jump relative if the Carry flag is set to 1
JUMP relative if the Carry flag is reset to 0
JUMP relative if addressable bit set to 1
JUMP relative if addressable bit is set, and clear the
Unconditional Jumps
Mnemonic
JMP @A+DPTR
an unconditional
Operation
Jump to the address formed by adding A to the DPTR; this is
Jump and will always be done; the address can be anywhere
in program
memory; A, the DPTR, and the flags are unchanged
AJMP sadd
Jump to absolute short range address sadd; this an unconditional jump
and is always taken;no flags are affected
LJMP sadd
Jump to absolute long range address ladd; this is an unconditional
jump and is always taken; no flags are affected
SJMP radd
Jump to relative address radd; this is an unconditional jump and is
always taken; no flags are affected
NOP
Do nothing and go to the next is instruction; NOP (no operational) is
used to waste time in a software timing loop, or to leave room in a program for later
additions; no flags are affected
DJNZ decrements first, then check for 0. A location set to 00h and then decremented
goes to FFh, then Feh, and so on, down to 00h.
CJNE does nor change the contents of any register or RAM location. It can change
the Carry flag to 1 if the destination byte is less than the source byte.
There is no zero flag; the JZ and JNZ instructions check the contents of the A register
for 0.
JMP @A+DPTR does not change A, DPTR, or any flags,
The student version of A51 will not assemble more than 400h bytes of code (0000to
03FFh). Addresses greater than 03FFh are not assembled.
HARDWARE
POWER SUPPLY:
Main building block of any electronic system is the power supply to provide
required power for their operation. For the microcontroller, audio amplifier, keyboard,
edge connector +5V, required. And for driving the motor +12V. Is required. The
power supply provides regulated output voltage of +5V, and non regulated output
voltage +12V.
Three terminal IC 7805 meets the requirement of +5V regulated. The secondary
voltage from the main transformer is rectified by diodes D1-D4 and are filtered by
capacitor C1. This unregulated dc voltage is supplied to input pin of regulator IC. C2
is an input bypass capacitor and C3 is to improve ripple rejection. The IC used are
fixed regulator with internal short circuit current limiting and thermal shut down
capability
number of instructions to the LCD. The first instruction will be to specify whether we
are
using 4 or 8- line data bus. Sending a 38h command to the LCD dose this. Before we
send the
Command the RS line should be made low. We then send the 0Eh command to turn
the LCD
On. Lastly we send the 06h command so that every time we send a character the
cursor
automatically moves right.
NOTE: the LCD can be cleared using the 01h command.
Cursor Positioning
The 44780 contain a certain amount of memory, which is assigned to display. All
Text we write to 44780 is stored in this memory, and the 44780 subsequently reads
this
Memory to display the text on LCD itself. This memory maps is shown below.
DISPLAY
In the above memory map, area up to 0F and 4F is the visible display. As one can see, it
measures 16
Characters per 2 lines. The numbers in each box in memory address that corresponds to that
on screen.
Thus the Set Cursor Position instruction 80h tell the LCD to position the cursor. Adding the
cursor
Position to 80h does these sets the cursor to the required position on the screen.
PIN Assignment:
PIN NO.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SYMBOL
Vss
VDD
V0
RS
R/W
E
DBO
DB1
DB2
DB3
DB4
DB5
DB6
DB7
LED-(K)
LED-(A)
RS
0
RW
0
DB7
0
DB6
0
FUNCTIONAL SET
DB5 DB4 DB3
1
1
N
DB2
F
DB1
X
DB0
X
RS
0
RW
0
DB1
C
DB0
B
DB2
0
DB1
0
DB0
1
DB2
1
DB1
I/D
DB0
SH
RW
0
DB7
0
DB6
0
DB5
0
DB4
0
DB3
0
RS
0
RW
0
DB7
0
condition: fosc=270khz
N
0
1
1-LINE MODE
2-LINE MODE
0
1
DISPLAY OFF
DISPLAY ON
DISPLAY OFF
DISPLAY ON
0
1
CURSOR OFF
CURSOR ON
0
1
BLINK OFF
BLINK ON
DECREMENT
MODE
INCREMENT
MODE
I/D
1
0
SH
1
ENTTIRE SHIFT
OFF
ENTIRE SHIFT
ON
RS
0
RW
0
DB7
0
DB6
0
FUNCTION SET
DB5 DB4 DB3
1
0
X
DB2
X
DB1
X
DB0
X
0
0
0
0
0
N
0
F
1
X
0
X
X
X
X
F
X
X
X
X
DB1
X
X
DB0
X
X
DB1
X
X
RS
0
0
RW
0
0
RS
0
0
RW
0
0
DB7
0
0
RS
0
0
RW
0
0
DB7
0
0
Condition : f0sc=270khz
N
0
1
1-LINE MODE
2-LINE MODE
0
1
DISPLAY OFF
DISPLAY ON
0
1
DISPLAY OFF
DISPLAY ON
0
1
CURSOR OFF
CURSOR ON
DB2
X
X
DB1
X
X
DB0
X
X
DB0
X
X
0
1
BLINK OFF
BLINK ON
DECREMENT
MODE
INCREMENT
MODE
I/D
1
0
SH
1
ENTTIRE SHIFT
OFF
ENTIRE SHIFT
ON
ASK Tx and Rx
Here we are using amplitude shift keying modulation type RF transmitter and
Receiver, and the specification of each are as bellow.
Transmitter:
* Frequency
* Bandwidth
433 M Hz
+/- 200 k hz
* current
12 m amp
* Frequency
433 M Hz
Receiver:
* Bandwidth
* current
+/- 200 k hz
30 m amp
INTERFACING KEYBOARD:
A matrix keyboard is a commonly used input device when more than
eight keys are necessary, rather than a row of keys as illustrated. A matrix
keyboard reduces the number of connections, thus
The number of interfacing devices required. For example, a keyboard
With 16 keys, arranged in a 4*4 matrix. Requires eight lines from the
Microcontroller to make all the connections instead of 16 lines if the
Keys are connected in a linear format. When a key is pressed, it shorts
one row and column; otherwise, the row and the column do not
Have any connection. The interfacing of a matrix keyboard requires
Two ports; one output port and the input port. Rows are connected to
The output port, and the columns are connected to the input port. They
are capable of interfacing a matrix keyboard as large as 64 keys,
INTERFACING KEYBOARD:
RELAY SPDT
12V VCC
Common
NC
NO
VALVE
1
2
R1
1
Q1
SL 100
10 k
From
Micro
Controller
GND
GND
SOFTWARE
FLOW CHART
Transmitter
Start
Search Item
Tx ID of item
Receiver
Start
Receive Message
No
Is ID
Matche
d
Yes
ON Buzzer
PROGRAM