handy vehicle documentation
TRANSCRIPT
-
8/2/2019 Handy Vehicle Documentation
1/46
CHAPTER- 1
INTRODUCTION
In this project handy vehicle regulation using digitally addressed micro controllers , a
micro controller is interfaced with a computer , transmitter ,LCD . The Micro controller is used
for monitoring and decoding the digital signaling. The LCD is used for user interface. . Linear
power supply is used to provide operating voltages. The Real time clock chip (RTC) is used to
generate real time signals to maintain the clock in our system in the power failure conditions.
Here computer is interfaced to input the data through the keyboard to the MC for
iteration to the human (user). By this the user transmits the required data to be displayed on the
dislplay .
When power is switched on, Micro controller (MC) is reset by power through the reset
circuit. It produces one high pulse and continues low pulse. During the high pulse the program
counter is set to 0000h. During low pulse the program counter starts its count and the
remaining operations are executed.
First the MC sends the signals to the LCD to display the massage such as project title
etcthis also indicate the reset of MC. Next it monitor the input address i.e the digital address
of mc for editing the menu items such as [*/# ]. Next MC initiates the RTC and gets the timing
details from its data bus. And it will initiate the ADC (adc0809). This is a multiplexed ADC and
it will handle 8 analog signals and they selected according to the address pins (A0, A1, A2). MC
1
-
8/2/2019 Handy Vehicle Documentation
2/46
selects the one of the parameter (CT\PT) by giving address signals. And it will give the start of
conversion signal and it will wait for end of the conversion.
According to the user settings i.e the address initially sent is decoded at the mc end , checks
wether the data is sent to it or not , by matching and checking the address ( $/# ) further driver
manually checks the data obtained to match a certain place in a industry with help of look up
table provided.
Block diagram
2
-
8/2/2019 Handy Vehicle Documentation
3/46
Chapter-2
Radio
433 MHz RF Receiver STR-433
The STR-433 is ideal for short-range remote control applications where cost is a primary
concern. The receiver module requires no external RF components except for the antenna. It
generates virtually no emissions, making FCC and ETSI approvals easy. The super-regenerative
design exhibits exceptional sensitivity at a very low cost. Themanufacturing-friendly SIP style
package and low-cost make the STR-433 suitable for high volume applications.
2.1.1 Features
Low Cost
5V operation
3.5mA current drain
No External Parts are required
Receiver Frequency: 433.92 MHZ
Typical sensitivity: -105dBm
IF Frequency: 1MHz
2.1.2 Applications
Car security system
Sensor reporting
Automation system
3
-
8/2/2019 Handy Vehicle Documentation
4/46
Remote Keyless Entry (RKE)
Remote Lighting Controls
On-Site Paging
Asset Tracking
Wireless Alarm and Security Systems
Long Range RFID
433 MHz RF Transmitter STT-433
The STT-433 is ideal for remote control applications where low cost and longer range is
required. The transmitter operates from 1.5-12V supply, making it ideal for battery-powered
applications.The transmitter employs SAW-stabilized oscillator, ensuring accurate frequency
control for best range performance. Output power and harmonic emissions are easy to control,
making FCC and ETSI compliance easy. The manufacturing-friendly SIP style package and
low-cost make the STT-433 suitable for high volume applications.
2.2.1 Features
433.92 MHz Frequency
Low Cost
1.5-12V operation
11mA current consumption at 3V
Small size
4 dBm output power at 3V
4
-
8/2/2019 Handy Vehicle Documentation
5/46
2.2.2 Applications
Remote Keyless Entry (RKE)
Remote Lighting Controls
On-Site Paging
Asset Tracking
Wireless Alarm and Security Systems
Automated Resource Management
2.2.3 Specification
CHAPTER-3
Interfacing
3.1 8- bit micro controller: 89C2051
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 elements-the CPU, I/O devices and memory-have developed in distinct
directions. While the CPU has been the proprietary item, the memory devices fall into general-
purpose category and the I/O devices may be grouped somewhere in-between.
5
-
8/2/2019 Handy Vehicle Documentation
6/46
The AT89C2051 is a low-power, high-performance CMOS 8-bit microcomputer with 2kbytes of
Flash programmable and erasable read only memory (EPROM). The device is manufactured
using Atmels high-density nonvolatile memory technology and is compatible with the industry-
standard MCS-51 instruction set and pin out. The on-chip Flash allows the program memory to
be reprogrammed in-system or by a conventional nonvolatile memory programmer. By
combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C2051 is a
powerful microcomputer, which provides a highly flexible and cost-effective solution to many
embedded control applications.
The AT89C2051 provides for 2k EPROM/ROM, 128 byte RAM and 15 I/O lines. It also
includes a universal asynchronous receive-transmit (UART) device, two 16-bit timer/counters
and elaborate interrupt logic. Lack of multiply and divide instructions which had been always
felt in 8-bit microprocessors/micro controllers, has also been taken care of in the 89s52- Thus
the 89s52 may be called nearly equivalent of the following devices on a single chip: 8085 +
8255 + 8251 + 8253 + 2764 + 6116.
AT89C2051 has the following on-chip features:
89s52 Central Processing Unit
On-chip FLASH Program Memory
Speedup to 33 MHz
RAM expandable externally up to 64 Kbytes
Four interrupt priority levels
Six interrupt sources
Four 8-bit input output ports
6
-
8/2/2019 Handy Vehicle Documentation
7/46
Full-duplex enhanced UART
Framing error detection
Automatic address recognition
o Three 16-bit timers/counters T0, T1and additional T2
Programmable clock out
Second DPTR register
Asynchronous port reset
Power control modes
o -Clock can be stopped and resumed
o -Idle mode
o -Power down mode
non-volatile FLASH program memory that is parallel programmable
Flash memory features
FLASH EPROM internal program memory with chip erases.
Up to 64K byte external program memory if the internal program memory is
disabled
Programmable security bits.
10,000 minimum erase/program cycles for each byte.
3.2 INTERNAL STRUCTURE OF CONTROLLER
7
-
8/2/2019 Handy Vehicle Documentation
8/46
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.
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
11.0596 MHz crystals; available abundantly, can provide a baud rate of 9600.
The internal RAM utilizes the 256-byte address space and special function
registers (SFRs) array, which is separate from external data RAM space of 64k. The
00-7F space is occupied by the RAM and the 80 - FF space by the SFRs. The 128byte internal RAM has been utilized in the following fashion:
00-IF: Used for four banks of eight registers of 8-bit each. The four banks may be
selected by software any time during the program.
20-2F: The 16 bytes may be used as 128 bits of individually addressable locations.
These are extremely useful for bit-oriented programs.
30- 7F: This area is used for temporary storage, pointers and stack. On reset, the stack
starts at 08 and gets incremented during use.
8
-
8/2/2019 Handy Vehicle Documentation
9/46
\INTERNAL DIAGRAM OF 89s52 fig 2
9
-
8/2/2019 Handy Vehicle Documentation
10/46
The list of special function registers along with their hex addresses is given-(table1)
10
-
8/2/2019 Handy Vehicle Documentation
11/46
11
AT 89s52 Address
register
Addr. Port/Register
80 P0 (Port 0)
81 SP (stack pointer)
82 DPH (data pointer High)
83 DPL (data pointer Low)
88 TCON (timer control)
89 TMOD (timer mode)
8A TLO (timer 0 low byte)
8B TL1 (timer 1 low byte)
8C TH0 (timer 0 high byte)
8D TH1 (timer 1 high byte)
90 P1 (port 1)
98 SCON (serial control)
99 SBUF (serial buffer)
A0 P2 (port 2)
A8 Interrupt enable (IE)
B0 P3 (port 3)
B8 Interrupt priority (IP)
D0 Processor status word (PSW)
E0 Accumulator (ACC)
F0 B register
-
8/2/2019 Handy Vehicle Documentation
12/46
SFR ADDRESSES IN 89s52
SPECIAL FUNCTION REGISTERS(SFRs)
SFR DESCRIPTIONS
P0 (Port 0, Address 80h, Bit-Addressable): This is input/output port 0. Each bit
of this SFR corresponds to one of the pins on the microcontroller. For example, bit 0
of port 0 is pin P0.0, bit 7 is pin P0.7. Writing a value of 1 to a bit of this SFR will
send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a
low level.
DPL/DPH (Data Pointer Low/High, Addresses 82h/83h)
The SFRs DPL and DPH work together to represent a 16-bit value called the
Data Pointer. The data pointer is used in operations regarding external RAM and some
instructions involving code memory. Since it is an unsigned two-byte integer value, it
can represent values from 0000h to FFFFh (0 through 65,535 decimal).
PCON (Power Control, Addresses 87h): The Power Control SFR is used to
control the 8051's power control modes. Certain operation modes of the 8051 allow the
8051 to go into a type of "sleep" mode which requires much less power. These modes
of operation are controlled through PCON. Additionally, one of the bits in PCON is
used to double the effective baud rate of the 8051's serial port.
TCON (Timer Control, Addresses 88h, Bit-Addressable)
The Timer Control SFR is used to configure and modify the way in which the
8051's two timers operate. This SFR controls whether each of the two timers is running
or stopped and contains a flag to indicate that each timer has overflowed. Additionally,
some non-timer related bits are located in the TCON SFR. These bits are used to
12
-
8/2/2019 Handy Vehicle Documentation
13/46
configure the way in which the external interrupts are activated and also contain the
external interrupt flags which are set when an external interrupt has occured.
TMOD (Timer Mode, Addresses 89h)
The Timer Mode SFR is used to configure the mode of operation of each of the
two timers. Using this SFR your program may configure each timer to be a 16-bit
timer, an 8-bit autoreload timer, a 13-bit timer, or two separate timers. Additionally, you
may configure the timers to only count when an external pin is activated or to count
"events" that are indicated on an external pin.
TL0/TH0 (Timer 0 Low/High, Addresses 8Ah/8Ch)
These two SFRs, taken together, represent timer 0. Their exact behavior depends on
how the timer is configured in the TMOD SFR; however, these timers always count
up. What is configurable is how and when they increment in value.
GATE: When set, start and stop of timer by hardware
When reset, start and stop of timer by software
C/T : Cleared for timer operation
table-2
M1 M0 MODE OPERATING MODE
13
-
8/2/2019 Handy Vehicle Documentation
14/46
0 0 0 13-bit timer mode
0 1 1 16-bit timer mode
1 0 2 8-bit auto reload mode
1 1 3 Split timer mode
TL1/TH1 (Timer 1 Low/High, Addresses 8Bh/8Dh)
These two SFRs, taken together, represent timer 1. Their exact behavior depends
on how the timer is configured in the TMOD SFR; however, these timers always count
up. What is configurable is how and when they increment in value.
Address =88H.
Bit addressable.
TF: Timer overflow flag: Set by hardware when the timer/counter overflows. It is
cleared by hardware, as the processor vectors to the interrupt service routine.
TR: timer run control bit: Set or cleared by software to turn timer or counter on/off.
IE: set by CPU when the external interrupt edge (H-to-L transition) is detected. It
is cleared by CPU when the interrupt is processed.
14
-
8/2/2019 Handy Vehicle Documentation
15/46
IT: set/cleared by software to specify falling edge/low-level triggered external
interrupt.
P1 (Port 1, Address 90h, Bit-Addressable)
This is input/output port 1. Each bit of this SFR corresponds to one of the pins
on the microcontroller. For example, bit 0 of port 1 is pin P1.0, bit 7 is pin P1.7.
Writing a value of 1 to a bit of this SFR will send a high level on the corresponding
I/O pin whereas a value of 0 will bring it to a low level.
SCON (Serial Control, Addresses 98h, Bit-Addressable)
The Serial Control SFR is used to configure the behavior of the 8051's on-board
serial port. This SFR controls the baud rate of the serial port, whether the serial port is
activated to receive data, and also contains flags that are set when a byte is successfully
sent or received.
8H
REN set or cleared by software to enable or disable reception.
TB 8 not widely used.
RB 8 not widely used.
TI transmits interrupt flag. Set by hardware at the beginning of the stop bit in
mode 1. It must be cleared by software.
RI received interrupts flag. Set by hardware halfway through the stop bit time in
mode 1. It must be cleared by software.
table-3
15
-
8/2/2019 Handy Vehicle Documentation
16/46
SM0 SM1 Serial mode 0
0 0 Synchronous mode
0 1 8-bit data, 1 start bit, 1 stop bit,
variable baud rate
1 0 9- bit data, 1 start bit, 1 stop bit,
fixed baud rate
1 1 9- bit data, 1 start bit, 1 stop bit,
variable baud rate
SBUF (Serial Control, Addresses 99h)
The Serial Buffer SFR is used to send and receive data via the on-board serial
port. Any value written to SBUF will be sent out the serial port's TXD pin. Likewise,
any value which the 8051 receives via the serial port's RXD pin will be delivered to
the user program via SBUF. In other words, SBUF serves as the output port when
written to and as an input port when read from.
P2 (Port 2, Address A0h, Bit-Addressable)
This is input/output port 2. Each bit of this SFR corresponds to one of the pins
on the microcontroller. For example, bit 0 of port 2 is pin P2.0, bit 7 is pin P2.7.
Writing a value of 1 to a bit of this SFR will send a high level on the corresponding
I/O pin whereas a value of 0 will bring it to a low level.
3.3 SERIAL COMMUNICATION
When a microprocessor communicates with the outside world, it provides data in
byte-sized chunks. In some cases, such as printers, the information is simply grabbed
from the 8-bit data bus and presented to the 8-bit data bus of the printer. This can
work only if the cable is not too long, since long cables diminish and ever distort
signals. Furthermore, and 8-bit data path is expensive.
16
-
8/2/2019 Handy Vehicle Documentation
17/46
For these reasons, serial communication is used for transferring data between two
systems located at distances of hundreds of feet to millions of miles apart.
The fact that in serial communication a single data line is used instead of the 8-
bit data line of parallel communication makes it not only much cheaper but also makes
it possible for two computers located in two different cities to communicate over the
telephone.
Serial data communication uses two methods, a synchronous and asynchronous.
The synchronous method transfers a block of data at a time while the synchronous
transfers a single byte at a time.
It is mean possible to write software to use either of these methods, but the
programs can be tedious and long. For this reason, there are special IC chips made bymany manufacturers for serial data communications.
These chips are commonly referred to as UART (universal asynchronous receiver-
transmitter) and USART (universal synchronous -asynchronous receiver-transmitter).
The8051 chips has built-in UART, which is discussed
DATA TRANSFER RATE
The rate of data transfer in serial data communication is stated in bps (bits per
second). Another widely used terminology for bps is baud rate. Baud rate is defined
as the number of signal changes per second.
As far as the conductor wire is concerned, the baud rates as bps are the same.
If each signal change represents more than one bit, bits per second may be greater than
baud rate.
3.4 RS 232 STANDARDS INTERFACING
To allow compatibility among the data communication equipment made by
various manufacturers; an interfacing standard called RS232, was set by the electronics
industries association (EIA) in 1960. RS 232 is the standard defined for the connection
of "Data Terminal Equipment" (DTE) to "Data Communications Equipment" (DCE).
17
-
8/2/2019 Handy Vehicle Documentation
18/46
DTE (Data Terminal Equipment) is a generic term for an item which forms part
of the "information processing" portions of a system. Examples are: computer, printer,
and terminal.
DCE (Data Communications Equipment) is a device, which provides an interface
between a DTE and a communications link.
DTE/DCE CONNECTION
All Signals Are Ground Referenced to in Pin 7
TXD, RXD---- Transmit and Receive Signal
RTS---- Request to Send, from DTE
CTS---- Clear to send, from DCE together with RTS
DTE---- Data Terminal Ready, indicates to the modem that a DTE is Connected and
enabled.
fig 3 DTE
DC connections
DSR--- Data Set Ready,
indicates to the DTE that
the modem is present
and turned on
CD-- Carrier Detect,
indicates that this modem is
receiving a signal from the
remote modem.
In RS 232, a 1 is represented by -3 to -25V which is called Mark, while a 0
bit is + 3 to + 25V which is called Space.
To connect any RS 232 to a c system, voltage converters such as Max 232are
used. Max 232 IC chips are commonly referred to as line drivers.8.3. MAX 232. The
RS 232 is not compatible with micro controllers, so a line driver converts the RS 232's
signals to TTL voltage levels.
18
-
8/2/2019 Handy Vehicle Documentation
19/46
3.5 LCD MODULE INTERFACING
To display an interactive messages we are using LCD Module. We examine an
intelligent LCD display of two lines, 20 characters per line, that is interfaced to the
8051.The protocol (handshaking) for the display is as shown.
Where as D0 to D7thbit is the Data lines, RS, RW and EN pins are the control
pins and remaining pins are +5V, -5V and GND to provide supply. Where RS is the
Register Select, RW is the Read Write and EN is the Enable pin.
The display contains two internal byte-wide registers, one for commands (RS=0)
and the second for characters to be displayed (RS=1). It also contains a user-
programmed RAM area (the character RAM) that can be programmed to generate any
desired character that can be formed using a dot matrix.
To distinguish between these two data areas, the hex command byte 80 will be
used to signify that the display RAM address 00h will be chosen.
Port1 is used to furnish the command or data type, and ports 3.2 to3.4 furnish
register select and read/write levels, The display takes varying amounts of time to
accomplish the functions as listed. LCD bit 7 is monitored for logic high (busy) to
ensure the display is overwritten.
3.6 SOFTWARE IMPLEMENTATION
19
-
8/2/2019 Handy Vehicle Documentation
20/46
Now that the basic form of an assembly language program has been given,
the next question is: how it is created, assembled and made ready to run? The
steps to create an executable assembly language program are outlined as follows.
BASIC FORM OF ASSEMBLY LANGUAGE PROGRAM
First we use an editor to type in a program similar to program. Many excellent
editors or word processors are available that can be used to create and/or edit
the program. A widely used editor is the MS-DOS EDIT program (or notepad
in Windows), which comes with all Microsoft operating systems. Notice that theeditor must be able to produce an ASCII file. For many assemblers, the file
names follow the usual DOS conventions, but the source file has the extension
"ASM "or "SRC ", depending on which assembler you are using. Check your
assembler for the convention. The "asm ", extension for the source file is used
by an assembler in the next step.
The "ASM "source file containing the program code is created in step 1 is fed
to an 8051 assembler. The assembler converts the instructions into machine code.
The assembler will produce an object file and a list file. The extension for the
object file is "OBJ "by the extension for the list file is "1ST ".
Assemblers require a third step calling linking. The link program takes one or
more objects files and produces an absolute object file with the extension "ABS".
8051 trainers that have a monitor program use this ABS file.
Next the "ABS "file is fed into a program called "OH "(Object to Hex
Converter) which creates a file with extension "HEX "that these ready to burn
into ROM. This program comes with all 8051 assemblers. Recent Windows-
based assemblers combine steps 2 through 4 into one step.
20
-
8/2/2019 Handy Vehicle Documentation
21/46
EVALUATION OF KEIL
Start the Vision Program
After the program has started:
Select File, New from the program menu
Type your assembly file. The following is an example of a toggle program.
Select File, Save from the program menu
The first time you save the program a dialog box will popup and allow you to
name your file and file type.
Save program with filename: xxxxx.asm
The File type is mentioned at last (.asm) means assembly language
Select Project, New Project from the program menu
Give some project name: xxxx.prj
Click on the Add button
A dialog-box appears, allowing you to add files to the project
Change the file type to Assembly.
Select your assembly file.
Click on the Add button then close the Add dialog box. Click on Save in your Project dialog box.
Select Project, Make: Build Project from the program menu
This creates the HEX file you need for the 8051
Chapter-4
Data transmission process
21
-
8/2/2019 Handy Vehicle Documentation
22/46
4.1 Introduction to micro controller
The AT89C2051 is a low-power, high-performance CMOS 8-bit microcomputer
with 2kbytes of Flash programmable and erasable read only memory (EPROM).
By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel
AT89C2051 is a powerful microcomputer, which provides a highly flexiblemany
embedded control applications.It also includes a universal asynchronous receive-
transmit (UART) device, two 16-bit timer/counters and elaborate interrupt logic
30- 7F: This area is used for temporary storage, pointers and stack. On reset,
the stack starts at 08 and gets incremented during use
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.
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 11.0596 MHz crystals; available abundantly, can provide a baud rate of
9600.
The internal RAM utilizes the 256-byte address space and special function
registers (SFRs) array, which is separate from external data 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-IF: Used for four banks of eight registers of 8-bit each. The four banks may
be selected by software any time during the program.
20-2F: The 16 bytes may be used as 128 bits of individually addressable
locations
22
-
8/2/2019 Handy Vehicle Documentation
23/46
4.2 SIX INTERRUPTS IN THE 89S52
Reset.
Two interrupts are set aside for the timers.
Two interrupts are set aside for hardware external hardware interrupts.
Serial Communications has a single interrupt (receive and transfer).
The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7
bits of the SFR are used to enable/disable the specific interrupts, where as the highest
bit is used to enable or disable ALL interrupts. Thus, if the high bit of IE is 0 all
interrupts are disabled regardless of whether an individual interrupt is enabled by setting
a lower bit.
EA disable all interrupts. If EA = 0, now interrupt is acknowledged. If EA = 1,
each interrupt source is individually enabled or disabled by setting or clearing its enable
a lap bit.
---- Not implemented, reserved for future use.
ET2 enables or disables timer 2 overflow or capturer interrupt.
ES enables or disables the serial port interrupt.
ET1 enables or disables timer 1 overflow interrupt.
EX1 enables or disables external interrupt 1.ET0 enables or disables timer 0 overflow interrupt.
EX0 enables or disables external interrupt 0.
P3 (Port 3, Address B0h, Bit-Addressable)
23
-
8/2/2019 Handy Vehicle Documentation
24/46
This is input/output port 3. Each bit of this SFR corresponds to one of the pins
on the microcontroller.
For example, bit 0 of port 3 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1
to a bit of this SFR will send a high level on the corresponding I/O pin whereas a
value of 0 will bring it to a low level.
IP (Interrupt Priority, Addresses B8h, Bit-Addressable)
The Interrupt Priority SFR is used to specify the relative priority of each
interrupt. On the 8051, an interrupt may either be of low (0) priority or high (1)
priority. An interrupt may only interrupt interrupts of lower priority.
If a serial interrupt is executing no other interrupt will be able to interrupt the
serial interrupt routine since the serial interrupt routine has the highest priority.
--- IP.7 Reserved
--- IP.6 Reserved
PT2 IP.5 Timer2 Interrupt Priority bit (for 8052 only)
PS IP.4 Serial Port Interrupt Priority Bit
PT1 IP.3 Timer1 Interrupt Priority Bit
PX1 IP.2 External Interrupt Priority Bit
PT0 IP.1 Timer0 Interrupt Priority Bit
PX0 IP.0 External Interrupt Priority Bit
PSW (Program Status Word, Addresses D0h, Bit-Addressable)
The Program Status Word is used to store a number of important bits that are
set and cleared by microcontroller instructions.
The PSW SFR contains the carry flag, the auxiliary carry flag, the overflow flag,
and the parity flag. Additionally, the PSW register contains the register bank select flags
which are used to select which of the "R" register banks are currently selected. The
24
-
8/2/2019 Handy Vehicle Documentation
25/46
-
8/2/2019 Handy Vehicle Documentation
26/46
Pin number Common
Name
RS232
name
Description Signal
direction
1 /CD CF Received line signal detector IN
2 RXD BB Received data IN
3 TXD BA Transmitted data OUT4 /DTR CD Data terminal ready OUT
5 GND AB Signal ground --
6 /DSR CC Data set ready IN
7 /RTS CA Request to send OUT
8 /CTS CB Clear to send IN
9 -- CE Ring indicator IN
Table 4.1
We cannot simply connect our system to this terminal with out providing proper
hand shaking signal. For communicating with RS-232 type equipment, the /RTS
of the connector is simply looped into the /CTS, so /CTS will automatically be
asserted when /RTS is asserted internally. Similarly the /DTR is looped into
/DSR and /CD, so when PC asserts its /DTR output the /DSR and /CD inputs are
automatically be asserted, these connections do not provide for any hardware
hand shaking. They are necessary to get the PC and our system talk each other.
The fact that in serial communication a single data line is used instead of
the 8-bit data line of parallel communication makes it not only much
cheaper but also makes it possible for two computers located in two
different cities to communicate over the telephone.
Serial data communication uses two methods, a synchronous and
asynchronous. The synchronous method transfers a block of data at a
time while the synchronous transfers a single byte at a time.
It is mean possible to write software to use either of these methods, but
the programs can be tedious and long. For this reason, there are special
IC chips made by many manufacturers for serial data communications.
These chips are commonly referred to as UART (universal asynchronous
receiver-transmitter) and USART (universal synchronous -asynchronous
26
-
8/2/2019 Handy Vehicle Documentation
27/46
receiver-transmitter). The8051 chips has built-in UART, which is
discussed
4.4 LCD DISPLAY
G +5V -5
11
D0 D1 D2 D3 D4 D5 D6 D7 RS R\W
BIT RS R/W D7 D6 D5 D4 D3 D2 D1 D0 Function
0 0 0 0 0 0 0 0 0 1 Clear LCD and memory, home cursor
0 0 0 0 0 0 0 0 1 0 Clear and home cursor only
0 0 0 0 0 0 0 1 1/0 S Screen action as display character written
S=1/0:Shift screen/cursor
I/O=1/0:cursor R/L,screen L/R
0 0 0 0 0 0 1 D C B D=1/0:Screen on/off
C=1/0:Cursor on/off
B=1/0:Cursor blink/no blink
0 0 0 0 0 1 S/C R/L 0 0 S/C:1/0:screen/Cursor
R/L:Shift one space R/L
0 0 0 0 1 DL N F 0 0 DL=1/0:8/4 Bits per Caracter
N=1/0; 2/1 Rows of Characters
F=1/0;5*10/5*7Dots/Character
27
1 2 3
7 8 9 10 11 12 13 14 4 5 6
-
8/2/2019 Handy Vehicle Documentation
28/46
0 0 0 1 Character address Write to character RAM address after this
0 0 1 Display data address Write to display RAM address after this
0 1 BF Current address BF=1/0:busy/Notbusy
1 0 Character type Write byte to last RAM chosen
1 1 Charcter type Read byte from last RAM chosen
Table -4
BIT RS R/W D7 D6 D5 D4 D3 D2 D1 D0 FUNCTION
0 0 0 0 0 0 0 0 0 0 1 Clear display
0 0 0 0 0 0 0 0 0 1 - Return Home
0 0 0 0 0 0 0 0 1 1/
D
S Entry Mode
0 0 0 0 0 0 0 1 D C B Display On/Off control
0 0 0 0 0 0 1 S/
C
R/
L
- - Cursor or display shift
28
-
8/2/2019 Handy Vehicle Documentation
29/46
0 0 0 0 0 1 D
L
N F - - Function Set
0 0 0 0 0 0 0 0 0 0 0 Set CG RAM address
0 0 0 1 Set DD RAM address
0 0 0 0 Read Busy Flag & add
0 0 0 0
Write data CG or DD
RAM
CHAPTER 5
Internal CIRCUIT DIAGRAM
5.1 Transmitter end
29
-
8/2/2019 Handy Vehicle Documentation
30/46
C 4
E 2A N T E N N A
C 1 3 3 p f
C 1 3 3
U 1 3
M A X 2 3 2 A
1
3
4
5 1 6
1
5
2
6
1 29
1 1
1 01 3
8
1 4
7
C 1 +
C 1 -
C 2 +
C 2 - V C C15
V +
V
-
R 1 O U TR 2 O U T
T 1 I N
T 2 I NR 1 I N
R 2 I N
T 1 O U T
T 2 O U T
V C C
C 1 3 3 p f
P 1
C O N N E C T
5948
37261
5.2 Receiver end:
30
-
8/2/2019 Handy Vehicle Documentation
31/46
V C C
7 8 0 51 3
2
v c c
1 . 2 K
D 4
T 1
1 3
2 5
9
4
0
3 9R S TP 0 . 0 / A D 0
R 1
D 9
1 0 K
U 7
2 3 4 5 1
4
1
3
1
2
1
1
6 71 1
5
9 1
0
1
6
8
V
C
C
V
E
E
R
S
R
/W
D
B
7
D
B
6
D
B
5
D
B
4
E
N
D
B
0
G
N
D
L
E
D
+
D
B
2
D
B
3
L
E
D
-
D
B
1
L E D
1 0 0 K
Q 1B C 5 4 7
4 7 0 U F
R 5
V C C
1 0 0 0 U F
L C D
V C C
P S
31
-
8/2/2019 Handy Vehicle Documentation
32/46
1 M F
3
1
2
3
1
2 S T R 4 3 3
3
5
12 87
4
2 2 K
V C C
7 8 0 51 3
2
v c c
1 1 . 0 5 9 M H z
C 1 3 3 p f
1 . 2 K
R 8
D 4
T 1
1 3
2 5
V C C
C 2 3 3 p f
A
T
8
9
S
5
1
U 8
9
1
8
1
9
2
0
2 9
3 0
3 1
4
0
1
2
3
4
5
6
7
8
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
1 0
1 11 2
1 3
1 4
1 5
1 6
1 7
3 9
3 8
3 73 6
3 5
3 4
3 3
3 2
R S T
X
T
A
L
2
X
T
A
L
1
G
N
D
P S E N
A L E / P R O G
E A / V P P
V
C
C
P 1 . 0
P 1 . 1
P 1 . 2
P 1 . 3
P 1 . 4
P 1 . 5
P 1 . 6
P 1 . 7
P 2 . 0 / A 8
P 2 . 1 / A 9
P 2 . 2 / A 1 0
P 2 . 3 / A 1 1
P 2 . 4 / A 1 2
P 2 . 5 / A 1 3
P 2 . 6 / A 1 4
P 2 . 7 / A 1 5
P 3 . 0 / R X D
P 3 . 1 / T X D
P 3 . 2 / I N T 0
P 3 . 3 / I N T 1
P 3 . 4 / T 0
P 3 . 5 / T 1
P 3 . 6 / W R
P 3 . 7 / R D
P 0 . 0 / A D 0
P 0 . 1 / A D 1
P 0 . 2 / A D 2
P 0 . 3 / A D 3
P 0 . 4 / A D 4
P 0 . 5 / A D 5
P 0 . 6 / A D 6
P 0 . 7 / A D 7
R 1
D 9
R 7
V C C
1 0 K
U 7
2 3 4 5 1
4
1
3
1
2
1
1
6 71 1
5
9 1
0
1
6
8
V
C
C
V
E
E
R
S
R
/W
D
B
7
D
B
6
D
B
5
D
B
4
E
N
D
B
0
G
N
D
LE
D
+
D
B
2
D
B
3
LE
D
-
D
B
1
J 1
C O N 2
L E D
R 3
1 0 0 K
Q 1B C 5 4 7
4 7 0 U F
R 5
V C C
1 0 0 0 U F
L C D
V C C
C 5
P S
5.4 Power supply circuit
32
-
8/2/2019 Handy Vehicle Documentation
33/46
C 7
2 2 0 0 u f
R 51 K
D 26 A
D
L
T P 7
P
V C C
U 3
L M 7 8 0 5 / T O1 2
V I N V O U T
T P 8
N
D 26 A
+ 1 2 V
T 2
9 - 0 - 9 / 3 A
2
7
5
8
1 1 6
C 8
1 0 0 0 u
D 3
6 A
chapter 6
33
-
8/2/2019 Handy Vehicle Documentation
34/46
Appendix
SOURCE CODE
6.1
/*------------------------------------------------------------------------------
Handy vehicle regulation using digitally
adressed micro controllers [add=$]
------------------------------------------------------------------------------*/
#include /* define 8051 registers */
#include /* define I/O functions */
#include
sbit C1 = P1^4;
sbit C2 = P1^5;
sbit C3 = P1^6;
sbit tb1 = P3^7;
sbit blink = P2^1;
char code NAME[] = " HANDY VEHICLE ";
char code NAME1[] = " REGULATION ";
char code PRSK[] = "PRESS ANY KEY.. ";
char code BLNK[] = " ";
char code COL[] = " V.I.T.S ";
char code LOC[] = " HYDERABAD ";
char code SUBM[] = "SUBMITTED BY.. ";char code NAME2[] = "M.V.NAREN ";
char code HOD[] = "OUR HOD.. ";
char code HODN[] = "MR.SUDHAKAR RAO ";
34
-
8/2/2019 Handy Vehicle Documentation
35/46
void delay();
void delayl();
char scnt = 0, cmd;
bit lock = 0;char endat;
char seq = 0;
char tdl = 0;
void timer (void) interrupt 1 using 0
{
tdl++;
if(tdl >= 15){
tdl = 0;
blink = 1;
}
}
void serl (void) interrupt 4 using 0
{
if(RI == 1)
{
RI = 0;
if((scnt == 1)&(SBUF != '#'))
{
cmd = SBUF;
scnt = 0;
lock = 1;blink = 0;
}
if(SBUF == '#')scnt = 1;
if(SBUF == '@')scnt = 0;
35
-
8/2/2019 Handy Vehicle Documentation
36/46
}
}
void main (void)
{char ch=0xFF,pch=0xFF;
int keycnt = 1;
// char pkey,prk;
bit PL_RE = 1;
P0 = 0xFF;
P1 = 0xFF;P2 = 0xFF;
P3 = 0xFF;
SP = 0x55;
init_LCD();
disp_L1(NAME);
disp_L2(NAME1);
delayl();
disp_L1(COL);
disp_L2(LOC);
delayl();
disp_L1(SUBM);
// disp_L2(BLNK);
// delayl();
disp_L2(NAME2);// disp_L2(NAME3);
delayl();
disp_L1(HOD);
disp_L2(HODN);
36
-
8/2/2019 Handy Vehicle Documentation
37/46
delayl();
sendcom(0x01);
TMOD = 0X21;IE = 0X92;
TH1 = 0xE8;
SCON = 0x50;
PCON &= 0x7F;
TR1 = 1;
TR0 = 1;
while (1)
{
tb1 = !tb1;
if(lock == 1)
{
lock = 0;
if(keycnt 16)
set_loc(2,keycnt - 16);
keycnt++;
if(keycnt>=33)keycnt = 1;
disp_char(cmd);
if(cmd == '^')
{sendcom(0x01);
keycnt = 1;
}
//blink = 1;
37
-
8/2/2019 Handy Vehicle Documentation
38/46
}
}
}
void delay(){
int di = 0;
for(di = 0;di < 2000;di++);
}
void delayl()
{
long int di = 0;for(di = 0;di < 50000;di++);
}
6.2
/*------------------------------------------------------------------------------
Handy vehicle regulation using digitally
adressed micro controllers [add=#]
------------------------------------------------------------------------------*/
#include /* define 8051 registers */
#include /* define I/O functions */
#include
sbit C1 = P1^4;
sbit C2 = P1^5;
sbit C3 = P1^6;
sbit tb1 = P3^7;
sbit blink = P2^1;
38
-
8/2/2019 Handy Vehicle Documentation
39/46
char code NAME[] = " HANDY VEHICLE ";
char code NAME1[] = " REGULATION ";
char code PRSK[] = "PRESS ANY KEY.. ";
char code BLNK[] = " ";char code COL[] = " V.I.T.S ";
char code LOC[] = " HYDERABAD ";
char code SUBM[] = "SUBMITTED BY.. ";
char code NAME2[] = "M.V.NAREN ";
char code HOD[] = "OUR HOD.. ";
char code HODN[] = "MR.SUDHAKAR RAO ";
void delay();
void delayl();
char scnt = 0, cmd;
bit lock = 0;
char endat;
char seq = 0;
char tdl = 0;
void timer (void) interrupt 1 using 0
{
tdl++;
if(tdl >= 15)
{
tdl = 0;
blink = 1;
}}
void serl (void) interrupt 4 using 0
{
if(RI == 1)
39
-
8/2/2019 Handy Vehicle Documentation
40/46
{
RI = 0;
if((scnt == 1)&(SBUF != '$'))
{cmd = SBUF;
scnt = 0;
lock = 1;
blink = 0;
}
if(SBUF == '$')scnt = 1;
if(SBUF == '@')scnt = 0;}
}
void main (void)
{
char ch=0xFF,pch=0xFF;
int keycnt = 1;
// char pkey,prk;
bit PL_RE = 1;
P0 = 0xFF;
P1 = 0xFF;
P2 = 0xFF;
P3 = 0xFF;
SP = 0x55;
init_LCD();
disp_L1(NAME);
disp_L2(NAME1);
delayl();
40
-
8/2/2019 Handy Vehicle Documentation
41/46
disp_L1(COL);
disp_L2(LOC);
delayl();
disp_L1(SUBM);// disp_L2(BLNK);
// delayl();
disp_L2(NAME2);
// disp_L2(NAME3);
delayl();
disp_L1(HOD);
disp_L2(HODN);delayl();
sendcom(0x01);
TMOD = 0X21;
IE = 0X92;
TH1 = 0xE8;
SCON = 0x50;
PCON &= 0x7F;
TR1 = 1;
TR0 = 1;
while (1)
{
tb1 = !tb1;
if(lock == 1){
lock = 0;
if(keycnt
-
8/2/2019 Handy Vehicle Documentation
42/46
if(keycnt > 16)
set_loc(2,keycnt - 16);
keycnt++;
if(keycnt>=33)keycnt = 1;disp_char(cmd);
if(cmd == '^')
{
sendcom(0x01);
keycnt = 1;
}
//blink = 1;}
}
}
void delay()
{
int di = 0;
for(di = 0;di < 2000;di++);
}
void delayl()
{
long int di = 0;
for(di = 0;di < 50000;di++);
}
6.3
42
-
8/2/2019 Handy Vehicle Documentation
43/46
/*------------------------------------------------------------------------------
Handy vehicle regulation using digitally
addressed micro controllers- comp------------------------------------------------------------------------------*/
#include
#include
#include
#include
#define COM1 1
#define DATA_READY 0x100
#define TRUE 1
#define FALSE 0
#define SETTINGS (_COM_1200 | _COM_NOPARITY | _COM_STOP1 | _COM_CHR8)
#define XVAL 10
#define YVAL 10
int main(void)
{
unsigned in, out, status;
int xcnt = XVAL, ycnt = YVAL;
int adr = 0, snt = 0;
textmode(C40);
_bios_serialcom(_COM_INIT, COM1, SETTINGS);
clrscr();
gotoxy(5, 2);
43
-
8/2/2019 Handy Vehicle Documentation
44/46
textcolor(LIGHTRED);
textbackground(BLUE);
cprintf(" PC BASED MOVING MESSAGE DISPLAY\n");
gotoxy(4, 4);textcolor(LIGHTGREEN);
textbackground(BLACK);
cprintf("\n");
textcolor(RED);
textbackground(LIGHTGRAY);
gotoxy(10,18);
cprintf("No Device selected ");gotoxy(XVAL, YVAL);
for (;;)
{
// status = _bios_serialcom(_COM_STATUS, COM1, 0);
// if (status & DATA_READY)
// if ((out = _bios_serialcom(_COM_RECEIVE, COM1, 0) & 0xFF) !=
0)
// putch(out);
_bios_serialcom(_COM_SEND, COM1, '@');
delay(10);
if (kbhit())
{
if ((in = getch()) == '\x1B')
break;
snt = 0;textcolor(RED);
textbackground(LIGHTGRAY);
if(in == '#'){adr = '#';snt = 1;gotoxy(10,18);cprintf("Device 1 selected
");gotoxy(xcnt, ycnt);}
44
-
8/2/2019 Handy Vehicle Documentation
45/46
if(in == '$'){adr = '$';snt = 1;gotoxy(10,18);cprintf("Device 2 selected
");gotoxy(xcnt, ycnt);}
if(snt == 0)
{textcolor(CYAN);
textbackground(BLACK);
_bios_serialcom(_COM_SEND, COM1, adr);
_bios_serialcom(_COM_SEND, COM1, in);
// _bios_serialcom(_COM_SEND, COM1, adr in);
xcnt++;
if (xcnt >= XVAL + 20){
xcnt = XVAL;
ycnt++;
if (ycnt >= YVAL + 6)ycnt = XVAL;
gotoxy(xcnt, ycnt);
}
putch(in);
}
}
}
return 0;
}
CHAPTER 7
BIBLIOGRAPHY
45
-
8/2/2019 Handy Vehicle Documentation
46/46
Mazidi ( 89s52 Programming and Embedded System)
http://www.am.pepperl-fuchs.com/products for Inductive proximity sensor
http://www.scienceprog.com/ir-remote-control-signal-receiver-using-avr-
microcontroller/
http://www.beyondlogic.org/parlcd/parlcd.htm
ADC0809 DATA SHEET (datasheet.com)
Atmel.com
LM358 (datasheet.com)