Chapters
Chapters
Chapters
INTRODUCTION
To design this embedded system we are using a wireless network, Infrared sensors,
limit switch, microcontrollers, interfacing circuits like MAX232, conditioning circuits and
other components.
By this project we can display the presence or absence of a specific person and the
number of persons in his/her cabin on the LCD display placed at the receiver side using
wireless transmission. Here we are using Xbee module which uses Zigbee protocol for the
wireless transmission.
The microcontrollerAT89S52 was used in this project which has facilities of interfacing
with other devices and circuits and its programming speed is high. Its ROM size is 8 kilo
bytes and RAM size is 256 bytes. We are using two microcontrollers in this project.
Hardware Components:
Keil u Vision 4
Until now for knowing the presence of a specific person in his/her respective cabin or
workspace we used to either enquire or watch at them without their notice and which is not so
advisable in case of higher officials.
A remedy to this is the usage of a IN/OUT box which is placed outside the door of the
personnel and it must be operated by any other person as if to know whether the person is
present in the room or not. But if the box is not adjusted according to the status of the person,
it might be another problem for the people who come to meet the respected person in the
cabin.
So taking this as a problem for human kind we had started this project to find a
solution to this problem using the concepts of electronics and the usage of electronic devices.
A specified person must every time change the status of the box.
If such types of devices are not used the time of the persons who comes to meet the
official gets wasted.
For overcoming the disadvantages in the existing model and to find a solution to the
above problem we had started designing this system using the concepts of electronics and the
use of simple electronic devices.
In this system we use the IR sensor and the limit switch as the inputs at the transmitter
side and these are given as inputs to the microcontroller and the output is transmitted to the
receiver section using the Zigbee wireless transmission protocol and is received at the
receiver end and is displayed in the 16*2 LCD display unit.
Chapter 3 deals with brief explanation of the microcontroller and the other
components and also their interfacing with the microcontroller and the overall circuit
diagram.
In this chapter the overview and requirements of the project are discussed along with
criteria to choose microcontroller. In the next chapter block diagram and its operations are
explained.
In the last chapter the overview and requirements of the project are discussed. This
chapter deals with the block diagram and its operation. The basic operation of the circuit can
be explained using the block diagram.
Figure 2.1 shows the transmitter block diagram of the system. The transmitter block
mainly consists of the power supply section which takes input from 230V, 50Hz AC Supply
and gives it to the 12V step-down transformer and the 12V output from the transformer is
given to the bridge rectifier to get it converted to DC voltage and then to the voltage regulator
circuit to limit the output voltage to 5V for giving the power supply to the micro controller
board.
The other main components in the transmitter section are the IR Sensors and the limit
switch which are the input devices for the micro controller. The controller is the heart of the
circuit which gives the output whether the person is present or not in the 16*2 LCD display
device in the receiver section.
Power supply
Tx
Sensor 1
Limit
switch
Figure 2.2 shows the receiver block diagram of the system. The receiver section is a
combination of the ZIGBEE TRANSRECEIVER, MAX232, Micro controller and LCD
display with power supply section.
Power
Supply
Rx
Zigbee 16*2
Max Micro
Transceiver
232 controller LCD Display
2.3 Working
The input to the circuit is applied from the regulated power supply. The ac input i.e.,
230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier.
The output obtained from the rectifier is a pulsating dc voltage. So in order to get a pure dc
voltage, the output voltage from the rectifier is fed to a filter to remove any ac components
present even after rectification. Now, this voltage is given to a voltage regulator to obtain a
In transmitter section IR sensors are used which emits infrared radiation. This
radiation illuminates the surface in front of LED. Surface reflects the infrared light.
Depending on the reflectivity of the surface, amount of light reflected varies. This reflected
light is made incident on reverse biased IR sensor when photons are incident on reverse
biased junction of this diode, electron-hole pairs are generated, which results in reverse
leakage current. Amount of electron-hole pairs generated depends on intensity of incident IR
radiation. More intense radiation results in more reverse leakage current. This current can be
passed through a resistor so as to get proportional voltage. Thus as intensity of incident rays
varies, voltage across resistor will vary accordingly.
This voltage can then be given to OP-AMP based comparator. Output of the
comparator can be read by the micro controller and it processes and the resulting data is
transmitted through wireless Zigbee transceiver.
Another input device in the system is the limit switch. It is connected to the
microcontroller at the port 1.2 and which gives the signal to the microcontroller when the
person is present in his / her respective chair. This gives the high enable signal to the
microcontroller when the person sits in the chair and with respective to this the output of the
system varies accordingly.
The limit switch is a device which gives the high output signal when the two
terminals get touched with each other. This is done only when the person sits in the chair and
so it is placed beneath the chair.
The both outputs from the IR sensors and the limit switch are given to the
microcontroller and it is programmed in such a way that according to these input conditions
the output is obtained and it is transferred to the receiver section by using the Zigbee
transceiver.
In between the microcontroller and the Zigbee module we had used an MAX 232 IC
which is used to convert the TTL logic levels to the RS 232 standard values and vice-versa.
This is placed as the Zigbee transceiver works with RS 232 standard and the microcontroller
At receiver section the Zigbee transceiver receives the signal and it is transmitted to
microcontroller through MAX232 IC. It is a specialized circuit which makes standard
voltages as required by RS232 standards. This IC provides best noise rejection and very
reliable against discharges and short circuits. MAX232 IC chips are commonly referred to as
line drivers. To ensure data transfer between PC and microcontroller, the baud rate and
voltage levels of Microcontroller and PC should be the same. The voltage levels of
microcontroller are logic1 and logic 0 i.e., logic 1 is +5V and logic 0 is 0V. But for PC,
RS232 voltage levels are considered and they are: logic 1 is taken as -3V to -25V and logic 0
as +3V to +25V. So, in order to equal these voltage levels, MAX232 IC is used. Thus this IC
converts RS232 voltage levels to microcontroller voltage levels and vice versa.
The microcontroller reads the information and it is programmed such that port 3 is
taken as input port and port 2 as output port. The resultant output data is transferred to LCD
section. LCD are very commonly used , LCDs are easy to program and are proved to be a
better display unit as compared to other devices like seven segments and LED display units.
HARDWARE IMPLEMENTATION
In the previous chapter the block diagram and its operation are discussed. This chapter
explains about Microcontroller AT89S52 features, pin diagram, and the other components
used and their interfacings with the microcontroller are discussed.
Hardware Architecture:
Applications:
Addressing modes provide access to large arrays of data using pointers and offsets.
They have instructions to set and clear individual bits and perform bit operations. They have
instructions for input/output operations, event timing, enabling and setting priority levels for
interrupts caused by external stimuli. Processing power of a microcontroller is much less than
a microprocessor.
The Power Supply is a primary requirement for the circuit to operate. The required
DC power supply for the base unit as well as for the recharging unit is derived from the mains
line. For this purpose centre tapped secondary of 12V-0-12V transformer is used. From this
transformer after regulating we get 5V power supply. In this +5V output is a regulated output
and it is designed using 7805 positive voltage regulator. This is a three pin voltage regulator
which can deliver current up to 800 mA. Rectification is a process of rendering an alternating
current or voltage into a uni-directional one. The component used for rectification is called
rectifier. A rectifier permits current to flow only during positive half cycles of the applied AC
voltage. Thus, pulsating DC is obtained and further to obtain smooth DC power additional
filter circuits required. The ac voltage, typically 120 Vrms, is connected to a transformer,
which steps that ac voltage down to the level for the desired dc output. A diode rectifier then
provides a full-wave rectified voltage that is initially filtered by a simple capacitor filter to
produce a dc voltage. This resulting dc voltage usually has some ripple or ac voltage
variation.
230V AC
D.C
50Hz Output
A diode can be used as rectifier. These are various types of diodes. However,
semiconductor diodes are very popularly used as rectifiers. A semiconductor diode is a solid-
state device consisting of two elements is being an electron emitter or cathode, the other an
electron collector or anode. Since electrons in a semiconductor diode can flow in one
direction only-form emitter to collector-the diode provides the unilateral conduction
necessary for rectification. The rectified output is filtered for smoothening the DC, for this
purpose capacitor is used in the filter circuit. The filter capacitors are usually connected in
parallel with rectifier output and the load. The AC can pass through a capacitor but DC
cannot, the ripples are thus limited and the output becomes smoothed. When the voltage
across the capacitor plates tends to rise, it stores up energy back into voltage and current.
Thus, the fluctuation in the output voltage is reduced considerable.
Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the
circuitry for reference source, comparator amplifier, control device, and overload protection
all in a single IC. Although the internal construction of the IC is somewhat different from that
described for discrete voltage regulator circuits, the external operation is also in the same
manner. IC units provide regulation of either a fixed positive or negative voltage, or an
adjustable set voltage. A power supply can be built using a transformer connected to the ac
supply line to step down the ac voltage to desired amplitude, then rectifying that ac voltage,
filtering with a capacitor and finally regulating the dc voltage using an IC regulator.
3.6 IR LED
The appearance is same as a common LED. Since the human eye cannot see the
infrared radiations, it is not possible for a person to identify whether the IR LED is working
3.7 Photodiode
A photodiode is a type of photo detector capable of converting light into either current
or voltage, depending upon the mode of operation. The common, traditional solar cell used to
generate electric solar power is a large area photodiode.
Photodiodes are similar to regular semiconductor diodes except that they may be
either exposed (to detect vacuum UV or X-rays) or packaged with a window or optical fiber
connection to allow light to reach the sensitive part of the device. Many diodes designed for
use specifically as a photodiode use a PIN junction rather than a p-n junction, to increase the
speed of response. A photodiode is designed to operate in reverse bias.
3.8 IR Sensor
IR sensor works on the principle of emitting IR rays and receiving the reflected ray by
a receiver (Photo Diode).
IR source (LED) is used in forward bias.
IR Receiver (Photodiode) is used in reverse bias
3.9 Resistor
Units
The ohm (symbol: ) is the SI unit of electrical resistance, named after George
Simon Ohm. An ohm is equivalent to a volt per ampere. Since resistors are specified and
manufactured over a very large range of values, the derived units of milliohm (1 m = 10 3
), kilo ohm (1 k = 103 ), and mega ohm (1 M = 106 ) are also in common usage.
The symbol used for a resistor in a circuit diagram varies from standard to standard
and country to country. Two typical symbols are as follows.
Fig. 3.8 Resistor symbols. (a) Resistor, (b) Rheostat (variable resistor)
Lead arrangements
Through-hole components typically have leads leaving the body axially. Others have
leads coming off their body radially instead of parallel to the resistor axis. Other components
may be SMT (surface mount technology) while high power resistors may have one of their
leads designed into the heat sink.
The electronic color code is used to indicate the values or ratings of electronic
components, very commonly for resistors, but also for capacitors, inductors, and others. A
separate code, the 25-pair color code, is used to identify wires in some telecommunications
cables. The electronic color code was developed in the early 1920s by the Radio
Manufacturers Association (now part of Electronic Industries Alliance (EIA)), and was
published as EIA-RS-279. The current international standard is IEC 60062.
Resistors manufactured for military use may also include a fifth band which indicates
component failure rate (reliability). Tight tolerance resistors may have three bands for
significant figures rather than two, or an additional band indicating temperature coefficient, in
units of ppm/K. Table 3.1 shows standard colour code of the resistors.
3.10 Capacitor
When there is a potential difference (voltage) across the conductors, a static electric
field develops across the dielectric, causing positive charge to collect on one plate and
negative charge on the other plate. Energy is stored in the electrostatic field. An ideal
capacitor is characterized by a single constant value, capacitance, measured in farads. This is
the ratio of the electric charge on each conductor to the potential difference between them.
The capacitance is greatest when there is a narrow separation between large areas of
conductor, hence capacitor conductors are often called "plates," referring to an early means of
construction. In practice, the dielectric between the plates passes a small amount of leakage
current and also has an electric field strength limit, resulting in a breakdown voltage, while
the conductors and leads introduce an undesired inductance and resistance.
Capacitors are widely used in electronic circuits for blocking direct current while
allowing alternating current to pass, in filter networks, for smoothing the output of power
supplies, in the resonant circuits that tune radios to particular frequencies, in electric power
transmission systems for stabilizing volt A capacitor consists of two conductors separated by
a non-conductive region. The non-conductive region is called the dielectric. In simpler terms,
the dielectric is just an electrical insulator. Examples of dielectric media are glass, air, paper,
vacuum, and even a semiconductor depletion region chemically identical to the conductors. A
capacitor is assumed to be self-contained and isolated, with no net electric charge and no
influence from any external electric field. The conductors thus hold equal and opposite
charges on their facing surfaces, and the dielectric develops an electric field. In SI units, a
A Liquid Crystal Display is used to display any message on its screen which can be
programmed by a microcontroller.
3.11.1 Description
The LCD unit receives character codes (8 bits per character) from a microprocessor or
microcomputer, latches the codes to its display data RAM (80-byteDD RAM for storing 80
characters), transforms each character code into a 5X7 dot matrix character pattern, and
displays the characters on its LCD screen. The LCD unit incorporates a character generator
ROM which produces 160 different 5X7 dot-matrix character patterns.
The unit also provides a character generator RAM (64 bytes) through which the user
may define up to eight additional 5X7 dot matrix character patterns, as required by the
application. To display a character, positional data is sent via the data bus from the
microprocessor to the LCD unit, where it is written into the instruction register. A character
code is then sent and written into the Data register. The LCD unit displays the corresponding
character pattern in the specified position.
The LCD unit can either increment or decrement the display position automatically
after each character entry, so that only successive characters codes need to be entered to
display a continuous character string. The display/cursor shift instruction allows the entry of
characters in either the left-to-right or right to left direction.
Since the display data RAM (DDRAM) and the character generator RAM (CG RAM)
many be accessed by the microprocessor, unused portions of each RAM may be used as
general purpose data areas.
The LCD unit may be operated with either dual 4-bit or single 8-bit data transfers, to
accommodate interfaces with both 4-bit and 8-bit microprocessors. The low power feature of
the LCD unit will be further appreciated when combined with a CMOS microprocessor.
The description of each pin is shown in the Table 3.2 along with symbol and also
indicating whether it is used as input or output pin.
1 VSS -- Ground
2 VCC -- +5V power supply
3 VEE -- Power supply to control contrast
4 RS I RS=0 to select command register
RS=1 to select data register
5 R/W I R/W=0 for write
R/W=1 for read
6 EN I/O Enable
7 DB0 I/O The 8-bit data bus
8 DB1 I/O The 8-bit data bus
9 DB2 I/O The 8-bit data bus
10 DB3 I/O The 8-bit data bus
11 DB4 I/O The 8-bit data bus
12 DB5 I/O The 8-bit data bus
13 DB6 I/O The 8-bit data bus
14 DB7 I/O The 8-bit data bus
All data transferred to LCD through outputs D0-D7 will be interpreted as commands
or as data, which depends on logic state on pin RS:
Rarely, a final operating device such as a lamp or solenoid valve will be directly
controlled by the contacts of an industrial limit switch, but more typically the limit switch
will be wired through a control relay, a motor contactor control circuit, or as an input to
a programmable logic controller.
1. Microcontroller
2. PC or any external device which can be interfaced with the microcontroller through
serial communication.
When the pins P3.0 and P3.1 of microcontroller are set, UART which is inbuilt in the
microcontroller will be enabled to start the serial communication.
Both timers 0 and 1 use the same register TMOD to set the various operation modes.
TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4
bits for Timer 1. In each case, the lower 2 bits are used to set the timer mode and the upper 2
bits to specify the operation. The syntax for TMOD register is given in table 3.4.
GATE
Every timer has a means of starting and stopping. Some timers do this by software,
some by hardware and some have both software and hardware controls. The timers in the
8051 have both. The start and stop of the timer are controlled by the way of software by the
TR (timer start) bits TR0 and TR1. These instructions start and stop the timers as long as
GATE=0 in the TMOD register. The hardware way of starting and stopping the timer by an
external source is achieved by making GATE=1 in the TMOD register.
Timer or counter selected. Cleared for timer operation and set for counter operation.
Table 3.5 shows the operating modes of the timers in according to the register values.
The MAX232 has two sets of line drivers for transferring and receiving data. The line
drivers used for TXD are called T1 and T2 with the line drivers for RXD are designated as
R1 and R2. In many applications only one of each are used. For example, T1 and R1 are used
together for TXD and RXD of 89S52, and the second set is left unused. In MAX232 T1 line
driver has a designation of T1in andT1out as pin numbers 11 and 14 respectively. The T1 pin
is the TTL side and is connected to TXD of the micro-controller, while T1 out is the RS232
side that is connected to the RXD pin of the RS232 DB connecter .The line drivers has a
designation of R1 in and R1out on pin numbers 13 and 12 respectively.
The SCON register is an 8-bit register used to program the start bit, stop bit and data
bits of data framing. The syntax for SCON register, its pins functions and the modes of serial
communication are given in table 3.6, table 3.7 and table 3.8 respectively.
The current list of application profiles either published or in the works are:
Home Automation
Zigbee Smart Energy
Commercial Building Automation
Telecommunication Applications
Personal, Home, and Hospital Care
Toys
Protocols
As the output we get from the IR sensor is very low for the controller to get operated
we use a conditioning circuit by using LM 358 IC which acts as non-inverting amplifier and
whose output is connected to the microcontroller.
The reset switch is connected at the 9th pin of the microcontroller. The 2nd port of pins
(pin 2.0 to 2.7) are connected to the LCD display device which is used for displaying the
name of the system.
As the 3rd port pins have alternate functionalities the 10th and 11th pins of the
microcontroller are connected to the Xbee module through the MAX 232 IC.
MAX 232 is a 16 pin IC and the 10th pin of microcontroller is connected to 11th pin of
the MAX 232 IC and the 11th pin of the controller is connected to 12th pin of IC. The Xbee
module is connected between the pins 13 and 14 of the Max 232 IC.
The schematic of the receiver section of the system is shown in figure 3.19 which
deals with the circuit connection of the receiver circuit.
The receiver section is almost same as that of the transmitter section and it also
consists of the Xbee module (Zigbee transceiver) which is connected to the microcontroller
through the MAX 232 IC. Same as that of in the transmitter section the MAX 232 IC is
connected in between 10 and 11 pins of the microcontroller.
The Zigbee transceiver here receives the information from the transmitter and
sends it to the microcontroller through the MAX232 IC and the microcontroller
processes it accordingly and displays the count of the persons entering the room by
incrementing the count value and by decrementing the value shows the number of
persons coming out of the room and the available status of the person is given by the
limit switch as IN/OUT. This information is displayed in the LCD display at the receiver
end.
SOFTWARE IMPLEMENTATION
This chapter deals with the software we had used in this project for executing the
program we had written. We had chosen the Keil software for our programming.
Keil is a cross compiler. So first we have to understand the concept of compilers and
cross compilers. After then we shall learn how to work with keil.
Compilers are programs used to convert a High Level Language to object code.
Desktop compilers produce an output object code for the underlying microprocessor, but not
for other microprocessors. I.E the programs written in one of the HLL like C will compile
the code to run on the system for a particular processor like x86 (underlying microprocessor
in the computer). For example compilers for Dos platform is different from the Compilers for
Unix platform.
A cross compiler is similar to the compilers but we write a program for the target
processor (like 8051 and its derivatives) on the host processors (like computer of x86)
It means being in one environment you are writing a code for another environment is
called cross development. And the compiler used for cross development is called cross
compiler.
Keil Software provides you with software development tools for the 8051 family of
microcontrollers. With these tools, you can generate embedded applications for the multitude
of 8051 derivatives. Keil provides following tools for 8051 development
The keil 8051 tool kit includes three main tools, assembler, compiler and linker. An
assembler is used to assemble your 8051 assembly program. A compiler is used to compile
your C source code into an object file. A linker is used to create an absolute object module
suitable for your in-circuit emulator.
In this project we are using two IR sensors and limit switch as inputs to the
microcontroller. The program flowchart and algorithm of this project are explained in this
chapter.
4.4 Algorithm
Step1: start
Step2: Initialise IR1 and IR2 to one and limit switch to one.
Step10: Stop.
The result of the above given algorithm is that the system takes the input and
processes it and displays either the person is present or not in the output display unit
according to the taken conditions.
Start
Make IR1=1and
IR2=1 Limit
Switch=0 and
Count=0
IF IR1=0
=>Count++
Display the count value
IF IR2=0 =>Count--
IF
LS=1
Person is in Cabin
Stop
Then the values from the IR sensor and limit switch are taken and accordingly the
conditions are checked and the output is displayed on the LCD display.
5.1 RESULT
The results obtained from the project are shown in the figures 5.1, 5.2, 5.3 and 5.4 and
they make a view to users how the project works and the usage of the project. The images
shown below are about when power supply is not given to the circuit.
The figure 5.1 shows the interconnection of the modules in the transmitter section
like microcontroller, LCD display, IR sensor, limit switch, Xbee module, on the PCB when
the power supply is not given to the circuit. The result of the circuit when the supply is given
is shown in the figure 5.3.
Figure 5.3 shows the transmitter section circuit when the supply is given to the circuit.
The LCD display show the title of the system and the LEDs glow on the board connected to
the IR sensors and they get OFF when an obstacle is placed in between them. the output is
transmitted to the receiver section using the Zigbee transceiver.
For IR sensors:
Table 5.1 shows the outputs of IR sensors based on the presence of obstacle. After
integration the results are obtained as the microcontroller identifies the sensor signal and
responds by glowing corresponding LEDs, indicating LCD display.
Table 5.2 shows the outputs of the limit switch based on the connection of the limit
switch. After integration the results are obtained as the microcontroller identifies the if the
limit switch is pressed then the microcontroller responds by displaying the status of the
person.
Some of the considerations should be taken while introducing the product into the
market.Some of them are Cost of the objective ,as this project is implemented with the basic
embedded components the preparation and placement cost is low its a good advantage.
Complexity of establishment, here the only main thing is connections and placement as both
are easier the complexity is very less.
Scope and usage are at cabins of the higher officials where people go and just look at
the display device and get their work done when the respective person is free and thus the
time doesnot get wasted.
This project may be extended by maintaing a database for the person availability and
in real time the basic limit switch can be repalced by high level cameras and by using the
concepts of Digital Image Processing.
[4] Upena Dalal WIRELESS COMMUNICATION Oxford Higher education pvt limited
First published in 2009.
URLs
[6] www.atmel.in/images/doc1919.pdf
[7] http://www.alldatasheet.com/datasheet/MOTOROLA/LM358N
[8] www.alldatasheet.com/MAX232+datasheet
Appendix A
Program Code
#include<reg51.h>
#define lcd_data P2
sbit ir1=P1^0;
sbit ir2=P1^1;
sbithod=P1^2;
sbitlcd_rs = P2^0;
sbitlcd_en = P2^1;
int x=0,y=0;
unsignedintx,y;
for(x=0;x<value;x++)
for(y=0;y<200;y++);
lcd_en=0;
delay(3);
lcd_en=0;
voidlcd_init(void)
lcdcmd(0x02);
lcdcmd(0x02);
delay(3);
lcd_en=0;
delay(3);
lcd_en=0;
delay(3);
for(s=0;b[s]!='\0';s++)
count++;
if(s==16)
lcdcmd(0xc0);
if(s==32)
lcdcmd(1);
count=0;
lcddata(b[s]);
voidserinit()
TMOD=0x20;
TH1=0xFD; //9600
SCON=0x50;
while(RI == 0);
rx=SBUF;
RI=0;
returnrx;
for(;*tx != '\0';tx++)
SBUF=*tx;
while(TI == 0);
TI=0;
SBUF=tx;
while(TI == 0);
TI=0;
void main()
ir1=1;
ir2=1;
hod=0;
serinit();
lcd_init();
msgdisplay("DYNAMIC DETECTION");
lcdcmd(0xc0);
delay(200);
lcdcmd(0x80);
msgdisplay("COUNT:");
while(1)
if(hod==1) //in
{ tt='1';
//sertx('c');
// lcdcmd(0xc0);
if(hod==0) //out
{ tt='0';
//sertx('d');
//lcdcmd(0xc0);
if(ir1 == 1)
{while(ir1 == 1);
x++;
// sertx('a');
if(ir2 == 1)
{while(ir2 == 1);
x--;
if(x <= 0)
x=0;
sertx('*');
sertx(tt);
convert(x);
sertxs("lkjlskajflksjflkjsdflkjsdlfkjslkfj");
a=value/100;
b=value%100;
c=b/10;
a=a|0x30;
c=c|0x30;
d=d|0x30;
// lcddata(a);
// lcddata(c);
// lcddata(d);
sertx(a);sertx(c);sertx(d);
return 1;
#include<reg51.h>
#define lcd_data P2
sbitlcd_rs = P2^0;
sbitlcd_en = P2^1;
unsignedintx,y;
for(x=0;x<value;x++)
for(y=0;y<200;y++);
delay(3);
lcd_en=0;
delay(3);
lcd_en=0;
voidlcd_init(void)
lcdcmd(0x02);
lcdcmd(0x02);
delay(3);
lcd_en=0;
delay(3);
lcd_en=0;
delay(3);
for(s=0;b[s]!='\0';s++)
count++;
if(s==16)
lcdcmd(0xc0);
if(s==32)
lcdcmd(1);
count=0;
lcddata(b[s]);
voidserinit()
TMOD=0x20;
TH1=0xFD; //9600
SCON=0x50;
TR1=1;
while(RI == 0);
rx=SBUF;
RI=0;
returnrx;
for(;*tx != '\0';tx++)
SBUF=*tx;
while(TI == 0);
TI=0;
SBUF=tx;
while(TI == 0);
TI=0;
voidsie()
ET0 = 0;
EA = 1;
voidsid()
ET0 = 1;
EA = 0;
void main()
serinit();
//sie();
//delay(10);
lcd_init();
msgdisplay("DYNAMIC DETECTION");
lcdcmd(0xc0);
delay(400);lcdcmd(1);
lcdcmd(0x80);
msgdisplay("COUNT:");//0x86..8a
lcdcmd(0x8a);
lcddata('-');//0x8b
//msgdisplay("Norml");
//lcdcmd(0xc0);
while(1)
do{
rcv1 = receive();
}while(rcv1 != '*');
rcv2 = receive();
rcv3 = receive();
rcv4 = receive();
rcv5 = receive();
lcdcmd(0x86);
lcddata(rcv3);lcddata(rcv4);lcddata(rcv5);
if(x <= 5)
lcdcmd(0x8b);msgdisplay("Norml");
if(x > 5)
//lcdcmd(0x8b);
if(rcv2 == '1')
lcdcmd(0xc0);
if(rcv2 == '0')
lcdcmd(0xc0);
delay(300);
a=value/100;
b=value%100;
c=b/10;
d=b%10;
a=a|0x30;
c=c|0x30;
d=d|0x30;
lcddata(c);
lcddata(d);
return 1;
DC Characteristics of AT89S52
LCD Display