Sunteți pe pagina 1din 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

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

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

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

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 generalpurpose category and the I/O devices may be grouped somewhere in-between.

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 industrystandard 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

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

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. 00-7F space is occupied by the RAM and the 80 - FF space by the SFRs. byte internal RAM has been utilized in the following fashion: 00-IF: Used for four banks of eight registers of 8-bit each. 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. The four banks may be The The 128

\INTERNAL DIAGRAM OF 89s52 fig 2

The list of special function registers along with their hex addresses is given-(table1)

10

AT 89s52 Address register Addr. 80 81 82 83 88 89 8A 8B Port/Register P0 (Port 0) SP (stack pointer) DPH (data pointer High) DPL (data pointer Low) TCON (timer control) TMOD (timer mode) TLO (timer 0 low byte) 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) 11 Accumulator (ACC) B register

E0 F0

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

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: C/T : M1

When set, start and stop of timer by hardware When reset, start and stop of timer by software Cleared for timer operation table-2 M0 MODE OPERATING MODE

13

0 0 1 1

0 1 0 1

0 1 2 3

13-bit timer mode 16-bit timer mode 8-bit auto reload mode 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: IE: timer run control bit: Set or cleared by software to turn timer or counter on/off. 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

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 RI transmits interrupt flag. received interrupts flag. table-3 Set by hardware at the beginning of the stop bit in Set by hardware halfway through the stop bit time in mode 1. It must be cleared by software. mode 1. It must be cleared by software.

15

SM0 0 0 1 1

SM1 0 1 0 1

Serial mode 0 Synchronous mode 8-bit data, 1 start bit, 1 stop bit, variable baud rate 9- bit data, 1 start bit, 1 stop bit, fixed baud rate 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

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 8bit 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 receivertransmitter) 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

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 Data Set Ready, to the DTE that modem is present turned on Carrier Detect, that this modem is a signal from the DSR--indicates the and CD-indicates receiving 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

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 D7th bit 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 userprogrammed 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

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. the program. Many excellent

editors or word processors are available that can be used to create and/or edit A widely used editor is the MS-DOS EDIT program (or notepad Notice that the For many assemblers, the file Check your in Windows), which comes with all Microsoft operating systems. editor must be able to produce an ASCII file.

names follow the usual DOS conventions, but the source file has the extension "ASM "or "SRC ", depending on which assembler you are using. assembler for the convention. 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 Windowsbased assemblers combine steps 2 through 4 into one step. The "asm ", extension for the source file is used

20

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 Click on the Add button Give some project name: xxxx.prj A dialog-box appears, allowing you to add files to the project Change the file type to Assembly. Select your assembly file. Click on Save in your Project dialog box. Select Project, Make: Build Project from the program menu Click on the Add button then close the Add dialog box.

This creates the HEX file you need for the 8051

Chapter-4 Data transmission process 21

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 receivetransmit (UART) device, two 16-bit timer/counters and elaborate interrupt logic 30- 7F: This area is used for temporary storage, pointers and stack. On 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. be selected by software any time during the program. 20-2F: The 16 bytes may be used as 128 bits of individually addressable locations The four banks may reset,

22

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. ---ET2 ES ET1 EX1 ET0 EX0 Not implemented, reserved for future use. enables or disables timer 2 overflow or capturer interrupt. enables or disables the serial port interrupt. enables or disables timer 1 overflow interrupt. enables or disables external interrupt 1. enables or disables timer 0 overflow interrupt. enables or disables external interrupt 0.

P3 (Port 3, Address B0h, Bit-Addressable)

23

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.

----PS

IP.7 Reserved IP.6 Reserved IP.4 Serial Port Interrupt Priority Bit

PT2 IP.5 Timer2 Interrupt Priority bit (for 8052 only) 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

program status word (PSW) register is on 8-bit register. flag register.

It is also referred to as the

CY AC RS1 RS0 OV P

Carry-flag. Auxiliary carry-flag. register bank selector bit 1. register bank selector bit 0. overflow flag. Parity flag. Set/cleared by hardware each instruction cycle to indicate an

odd/even member of 1 bit in the accumulator. 4.3 Serial communication using rs-232 The MAX232 family of line drivers/receivers is intended for all EIA/TIA-232E and V.28/V.24 communications interfaces, particularly applications where 12V is not available. These parts are especially useful in battery-powered systems, since their low-power shutdown mode reduces power dissipation to less than 5W. the features of these I.C. are Superior to Bipolar, Operate from Single +5V Power Supply, Meet All EIA/TIA-232E and V.28 Specifications, Multiple Drivers and Receivers, 2-State Driver and Receiver Outputs.

1 2 3 4 5

6 7 8 9

Fig 4.1 The above shown connector known as 9-pin, D-type male connector is used for RS232 connections. The pin description is given in the following table.

25

Pin number 1 2 3 4 5 6 7 8 9 Table 4.1

Common Name /CD RXD TXD /DTR GND /DSR /RTS /CTS --

RS232 name CF BB BA CD AB CC CA CB CE

Description Received line signal detector Received data Transmitted data Data terminal ready Signal ground Data set ready Request to send Clear to send Ring indicator

Signal direction IN IN OUT OUT -IN OUT IN IN

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,

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

receiver-transmitter). discussed

The8051 chips has built-in UART,

which is

4.4 LCD DISPLAY

G +5V -5

11

D0 D1 D2 D3 D4 D5

D6 D7 RS R\W

7 1

9 10 11 12 13 14 4
Function 1 0

BIT RS R/W D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

Clear LCD and memory, home cursor Clear and home cursor only Screen action as display character written S=1/0:Shift screen/cursor I/O=1/0:cursor R/L,screen L/R

1 1/0 S

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 0

0 0

0 1

S/C R/L 0 0 F 0 0

S/C:1/0:screen/Cursor R/L:Shift one space R/L DL=1/0:8/4 Bits per Caracter N=1/0; 2/1 Rows of Characters F=1/0;5*10/5*7Dots/Character

DL N

27

0 0 0 1 1

0 0 1 0 1

0 1 BF

Character address Current address Character type Charcter type Table -4

Write to character RAM address after this Write to display RAM address after this BF=1/0:busy/Notbusy Write byte to last RAM chosen Read byte from last RAM chosen

Display data address

BIT

RS

R/W

D7

D6

D5

D4

D3

D2

D1

D0

FUNCTION

Clear display

Return Home

1 D

1/

Entry Mode

Display On/Off control

1 C

S/ L

R/

Cursor or display shift

28

1 L

Function Set

Set CG RAM address

Set DD RAM address

Read Busy Flag & add Write data CG or DD

RAM

CHAPTER 5 Internal CIRCUIT DIAGRAM

5.1 Transmitter end

29

E A

2 N

U 1 T E N N 1 1 1 3 T 1 1 0 R 1 T 2 1
C 1

I N R 1 O I NR 2 O I N T 1 O +
f

1 2 U T 9 U 1 4T U T T

P 5 9 4 8 3 7 2 6 1 C
V C C

C
3 3

1
p

T 2 R V

7 O U8 2 I N + 2

3 4
C 1 3 3 p f

C C C

1 2 2

+ V

C C 1 C V6

15

15 M A X 2 3 2 A

5.2 Receiver end:

30

T 1

1 3 D 9
1

1
0

7 0

8 0

03 5 U F 4 7 0

P S
U

v c c
F

1
L

. 2
E D

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

GND VCC VEE RS R /W EN DB0 DB1 DB2 DB3 DB4 DB5 D B6 D B7 LED + LED -

31
V C C

4R

0 10 0 K K

5R

2 1
Q B 1 C

40

9 P

. 0

/ A

RD

9 S0

3 D 9
1

1
0

7 0

8 0

03 5 U F 4 7 0

P S
U

v c c
F

2 L C D U 7

1
L

. 2
E D

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

GND VCC VEE RS R /W EN DB0 DB1 DB2 DB3 DB4 DB5 D B6 D B7 LED + LED -

D
V C C

4R

0 10 0 K K

5R

2 1
Q B 1 C

40

3 3 3 3 3 3 3 3 2 2 2 2 1 1 2 2 2 2

9 8P 7P 6P 5P 4P 3P 2P 5P 4P 2P 1P 6P 7P P 3 8P 7P 6P P

0 0 0 0 0 0 0 0 2 2 2 2 3 3 2 2 2 2 XT AL2

. . . . . . . . . . . . . . . . . .

0 1 2 3 U4 5 6 7 4 3 1 0 6 7 2 7 6 5

/ / / / / / / / / / / / / / / / / /

A RD AP D3 . AP D3 . PA 3D . 8 PA 3D . A P D3 A P D3 A PD S AA L 1 E 2 AE 1A 1 A 9 A 8 W P R 1 R PD 1 P 1 P 1 A P1 01 A P1 51 A P1 41 A P1 31 XT AL1

9 0S1 0T 11 0 1 / 21 1 2 / 312 3/ 413 4/ 51. 4 5 62. 5 9 73 E 0 3 / 1P / V 1 2 3 4 6 7 8 5 . . . . . . . . 0 1 2 3 5 6 7 4

I N T I N T / T 0 / T 1 N R O P P

R T

X X D

D 0 1
1

VCC

52
F

G R J 1
V C C

AT89S 51

3 2 C O 1 N 2 2 3

3 7 4 5 1 2 3 8

20

18

GND

3C 3 2 p

19

f3

. 0

5.4 Power supply circuit 32

+ T P P 7 2 T 2 D 8 5 7 T N 9 - 0 - 9 / 3 A P 8 1 1 6 D 3 6 2 6

1 D A

V U 2 6 A 1 V L 3 M I NV 7 O 8 2 0 U T

V 5

C 5 1 K

/ T RO

C C A 2 2 0 0 u f 7 1 0

8 D L 0 0 u f 4 E D

chapter 6

33

Appendix SOURCE CODE 6.1 /*-----------------------------------------------------------------------------Handy vehicle regulation using digitally adressed micro controllers [add=$] ------------------------------------------------------------------------------*/ #include <reg51.h> #include <stdio.h> #include <mylcd.h> 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 "; /* define 8051 registers */ /* define I/O functions */

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

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

} } 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

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(1,keycnt); 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

} } } 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 <reg51.h> #include <stdio.h> #include <mylcd.h> sbit C1 = P1^4; sbit C2 = P1^5; sbit C3 = P1^6; sbit tb1 = P3^7; sbit blink = P2^1; /* define 8051 registers */ /* define I/O functions */

38

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

{ 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

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 <=16) set_loc(1,keycnt); 41

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

/*-----------------------------------------------------------------------------Handy vehicle regulation using digitally addressed micro controllers- comp ------------------------------------------------------------------------------*/

#include <bios.h> #include <conio.h> #include <stdio.h> #include <ctype.h> #define COM1 #define TRUE #define FALSE 1 1 0

#define DATA_READY 0x100

#define SETTINGS (_COM_1200 | _COM_NOPARITY | _COM_STOP1 | _COM_CHR8) #define XVAL #define YVAL 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 10 10

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 (;;) { // // // 0) // 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 putch(out); _bios_serialcom(_COM_SEND, COM1, '@'); status = _bios_serialcom(_COM_STATUS, COM1, 0); if (status & DATA_READY) if ((out = _bios_serialcom(_COM_RECEIVE, COM1, 0) & 0xFF) !=

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

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-avrmicrocontroller/

http://www.beyondlogic.org/parlcd/parlcd.htm

ADC0809 DATA SHEET (datasheet.com)

Atmel.com

LM358 (datasheet.com)

46

S-ar putea să vă placă și