You are on page 1of 86

KEYWORDS

ACC B PSW SP DPTR DPL DPH P0 P1 P2 P3 IE IP TMOD TCON T2CON T2MOD TH0 TL0 TH1 TL1 TH2 TL2 SCON SBUF PCON IR : Accumulator : : : : : : : : : : : : : : : : : : : : : : : : : : B Register Program Status Word Stack Pointer Data Pointer Low byte High byte Port 0 Port 1 Port 2 Port 3 Interrupt Enable control Interrupt Priority control Timer/counter Mode control Timer/counter control Timer/counter 2 control Timer/counter mode2 control Timer/counter 0high byte Timer /counter 0low byte Timer/counter 1high byte Timer/counter 1low byte Timer/counter 2 high byte Timer/counter 2 low byte Serial control Serial data buffer Power control Infra Red

INDEX
ACKNOWLEDGE ABSTRACT ----------------------------------------------------------------------6 7 9
11 11 11 12 12 12 12 13 15 15 16 16 16 17 18 19 20 21 21 23 24 25 25 26 26 27 30 30 31 33 33 34 34 35 36 36 37 37 37 38

I.INTRODUCTION II. LITERATURE SURVEY


2.1 Motivation 2.2 Background 2.3 Aim 2.4 Requirement Analysis 2.4.1 Hardware Requirements 2.4.2 Software Requirements 2.5 Scope 2.6 Advantages

III.DESIGN METHODOLOGY
3.1 Hardware system design 3.1.1 Block level design of SMS notice board 3.1.2 Selection of Hardware 3.1.3 Design consideration of Microcontroller 3.1.3.1 8051 3.1.3.2 Internal architecture of P89V51RD2FN 3.1.3.2.1 I/O ports 3.1.3.2.2 Interrupt controls 3.1.3.2.3 Bus controllers 3.1.3.2.4 Memory organization 3.1.3.2.5 Registers in 8051 3.1.3.2.6 Oscillator 3.1.3.3 Features 3.1.4 Serial communication 3.1.4.1 Introduction 3.1.4.2 Baud rate 3.1.5 Hardware design of LCD 3.1.5.1 LCD screen 3.1.5.2 Features 3.1.5.3 Pin configuration 3.1.5.4 Specifications 3.1.5.5 Functionality of LCD in project 3.1.6 GSM Module 3.1.6.1 Wireless MODEM 3.1.6.2 GSM/GPRS MODEM 3.1.6.3 GSM/GPRS Module 3.1.6.4 Mobile Station 3.1.6.5 Difference between GSM Mobile and GSM Module 3.1.6.6 Applications of GSM/GPRS Module 3.1.6.7 AT Commands 3.1.6.8 Command, information response and result code 3.1.6.9 AT Commands syntax
2

3.1.6.10 Interfacing MODEM/Module with WINDOWS 3.1.7 Max232 3.1.7.1 Pin Configuration 3.1.8 RS232 (Female port) 3.1.8.1 Voltage levels 3.1.8.2 Pin configuration 3.1.8.3 DB9 interfacing microcontroller using MAX232 3.1.9 Serial port connector 3.1.10 Resistors 3.1.11 Capacitors 3.1.12 Crystal oscillators 3.1.13 Power supply 3.2 Software design 3.2.1 Liquid Crystal Display 3.2.1.1 Checking busy state of LCD 3.2.1.2 LCD Initialization 3.2.1.3 Writing commands for display flow chart 3.2.2.1 Flow chart of the project

40 40 41 41 41 42 42 43 43 43 44 45 46 46 46 43 47 50

IV. IMPLEMENTATION
4.1 Hardware implementation 4.1.1 Complete Schematic of SMS notice board 4.1.2 Connections of P89V51RD2FN 4.1.3 Pin connections of LCD 4.1.4 MAX232, DB9 and GSM connections 52 52 53 54 54

V. SOFTWARE IMPLEMENTATION
5.1 JHD204A LCD interfacing 5.1.1 Initialization of LCD 5.1.2 Initialization sequence code 5.1.3 Display the data into the LCD 5.1.4 Writing the command to display 5.1.5 Reading data to display 56 56 56 56 57 57 59 59 59 62 62 62 63 64 64 65 66 66 67

VI. APPLICATION, ADVANTAGES AND FUTURE SCOPE


6.1 Advantages. 6.2 Applications 6.3 Future Enhancements

VII. DEBUGGING TECHNIQUES


7.1 KEIL micro vision debugger 7.1.1 Introduction to KEIL IDE 7.1.2 Features 7.1.3 Steps to follow while writing program in KEIL 7.2 Flash Magic 7.2.1 Features 7.3 Null MODEM checking (HYPER TERMINAL) 7.4 Hardware debugging techniques

CONCLUSION RESULT VIII. BIBILOGRAPHY


3

67

IX. APPENDIX
KEIL MICROVISION IDE FLASH MAGIC SET UP OF HYPER TERMINAL COMPLETE CODE 68 76 79 82

ACKNOWLEDGEMENT
I wish to express my gratitude and indebtedness to all those people who provided valuable guidance and encouragement throughout the course of this project. I express thanks and gratitude to MANAGEMENT, RMCE for their support carrying my project. I express thanks and gratitude to Mr. Dr. K. PRABHAKAR RAO, principal, RMCE for his encouraging support and guidance in carrying my project. I express thanks and gratitude to Mr. DEEPRAJ DESHMUKH, H.O.D Electronics and communications engineering, RMCE for his encouraging support and guidance in carrying my project. I also thank lecturers at RMCE for their often enlightening lecturers and helpful attitude. I also thank Mr. BASHA project guide, SIGMA SOLUTIONS for his insistence on good designing technique which helped me to make successful system of SMS BASED WIRELESS NOTICE BOARD. Also I would like to thank my parents who are indirectly involved in the project.

ABSTRACT
Notice Board is primary thing in any institution / organization or public utility places like bus stations, railway stations and parks. But sticking various notices day-to-day is a difficult process. A separate person is required to take care of this notices display. This project deals about an advanced hi-tech wireless notice board. Notice Board is primary thing in any institution / organization or public utility places like bus stations, railway stations and parks. But sticking various notices day-to-day is a difficult process. A separate person is required to take care of this notices display. This project deals about an advanced hi-tech wireless notice board. The project is built around the 8051 micro controller from Atmel. This micro controller provides all the functionality of the display and wireless control. It also takes care of creating different display effects for given text. Display is obtained on LCD (16X4) Matrix Display Array on a printed circuit board. A GSM/CDMA Mobile Can is used to enter the required text or notice. The scrolling speed of the text also can be changed according to user requirement. After entering the text the SMS is sent to the no which is connected to the LCD display. At any time the user can add or remove or alter the text according to his requirement. At the receiving end the GSM modem which is connected to the Max 232 receives the message and is connected to the microcontroller 8051. The message is displayed on the LCD (16X4) Matrix Display Array. This project uses regulated 5V, 500mA power supply. 7805 three terminal voltage regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify the ac output of secondary of 230/12V step down transformer.

Keywords: Embedded System, Micro controller, Cross-compiler and Debugging.

CHAPTER-1

CHAPTER - I
INTRODUCTION
Notice Board is primary thing in any institution / organization or public utility places like bus stations, railway stations and parks. But sticking various notices day-to-day is a difficult process. A separate person is required to take care of this notices display. This project deals about an advanced hi-tech wireless notice board. An embedded system is a combination of software and hardware to perform a dedicated task. Some of the main devices used in embedded products are Microprocessors and Microcontrollers, Microprocessors are commonly referred to as general purpose processors as they simply accept the inputs, process it and give the output. In contrast, a microcontroller not only accepts the data as inputs but also manipulates it, interfaces the data with various devices, controls the data and thus finally gives the result. As everyone in this competitive world prefers to make the things easy and simple to handle, this project sets an example to some extent. Now a days every advertisement is going to be digital. The big shops and shopping centers are using the digital moving displays now. In Railway station and bus stands everything that is ticket information, platform number etc is displaying in digital moving display. But in these displays if they wants to change the message or style they have to go there and connect the display to PC or laptop. Suppose the same message if the person wants to display in main centers of the cities means he have to go there with laptop and change the message by connecting into PC. This project we can use mainly for police or army .I.e. displays will be connected to all the main centers in city if they wants to display messages about something crucial within 5 minute, they cant .So keeping in this mind we are designing a new display system which can access remotely, we are using the GSM technology to access the displays is one of the new technology in the embedded field to make the communication between microcontroller and mobile. This project is a remote notice board with MODEM connected to it, so if the user wants to display some messages, he will send the messages in SMS format the MODEM in the display system will receive the message and update the display according to the message. For every message received from the user mobile, the system will check for the password and if the password is correct the controller will display the message GSM based Control System implements the emerging applications of the GSM technology. Using GSM networks, a control system has been proposed that will act as an embedded system which can monitor and control appliances and other devices locally using built-in input and output peripherals. GSM (Global System for Mobile Communications): It is a cellular communication standard. SMS (Short Message Service): It is a service available on most digital mobile phones that permit the sending of short messages (also known as text messaging service). .

CHAPTER-2

CHAPTER- II LITERATURE SURVEY

2.1 MOTIVATION:
In present digitalized world, the exploit of GSM and SMS is popular. Notice Board is primary thing in any institution / organization or public utility places like bus stations, railway stations and parks. But sticking various notices day-to-day is a difficult process. A separate person is required to take care of this notices display. A new display using the GSM technology to access the displays is one of the new technologies in the embedded field to make the communication between microcontroller and mobile. From the past many years we are seeing the notices of the college, companies, offices is usually displayed on the normal board having number of notices written on the same board. So we were thinking that if all these notices are displayed at the same place one by one except occupying the whole board area. So we come to the conclusion to design a Notice board such that it can fulfill the requirements such as less manual operation, same notice can be displayed at the various places at the same time, the notice (board display) should be visible from maximum area or distance, compact and compatible, easy handling.

2.2 BACKGROUND:
Market research analysts are predicting that the wireless technologies will eventually become more widespread than the various wired solutions. The wireless communications present the ideal solution for the home network .This increasing demand of getting wireless can be seen not only in the field communication but also in the transferring information and data. The cell phones which are the best example of wireless data and voice transfer can be used for many other purposes that can replace the traditional system. One simple way of using this wireless communication is to use a simple cell phone for sending messages. Our administrator uses a simple GSM based handset for sending messages to different display stations which are located far away from him. The GSM modem used at the receiver end is used to receive the messages and LCD to display them. As we are using mobile for sending messages, its easy to handle and operate. As it's a wireless transmission the system has very less errors and maintenance. With greater efficiency we can display the messages at various places like public transports, crowded cities and advertisement of chain restaurants. We can use this displaying system at distant area where our wire or manpower can go easily.GSM and GPRS based designs have developed another innovative and Public Utility Product for mass communication. This is a Wireless Scrolling Message Electronic Display Board, which displays the messages, received as SMS or GPRS Packet.

10

2.3 AIM:
To design and implement a GSM based wireless message display system using 8051 microcontroller coded in EMBEDDED C language.

2.4 Requirement Analysis:


2.4.1 Hardware requirements
The components those are required for Smart Energy Meter project is given below. 1. 2. 3. 4. 5. 6. 7. Micro Controller (P89V51RD2BN). MAX 232. DB9 or RS232 connector. Power supply. LCD display. GSM module. SIM.

2.4.2 Software requirements


1. KEIL Vision 4IDE C51 Embedded Cross Compiler. 2. FLASH MAGIC Philips Serial ISP programming utility.

2.5 SCOPE:
The scope of this project is to introduce a new technology for notice board display system using GSM. A user can send a message from anywhere in the world. Multilingual display can be another added variation of the project. The display boards are one of the single most important media for information transfer to the maximum number of end users. This feature can be added by programming the microcontroller to use different encoding decoding schemes in different areas as per the local language. This will ensure the increase in the number of informed users. Graphical display can also be considered as a long term but achievable and target able output. MMS technology along with relatively high end microcontrollers to carry on the tasks of graphics encoding and decoding along with a more expansive bank of usable memory can make this task a walk in the park.

11

2.6 Advantages:
A lot of interaction and information sharing occurs. No printing & photocopying costs. No manual effort. Helps to retain and develop the knowledge base of your college or office. Saves Time, Energy and finally Environment.

12

CHAPTER-3

13

CHAPTER - III
DESIGN METHODOLOGY

3.1 Hardware System Design: 3.1. 1 Block level design.


The block diagram of GSM based message display system is given below

Fig 3.1: Functional block diagram of SMS notice board.

14

3.1.2 SELECTION OF HARDWARE:


The hardware selected must be such a way that Low cost Low power consumption, small, fast Continually reacts to changes in the systems environment Must compute certain results in real-time without delay Simple design Easy maintainability and interoperability Bug-free/Correctness, safety, many more.

3.1.3 DESIGN CONSIDERATIONS OF MICROCONTROLLER


WHY P89V51RD2FN? The system requirements and control specifications clearly rule out the use of 16, 32 bit microcontrollers. The P89V51RD2xx contains non-volatile 64KB Flash program memory that is both parallel programmable and serial In-System and In-Application Programmable. In-System Programming (ISP) allows the user to download new code while the microcontroller sits in the application. In-Application Programming (IAP) means that the microcontroller fetches new program code and reprograms itself while in the system. This allows for remote programming over a modem link. A default serial loader (boot loader) program in ROM allows serial In-System programming of the Flash memory via the UART without the need for a loader in the Flash code. For In-Application Programming, the user program erases and reprograms the Flash memory by use of standard routines contained in ROM.

3.1.3.1 8051
The 8051 is an 8 bit microcontroller originally developed by Intel in 1980. It is one of the most popular microcontrollers in the world for its high performance, rich instruction set and low cost. This device is a Single-Chip 8-Bit Microcontroller manufactured in an advanced CMOS process and is a derivative of the 8051 microcontroller family. The instruction set is 100% compatible with the 8051 instruction set. Three criteria in choosing the microcontrollers are as follows: 1. Meeting the computing needs of the task at hand efficiently and cost effectively. 2. Availability of software development tools such as compliers, assemblers, and debuggers. 3. Wide availability and reliable sources of the microcontroller.

15

Some of the features that have made the 8051 popular are:

64 KB on chip program memory. 128 bytes on chip data memory (RAM). 4 register banks. 128 user defined software flags. Four 8-bit data bus 16-bit address bus 32 general purpose registers each of 8 bits 16 bit timers (usually 2, but may have more, or less). 3 internal and 2 external interrupts. Bit as well as byte addressable RAM area of 16 bytes. Four 8-bit ports, (short models have two 8-bit ports). 16-bit program counter and data pointer. 1 Microsecond instruction cycle with 12 MHz Crystal.

8051 models may also have a number of special, model-specific features, such as UARTs, ADC, Op Amps, etc...

3.1.3.2 Internal architecture of P89C51RD2XX


The P89C51RD2xx contains a non-volatile 8KB/16KB/32KB/64KB Flash program memory that is both parallel programmable and serial In-System and In-Application Programmable. In-System Programming (ISP) allows the user to download new code while the microcontroller sits in the application. In-Application Programming (IAP) means that the microcontroller fetches new program code and reprograms itself while in the system.

16

The internal architecture of P89C51RD2FN microcontroller with suitable diagram

Fig 3.2: Internal architecture of P89C51RD2FN.

3.1.3.2.1 I/O ports:


All 8051 microcontrollers have 4 I/O ports each comprising 8 bits which can be configured as inputs or outputs. Accordingly, in total of 32 input/output pins enabling the microcontroller to be connected to peripheral devices are available for use. Pin configuration, i.e. whether it is to be configured as an input (1) or an output (0), depends on its logic state. In order to configure a microcontroller pin as an input, it is necessary to apply logic zero (0) to appropriate I/O port bit. In this case, voltage level on appropriate pin will be 0.

17

The 4I/O ports of 8051 are designated as port 0, port 1, port 2, and port 3. All these I/O ports have different functions and conditions while connecting to external peripherals.

3.1.3.2.1. a Port 0 (P0)The P0 port is characterized by two functions. If external memory is used then the lower address byte (addresses A0-A7) is applied on it. Otherwise, all bits of this port are configured as inputs/outputs. The other function is expressed when it is configured as an output. Unlike other ports consisting of pins with built-in pull-up resistor connected by its end to 5 V power supply; pins of this port have this resistor left out. If any pin of this port is configured as an input then it acts as if it floats. Such an input has unlimited input resistance and undetermined potential. When the pin is configured as an output, it acts as an open drain. By applying logic 0 to a port bit, the appropriate pin will be connected to ground (0V). By applying logic 1, the external output will keep on floating. In order to apply logic 1 (5V) on this output pin, it is necessary to built in an external pull-up resistor. 3.1.3.2.1. b Port 1 (P1)P1 is a true I/O port, because it doesn't have any alternative functions as is the case with P0, but can be configured as general I/O only. It has a pull-up resistor built-in and is completely compatible with TTL circuits. 3.1.3.2.1. c Port 2 (P2)P2 acts similarly to P0 when external memory is used. Pins of this port occupy addresses intended for external memory chip. This time it is about the higher address byte with addresses A8-A15. When no memory is added, this port can be used as a general input/output port showing features similar to P1. 3.1.3.2.1. d Port 3 (P3)All port pins can be used as general I/O, but they also have an alternative function. In order to use these alternative functions, a logic one (1) must be applied to appropriate bit of the P3 register. In terms of hardware, this port is similar to P0, with the difference that its pins have a pull-up resistor built-in.

3.1.3.2.2 Interrupts controls:


There are 7 kinds of interrupt controllers that 8051 handles. They are as follows. 1. 2. 3. 4. 5. 6. 7. INT0 external interrupt. INT1 external interrupt. Timer 0 Timer 1 Reset. Transmitted interrupt (TXD). Received interrupt (RXD).

There are two types of external hardware interrupts. Pin 12 (P3.2) and pin 13 (P3.3) of the 8051, designated as INT0 and INT1, are used as external hardware interrupts. Upon the activation of these pins, the 8051 gets interrupted in whatever it is doing and jumps to the vector table to perform the interrupt service routines (ISR).
18

Timer 0 and timer 1 interrupts can be used in pooling method. In this method, we have to wait until the TF is raised. The problem with this method is that the microcontroller is tied down the controller. If the timer interrupt in the IE register is enabled, whenever the timer rolls over, TF is raised, and the microcontroller is interrupted in whatever it is doing, and jumps to the interrupts vector table to service the ISR.

Reset pin is an input pin and is active high (normally low). Upon applying a high pulse to this pin, the microcontroller will reset and terminate all activities. This is often referred to as power-on reset. In order for RESET input to be effective, it must have a minimum duration of two machine cycles. In other words, the high pulse must be high for a minimum of two machine cycles before it is allowed to go low. TXD and RXD are serial communication interrupts.

3.1.3.2.3 BUS CONTROLS


The main bus controllers available in 8051 are ALE, EA, RST and PSEN. ALE (Address Latch Enable): Output pulse for latching the low byte of the address during an access to external memory. In normal operation, ALE is emitted twice every machine cycle, and can be used for external timing or clocking. Note that one ALE pulse is skipped during each access to external data memory. ALE can be disabled by setting SFR auxiliary.0. With this bit set, ALE will be active only during a MOVX instruction. EA (External Access Enable/Programming Supply Voltage): EA must be externally held low to enable the device to fetch code from external program memory locations. If EA is held high, the device executes from internal program memory. The value on the EA pin is latched when RST is released and any subsequent changes have no effect. This pin also receives the programming supply voltage (VPP) during Flash programming. RST (Reset): A high on this pin for two machine cycles while the oscillator is running resets the device. An internal resistor to VSS permits a power-on reset using only an external capacitor to VCC. PSEN (Program Store Enable): The read strobe to external program memory. When executing code from the external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. PSEN is not activated during fetches from internal program memory.

19

3.1.3.2.4 Memory organization


The 8051 has two types of memory and these are Program Memory and Data Memory. Program Memory (ROM) is used to permanently save the program being executed, while Data Memory (RAM) is used for temporarily storing data and intermediate results created and used during the operation of the microcontroller. Depending on the model in use (we are still talking about the 8051 microcontroller family in general) at most a few Kb of ROM and 128 or 256 bytes of RAM is used. All 8051 microcontrollers have a 16-bit addressing bus and are capable of addressing 64 kb memory. It is neither a mistake nor a big ambition of engineers who were working on basic core development. It is a matter of smart memory organization which makes these microcontrollers a real programmers goody.

3.1.3.2.4. a Program memory The first models of the 8051 microcontroller family did not have internal program memory. It was added as an external separate chip. These models are recognizable by their label beginning with 803 (for example 8031 or 8032). All later models have a few Kbyte ROM embedded. Even though such an amount of memory is sufficient for writing most of the programs, there are situations when it is necessary to use additional memory as well. A typical example is so called lookup tables. They are used in cases when equations describing some processes are too complicated or when there is no time for solving them. In such cases all necessary estimates and approximates are executed in advance and the final results are put in the tables (similar to logarithmic tables).

3.1.3.2.4. b Data memory Data Memory is used for temporarily storing data and intermediate results created and used during the operation of the microcontroller. Besides, RAM memory built in the 8051 family includes many registers such as hardware counters and timers, input/output ports, serial data buffers etc. The previous models had 256 RAM locations, while for the later models this number was incremented by additional 128 registers. However, the first 256 memory locations (addresses 0-FFh) are the heart of memory common to all the models belonging to the 8051 family.

3.1.3.2.5 Registers in 8051


In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. The vast majority of 8051 registers are 8- bit registers. In the 8051 there is only one data type: 8 bits. With an 8-bit data type, any data larger than 8 bits must be broken into 8- bit chunks before it is processed. The most widely used registers of the 8051 are A(Accumulator), B, and SPF (special function registers) and PSW (Program Status Word).

20

A register is a general-purpose register used for storing intermediate results obtained during operation. Prior to executing an instruction upon any number or operand it is necessary to store it in the accumulator first. All results obtained from arithmetical operations performed by the ALU are stored in the accumulator. Data to be moved from one register to another must go through the accumulator. In other words, the A register is the most commonly used register and it is impossible to imagine a microcontroller without it. More than half instructions used by the 8051 microcontroller use somehow the accumulator. Multiplication and division can be performed only upon numbers stored in the A and B registers. All other instructions in the program can use this register as a spare accumulator (A).

3.1.3.2.5. a R Registers (R0-R7) This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even though they are not true SFRs, they deserve to be discussed here because of their purpose. They occupy 4 banks within RAM. Similar to the accumulator, they are used for temporary storing variables and intermediate results during operation. Which one of these banks is to be active depends on two bits of the PSW Register. Active bank is a bank the registers of which are currently used.

3.1.3.2.5. b SFR (Special Function Registers) Special Function Registers (SFRs) are a sort of control table used for running and monitoring the operation of the microcontroller. Each of these registers as well as each bit they include, has its name, address in the scope of RAM and precisely defined purpose such as timer control, interrupt control, serial communication control etc. Even though there are 128 memory locations intended to be occupied by them, the basic core, shared by all types of 8051 microcontrollers, has only 21 such registers.

3.1.3.2.5.c PROGRAM STATUS WORD (PSW):

CY: Carry out from accumulator MSB of ALU operand AC: Auxiliary carry for BCD operations FO: General purpose RS1 & RS0: For register banks selection ( RB0-RB3) OV: Overflow flag P: Parity of accumulator set by hardware to 1 if it contains odd no of 1s

21

Table 3.1.The contents of (RS1-RS0) enable the working register banks RS 1 0 0 1 1 RS 0 0 1 0 1 BANKS AND REGISTERS BANK 0 (00H-07H) BANK 1 (08H0FH) BANK 2 (10H-17H) BANK 3 (18H-1FH)

Carry flag: Carry flag is set whenever there is carry out from the MSB. This flag is after 8bit ADD/SUB operation. It can also be set to 1 or 0 directly using SETB C or CLR C Auxiliary carry: If there is a carry from D3 to D4 position during Add/Sub operation, this bit will set. Otherwise, it is cleared. This flag is used for BCD operations. Parity flag reflects the number of 1s in A. If A contains an odd number of 1s, then P=1. Therefore P=0, if A has an even number of 1s. Overflow flag: This flag is set whenever the result of a signed number operation is too large to be accommodated in 7 bits, causing the higher order bit to overflow into the sign bit. 3.1.3.2.6 Oscillator: The microcontroller used in this project, P89C51RD2FN requires a baud rate of 9600. To acquire this baud rate, an 11.0592 MHz crystal must be connected between 19th and 20th pins of controller. The determination of machine cycle frequency and Baud rate is as follows. MCF = (XTL freq / 12) = (11.0592 * 10^6) / 12 = 921.6 KHz

Baud rate = MCF/32 = (921.6 10^3) / 32


22

= 28800 Hz

Where MCF = Machine Cycle Frequency, XTL = Crystal.

To synchronize with timer1 (TH1) to set the baud rate as 9600 we need to set those register value as -3 (decimal) or FD (Hexadecimal) so as to divide the baud rate i.e.. 28800Hz should be dividing with the decimal value of TH1 to get 9600 value.

Fig 3.3: Oscillator Connections

C1, C2 = 33pF.

3.1.3.3 FEATURES 80C51 Central Processing Unit On chip Flash Program Memory with In-System Programming (ISP) and InApplication Programming Boot ROM contains low level Flash programming routines for downloading via the UART Can be programmed by the end-user application(IAP) Supports 6-clock/12 clock mode via parallel programmer(default clock mode after Chip Erase is 12-clock)
23

Speed up to 20MHz with 6-clock cycles per machine cycle (40MHz equivalent performance), up to 33MHz with 12 clocks per machine cycle RAM expandable externally to 64Kbytes Four interrupt priority levels Seven interrupt sources Four 8-bit I/O ports Full-duplex enhanced UART 8-Bit ALU , with 2 registers A & B 11 bit program counter & data pointer 8-Bit program status word 8 bit stack pointer 4registers banks, each containing 8 registers 16bytes , which may be addressed at bit level 80 bytes of general purpose data Two 16 bit timer/counter T0 & T1

Control registers TCON, TMOD, SCON, PCON and IP & IE oscillator & clock circuits.

3.1.4 SERIAL COMMUNICATION


3.1.4.1 Introduction In order to connect microcontroller to a modem or a pc to modem a serial port is used. Serial is a very common protocol for device communication that is standard on almost every PC. Most computers include two RS-232 based serial ports. Serial is also a common communication protocol that is used by many devices for instrumentation; numerous GPIBcompatible devices also come with an RS232 port. Furthermore, serial communication can be used for data acquisition in conjunction with a remote sampling device. Typically, serial is used to transmit ASCII data. Communication is completed using 3 transmission lines. (1) Ground, (2) Transmit and (3) Receive. Since serial is asynchronous, the port is able to transmit data on one line while receiving data on another. Other lines are available for handshaking, but are not required. The important serial characteristics are baud rate, data bits, stop bits, and parity. For two ports to communicate, these parameters much match. Serial communication is a popular means of transmitting data between a computer and a peripheral device such as a programmable instrument or even another one bit at a time, over a single communication line to a receiver. You can use this method when data transfer rates are low or you must transfer data over long distances. Serial communication is popular because most computers have one or more serial ports, so no extra hardware is needed other than a cable to connect the instrument to the computer or two computers together. Any device you connect to the serial port will need the serial transmission converted back to parallel so that it can be used. In serial communication, the data will be sent from one system to another in bit by bit notation. Serial Ports come in two sizes, there are the DType 25 pin connector and the D-Type 9 Pin connector both of which are male on the back of the PC, and thus you will require a female connector on your device. The RS-232 and RS-485 come under serial communication.

24

3.1.4.2 Baud Rate: It is a speed measurement for communication. It indicates the number of bit transfers per second. For example, 300 baud is 300 bits per second. When a clock cycle is referred it means the baud rate. For example, if the protocol calls for a 4800 baud rate, then the clock is running at 4800Hz. This means that the serial port is sampling the data line at 4800Hz. Common baud rates for telephone lines are 12200, 28800 and 33600. Baud rates greater than these are possible, but these rates reduce the distance by which devices can be separated. These high baud rates are used for device communication where the devices are located together, as is typically the case with GPIB devices.

3.1.5 HARDWARE DESIGN OF LCD


The LCD (Liquid Crystal Display) used to display the output to the user in the form of GUI (Graphic User Interface) and a mono chromatic display. LCD used in this project is JHD204A series. There are 16 pins in all. They are numbered from left to right 1 to 16 (if you are reading from the backside). LCD shown above is marked to indicate which the 1st pin was and which the 16th was. In our project, we use a JHD204A LCD Display which has 4 rows and 20 characters. It contains internal 1 byte latch. It has a better contrast and a wider viewing angle. To develop a protocol to interface this LCD with 89V51 first we have to understand how they functions. These displays contain two internal byte-wide registers, one for command and second for characters to be displayed. There are three control signals called R/W, RS and EN. Select By making RS signal 0 you can send different commands to display. These commands are used to initialize LCD, to display pattern, to shift cursor or screen etc. You can see the markings right next to 1st and 16th pins. The 20by4 LCD with connections is as given below.

25

Fig 3.4: Pin configuration of LCD 3.1.5.1 LCD screen:LCD screen consists of two lines with 20 characters each. Each character consists of 5*7 dot matrix. Contrast on display depends on the power supply voltage and whether messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked as VEE. Trimmer potentiometer is usually used for that purpose. Some versions of displays have built in backlight (blue or green diodes). When used during operating, a resistor for current limitation should be used (like with any LE diode)

The main control pins on JHD204A are data lines, read or write and enable. LCD is finding wide spread use replacing LEDs (seven segment LEDs or other multi segment LEDs) because of the following reasons: 1. The ability to display numbers, characters and graphics. This is in contrast to LEDs, which are limited to numbers and a few characters. 2. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep displaying the data. 3. Ease of programming for characters and graphics. 4. These components are specialized for being used with the microcontrollers, which means that they cannot be activated by standard IC circuits. They are used for writing different messages on a miniature LCD.

26

Fig 3.5: LCD Display

3.1.5.1. a Data lines (D0-D7): The data lines are connected to the parallel port of the microcontroller. While connecting the data lines to port0 no pull up resistors are required. These data lines are used to pass the data from CPU i.e. controller to LCD internal memory and to pass commands from LCD to CPU. Pin 7 is the Least Significant Bit (LSB) and pin 14 is the Most Significant Bit (MSB) of the data inputs. If you want to display some number or letter on the display, you have to input the appropriate codes for that character on these pins. These pins are also used for giving certain commands to the display like clearing the display or moving the cursor to a different location. Upon giving the correct signals to the 3 control pins, the character codes or the commands that you have given to the Data pins will be written to the display or executed by the LCD respectively. To make it easier to give the appropriate inputs to these pin, i recommend wiring up a DIP switch to these pins.

3.1.5.1. b Read and write: Generally, we always use the LCD to show things on the screen. However, in some rare cases, we may need to read from the LCD what it is displaying. In such cases, the R/W pin is used. However, this function is beyond the scope of post and will not be explained. For all practical purposes, the R/W pin has to be permanently connected to GND. The timing diagram for write and read operation of JHD204A is as follows Write operation:

27

Fig 3.6: Timing diagram of write operation in LCD.

Read operation:

Fig 3.7: Timing diagram of read operation in LCD.

3.1.5.1. c Enable Pin: The enable pin has a very simple function. It is just the clock input for the LCD. The instruction or the character data at the data pins (D0-D7) is processed by the LCD on the falling edge of this pin. The Enable pin should be normally held at Vcc by a pull up resistor. When a momentary button switch is pressed, the Pin goes low and back to high again when you leave the switch. Your instruction or character will be executed on the falling edge of the pulse. (i.e. the moment the switch closes). 3.1.5.1. d Reset pin: The LCD has basically two operating modes: Instruction mode and Character Mode. Depending on the status of this pin, the data on the 8 data pins (D0-D7) is treated as either an instruction or as character data. You have to activate the command mode if you want to give an Instruction to the LCD. Example Clear the display, Move cursor to home etc. You have to activate the character mode if you want to tell the LCD to display some character. To set the LCD in Instruction mode, you set the 4th pin of the LCD (R/S) to GND. To put it in character mode, you connect it to Vcc.
28

3.1.5.2 Features RS232 compatible serial interface (2400 & 9600 Baud Selectable) Externally selectable serial polarities (Inverted & Non-Inverted) Serially controllable contrast and backlight levels 8 user programmable custom characters 16 Byte serial receive buffer 3.1.5.3 Pin Configuration: There are pins along one side of the small printed board used for connection to the microcontroller. There are total of 16 pins marked with numbers .Their function is described in the table below: Table 3.2 Pin Connections Description
Pins 1 8

Description Ground

Pins 9 -16

Description D2 (Not Used in 4bit operation) D3 (Not Used in 4bit operation) D4

Pin1

Pin9

Pin2

VCC (+5)

Pin10

Pin3

Contrast Data/Comman d (R/S) Read/Write (W) Enable (E1) D0 (Not Used

Pin11

Pin4

Pin12

D5

Pin5

Pin13

D6

Pin6

Pin14

D7

Pin7

in 4bit operation) D1 (Not Used

Pin15

VCC (LEDSV+)

Pin8

in 4bit operation)

Pin16

Ground

29

3.1.5.4 SPECIFICATIONS:

Number of Characters: 20 characters x 4 Lines Character Table: English-European (RS in Datasheet) Module dimension: 98.0x60.0x14.0 (MAX) View area: 76.0x25.2mm Active area: 56.2 x 11.5 mm Dot size: 0.6 x 0.66 mm Dot pitch: 0.60 x 0.70 mm Character size: 2.95 x 4.75 mm Character pitch: 3.55 x 5.94 mm LCD type: TN,STN(YELLOW GREEN,GREY,B/W) Duty: 1/16 View direction: Wide viewing angle

To start with LCD the user should initialize it first which should be programmed with its LCD commands. The LCD commands are given

30

Table 3.3 Commands for LCD

CODE 1 2 4 5 6 7 8 A C E F 10 14 18 1c 80 C0 38

COMMANDS TO THE LCD Clear display screen Return home Shift cursor to left Shift display right Shift cursor to right Shift display left Display off, cursor off Display off, cursor on Display on, cursor off Display on, cursor blinking Display off, cursor blinking Shift cursor position to left Shift cursor position to right Shift entire display left Shift entire display right Force cursor to begin in 1st row Force cursor to begin in 2nd row 2 lines &5x7 matrix

31

Fig 3.8: LCD Interface with P89C51RD2XX 3.1.5.5 Functionality of LCD in this project: LCD is used to display any message. After switching ON the power then it displays as Notice board. By receiving the message then it displays command signal received. Then the actual message will be displayed.

3.1.6 GSM MODULE:


GSM/GPRS module is used to establish communication between a computer and a GSM-GPRS system. Global System for Mobile communication (GSM) is an architecture used for mobile communication in most of the countries. Global Packet Radio Service (GPRS) is an extension of GSM that enables higher data transmission rate. GSM/GPRS module consists of a GSM/GPRS modem assembled together with power supply circuit and communication interfaces (like RS-232, USB, etc) for computer. The MODEM is the soul of such modules.

32

Fig 3.9: GSM/GPRS Module 3.1.6.1 Wireless MODEMs: Wireless MODEMs are the MODEM devices that generate, transmit or decode data from a cellular network, for establishing communication between the cellular network and the computer. These are manufactured for specific cellular network (GSM/UMTS/CDMA) or specific cellular data standard (GSM/UMTS/GPRS/EDGE/HSDPA) or technology (GPS/SIM). Wireless MODEMs like other MODEM devices use serial communication to interface with and need Hayes compatible AT commands for communication with the computer (any microprocessor or microcontroller system).

Fig 3.10: Applications of wireless MODEM. 3.1.6.2 GSM/GPRS MODEM GSM/GPRS MODEM is a class of wireless MODEM devices that are designed for communication of a computer with the GSM and GPRS network. It requires a SIM (Subscriber Identity Module) card just like mobile phones to activate communication with the network. Also they have IMEI (International Mobile Equipment Identity) number similar to

33

mobile phones for their identification. A GSM/GPRS MODEM can perform the following operations: 1. Receive, send or delete SMS messages in a SIM. 2. Read, add, search phonebook entries of the SIM. 3. Make, Receive, or reject a voice call. The MODEM needs AT commands, for interacting with processor or controller, which are communicated through serial communication. These commands are sent by the controller/processor. The MODEM sends back a result after it receives a command. Different AT commands supported by the MODEM can be sent by the processor/controller/computer to interact with the GSM and GPRS cellular network.

3.1.6.3 GSM/GPRS Module A GSM/GPRS module assembles a GSM/GPRS modem with standard communication interfaces like RS-232 (Serial Port), USB etc., so that it can be easily interfaced with a computer or a microprocessor / microcontroller based system. The power supply circuit is also built in the module that can be activated by using a suitable adaptor.

Fig 3.11: GSM module

34

3.1.6.4 Mobile Station (Cell phones and SIM) A mobile phone and Subscriber Identity Module (SIM) together form a mobile station. It is the user equipment that communicates with the mobile network. A mobile phone comprises of Mobile Termination, Terminal Equipment and Terminal Adapter.

Mobile Termination is interfaced with the GSM mobile network and is controlled by a baseband processor. It handles access to SIM, speech encoding and decoding, signaling and other network related tasks. The Terminal Equipment is an application processor that deals with handling operations related to keypad, screen, phone memory and other hardware and software services embedded into the handset. The Terminal Adapter establishes communication between the Terminal Equipment and the Mobile Termination using AT commands. The communication with the network in a GSM/GPRS mobile is carried out by the baseband processor.

3.1.6.5 Difference between GSM mobile and GSM/GPRS module A GSM mobile is a complete system in itself with embedded processors that are dedicated to provide an interface between the user and the mobile network. The AT commands are served between the processors of the mobile termination and the terminal equipment. The mobile handset can also be equipped with a USB interface to connect with a computer, but it may or may not support AT commands from the computer or an external processor/controller. The GSM/GPRS module, on the other hand, always needs a computer or external processor/controller to receive AT commands from. GSM/GPRS module itself does not provide any interface between the user and the network, but the computer to which module is connected is the interface between user and network. An advantage that GSM/GPRS modules offer is that they support concatenated SMS which may not be supported in some GSM mobile handsets. Also some mobile handsets cant receive MMS when connected to a computer.

35

3.1.6.6 Applications of GSM/GPRS module The GSM/GPRS module demonstrates the use of AT commands. They can feature all the functionalities of a mobile phone through computer like making and receiving calls, SMS, MMS etc. These are mainly employed for computer based SMS and MMS services. 3.1.6.7 AT Commands AT commands are used to control MODEMs. AT is the abbreviation for Attention. These commands come from Hayes commands that were used by the Hayes smart modems. The Hayes commands started with AT to indicate the attention from the MODEM. The dial up and wireless MODEMs (devices that involve machine to machine communication) need AT commands to interact with a computer. These include the Hayes command set as a subset, along with other extended AT commands. AT commands with a GSM/GPRS MODEM or mobile phone can be used to access following information and services: 1. Information and configuration pertaining to mobile device or MODEM and SIM card. 2. SMS services. 3. MMS services. 4. Fax services. 5. Data and Voice link over mobile network. The Hayes subset commands are called the basic commands and the commands specific to a GSM network are called extended AT commands.

3.1.6.8 Command, Information response and Result Codes: The AT commands are sent by the computer to the MODEM/ mobile phone. The MODEM sends back an Information Response i.e. the information requested by or pertaining to the action initiated by the AT command. This is followed by a Result Code. The result code tells about the successful execution of that command.

36

There are also unsolicited Result Codes that are returned automatically by the MODEM to notify the occurrence of an event. For example the reception of a SMS will force MODEM to return an unsolicited result code.

3.1.6.9 AT commands syntax


Case Sensitivity The AT commands are generally used in uppercase letters. However some MODEMs and mobile phones allow both uppercase and small case letters. Single Command The AT commands include a prefix AT which indicates the beginning of the command to MODEM; and a carriage return which indicates the end of the command.

However string AT itself is not the part of the command. For example in ATD, D is the command name not ATD. The extended AT commands have a + in the command name. For example: AT+CGMI<Carriage return> Command Line Multiple AT commands can be sent to MODEM in a single command line. The commands in a line are separated by a semi-colon (;).

For example: AT+CGMI; +CBS<Carriage return>


37

String in Command Line Strings in a command line are enclosed in double quotes. For example: AT+CGML=ALL<Carriage return> Information Response and Result Code The Information Response and Result Codes, returned by the MODEM, have a carriage return and line feed in the beginning as well as at the end.

For example: <Carriage return><Line feed>OK<Carriage return><Line feed> <Carriage return><Line feed>ERROR<Carriage return><Line feed> <Carriage return><Line feed>+CBC: 0, 60<Carriage return><Line feed> etc. Sequence of Execution In the command line, the command appearing first is executed first. The execution then follows for second appeared command and so on. The execution of commands in a command line takes place in sequential manner. If an error occurs in the execution of a command, an error result code is returned by the MODEM and the execution of the command line is terminated irrespective of presence of other commands next in the command line. Types of commands: There are four types of AT commands: Test commands Read commands Set commands Execution commands For more details, see AT Commands.

1) 2) 3) 4)

Different Result Codes:


RESULT CODE OK ERROR +CMS ERROR DESCRIPTION Successful Execution of a command Execution of a command failed Message service failure, is returned with an error code

38

Unsolicited Result Codes +CDS +CDSI Notify receipt of SMS status report of a new message to computer Notify receipt of SMS status report of a new message and its location in memory to computer +CMT +CMTI Notify forwarding of a new SMS to computer Notify receipt of SMS status report of a new message and its location in memory to computer
Fig 3.10 Commands used in GSM

3.1.6.10 Interfacing MODEM/Mobile phone with Windows platform The Windows (XP and lower versions) comes with an application called HyperTerminal for data communication through serial port of the computer. The interfacing of the GSM/GPRS module with the serial port of the computer involves following steps: 1) 2) 3) 4) 5) Connect RS-232 port of GSM module with the serial port of the computer. Insert a SIM card in the module. Open HyperTerminal from Start -> All Programs -> Accessories -> Communications -> HyperTerminal. Enter a name for the connection and press OK. Now select the communication port (COM) at which GSM module is connected. Create a new connection set on HyperTerminal. Set parameters, like baud rate as 9600, handshaking mode as none, parity bit as none, stop bit as 1 and data bit as 8.

3.1.7 MAX 232:


Max232 IC 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.

39

3.1.7.1 Pin Configuration:

Fig 3.9: Pin diagram of MAX 232 IC

3.1.8 RS 232(Female Port)


RS-232 is the component which is used to connect system (pc) to microcontroller. RS-232 (Recommended Standard 232) is the traditional name for a series of standards for serial binary single-ended data and control signals connecting between a DTE (Data Terminal Equipment) and a DCE (Data Circuit- terminating Equipment). It is commonly used in computer serial ports. The standard defines the electrical characteristics and timing of signals, the meaning of signals, and the physical size and pinout of connectors. RS232 is limited to point-to-point connections between PC serial ports and devices. RS 232 hardware can be used for serial communication up to distances of 50 feet. 3.1.8.1 Voltage levels: The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels for the data transmission and the control signal lines. For data transmission lines (TxD, RxD and their secondary channel equivalents) logic one is defined as a negative voltage, the signal condition is called marking, and has the functional significance. Logic zero is positive and the signal condition is termed spacing.

Table 3.4: indicating voltage levels for DB 9 connector Logic level 1 0 Voltage level -10V 10V

40

3.1.8.2 PIN CONFIGURATION

Fig 3.10: DB9 Connector with pinout

3.1.8.3 DB9 INTERFACING WITH MICROCONTROLLER USING MAX 232:

Fig 3.11: DB9 interfacing with microcontroller using MAX 232

3.1.9 Serial port connector:


The microcontroller is connected to the pc via a serial communication port. The serial communication port is a combination of a female port and a male port. The male port is connected to the DB-9 connector connected to the microcontroller while the female port is connected to the serial port of the pc.
41

Fig 3.12: serial port connector 3.1.10 Resistors: A resistor is a two-terminal passive electronic component that implements electrical resistance as a circuit element. When a voltage V is applied across the terminals of a resistor, a current I will flow through the resistor in direct proportion to that voltage. This constant of proportionality is called conductance, G. The reciprocal of the conductance is known as the resistance R, since, with a given voltage V, a larger value of R further "resists" the flow of current I as given by Ohm's law:

Fig 3.19: Resistors Practical resistors can be made of various compounds and films, as well as resistance wire (wire made of a high-resistivity alloy, such as nickel-chrome). Resistors are also implemented within integrated circuits, particularly analog devices, and can also be integrated into hybrid and printed circuits. 3.1.11 Capacitors: A capacitor (formerly known as condenser) is a device for storing electric charge. The forms of practical capacitors vary widely, but all contain at least two conductors separated by
42

a non-conductor. Capacitors used as parts of electrical systems, for example, consist of metal foils separated by a layer of insulating film. A capacitor is a passive electronic component consisting of a pair of conductors separated by a dielectric (insulator). 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.

Fig 3.20: capacitors 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 and for many other purposes. The capacitor is a reasonably general model for electric fields within electric circuits. An ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of charge Q on each conductor to the voltage V between them:

3.1.12 Crystal oscillator: A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them became known as "crystal oscillators."

43

Fig 3.21: crystal oscillator Quartz crystals are manufactured for frequencies from a few tens of kilohertz to tens of megahertz. More than two billion (2109) crystals are manufactured annually. Most are used for consumer devices such as wristwatches, clocks, radios, computers, and cell phones. Quartz crystals are also found inside test and measurement equipment, such as counters, signal generators, and oscilloscopes.

3.1.13 Power supply: Most 9-volt adapter units work by converting 110 volts of alternating current, or AC, electrical power into 9 volts of direct current, or DC, losing some energy in the process. The adapter then supplies DC power to an electronic device through a cord. Parts A 9-volt adapter contains several internal components that deliver the power safely, including a filter capacitor and a rectifier. Some contain fuses; if not, the manufacturer puts a fuse in the electronic device instead,

Conversion Nine-volt adapters accomplish the actual AC/DC conversion using the rectifier circuit. The rectifier uses diodes that only permit electricity to move in one direction. This process generates some heat, causing the adapter to become warm. Some 9-volt adapters contain grating in the plastic to release excess heat.

Effects An adapter can influence the size and weight of the electronic device, making it smaller and lighter, because the device doesn't have to convert AC power to 9 volts. Also, if retailers sell the adapter separately, the device's initial cost may decrease.

44

Fig 3.22 Power supply.

3.2 Software design:


3.2.1 Liquid Crystal Display
3.2.1.1 Initializing the LCD Before you using the LCD, the program must initialize and configure it. This is accomplished by sending a number of initialization instructions to the LCD. The first instruction to send is the no of data for the LCD i.e., with an 8-bit or 4-bit data bus. The other thing need to specify is display matrix; in the selected LCD it is a 5x8 dot character font. These two options are selected by sending the command 38h to the LCD as a command. The command can give to the LCD by invoking the pre defined function call lcd_cmd with passing parameters value of 38H, the syntax for the same can be given like lcd_cmd (0x38). 3.2.1.2 Checking the busy status of the LCD 3.2.1.2.1 Busy Flag (BF): When the busy flag is high or 1 the module is performing an internal operation and the next instruction will not be accepted. The RS=0 is used to check the Busy flag bit too see if the LCD is ready to receive information. The Busy flag is D7 and can be read when R/W = 1 and RS = 0, as follows: if R/W = 1, RS= 0.When D7=1 (busy flag), the LCD is busy taking care of internal operations and will not accept any new information. When D7=0, the LCD is ready to receive new information.

45

3.2.1.2.1.1 Busy flag flowchart

Fig 3.22: Busy flag flowchart 3.2.1.3. Writing command to the Display lcd_command(0x38); delay(100); lcd_command(0x80); delay(100); lcd_command(0xc0); delay(100); lcd_command(0x0e); delay(100); void lcd_command(unsigned char value) { chdata=value; rs=0; rw=0; en=1; delay(100); en=0; } To give a command to perform some special functions like move to position, clear LCD ,blink the curser etc. the instruction sequence must follow like first instruction must be set in the data bus set RS signal to logic 0 and enabling the LCD will receive the data . After finishing the instruction sequence the application must wait till the LCD completes the instruction by checking the LCD Busy status.

46

3.2.1.4. Writing command display flow chart

Fig 3.23: Writing command display flow chart 1. Check the Busy flag bit 2. Set the instruction in data lines (if it is writing) 3. Set RS bit to logic 1 to 0 4. Set R/W bit is to low 6. Set En line to high 7. Set line to low 3.2.1.5. Displaying the data in to the LCD Writing the string in the LCD, to get the result first the address at which the string has to display on the screen is given as command followed by displaying the individual characters as LCD data .That finishes the data to be display in the LCD.

47

The complete flow chart representation of LCD working process is as follows:

Fig 3.24: Flow chart for the LCD function.

48

3.2.2 Flowchart for the project

Fig 3.25 Flow chart of GSM based wireless notice board

49

CHAPTER - 4

50

CHAPTER 4 IMPLEMENTATION

4.1 HARDWARE IMPLEMENTATION


4.1.1 Complete Schematic of GSM based wireless message display system

Fig 4.1: Complete Schematic of GSM based wireless message display system

51

4.1.2 Connections of P89V51RD2BN


The pin configuration of P89V51RD2XX:-

Fig 4.2: Pin diagram of P89V51RD2BN In this project the microcontroller is connected to MAX232, LCD, and GSM. The connections of microcontroller are given briefly below: The reset pin is connected to the 9th pin (RST) of P89V51RD2BN, as it is used for set reset the program. While the 10pin is connected to the 12th pin of MAX232. 11th pin of controller is connected to the 11th pin of MAX232. The crystal oscillator which gives a frequency of 11.0592 MHz for the required Baud rate of 9600Hz to the microcontroller. This crystal oscillator is connected in between 18th (XALT 1) and 19th (XALT 2) pins of P89V51RD2BN controller. The 20th pin of controller is grounded. The pins from 21st to 28th (port 2 data lines) are used for the connections for data lines of LCD. The 29th pin is connected to a switch so as to dump and execute the program. Whenever the PSEN pin is pressed then we can execute the last dumped program, likewise when 29th pin is connected to VCC then code can be dumped into the controller. Address Latch Enable pin (30th pin) of controller is connected to the ground hence no connections need not to be given to this pin.
52

External Access Enable or programming supply voltage should be latched when RST is released and any subsequent changes have no effect. This pin also receives the programming supply voltage (VPP) during Flash programming. Hence the pin 31st must be connected to high i.e. VCC.

4.1.3 Pin connections of LCD


The LCD used for output display is JHD204A series. The detailed connections of LCD is described briefly as The 1st and 2nd pins of JHD204A LCD are connected to ground and high voltage VCC respectively. 3rd pin of LCD is connected to the centre pin of the potentiometer or variable resistor so as to adjust the contrast of LCD. The 4th, 5th, 6th pins are connected to 26th (P 2.5), 27th (P 2.6), 28th (P 2.7) pins of the microcontroller respectively. The 7th to 14th pins are data pins and are connected to the 39th (P 0.0) to 32nd (P 0.7) pins of the microcontroller respectively. The 15th and 16th pins are used for backlight purpose. 15th pin is connected to VCC and 16th pin to ground.

Fig 4.3: connection of LCD with P89V51RD2BN. 4.1.4 MAX232, DB9 AND GSM CONNECTION: MAX232 and DB9 connector plays a key role in program dumping and communication between project kit to the PC host. Capacitor C10 of capacitance 1Uf is connected across 1st and 3rd pins of MAX232 and C9 of capacitance 1Uf is connected in between 4th and 5th pins. Charge pump capacitors are required for the MAX232 to work it as voltage level shifter. The charge pump capacitors used here are C7 and C8 whose capacitance is 1Uf. C7 is connected between 6th pin and ground, while C8 is connected across 2nd pin of MAX232 and Vcc. 12th and 11th pins of MAX232 are connected to the 10th and 11th pins of P89C51RD2FN controller respectively. These acts as a transmitter and receiver for the data flow.
53

To connect the MAX232 to the PC host we require a medium named as DB9 connector. The 2nd and 3rd pin of the DB9 connector should be connected to the 14th and 13th pins of MAX232 respectively. While the 5th pin is grounded. The GSM module is connected to the controller through the connections between the DB9 connectors already mounted on the controller and GSM modules.

CHAPTER - 5

54

CHAPTER-5
SOFTWARE IMPLEMENTATION
This chapter explores some real world applications of the P89V51RD2xx, and also includes how to interface the P89V51RD2xx to devices such as an LCD and a keyboard and its software functionality using embedded C language.

5.1 JHD204A LCD INTERFACING 5.1.1Initializing the LCD Before you using the LCD, the program must initialize and configure it. This is accomplished by sending a number of initialization instructions to the LCD. The first instruction to send is the no of data for the LCD i.e., with an 8-bit or 4-bit data bus. The other thing need to specify is display matrix; in the selected LCD it is a 5x8 dot character font. These two options are selected by sending the command 38h to the LCD as a command. The command can give to the LCD by invoking the pre defined function call lcd_command with passing parameters value of 38H, the syntax for the same can be given like lcd_command (0x38). 5.1.2 The initialization sequence code can be given as follows:

lcd_command (0x38); // 2 lines and 5x7 matrix lcd_command (0x0E); // display on, cursor blinking lcd_command (0x01); //clear display screen lcd_command (0x06); // increment cursor (shift cursor right) lcd_command (0x80); // force cursor to begging of 1st line lcd_command (0xC0); // force cursor to begging of 2nd line lcd_command (0x94); // force cursor to begging of 3rd line lcd_command (0xD4); // force cursor to begging of 4th line 5.1.3 Displaying the data into the LCD void lcd_data(unsigned char value) { chdata=value; rs=1; rw=0; en=1; delay(150); en=0; }

55

5.1.4 Writing the commands to the LCD void lcd_command(unsigned char value) { chdata=value; rs=0; rw=0; en=1; delay(100); en=0; } 5.1.5 Reading data to LCD

void string(unsigned char *disp) { int x; for(x=0;disp[x]!=0;x++) { lcd_data(disp[x]); } } void nextline(unsigned char v) { if(v==1) { lcd_command(0XC0); } } void nextline1(unsigned char v) { if(v==21) { lcd_command(0X94); } } void nextline2(unsigned char v) { if(v==41) { lcd_command(0XD4); } }

56

CHAPTER 6

57

CHAPTER - 6
APPLICATION, ADVANTAGES AND FUTURE SCOPE

6.1 Advantages:
A lot of interaction and information sharing occurs. No printing & photocopying costs. No manual effort. Helps to retain and develop the knowledge base of your college or office. Saves Time, Energy and finally Environment. Saves from cutting of trees and becomes eco friendly.

6.2 Applications:
The applications of SMS based wireless display system in various fields includes Educational institutions. Railways. Stock marketing. Internal information. Bus stations. Menu information. Advertising. Public information

6.3 Future enhancement:


The use of microcontroller in place of a general purpose computer allows us to theorize on many further improvements on this project prototype. Temperature display during periods wherein no message buffers are empty is one such theoretical improvement that is very possible. The ideal state of the microcontroller is when the indices or storage space in the SIM memory are empty and no new message is there to display. With proper use of interrupt routines the incoming message acts as an interrupt, temperature display is halted and the control flow jumps over to the specific interrupt service routine which first validates the senders number and then displays the information field. Another very interesting and significant improvement would be to accommodate multiple receiver MODEMS at the different positions in a geographical area carrying duplicate SIM cards. With the help of principles of TDMA technique, we can choose to simulcast and /or broadcast important notifications. After a display board receives the valid message through the MODEM and displays it, it withdraws its identification from the network &synchronously another nearby MODEM signs itself into the network and starts to receive the message. The message is broadcast by the mobile switching center for a continuous time period during which as many

58

possible display board MODEMS catch the message and display it as per the constraint of validation. Multilingual display can be another added variation of the project. The display boards are one of the single most important media for information transfer to the maximum number of end users. This feature can be added by programming the microcontroller to use different encoding decoding schemes in different areas as per the local language. This will ensure the increase in the number of informed users. Graphical display can also be considered as a long term but achievable and target able output. MMS technology along with relatively high end microcontrollers to carry on the tasks of graphics encoding and decoding along with a more expansive bank of usable memory can make this task a walk in the park

59

CHAPTER - 7

60

Chapter 7
DEBUGGING TECHNIQUES

7.1 Keil uvision Debugger


7.1.1 Introduction to Keil IDE Keil is a compiler that has 3 windows, project window, edit window, and build or command window Schematic. Today, Keil Software provides a broad range of development tools for the embedded systems marketplace. Their products include ANSIC compilers, macro assemblers, debuggers, linkers, library managers, and real-time operating systems. . It was then that Keil Software implemented the first C compiler designed from the ground-up specifically for the 89C51 microcontroller.

7.1.2 Features 1. Nine basic data types, including 32-bit IEEE floating-point 2. Flexible variable allocation with bit, data, bdata, idata, xdata, and pdata memory types 3. Interrupt functions may be written in C 4. Full use of the 8051 register banks 5. Complete symbol and type information for source-level debugging 6. Bit-addressable data objects 7. Built-in interface for the RTX51 real-time kernel 8. Support for dual data pointers on Atmel, AMD, Cypress, Dallas semiconductor, Infineon, Philips, and Transcend microcontrollers 9. Support for Phillips 8xC510,8xC71,and 8xC752 limited instruction sets 10. Support for the Phillips 80C51 arithmetic unit.

The Keil 8051 Development Tools are designed to solve the complex problems facing embedded software developers. When starting a new project, simply select the microcontroller you use from the Device Database and the vision IDE sets all compiler, assembler, linker, and memory options for you. Numerous example programs are included to help you get started with most popular embedded 8051 devices. The Keil Vision Debugger accurately simulates on-chip peripherals (CAN, UART, SPI, Interrupts, I/O Ports, A/D Convertor, D/A convertor, and PWM Modules) of your 8051 device. Simulation helps you understand hardware configurations and avoids time
61

wasted on setup problems. Additionally, with simulation, you can write and test applications before target hardware is available. When you are ready to begin testing your software application with target hardware, use the MON51, MONADI, or FlashMON51 Target Monitors, the ISD51 In-system Debugger, or the ULINK USB-JTAG Adapter to download and test program code on your target system.

7.1.3 Steps to follow while writing a program in keil: 1. Install Keil Micro Vision in your PC, Then after Click on that Keil UVision icon. After opening the window go to toolbar and select Project Tab then close previous project. 2. Next select New Project from Project Tab. 3. Then it will open Create New Project window. Select the path where you want to save project and edit project name. 4. Next it opens Select Device for Target window, it shows list of companies and here you can select the device manufacturer company. 5. For an example, for your project purpose you can select the chip as 89c51rd2xx from Philips Group. Next Click OK Button, it appears empty window here you can observe left side a small window i.e., Project Window. Next create a new file. 6. From the Main tool bar Menu select File Tab and go to New, then it will open a window, there you can edit the program. 7. Here you can edit the program as which language will you prefer either Assembly or C. 8. After editing the program save the file with extension as .c or .asm, if you write a program in Assembly Language save as .asm or if you write a program in C Language save as .c in the selected path. 9. Then after saving the file, compile the program. For compilation go to project window select source group and right click on that and go to Add files to Group. 10. Here it will ask which file has to add. For an example here you can add test.c as you saved before 11. After adding the file, again go to Project Window and right click on your c file then select Build target for compilation. If there is any Errors or Warnings in your program you can check in Output Window that is shown bottom of the Keil window. 12. Here in this step you can observe the output window for errors and warnings 13. If you make any mistake in your program you can check in this slide for which error and where the error is by clicking on that error 14. After compilation then next go to Debug Session. In Tool Bar menu go to Debug tab and select Start/Stop Debug Session. 15. Write a program for Leds Blinking. LEDS are connected to PORT-1. you can observe the output in that port.
62

16. To see the Ports and other Peripheral Features go to main toolbar menu and select peripherals. 17. In this slide see the selected port i.e., PORT-1. 18. Start to trace the program in sequence manner i.e, step by step execution and observe the output in port window 19. After completion of Debug Session Create an Hex file for Burning the Processor. Here to create a Hex file goes to project window and right click on Target next select Option for Target. 20. It appears one window; here in target tab modify the crystal frequency as you connected to your microcontroller. 21. Next go to Output tab. In that Output tab click on Create HEX File and then click OK. 22. Finally Once again compile your program. The Created Hex File will appear in your path folder

7.2 Flash magic


Flash Magic is a PC tool for programming flash based microcontrollers from NXP using a serial or Ethernet protocol while in the target hardware. 7.2.1 Features Straightforward and intuitive user interface Read any section of Flash and save as an Intel Hex file. Program security bits Automatic verifying after programming Five simple steps to erasing and programming a device and setting key options Fills unused Flash to increase firmware security Check which Flash blocks are blank or in use with the ability to easily erase all blocks in use Reprogram the Boot Vector and Status Byte with the help of confirmation features that prevent accidentally programming incorrect values. Display the contents of Flash in ASCII and Hexadecimal formats Single-click access to the manual, Flash Magic home page and NXP Microcontrollers home page Use high-speed serial communications on devices that support it.
63

Command Line interface allowing use in IDEs and Batch Files. Supports half-duplex communications for many devices Verify Hex Files previously programmed Control the DTR and RTS RS232 signals to place the device into Boot ROM and Execute modes automatically (requires hardware support) Send commands to place the device in Boot loader mode Powerful, flexible Just In Time Code feature. Write your own JIT Modules to generate last minute code for programming, for example serial number generation. Displays information about the selected Hex File, including the creation and modification dates, flash memory used, percentage of the current device used Read the device signature Build your own Flash Magic based applications using the DLLs for C, C++, Python Build your own Flash Magic based applications using .NET languages (Windows only)

7.3 Null MODEM checking (Hyper Terminal)


Debugging of 8051 application can be very easy if we able to send debug information to serial port of PC. And its output can be seen on HyperTerminal (in Windows ) or Minicom ( in Linux ). We can display content of any variable, memory location etc. We can also print other useful information on serial terminal which could replicate the flow of the code.

The Microsoft HyperTerminal terminal emulation application can display messages sent from the serial port of a SDB or hardware platform. You can use these messages to verify whether the boot loader is on the SDB, to discover problems that may occur when the SDB boots, and to obtain the name of the SDB for use in the Platform Builder integrated development environment (IDE). To configure HyperTerminal for BSPs 1. From the Windows Start menu, choose All Programs, and then choose Accessories. 2. Choose Communications, and then choose HyperTerminal. 3. In the Connection Description dialog box, in the Name box, type a name for the connection to your SDB. 4. From the Icon list, choose an icon to represent your connection, and then choose OK. 5. In the Connect To dialog box, in the Connect using box, choose the communications (COM) port on the development workstation through which you want to receive messages from the SDB. The COM port that you choose must be the COM port on the development workstation to which you attach the null modem cable. 6. Choose OK.
64

7. In the COM<Port Number> Properties dialog box, modify the settings for your connection so that the settings are correct for your BSP.

7.4 Hardware debugging techniques


In the context of hardware debugging techniques, we are going to observe the different types of error and checking of the components in the project. While considering the microcontroller, the voltage level at 30th pin must be 1.6V because of the following reason 1. The voltage supply to the kit or mainly processor is 5V. 2. The duty cycle of the microcontroller is 33% Duty Cycle = T on / (T on+T off) Where T off = 2* T on DC = 1/ (1+2) DC= 0.333 Hence the voltage at 30th pin should be product of Duty Cycle and voltage supply VCC. Therefore the voltage should be 1.6V. 3. The voltage levels at 2nd and 6th pins of MAX232 should be -10V and +10V respectively.

CONCLUSION

RESULTS Now the most awaited part of the program is final result which can be seen by the following steps once the kit is ready. Give 5V Power supply and to both controller and GSM module. Now ON the circuit. We can see on the LCD display NOTICE BOARD. Send an SMS using mobile that starts with a and ends with $ i.e... a -------- $. After receiving the SMS to the GSM module then the LCD displaysCOMMAND SIGNAL RECEIVED. After a delay, the content of the SMS is displayed on to the LCD.

65

8. BIBILOGRAPHY:
Janci Gillespie Mazidi, Muhammad Ali Mazidi, The 8051 micro controller and embedded systems, PHI Prentice hall India, Eastern Economy Edition, www.phindia.com. Kenneth J. Ayala, The 8051 Microcontroller, architecture, Programming and Applications, Pen ram international publishing Pvt. Ltd. 1996 Arnold S. Berger, Embedded systems design, an introduction to process, tools, and Techniques, CMP Books, 2005. www.cmpbooks.com Yashvant Kanetkar, Let Us C, BPB Publications, 1999 www.bpbpub.com Dreamtech Software Team, Programming for Embedded systems, WILEY Publishing, Inc, 2003. http://en.wikipedia.org/wiki/Levels http://www.google.co.in

66

APPENDICES
KEIL MICRO VISION IDE
Keil is a compiler that has 3 windows, project window, edit window, and build or command window Schematic. Today, Keil Software provides a broad range of development tools for the embedded systems marketplace. Their products include ANSIC compilers, macro assemblers, debuggers, linkers, library managers, and real-time operating systems. Steps to follow while writing a program in keil:

1. 2.

Click on the Keil Vision Icon on Desktop The following fig will appear

3. 4.

Click on the Project menu from the title bar Then Click on New Project

67

5.

Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\

6. 7. 8.

Then Click on Save button above. Select the component for u r project. i.e. NXP Click on the + Symbol beside of NXP

68

9.

Select P89C51RD2XX as shown below

10. 11.

Then Click on OK The Following fig will appear

12. 13.

Then Click either YES or NOmostly YES. Now your project is ready to USE.
69

14.

Now double click on the Target1, you would get another option Source group 1 as shown in next page.

15.

Click on the file option from menu bar and select new.

70

16.

The next screen will be as shown in next page, and just maximize it by double clicking on its blue boarder.

17. 18.

Now start writing program in either in EMBEDDED C or ASM. For a program written in Assembly, then save it with extension . asm and for EMBEDDED C based program save it with extension .C

71

19.

Now right click on Source group 1 and click on Add files to Group Source.

20.

Now you will get another window, on which by default EMBEDDED C files will appear.

21. 22.

Now select as per your file extension given while saving the file Click only one time on option ADD.

72

23.

Now Press function key F7 to compile. Any error will appear if so happen.

24.

If the file contains no error, then press Control+F5 simultaneously.

25.

The new window is as follows

73

26. 27.

Then Click OK. Now click on the Peripherals from menu bar, and check your required port as shown in fig below.

28.

Drag the port a side and click in the program file.

74

29. 30.

Now keep Pressing function key F11 slowly and observe. You are running your program successfully.

FLASH MAGIC: Flash Magic is a PC tool for programming flash based microcontrollers from NXP using a serial or Ethernet protocol while in the target hardware. The steps for while using Flash Magic 1) Click on the flash magic icon on the desktop.

2) The below figure will appear

75

3) Select the device as P89C51RD2XX.

76

4) To check whether the device is connected or not. Click on ISP + Read device signature.

5) Then the device signature will be shown

6) Then by browsing the required HEX file we can dump the code into controller by pressing START button.

77

Setup of HyperTerminal

Go to 1. Start Menu>> Programs >> Accessories >> Communications >> Hyper Terminal After that HyperTerminal window will open. If it prompt for checking of default program as shown in fig, then say yes to it.

2. Click Yes 3. Type Connection Name as 8051 (or as per your Choice)

78

4. Select COM PORT (1, 2, 3 etc) whichever is available. Serial Converters as Reliable) So use Standard Serial Port

(NOTE: Very Less USB- TO

5. Do Port Setting as Given Below.

Then Click Apply and OK.

79

6. Now you See Bottom Left side It shows Connected.

7. Now burn the Hex File (Given) and Switch on the Circuit after Connecting Specified Serial Port .You will see output as Follows:

If everything works fine you will see Hello World on the screen. Otherwise check your setup.

80

COMPLETE CODE:
#include <REGX51.H> sbit rs=P1^0; sbit rw=P1^1; sbit en=P1^2; void lcd_command(unsigned char); void lcd_data(unsigned char); void string(unsigned char *disp); void delay(unsigned int); void read(char*); void newline(); void display (char); void send(); void serial(); void nextline(unsigned char); void nextline1(unsigned char); void nextline2(unsigned char); sfr chdata=0xA0; void lcdnewline(); char a[161]; char b[13]; int i,j,z,k,l,f=0; void main() { P0=0x00; P1=0x00; P2=0xFF; delay(100); lcd_command(0x38); delay(100); lcd_command(0x80); delay(100); lcd_command(0xc0); delay(100); lcd_command(0x0e); delay(100); lcdnewline(); serial(); read("AT"); newline(); read("AT+CMGF=1"); newline(); lcdnewline(); read("AT+CMGD=1"); newline(); lcdnewline(); while(1) {
81

lcd_command(0x83); string("NOTICE BOARD"); for(i=0;i<=13;i++) { while(RI==0); b[i]=SBUF; RI=0; } lcdnewline(); string("Command Signal"); if((b[2]=='+')||(b[3])=='+') { if((b[3]=='C')||(b[4])=='C') { if((b[4]=='M')||(b[5]=='M')) { if((b[5]=='T')||(b[6])=='T') { if((b[6]=='I')||(b[7])=='I') { lcd_command(0xC4); string("received"); lcdnewline(); //delay(300); read("AT+CMGF=1"); newline(); read("AT+CMGR=1"); newline(); newline(); //newline(); //newline(); for(l=0;l<=161;l++) { while(RI==0); a[l]=SBUF; RI=0; } for(l=60;l<=161;l++) { f=1; if(a[l]=='a') { k=0; do { k++; l++; if(k<=20) {
82

lcd_data(a[l]); } if((k>20) && (k<=40)) { nextline(f); lcd_data(a[l]); f++; } if((k>40) && (k<=60)) { nextline1(f); lcd_data(a[l]); f++; } if((k>60) && (k<=80)) { nextline2(f); lcd_data(a[l]); f++; } } while(a[l]!='$'); l=162; break; } //break; } delay(65000); } } } } } } /* while end here*/ } /* MAIN ends here*/ /* PROTOTYPE FUNCTIONS */ void lcd_command(unsigned char value) { chdata=value; rs=0; rw=0; en=1; delay(100); en=0; } void lcd_data(unsigned char value) { chdata=value; rs=1; rw=0;
83

en=1; delay(150); en=0; } void read(char *ch) { int i; for(i=0;ch[i]!='\0';i++) { display(ch[i]); } } void display(char c) { SBUF=c; send(); } void send() { while(TI==0); TI=0; } void newline() { SBUF='\r'; while(TI==0); TI=0; SBUF='\n'; while(TI==0); TI=0; } void delay(unsigned int num) { unsigned int k,q; for(k=0;k<num;k++) { for(q=0;q<num;q++); } } void lcdnewline() { lcd_command(0x01); delay(100); lcd_command(0x02); delay(100); } void serial() { SCON=0x50; TMOD=0x20;
84

TH1=0xFD; TR1=1; } void string(unsigned char *disp) { int x; for(x=0;disp[x]!=0;x++) { lcd_data(disp[x]); } } void nextline(unsigned char v) { if(v==1) { lcd_command(0XC0); } } void nextline1(unsigned char v) { if(v==21) { lcd_command(0X94); } } void nextline2(unsigned char v) { if(v==41) { lcd_command(0XD4); } }

85

86

You might also like