Sei sulla pagina 1di 62

Examination room guide using RFID for the jumbling system based EXAMS

ABSTRACT

aim of this project is guiding the student at the examination centers. Now a days 99% of the exams are held JUMBLING system. In this process so many students facing problems in searching rooms. Our project is helpful in this cases. Each and every student will be issued an RFID card as their hall ticket. While they reaching the college premises and by showing their hall ticket to the RFID reader. That will automatically displays the room number of that person. Our project will mainly saves the time in searching for the room in examination centers. The system uses a compact circuitry build around flash version of AT89S52 microcontroller with a non volatile memory. Programs are developed using Embedded C, compiled using RIDE tool. ISP is used to dump the code into microcontroller.

CHAPTER 1 INTRODUCTION TO EMBEDDED SYSTEMS


An embedded system is

a special-purpose computer system designed to perform one or a few dedicated functions, often with real-time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal computer, can do many different tasks depending on programming. Embedded systems control many of the common devices in use today .Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Physically,embedded systems range from portable devices such as

digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, Handheld computers share some elements with embedded systems such as the operating systems and microprocessors which power them but are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected. Embedded systems span all aspects of modern life and there are many examples of their use. Telecommunications systems employ numerous embedded systems from telephone switches for the network to mobile phones at the end-user. Computer networking uses dedicated routers and network bridges to route data. .Characteristics: 1. Embedded systems are designed to do some specific task, rather than be a generalpurpose computer for multiple tasks. Some also have real-time performance constraints that

must be met, for reasons such as safety and usability; others may have low or no performance requirements, allowing the system hardware to be simplified to reduce costs. 2. Embedded systems are not always standalone devices. Many embedded systems consist of small, computerized parts within a larger device that serves a more general purpose. For example, the Gibson Robot Guitar features an embedded system for tuning the strings, but the overall purpose of the Robot Guitar is, of course, to play music. Similarly, an embedded system in an automobile provides a specific function as a subsystem of the car itself. 3. The software written for embedded systems is often called firmware, and is usually stored in read-only memory or Flash memory chips rather than a disk drive. It often runs with limited computer hardware resources: small or no keyboard, screen, and little memory.

CPU platforms:

Embedded processors can be

broken into two broad categories: ordinary microprocessors (P) and microcontrollers (C), which have many more peripherals on chip, reducing cost and size. Contrasting to the personal computer and server markets, a fairly large number of basic CPU architectures are used; there are Von Neumann as well as various degrees of Harvard architectures, RISC as well as non-RISC and VLIW; word lengths vary from 4-bit to 64-bits and beyond (mainly in DSP processors) although the most typical remain 8/16-bit. Most architectures come in a large number of different variants and shapes, many of which are also manufactured by several different companies.

ASIC and FPGA solutions:

common

configuration for very-high-volume embedded systems is the system on a chip (SoC), an application-specific integrated circuit (ASIC), for which the CPU core was purchased and added as part of the chip design. A related scheme is to use a field-programmable gate array (FPGA), and program it with all the logic, including the CPU.

Peripherals:
outside world via peripherals, such as

Embedded Systems talk with the

Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485 etc Synchronous Serial Communication Interface: I2C, JTAG, SPI, SSC and ESSI Universal Serial Bus (USB)

10

Networks: Ethernet, Controller Area Network, LAN networks, etc Timers: PLL(s), Capture/Compare and Time Processing Units Discrete IO: aka General Purpose Input/output (GPIO) Analog to Digital/Digital to Analog (ADC/DAC) As for other

Tools:

software, embedded system designers use compilers, assemblers, and debuggers to develop embedded system software. However, they may also use some more specific tools:

In circuit debuggers or emulators Utilities to add a checksum or CRC to a program, so the embedded system can check if the program is valid.

For systems using digital signal processing, developers may use a math workbench such as MATLAB, Simulink, MathCad, or Mathematica to simulate the mathematics. They might also use libraries for both the host and target which eliminates developing DSP routines as done in DSPnano RTOS and Unison Operating System.

Custom compilers and linkers may be used to improve optimization for the particular hardware.

An embedded system may have its own special language or design tool, or add enhancements to an existing language such as Forth or Basic.

Another alternative is to add a Real-time operating system or Embedded operating system, which may have DSP capabilities like DSP nano RTOS.

Software tools can come from several sources:


Software companies that specialize in the embedded market Ported from the GNU software development tools Sometimes, development tools for a personal computer can be used if the embedded processor is a close relative to a common PC processor As the complexity of embedded systems grows, higher level tools and operating systems

are migrating into machinery where it makes sense. For example, cell phones, personal digital assistants and other consumer computers often need significant software that is purchased or provided by a person other than the manufacturer of the electronics. In these systems, an open

11

programming environment such as Linux, NetBSD, OSGi or Embedded Java is required so that the third-party software provider can sell to a large market.

CHAPTER 2 OVERVIEW OF RFID BASED EXAM ROOM GUIDE SYSTEM

INTRODUCTION

The main objective of this project is to develop an embedded system, which is used to verify and authenticate the authorized and display the room number.

Radio-frequency identification (RFID) is a technology that uses radio waves to transfer data from an electronic tag, called RFID tag or label, attached to an object, through a reader for the purpose of identifying and tracking the object. Some RFID tags can be read from several meters away and beyond the line of sight of the reader. The application of bulk reading enables an almostparallel reading of tags.

The tag's information is stored electronically. The RFID tag includes a small RF transmitter and receiver. An RFID reader transmits an encoded radio signal to interrogate the tag. The tag receives the message and responds with its identification information. Many RFID tags do not use a battery. Instead, the tag uses the radio energy transmitted by the reader as its energy source. The RFID system design includes a method of discriminating several tags that might be within the range of the RFID reader.

Whenever the student enters into the Examination center, he has to keep his RFID TAG to the reader which is attached to our microcontroller based embedded board. And enters the password (if necessary, their roll number is password) through the keypad interfaced. At that moment the reader will checks weather the information of the student is correct or not and then it will decide to display the student room number on LCD display. If the information of the student is correct then he
12

will be permitted inside otherwise he will not permit inside and switches on the buzzer. The information of the student will be send to the microcontroller through one wire protocol. And the information of the access system will be displayed on the LCD which we embedded to our board.

This project uses regulated 5v, 750ma 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/18v step down transformer.

BLOCK DIAGRAM :

RFID reader

Max232

RPS

MICROCONTROLLER

AT89S52
Crystal

LCD

KEYPAD

13

TOOLS USED:

HARDWARE TOOLS:
1. Microcontroller (AT89S52) 2. 125Mhz RFID reader and tags 3. LCD 4. Regulated power supply 5. KEYPAD

SOFTWARE TOOLS:
1. Keil uvision4 compiler 2. U flash 3. Protues

WORKING:

ADVANTAGES: APPLICATIONS

14

CHAPTER 3 AT89C52 MICROCONTROLLER


3.1 AT89C52 MICROCONTROLLER:
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 4 Kbytes of Flash Programmable and Erasable Read Only Memory (PEROM). The device is manufactured using Atmels high -density non-volatile memory technology and is compatible with the industry standard MCS-51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer, which provides a highly flexible and cost effective solution to many embedded control applications.

3.1.1 FEATURES OF MICROCONTROLLER:


Compatible with MCS-51TM Products 8 Kbytes of In-System Reprogram able Flash Memory- Endurance: 1,00Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-Level Program Memory Lock 256 x 8-Bit Internal RAM 32 Programmable I/O Lines Three 16-Bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel Low Power Idle and Power Down Modes

15

3.2 PIN CONFIGURATION :

Figure 3.1 pin configuration of AT89C52 microcontroller

16

3.2.1 LOGIC SYMBOL:

Figure 3.2 logic symbol of AT89C52

3.3 MEMORY ORGANIZATION:


The 89C52 micro controller has separate address for program memory and data memory. The logical separation of program and data memory allows the data memory to be accessed by 8-bit address, which can be quickly stored and manipulated by an 8-bit CPU. Nevertheless, 16-bit data memory address can also be generated through the DPTR register. Program memory (ROM, EPROM) can only be read, not written to. There can be up to 64k bytes if program memory the lowest 4k bytes of program are on chip. In the ROM less versions, all program memory is external. The read strobe for external program is the PSEN (program store enable). Data memory (RAM) occupies a separate address space from program memory the lowest 128 bytes of data memory are on chip. Up to 64 bytes of external RAM can be addressed in the external data memory space. In the ROM less version, the lowest 128bytes of data memory are on chip. The CPU generates read and write signals, RD and WR, as needed during external data memory access.
17

External program memory may be combined if desired by applying the RD and PSEN signals to the inputs of an AND gate and using the output of the gate as the read strobe to the external program/data memory.

3.3.1 DATA MEMORY:

FF

SFRS DIRECT ADDRESSING ONLY

FFFF

64K BYTES EXTERNAL

80 7F DIRECT ADDRESSING ONLY

AND

B B0000

18

3.3.2 PROGRAM MEMORY:


FFFF 60k Bytes External FFFF 64k

Bytes

1000

External

FFF

4k Bytes Internal

0000

0000

The 128 byte of RAM are divided into 3 segments a). Register banks 0 3 (00 1FH) b). Bit addressable area (20H 2FH) c). Scratch pad area (30H 7FH) If the SP is initialized to this area enough bytes should be left aside to prevent SP data destruction.

19

3.4 SPECIAL FUNCTION REGISTERS: 3.4.1 A & B REGISTERS:


They are used during math and logically operations. The register A is also used for all data transfers between the micro controller and memory. The B register is used during multiplication and divided operations. For other instructions it can be treated as another scratch pad register.

3.4.2 PSW (PROGRAM STATUS WORD):


It contains math flags; user flags F0 and register select bits RS1 and RS0 to determine the working register bank.

3.4.3 STACK AND STACK POINTER:


Stack is used to hold and retrieve data quickly. The 8 bit SP is incremented before data is stored during PUSH and CALL executions. While the stack may reside any where in on-chip RAM, the SP is initialized to 07H after the stack to begin at manipulated as a 16 bit register or as two independent 8 bit registers.

3.4.4 PC (PROGRAM COUNTER):


It addresses the memory locations that program instructions are to be fetched. It is the only register that does not have any internal address.

3.4.4 FLAGS:
They are 1bit register

provided to store the results of certain program instructions. Other instructions can test the conditions of the flags and make the decisions accordingly. To conveniently address, they are grouped inside the PSW and PCON. The micro controller has 4 main flags: carry(c), auxiliary carry

20

(AC), over flow (OV), parity (P) and 3 general-purpose flagsF0, GF0 and GF1.

3.4.5 PORTS:

All ports are bi-directional; each consists of a latch, an output driver and an input buffer. P0, P1, P2 and P3 are the SFR latches ports 0, 1, 2 and 3 respectively. The main functions of each port are mentioned below. Port0: input/output bus port, address output port and data input/output port. Port1: Quasi-bi-directional input/output port. Port2: Quasi-bi-directional input/output port and address output port. Port3: Quasi-bi-directional input/output port and control input/output pin.

3.4.6 SBUF (SERIAL BUFFER):


The microcontroller has serial transmission circuit that uses SBUF register to hold data. It is actually two separate registers, a transmit buffer and a receive buffer register. When data is moved to SBUF, it goes to transmit buffer, where it is held for serial transmission and when it is moved from SBUF, it comes from the receive buffer.

3.5 TIMER REGISTER:


Register pairs (TH0, TL1), (TH1, TL1) are the 16-bit counter registers for timer/counters 0 and 1.

3.5.1 CONTROL REGISTERS:


SFRs, IP, TMOD, SCON, and PCON contain control and status bits for the interrupt system, Timers/counters and the serial port.

21

3.5.2 OSCILLATOR AND CLOCK CIRCUIT:


This circuit generates the clock pulses by which all internal operations are synchronized. For the microcontroller to yield standard baud rates, the crystal frequency is chosen as 11.059MHz.

3.5.3 RESET:
The reset switch is the RST pin of the microcontroller, which is the input to a Schmitt trigger. It is accomplished by holding the RST pin HIGH for at least two machine cycles while the oscillator frequency is running the CPU responds by generating an internal reset.

3.5.4 TIMERS/COUNTERS:
A micro controller has two 16- bit Timer/Counter register T0 and T1 configured to operate either as timers or event counters. There are no restrictions on the duty cycle of the external input signal, but it should be for at least one full machine to ensure that a given level is sampled at least once before it changes. Timers 0 and 1 have four operating modes: 13-bit mode, 16 bit mode, 8 bit auto-reload mode. Control bits C/t in TMOD SFR select the timer or counter function. MODE 0: Both timers in MODE0 are counters with a divide by 32 pre-scalar. The timer register is configured as a 13 bit register with all 8 bits of TH1 and the lower 5-bit of TL1.The upper 3 bits of TL1 are in determinate and should be ignored. Setting the run flags (TR1) doesnt clear the register or the registers. MODE 1: Mode 1 is same as mode 0, except that the timer register is run with all 16 bits. The clock is applied to the combined high and low timer registers. An overflow occurs on the overflow flag. The timer continues to count. MODE 2: This mode configures the timer register as an 8
22

bit counter (TL1/0) with automatic reload. Overflow from TL1/0 not only sets TF1/0, but also reloads TL1/0 with the contents of TH1/0, which is preset by software. The reload leaves unchanged. MODE 3: Mode 3 is used for application that requires an extra 8 bit timer or counter. Timer 1 in mode 3 simply holds its count. The effect is same as setting TR0. Timer 0 its mode 3 establishes TL0 and TL1 as two separate counters. TL0 uses the timer0 control bits C/T, GATE, TR0, INT0 and TF0. TH0 is locked into a timer function and over the use of TR1 and TR2 from timer 1. Thus TH0 controls the timer 1 interrupts.

3.6 INTERRUPTS:
The micro controller provides 6 interrupt sources, 2 external interrupts, 2 timer interrupts and a serial port interrupt and a reset. The external interrupts (INT0 & INT1) can each be either level activated or transition activated depending on bits IT0 and IT1 in register TCON. The flags that actually generate these interrupts are IE0 & IE1 bits in TCON. TF0 and TF1 generate the timer 0 & 1 interrupts, which are set by a roll over in their respective timer/counter registers. When a timer interrupt is generated the on-chip hardware clears the flag that generated it when the service routine is vectored to. The serial port interrupt is generated by logical OR of R1 & T1. Neither of these flags is cleared by hardware when service routine is vectored to. In fact, the service routine itself determines whether R1 & T1 generated the interrupt, and the bit is cleared in the software. Upon reset, all interrupts are disabled, meaning that none will be responded to by the micro controller if they are activated. The interrupts must be enabled by software in order for the micro controller to respond to them.

23

3.7 SERIAL INTERFACE:


The serial port is full duplex, i.e. it can transmit and receive simultaneously. It is also receive buffered which implies it can begin receiving a second byte before a previously byte has been read from the receive register. The serial port receives and transmits register and reading SBUF accesses a physically separate receive register. This serial interface had four modes of operation: MODE 0: In this mode of operation the serial data enters and exists through RXD.TXD outputs the shift clock. Eight data bits are transmitted/ received, with the LSB first, the baud rate is fixed at 1/12 of the oscillator frequency. Reception is initialized by the condition RI-0 and

REN=1.
MODE 1: In this mode 10 bits (a start bit 0, 8 data bits with LSB first and a stop bit are transmitted through TXD port received through RXD. At the receiving end the stop bits goes into RB8 in the SFR SCON. The baud rate is variable. MODE 2: In the 2, 16 bits (a start bit 0, 8 data bits (LSDB first), a programmable 9th data bit and a stop bit) are transmitted through TXD or received through RXD.The baud rate is programmable to either 1/32 or 1/64 of the oscillator frequency MODE 3: The function of mode 3 is same as mode 2 except that the baud rate is variable. Reception is initialized by the incoming start bit if REN=1.

3.8 BAUDRATE CALCULATIONS:


Baud rate in mode 0 is fixed. Mode 0 baud rate=oscillator frequency/12

24

(1 machine cycle=12 clock. cycles) The baud rate in mode 2 depends on the value of SMOD bit in PCON Register. SMOD=0, baud rate= (1/64) x oscillator frequency. SMOD=1baud rate= (1/32) oscillator frequency. I.e. mode 2 baud rate= [2(POW) SMOD/64)] x oscillator frequency. In the modes 1 and 3, timer 1 over flow rate and the value of SMOD determines the baud rate. Baud rate of mode 1 and 3 = [(2(POW) SMOD/32)] x timer 1 over flow rate. The timer 1 interrupt should be disabled in this application.

3.9 PROGRAM MEMORY LOCK BITS:


On the chip are three lock bits, which can be left un-programmed (u) or can be programmed (p) to obtain the additional features listed in the table below. When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset.

If the device is powered up with out a reset, the latch initializes to a random value, and holds that value until reset is activated. It is necessary sthat the latched value of EA be in agreement with the current logic level at that pin in order for the device to function properly.

25

CHAPTER 4 IMPLEMENTATION OF HARDWARE

RFID (RADIO FREQUENCY IDENTIFIER)

Introduction:

Radio-frequency identification (RFID) is an automatic identification method, relying on storing and remotely retrieving data using devices called RFID tags or transponders. An RFID tag is an object that can be applied to or incorporated into a product, animal, or person for the purpose of identification using radio waves. Some tags can be read from several meters away and beyond the line of sight of the reader. Most RFID tags contain at least two parts. One is an integrated circuit for storing and processing information, modulating and demodulating a (RF) signal, and other specialized functions. The second is an antenna for receiving and transmitting the signal. Chip less RFID allows for discrete identification of tags without an integrated circuit, thereby allowing tags to be printed directly onto assets at a lower cost than traditional tags.

26

Primarily, the two main components involved in a Radio Frequency Identification system are the Transponder ( tags that are attached to the object ) and the Interrogator (RFID reader). Communication between the RFID reader and tags occurs wirelessly and generally does not require a line of sight between the devices.

RFID transponder / tag: An RFID transponder, considered as a next generation barcode, is a miniscule microchip that is attached to an antenna. They come in a wide variety of sizes, shapes, and forms and can be read through most materials with the exception of conductive materials like water and metal, but with modifications and positioning even these can be overcome.

Fig: RFID Tag Passive tags Passive tags are generally smaller, lighter and less expensive than those that are active and can be applied to objects in harsh environments, are maintenance free and will last for years. These transponders are only activated when within the response range of a reader. The RFID reader emits a

27

low-power radio wave field which is used to power up the tag so as to pass on any information that is contained on the chip.

Active tags Active tags differ in that they incorporate their own power source, where as the tag is a transmitter rather than a reflector of radio frequency signals which enables a broader range of functionality like programmable and read/write capabilities.

Semi-passive tags Semi-passive tags are similar to active tags in that they have their own power source, but the battery only powers the microchip and does not power the broadcasting of a signal. The response is usually powered by means of backscattering the RF energy from the reader, where energy is reflected back to the reader as with passive tags. An additional application for the battery is to power data storage. Semipassive tags leads to greater sensitivity than passive tags, typically 100 times more. The enhanced sensitivity can be leveraged as Semi-passive tags have three main advantages: greater sensitivity than passive tags; longer battery powered life cycle than active tags; they can perform active functions (such as temperature logging) under their own power, even when no reader is present for powering the circuitry.

RFID reader/ Interrogator: An RFID reader typically contains a module (transmitter and receiver), a control unit and a coupling element (antenna). The reader has three main functions: energizing, demodulating and decoding. In addition, readers can be fitted with an additional interface that converts the radio waves returned from the RFID tag into a form that can then be passed on to another system, like a computer or any programmable logic controller. Anti-Collision algorithms permit the simultaneous reading of large numbers of tagged objects, while ensuring that each tag is read only once.

28

RFID operates in several frequency bands. The exact frequency is controlled by the Radio Regulatory body in each country.

RFID Frequencies: The generic frequencies for RFID are:


125 - 134 kHz 13.56 MHz UHF (400 930 MHz) 2.45 GHz 5.8 GHz

Although there are other frequencies used, these are the main ones. In the UHF band, there are two areas of interest. Several frequencies in the 400 MHz band and then the band 860 930 MHz Each of the frequency bands have advantages and disadvantages for operation. The lower frequencies 125-134 kHz and 13.56 MHz work much better near water or humans than do the

29

higher frequency tags. Comparing passive tags, the lower frequencies usually have less range, and they have a slower data transfer rate. The higher frequency ranges have more regulatory controls and differences from country to country.
Applications:

RFID tags are useful for a huge variety of applications. Some of these applications include: supply chain management, automated payment, physical access control, counterfeit prevention, and smart homes and offices. RFID tags are also implanted in all kinds of personal and consumer goods, for example, passports, partially assembled cars, frozen dinners, ski-lift passes, clothing, and public transportation tickets. Implantable RFID tags for animals allow concerned owners to label their pets and livestock. Verichip Corp. has also created a slightly adapted implantable RFID chip, the size of a grain of rice, for use in humans. Since its introduction, the Verichip was approved by the U.S. Food and Drug Administration, and this tiny chip is currently deployed in both commercial and medical systems.

LCD (Liquid Cristal Display)

Introduction:

A liquid crystal display (LCD) is a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector. Each pixel consists of a column of liquid crystal molecules suspended between two transparent electrodes, and two polarizing filters, the axes of polarity of which are perpendicular to each other. Without the liquid crystals between them, light passing through one would be blocked by the other. The liquid crystal twists the polarization of light entering one filter to allow it to pass through the other.

A program must interact with the outside world using input and output devices that communicate directly with a human being. One of the most common devices attached to an controller is 30

an LCD display. Some of the most common LCDs connected to the contollers are 16X1, 16x2 and 20x2 displays. This means 16 characters per line by 1 line 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively.

Many microcontroller devices use 'smart LCD' displays to output visual information. LCD displays designed around LCD NT-C1611 module, are inexpensive, easy to use, and it is even possible to produce a readout using the 5X7 dots plus cursor of the display. They have a standard ASCII set of characters and mathematical symbols. For an 8-bit data bus, the display requires a +5V supply plus 10 I/O lines (RS RW D7 D6 D5 D4 D3 D2 D1 D0). For a 4-bit data bus it only requires the supply lines plus 6 extra lines(RS RW D7 D6 D5 D4). When the LCD display is not enabled, data lines are tri-state and they do not interfere with the operation of the microcontroller.

Features:

(1) Interface with either 4-bit or 8-bit microprocessor. (2) Display data RAM (3) 80x 8 bits (80 characters). (4) Character generator ROM (5). 160 different 5 7 dot-matrix character patterns.

(6). Character generator RAM (7) 8 different user programmed 5 7 dot-matrix patterns.

available. Line lengt (8).Display data RAM and character generator RAM may be Accessed by the microprocessor.

(9) Numerous instructions

31 Shapes and S

(10) .Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF, Blink Character, Cursor Shift, Display Shift. (11). Built-in reset circuit is triggered at power ON. (12). Built-in oscillator.

Data can be placed at any location on the LCD. For 161 LCD, the address locations are:

Fig : Address locations for a 1x16 line LCD

32

Shapes and sizes:

Even limited to character based modules,there is still a wide variety of shapes and sizes available. Line lenghs of 8,16,20,24,32 and 40 charecters are all standard, in one, two and four line versions.

Several different LC technologies exists. supertwist types, for example, offer Improved contrast and viewing angle over the older twisted nematic types. Some modules are available with back lighting, so so that they can be viewed in dimly-lit conditions. The back lighting may be either electro-

luminescent, requiring a high voltage inverter circuit, or simple LED illumination.

33

Electrical blockdiagram:

Power supply for lcd driving:

34

PIN DESCRIPTION:

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are extra in both for back-light LED connections).

Fig: pin diagram of 1x16 lines lcd

35

CONTROL LINES: EN: Line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again. RS: Line is the "Register Select" line. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which sould be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high. RW:

36

Line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands, so RW will almost always be low. Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7. Logic status on control lines: E - 0 Access to LCD disabled - 1 Access to LCD enabled
R/W - 0 Writing data to LCD - 1 Reading data from LCD RS - 0 Instructions 1 Character

Writing data to the LCD: 1) Set R/W bit to low 2) Set RS bit to logic 0 or 1 (instruction or character) 3) Set data to data lines (if it is writing) 4) Set E line to high 5) Set E line to low

Read data from data lines (if it is reading)on LCD:

37

1) Set R/W bit to high 2) Set RS bit to logic 0 or 1 (instruction or character) 3) Set data to data lines (if it is writing) 4) Set E line to high 5) Set E line to low

Entering Text:

First, a little tip: it is manually a lot easier to enter characters and commands in hexadecimal rather than binary (although, of course, you will need to translate commands from binary couple of subminiature hexadecimal rotary switches is a simple matter, although a little bit into hex so that you know which bits you are setting). Replacing the d.i.l. switch pack with a of re-wiring is necessary. The switches must be the type where On = 0, so that when they are turned to the zero position, all four outputs are shorted to the common pin, and in position F, all four outputs are open circuit. All the available characters that are built into the module are shown in Table 3. Studying the table, you will see that codes associated with the characters are quoted in binary and hexadecimal, most significant bits (left-hand four bits) across the top, and least significant bits (right-hand four bits) down the left. Most of the characters conform to the ASCII standard, although the Japanese and Greek characters (and a few other things) are obvious exceptions. Since these intelligent modules were designed in the Land of the Rising Sun, it seems only fair that their Katakana phonetic symbols should also be incorporated. The more extensive Kanji character set, which the Japanese share with the Chinese, consisting of several thousand different characters, is not included! Using the switches, of whatever type, and referring to Table 3, enter a few characters onto the display, both letters and numbers. The RS switch (S10) must be up (logic 1) when sending the characters, and switch E (S9) must be pressed for each of them. Thus the operational order is: set RS high, 38

enter character, trigger E, leave RS high, enter another character, trigger E, and so on. The first 16 codes in Table 3, 00000000 to 00001111, ($00 to $0F) refer to the CGRAM. This is the Character Generator RAM (random access memory), which can be used to hold user-defined graphics characters. This is where these modules really start to show their potential, offering such capabilities as bar graphs, flashing symbols, even animated characters. Before the user-defined characters are set up, these codes will just bring up strange looking symbols.

Codes 00010000 to 00011111 ($10 to $1F) are not used and just display blank characters. ASCII codes proper start at 00100000 ($20) and end with 01111111 ($7F). Codes 10000000 to 10011111 ($80 to $9F) are not used, and 10100000 to 11011111 ($A0 to $DF) are the Japanese characters.

39

40

Initialization by Instructions:

41

If the power conditions for the normal operation of the internal reset circuit are not satisfied, then executing a series of instructions must initialize LCD unit. The procedure for this initialization process is as above show.

KEYPAD

Introduction:

A keypad is a set of buttons arranged in a block which usually bear digits and other symbols but not a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a numeric keypad. Keypads are found on many alphanumeric keyboards and on other devices such as calculators, combination locks and telephones which require largely numeric input. An input device, sometimes part of a standard computer keyboard, consisting of a separate grid of numerical and function keys arranged for efficient data entry.

A computer keyboard usually contains a small numeric keypad with a calculator-style arrangement of buttons duplicating the numeric and arithmetic keys on the main keyboard to allow efficient entry of numerical data. This number pad (commonly abbreviated to "numpad") is usually positioned on the right side of the keyboard because most people are right-handed. Many laptop computers have special function keys which turn part of the alphabetical keyboard into a numerical keypad as there is insufficient space to allow a separate keypad to be built into the laptop's chassis. Separate plug-in keypads can be purchased. The keypad of a calculator contains the digits 0 through 9, together with the four arithmetic operations, the decimal point and other more advanced functions. Keypads are a part of mobile phones that are replaceable and sit on a sensor board. Some multimedia mobile phones have a small joystick which has a cap to match the keypad. Keypads are also a feature of some combination locks. This type of lock is often used on doors, such as that found at the main entrance to some offices.
42

Types of keypad:

1. Numeric keypad 2. Telephony keypad 3. Gaming keypad 4. Matrix keypad

Numeric keypad:

A numeric keypad, or numpad for short, is the small, palm-sized, seventeen key section of a computer keyboard, usually on the very far right. The numeric keypad features digits 0 to 9, addition (+), subtraction(-), multiplication (*) and division (/) symbols, a decimal point (.) and Num Lock and Enter keys. Laptop keyboards often do not have a numpad, but may provide numpad input by holding a modifier key (typically labelled "Fn") and operating keys on the standard keyboard. Particularly large laptops (typically those with a 17 inch screen or larger) may have space for a real numpad, and many companies sell separate numpads which connect to the host laptop by a USB connection. Numeric keypads usually operate in two modes: when Num Lock is off, keys 8, 6, 2, 4 act like an arrow keys and 7, 9, 3, 1 act like Home, PgUp, PgDn and End; when Num Lock is on, digits keys produce corresponding digits. These, however, differ from the numeric keys at the top of the keyboard in that, when combined with the Alt key on a PC, they are used to enter characters which may not be otherwise available: for example, Alt-0169 produces the copyright symbol. These are referred to as Alt codes. On Apple Computer Macintosh computers, which lack a Num Lock key, the numeric keypad always produces only numbers.

43

Telephony keypad:

It is a keypad that appears on a Touch Tone telephone. It was standardized when the dualtone multi-frequency (DTMF) system was introduced in the 1960s, and replaced the rotary dial. The contemporary keypad is laid out in a 34 grid, although the original DTMF keypad had an additional column for four now-defunct menu selector keys. When used to dial a telephone number, pressing a single key will produce a pitch consisting of two simultaneous pure tone sinusoidal frequencies. The row in which the key appears determines the low frequency, and the column determines the high frequency. For example, pressing the '1' key will result in a sound composed of both a 697 and a 1209 hertz (Hz) tone. The * is called the star key or asterisk key. The # is called the number sign, pound key, or hash key, depending on one's nationality or personal preference. What it is really called on its patent is an octothorpe (Flanagan et al., US 3,675,513 A, does not use the word octothorpe; however, Knowlton, US 3,967,273 A does. The earliest US patent to Mitchell [US 3,035,211 A] refers to "operator" [OP] and "Long-Distance" [LD] keys, and four additional keys for future services [at column 2, lines 65-71]). These can be used for special functions. For example, in the UK, users can order a 7.30am alarm call from a British Telecom telephone exchange by dialling: *55*0730#.

44

Gaming keypad:

A gaming keypad is a small, auxiliary keyboard deisigned only for gaming. It has a limited number of the original keys from a standard keyboard, and they are arranged in a more ergonomic fashion to facilitate quick and efficient gaming key presses. The commonly used keys for gaming on a computer are the 'W', 'A', 'S', 'D', and the keys close and adjescent to these keys. These keys and style of using a keyboard is referred to as WASD. A gaming keypad will not only optimize the WASD layout, but will often contain extra funcitonality, such as volume control, the Esc. key, and the F1-F12 keys.

Matrix keypad(4x4):

45

A sample schematic:

A very simple circuit to experiment with AT90S2313, 2x16 LCD display and 4x4 keypad. The clock based on 4 MHz crystal, but you can use anyone crystal between 1-4 MHz. The keys with the name "A", "B" ... "F" are typed to the LCD with numbers 10-16

46

Operation:

The AVR configure the PortB as PB0-PB3 inputs and PB4-PB7 outputs. At the firt, the AVR put the pin PB4 at logic '0' to enable the column1 (the first 4 keys) and reading the state of the keys. If we have pressed any of the 4 firt keys then the AVR send the number of the key to the LCD display. If we have not pressed any of 4 first keys, theAVR put the PB4 at logic '1' and PB5 at logic '0' to enable the 2th column. Reading the state of the keys and display the resault to LCD, etc, until to read the 16th key. After that, the circuit start again to read from the 1st key (1st column).
Flow chart:

47

Start

Ground all rows

Read all columns

no All keys open? yes Read all columns

no

Any key down

yes

Wait for debounce

Read all colomns

no Any key down yes

48

1 Ground next row Read all columns no Key press in this row? yes

Find which key is pressed

Get scan code from table

return

BUZZER
A buzzer or beeper is a signaling device, usually electronic, typically used in automobiles, household appliances such as a microwave oven, or game shows. It most commonly consists of a number of switches or sensors connected to a control unit that determines if and which button was pushed or a preset time has lapsed, and usually illuminates a light on the appropriate button or control panel, and sounds a warning in the form of a continuous or intermittent buzzing or beeping sound. Initially this device was based on an electromechanical system which was identical to an electric bell without the metal gong . Often these units were anchored to a wall or ceiling and used the ceiling or wall as a sounding board. Another implementation with some AC-connected devices was to implement a circuit to make

49

the AC current into a noise loud enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric sounder like a Son alert which makes a high-pitched tone. Usually these were hooked up to "driver" circuits which varied the pitch of the sound or pulsed the sound on and off. In game shows it is also known as a "lockout system," because when one person signals ("buzzes in"), all others are locked out from signaling. Several game shows have large buzzer buttons which are identified as "plungers". The word "buzzer" comes from the rasping noise that buzzers made when they were electromechanical devices, operated from stepped-down AC line voltage at 50 or 60 cycles. Other sounds commonly used to indicate that a button has been pressed are a ring or a beep.

MAX 232

Introduction:

A standard serial interface for PC, RS232C, requires negative logic, i.e., logic 1 is -3V to -12V and logic 0 is +3V to +12V. To convert TTL logic, say, TxD and RxD pins of the microcontroller thus need a converter chip. A MAX232 chip has long been using in many microcontrollers boards. It is a dual RS232 receiver / transmitter that meets all RS232 specifications while using only +5V power supply. It has two onboard charge pump voltage converters which generate +10V to -10V power supplies from a single 5V supply. It has four level translators, two of which are RS232 transmitters that convert TTL/CMOS input

50

levels into +9V RS232 outputs. The other two level translators are RS232 receivers that convert RS232 input to 5V. Typical MAX232 circuit is shown below.

Feachers:

1. Operates With Single 5-V Power Supply 2.LinBiCMOSE Process Technology 3.Two Drivers and Two Receivers 4.30-V Input Levels 5.Low Supply Current . 8 mA Typical

51

6.Meets or Exceeds TIA/EIA-232-F and ITU Recommendation V.28 7.Designed to be Interchangeable With Maxim MAX232 8.Applications TIA/EIA-232-F Battery-Powered Systems Terminals Modems Computers 9.ESD Protection Exceeds 2000 V Per MIL-STD-883, Method 3015 10.Package Options Include Plastic Small-Outline (D, DW) Packages and Standard Plastic (N) DIPs

Cicuit connections: A standard serial interfacing for PC, RS232C, requires negative logic, i.e., logic '1' is -3V to -12V and logic '0' is +3V to +12V. To convert a TTL logic, say, TxD and RxD pins of the uC chips, thus need a converter chip. A MAX232 chip has long been using in many uC boards. It provides 2-channel RS232C port and requires external 10uF pacitors. Carefully check the polarity of capacitor when soldering the

52

board. A DS275 however, no need external capacitor and smaller. Either circuit can be used without any problems.

53

CHAPTER 5 IMPLEMENTATION OF SOFTWARE

Keil Software

Installing the Keil software on a Windows PC

Insert the CD-ROM in your computers CD drive On most computers, the CD will auto run, and you will see the Keil installation menu. If the menu does not appear, manually double click on the Setup icon, in the root directory: you will then see the Keil menu. On the Keil menu, please select Install Evaluation Software. (You will not require a license number to install this software). Follow the installation instructions as they appear.

54

Loading the Projects

The example projects for this book are NOT loaded automatically when you install the Keil compiler. These files are stored on the CD in a directory /Pont. The files are arranged by chapt er: for example, the project discussed in Chapter 3 is in the directory /Pont/Ch03_00-Hello. Rather than using the projects on the CD (where changes cannot be saved), please copy the files from CD onto an appropriate directory on your hard disk. Note: you will need to change the file properties after copying: file transferred from the CD will be read only.

Configuring the Simulator

Open the Keil Vision2

55

Go to Project Open Project and browse for Hello in Ch03_00 in Pont and open it.

Go to Project Select Device for Target Target1

56

Select 8052(all variants) and click OK

57

Now we need to check the oscillator frequency: Go to project Options for Target Target1

58

Make sure that the oscillator frequency is 12MHz.

Building the Target

Build the target as illustrated in the figure below

59

Running the Simulation

Having successfully built the target, we are now ready to start the debug session and run the simulator. First start a debug session

60

The flashing LED we will view will be connected to Port 1. We therefore want to observe the activity on this port

61

To ensure that the port activity is visible, we need to start the periodic window update flag

62

Go to Debug - Go

While the simulation is running, view the performance analyzer to check the delay durations.

63

64

Go to Debug Performance Analyzer and click on it

Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button

65

SOURCE CODE

66

CHAPTER 6 RESULT ANALYSYS

67

Bibliography:

The 8051 Micro controller and Embedded Systems Muhammad Ali Mazidi Janice Gillispie Mazidi The 8051 Micro controller Architecture, Programming & Applications Kenneth J.Ayala Fundamentals of Micro processors and Micro computers B.Ram Micro processor Architecture, Programming & Applications Ramesh S.Gaonkar Electronic Components D.V.Prasad

References on the Web:

www.national.com www.atmel.com www.microsoftsearch.com www.geocities.com

68

69

Potrebbero piacerti anche