An Embedded Systems and Rfid Solution for Transport Related Issues

131
AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES CHAPTER -1 INTRODUCTION TO EMBEDDED SYSTEMS 1.1 WHAT IS AN EMBEDDED SYSTEM? An embedded system can be defined as a computing device that does a specific focused job. Appliances such as the air- conditioner, VCD player, DVD player, printer, fax machine, mobile phone etc. are examples of embedded systems. Each of these appliances will have a processor and special hardware to meet the specific requirement of the application along with the embedded software that is executed by the processor for meeting that specific requirement. The embedded software is also called “firm ware”. The desktop/laptop computer is a general purpose computer. You can use it for a variety of applications such as playing games, word processing, accounting, software development and so on. In contrast, the software in the embedded systems is always fixed. 1.1.1 HISTORY In the earliest years of computers in the 1940s, computers were sometimes dedicated to a single task, but were too large to be considered "embedded". Over time however, the concept of programmable controllers developed from a mix of computer DEPT OF ECE, SSNEC Page 1

Transcript of An Embedded Systems and Rfid Solution for Transport Related Issues

Page 1: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

CHAPTER -1

INTRODUCTION TO EMBEDDED SYSTEMS

1.1 WHAT IS AN EMBEDDED SYSTEM?

An embedded system can be defined as a computing device that does a specific

focused job. Appliances such as the air-conditioner, VCD player, DVD player, printer, fax

machine, mobile phone etc. are examples of embedded systems. Each of these appliances will

have a processor and special hardware to meet the specific requirement of the application

along with the embedded software that is executed by the processor for meeting that specific

requirement. The embedded software is also called “firm ware”. The desktop/laptop computer

is a general purpose computer. You can use it for a variety of applications such as playing

games, word processing, accounting, software development and so on. In contrast, the

software in the embedded systems is always fixed.

1.1.1 HISTORY

In the earliest years of computers in the 1940s, computers were sometimes dedicated

to a single task, but were too large to be considered "embedded". Over time however, the

concept of programmable controllers developed from a mix of computer technology, solid

state devices, and traditional electromechanical sequences.

The first recognizably modern embedded system was the Apollo Guidance Computer,

developed by Charles Stark Draper at the MIT Instrumentation Laboratory. At the project's

inception, the Apollo guidance computer was considered the riskiest item in the Apollo

project. The use of the then new monolithic integrated circuits, to reduce the size and weight,

increased this risk.

The first mass-produced embedded system was the Autonetics D-17 guidance computer for

the Minuteman (missile), released in 1961. It was built from transistor logic and had a hard

disk for main memory. When the Minuteman II went into production in 1966, the D-17 was

DEPT OF ECE, SSNEC Page 1

Page 2: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

replaced with a new computer that was the first high-volume use of integrated circuits. This

program alone reduced prices on quad nand gate ICs from $1000/each to $3/each, permitting

their use in commercial products.

Since these early applications in the 1960s, embedded systems have come down in

price. There has also been an enormous rise in processing power and functionality. For

example the first microprocessor was the Intel 4004, which found its way into calculators and

other small systems, but required external memory and support chips.

In 1978 National Engineering Manufacturers Association released the standard for a

programmable microcontroller. The definition was an almost any computer-based controller.

They included single board computers, numerical controllers, and sequential controllers in

order to perform event-based instructions.

By the mid-1980s, many of the previously external system components had been

integrated into the same chip as the processor, resulting in integrated circuits called

microcontrollers, and widespread use of embedded systems became feasible.

As the cost of a microcontroller fell below $1, it became feasible to replace expensive

knob-based analog components such as potentiometers and variable capacitors with digital

electronics controlled by a small microcontroller with up/down buttons or knobs. By the end

of the 80s, embedded systems were the norm rather than the exception for almost all

electronics devices, a trend which has continued since.

1.2 EMBEDDED SYSTEMS ARE CHARACTERIZED BY SOME

SPECIAL FEATURES LISTED BELOW

Embedded systems do a very specific task; they cannot be programmed to do different

things. . Embedded systems have very limited resources, particularly the memory.

Generally, they do not have secondary storage devices such as the C DROM or the

floppy disk. Embedded systems have to work against some deadlines. A specific job

has to be completed within a specific time. In some embedded systems, called real-

DEPT OF ECE, SSNEC Page 2

Page 3: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

time systems, the deadlines are stringent. Missing a deadline may cause a catastrophe-

loss of life or damage to property. Embedded systems are constrained for power. As

many embedded systems operate through a battery, the power consumption has to be

very low.

Embedded systems need to be highly reliable. Once in a while, pressing ALT-CTRL-

OEL is OK on your desktop, but you cannot afford to reset your embedded system.

Some embedded systems have to operate in extreme environmental conditions such as

very high temperatures and humidity.

Embedded systems that address the consumer market (for exam-ple, electronic toys)

are very cost-sensitive: Even a reduction of $0.1 is lot of cost saving, because

thousands or millions systems may be sold.

Unlike desktop computers in which the hardware platform is dominated by Intel and

the operating system is dominated by Microsoft, there is a wide variety of processors

and operating systems for the embedded systems. So, choosing the right plat-form is

the most complex task.

1.2.1 APPLICATION AREAS

Nearly 99 per cent of the processors manufactured end up in embedded systems. The

embedded system market is one of the highest growth areas as these systems are used in very

market segment- consumer electronics, office automation, industrial automation, biomedical

engineering, wireless communication, data communication, telecommunications,

transportation, military and so on.

1.2.2 CONSUMER APPLIANCES

At home we use a number of embedded systems which include digital camera, digital

DEPT OF ECE, SSNEC Page 3

Page 4: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

diary, DVD player, electronic toys, microwave oven, remote controls for TV and air-

conditioner, VCO player, video game consoles, video recorders etc. Today’s high-tech car has

about 20 embedded systems for transmission control, engine spark control, air-conditioning,

navigation etc. Even wristwatches are now becoming embedded systems. The palmtops are

powerful embedded systems using which we can carry out many general-purpose tasks such

as playing games and word processing.

1.2.3 OFFICE AUTOMATION

The office automation products using embedded systems are copying machine, fax

machine, key telephone, modem, printer, scanner etc. Industrial automation: Today a lot of

industries use embedded systems for process control. These include pharmaceutical, cement,

sugar, oil exploration, nuclear energy, electricity generation and transmission. The embedded

systems for industrial use are designed to carry out specific tasks such as monitoring the

temperature, pressure, humidity, voltage, current etc., and then take appropriate action based

on the monitored levels to control other devices or to send information to a centralized

monitoring station. In hazardous industrial environment, where human presence has to be

avoided, robots are used, which are programmed to do specific jobs. The robots are now

becoming very powerful and carry out many interesting and complicated tasks such as

hardware assembly.

1.3 CATEGORIES OF EMBEDDED SYSTEMS

Based on functionality and performance requirements, embedded systems can be

categorized as:

Stand-alone embedded systems

Real-time systems

Networked information appliances

Mobile devices

DEPT OF ECE, SSNEC Page 4

Page 5: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

1.3.1 STAND ALONE EMBEDDED SYSTEMS

As the name implies, stand-alone systems work in stand-alone mode. They take inputs,

process them and produce the desired output. The input can be electrical signals from

transducers or commands from a human being such as the pressing of a button. The output

can be electrical signals to drive another system, an LED display or LCD display for

displaying of information to the users. Embedded systems used in process co~1’rol,

automobiles, consumer electronic items etc. fall into this category. In a process control

system, the inputs are from sensors that convert a physical entity such as temperature or

pressure into its equivalent electrical signal. These electrical signals are processed by the

system and the appropriate electrical signals are produced using which an action is taken such

as opening a valve. A few embedded systems used at home are shown in fig

Figure1-1 stand alone embedded systems at home

1.3.2 REAL TIME SYSTEMS

Embedded systems in which some specific work has to be done in a specific time

period are called real-time systems. For example: consider a system that has to open a valve

within 30milliseconds when the humidity crosses a particular threshold. If the valve is not

opened within 30 milliseconds, a catastrophe may occur. Such systems with strict deadlines

are called hard real-time systems. In some embedded systems, deadlines are imposed, but not

adhering to them once in a while may not lead to a catastrophe. For example, consider a DVD

player. Suppose, you give a command to the DVD player from are mote control, and there is a

DEPT OF ECE, SSNEC Page 5

Page 6: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

delay of a few milliseconds in executing that command. But, this delay won’t lead to a serious

simplification. Such systems are called soft real-time systems.

Figure 1-2 Hard Real Time embedded Systems

1.3.3 NETWORKED INFORMATION APPLIANCES

Embedded systems that are provided with network interfaces and accessed by

networks such as Local Area Network or the Internet are called networked information

appliances. Such embedded systems are connected to a network, typically a network running

TCP/IP (Transmission Control Protocol! Internet Protocol) protocol suite, such as the Internet

or a company’s Intranet. These systems have emerged in recent years These systems run the

protocol TCP/IP stack and get connected either through PPP or Ethernet to a network and

communicate with other nodes in the network. Here are some examples of such systems:

Figure 1-3 Networked Information Appliance

DEPT OF ECE, SSNEC Page 6

Page 7: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

1.3.4 MOBILE DEVICES

Mobile devices such as mobile phones, Personal Digital Assistants (PDAs), smart

phones etc. are a special category of embedded systems. Though the PDAs do many general

purpose tasks, they need to be designed just like the ‘conventional’ embedded systems. The

limitations of –the mobile devices- memory constraints, small size, lack of good user

interfaces such as full-fledged keyboard and display etc.-are same as those found in the

embedded systems discussed above. Hence, mobile devices are considered as embedded

systems. However, the PDAs are now capable of supporting general-purpose application

software such as word processors, games, etc.

User Interfaces

Embedded systems range from no user interface at all - dedicated only to one task - to

full user interfaces similar to desktop operating systems in devices such as PDAs.

Simple Systems

Simple embedded devices use buttons, LEDs, and small character- or digit-only

displays, often with a simple menu system.

In More Complex Systems

A full graphical screen, with touch sensing or screen-edge buttons provides flexibility

while minimizing space used: the meaning of the buttons can change with the screen, and

selection involves the natural behavior of pointing at what's desired. Handheld systems often

have a screen with a "joystick button" for a pointing device.

The rise of the World Wide Web has given embedded designers another quite different

option: providing a web page interface over a network connection. This avoids the cost of a

sophisticated display, yet provides complex input and display capabilities when needed, on

another computer. This is successful for remote, permanently installed equipment. In

particular, routers take advantage of this ability.

DEPT OF ECE, SSNEC Page 7

Page 8: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

CPU Platform

Embedded processors can be broken into two distinct categories: microprocessors (μP)

and micro controllers (μC). Micro controllers have built-in peripherals on the chip, reducing

size of the system.

There are many different CPU architectures used in embedded designs such as ARM,

MIPS, Coldfire/68k, PowerPC, x86, PIC, 8051, Atmel AVR, Renesas H8, SH, V850, FR-V,

M32R, Z80, Z8, etc. A 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.

1.4 PERIPHERALS

Embedded Systems talk with the outside world via peripherals, such as:

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)

Networks: Controller Area Network, Lan Works, etc

Timers: PLL(s), Capture/Compare and Time Processing Units

Discrete IO: aka General Purpose Input Output (GPIO)

1.4.1 TOOLS

As for other software, embedded system designers use compilers, assemblers, and

debuggers to develop embedded system software. However, they may also use some more

specific tools:

An in-circuit emulator (ICE) is a hardware device that replaces or plugs into the

microprocessor, and provides facilities to quickly load and debug experimental code in

the system.

DEPT OF ECE, SSNEC Page 8

Page 9: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

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 MathCAD or Mathematic to simulate the mathematics.

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.

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

DEPT OF ECE, SSNEC Page 9

Page 10: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

CHAPTER -2

INTRODUCTION TO MICROCONTROLLERS

2.1 MICROCONTROLLER

Microprocessors and microcontrollers are widely used in embedded systems products.

Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed

amount of RAM, ROM, I/O ports and a timer embedded all on a single chip. The fixed

amount of on-chip ROM, RAM and number of I/O ports in microcontrollers makes them ideal

for many applications in which cost and space are critical.

The Intel 8051 is Harvard architecture, single chip microcontroller (µC) which was

developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s and

early 1990s, but today it has largely been superseded by a vast range of enhanced devices with

8051-compatible processor cores that are manufactured by more than 20 independent

manufacturers including Atmel, Infineon Technologies and Maxim Integrated Products.

8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a

time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU.

8051 is available in different memory types such as UV-EPROM, Flash and NV-RAM.

DEPT OF ECE, SSNEC Page 10

Page 11: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

2.2 FEATURES OF AT89S52

8K Bytes of Re-programmable Flash Memory.

RAM is 256 bytes.

4.0V to 5.5V Operating Range.

Fully Static Operation: 0 Hz to 33 MHz’s

Three-level Program Memory Lock.

256 x 8-bit Internal RAM.

32 Programmable I/O Lines.

Three 16-bit Timer/Counters.

Eight Interrupt Sources.

Full Duplex UART Serial Channel.

Low-power Idle and Power-down Modes.

Interrupt recovery from power down mode.

Watchdog timer.

Dual data pointer.

Power-off flag.

Fast programming time.

Flexible ISP programming (byte and page mode).

2.3 DESCRIPTION OF MICROCONTROLLER

The AT89s52 is a low-voltage, high-performance CMOS 8-bit microcomputer with

8K bytes of Flash programmable memory. The device is manufactured using Atmel’s high

density nonvolatile memory technology and is compatible with the industry-standard MCS-51

instruction set. 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 AT89s52 is a powerful microcomputer, which

provides a highly flexible and cost-effective solution to many embedded control applications.

DEPT OF ECE, SSNEC Page 11

Page 12: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

In addition, the AT89s52 is designed with static logic for operation down to zero

frequency and supports two software selectable power saving modes. The Idle Mode stops the

CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue

functioning. The power-down mode saves the RAM contents but freezes the oscillator

disabling all other chip functions until the next hardware reset.

Figure 2-1 Pin Diagram

DEPT OF ECE, SSNEC Page 12

Page 13: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Figure 2-2 Block Diagram

DEPT OF ECE, SSNEC Page 13

Page 14: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

2.3 PIN DESCRIPTION

VCC Pin 40 provides supply voltage to the chip. The voltage source is +5V.

GND Pin 20 is the ground.

PORT 0

Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink

eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance

inputs. Port 0 can also be configured to be the multiplexed low-order address/data bus during

accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0

also receives the code bytes during Flash programming and outputs the code bytes during

Program verification. External pull-ups are required during program verification.

PORT 1

Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output

buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled

high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are

externally being pulled low will source current (IIL) because of the internal pull-ups. In

addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input

(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the

following table.

Port 1 also receives the low-order address bytes during Flash programming and verification.

Table 2-1 Description Of Port 1 Pins

DEPT OF ECE, SSNEC Page 14

Page 15: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

PORT 2

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output

buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled

high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are

externally being pulled low will source current (IIL) because of the internal pull-ups.

Port 2 emits the high-order address byte during fetches from external program

memory and during accesses to external data memory that uses 16-bit addresses (MOVX @

DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During

accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the

contents of the P2 Special Function Register. The port also receives the high-order address

bits and some control signals during Flash programming and verification.

PORT 3

Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output

buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled

high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are

externally being pulled low will source current (IIL) because of the pull-ups. Port 3 receives

some control signals for Flash programming and verification. Port 3 also serves the functions

of various special features of the AT89S52, as shown in the following table.

Table 2-2 Description of Port 3 Pins

DEPT OF ECE, SSNEC Page 15

Page 16: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

RST

Reset input A high on this pin for two machine cycles while the oscillator is running

resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out.

The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the

default state of bit DISRTO, the RESET HIGH out feature is enabled.

ALE / PROG

Address Latch Enable (ALE) is an output pulse for latching the low byte of the

address during accesses to external memory. This pin is also the program pulse input (PROG)

during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the

oscillator frequency and may be used for external timing or clocking purposes. Note,

however, that one ALE pulse is skipped during each access to external data memory.

PSEN

Program Store Enable (PSEN) is the read strobe to external program memory. When

the AT89S52 is executing code from external program memory, PSEN is activated twice each

machine cycle, except that two PSEN activations are skipped during each access to external

data memory.

EA/VPP

External Access Enable EA must be strapped to GND in order to enable the device to

fetch code from external program memory locations starting at 0000H up to FFFFH. Note,

however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should

be strapped to VCC for internal program executions. This pin also receives the 12-volt

programming enable voltage (VPP) during Flash programming.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

DEPT OF ECE, SSNEC Page 16

Page 17: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Oscillator Connections

C1, C2 = 30 pF ± 10 pF for Crystals = 40 pF ± 10 pF for Ceramic Resonators

External Clock Drive Configuration

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier

that can be configured for use as an on-chip oscillator. Either a quartz crystal or ceramic

resonator may be used. To drive the device from an external clock source, XTAL2 should be

left unconnected while XTAL1 is driven. There are no requirements on the duty cycle of the

external clock signal, since the input to the internal clocking circuitry is through a divide-by-

two flip-flop, but minimum and maximum voltage high and low time specifications must be

observed.

2.4 SPECIAL FUNCTION REGISTERS

A map of the on-chip memory area called the Special Function Register (SFR) space

is shown in the following table. It should be noted that not all of the addresses are occupied

and unoccupied addresses may not be implemented on the chip. Read accesses to these

DEPT OF ECE, SSNEC Page 17

Page 18: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

addresses will in general return random data, and write accesses will have an indeterminate

effect.

User software should not write 1s to these unlisted locations, since they may be used

in future products to invoke new features. In that case, the reset or inactive values of the new

bits will always be 0.

Table 2-3 AT89S52 SFR Map and Reset Values

DEPT OF ECE, SSNEC Page 18

Page 19: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Power off Flag

The Power Off Flag (POF) is located at bit 4 (PCON.4) in the PCON SFR. POF is set

to “1” during power up. It can be set and rest under software control and is not affected by

reset.

Memory Organization

MCS-51 devices have a separate address space for Program and Data Memory. Up to

64K bytes each of external Program and Data Memory can be addressed.

Program Memory

If the EA pin is connected to GND, all program fetches are directed to external

memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H

through 1FFFH are directed to internal memory and fetches to addresses 2000H through

FFFFH are to external memory.

Data Memory

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a

parallel address space to the Special Function Registers. This means that the upper 128 bytes

have the same addresses as the SFR space but are physically separate from SFR space. When

an instruction accesses an internal location above address 7FH, the address mode used in the

instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR

space. Instructions which use direct addressing access the SFR space.

For example, the following direct addressing instruction accesses the SFR at location 0A0H

(which is P2).

MOV 0A0H, #data

The instructions that use indirect addressing access the upper 128 bytes of RAM. For

example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the

data byte at address 0A0H, rather than P2 (whose address is 0A0H).

MOV @R0, #data

DEPT OF ECE, SSNEC Page 19

Page 20: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

It should be noted that stack operations are examples of indirect addressing, so the

upper 128 bytes of data RAM are available as stack space.

UART

The Atmel 8051 Microcontrollers implement three general purpose, 16-bit timers/

counters. They are identified as Timer 0, Timer 1 and Timer 2 and can be independently

configured to operate in a variety of modes as a timer or as an event counter. When operating

as a timer, the timer/counter runs for a programmed length of time and then issues an interrupt

request. When operating as a counter, the timer/counter counts negative transitions on an

external pin. After a preset number of counts, the counter issues an interrupt request. The

various operating modes of each timer/counter are described in the following sections.

A basic operation consists of timer registers THx and TLx (x= 0, 1) connected in

cascade to form a 16-bit timer. Setting the run control bit (TRx) in TCON register turns the

timer on by allowing the selected input to increment TLx. When TLx overflows it increments

THx; when THx overflows it sets the timer overflow flag(TFx) in TCON register. Setting the

TRx does not clear the THx and TLx timer registers. Timer registers can be accessed to obtain

the current count or to enter preset values. They can be read at any time but TRx bit must be

cleared to preset their values, otherwise the behavior of the timer/counter is unpredictable.

The C/T control bit (in TCON register) selects timer operation or counter operation,

by selecting the divided-down peripheral clock or external pin Tx as the source for the

counted signal. TRx bit must be cleared when changing the mode of operation, otherwise the

behavior of the timer/counter is unpredictable. For timer operation (C/Tx# = 0), the timer

register counts the divided-down peripheral clock. The timer register is incremented once

every peripheral cycle (6 peripheral clock periods). The timer clock rate is FPER / 6, i.e.

FOSC / 12 in standard mode or FOSC / 6 inX2 mode For counter operation (C/Tx# = 1), the

timer register counts the negative transitions on the Tx external input pin. The external input

is sampled every peripheral cycle. When the sample is high in one cycle and low in the next

one, the counter is incremented.

DEPT OF ECE, SSNEC Page 20

Page 21: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Since it takes 2 cycles (12 peripheral clock periods) to recognize a negative transition, the

maximum count rate is FPER / 12, i.e. FOSC / 24 in standard mode or FOSC / 12 in X2mode.

There are no restrictions on the duty cycle of the external input signal, but to ensure that a

given level is sampled at least once before it changes, it should be held forat least one full

peripheral cycle. In addition to the “timer” or “counter” selection, Timer 0 and Timer 1 have

four operating modes from which to select which are selected by bit-pairs (M1, M0) in

TMOD. Modes 0, 1and 2 are the same for both timer/counters. Mode 3 is different.

The four operating modes are described below. Timer 2, has three modes of operation:

‘capture’, ‘auto-reload’ and ‘baud rate generator’.

TIMER 0

Timer 0 functions as either a timer or event counter in four modes of operation. Timer

0 is controlled by the four lower bits of the TMOD register and bits0, 1, 4 and 5 of the TCON

register. TMOD register selects the method of timer gating (GATE0), timer or counter

operation (T/C0#) and mode of operation (M10and M00). The TCON register provides timer

0 control functions: overflow flag (TF0), run control bit (TR0), interrupt flag (IE0) and

interrupt type control bit (IT0).

For normal timer operation (GATE0= 0), setting TR0 allows TL0 to be incremented

by the selected input. Setting GATE0 and TR0 allows external pin INT0# to control timer

operation.

Timer 0 overflow(count rolls over from all 1s to all 0s) sets TF0 flag, generating an

interrupt request. It is important to stop timer/counter before changing mode.

Mode 0 (13-bit timer)

Mode 0 configures timer 0 as a 13-bit timer which is set up as an 8-bit timer (TH0

register)with a modulo-32 prescaler implemented with the lower five bits of the TL0 register.

The upper three bits of TL0 register are indeterminate and should be ignored. Prescaler

overflow increments the TH0 register.

DEPT OF ECE, SSNEC Page 21

Page 22: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

As the count rolls over from all 1’s to all 0’s, it sets the timer interrupt flag TF0. The counted

input is enabled to the Timer when TR0 = 1 and either GATE = 0 or INT0 = 1.(Setting GATE

= 1 allows the Timer to be controlled by external input INT0, to facilitate pulse width

measurements). TR0 is a control bit in the Special Function register TCON. GATE is in

TMOD.

The 13-bit register consists of all 8 bits of TH0 and the lower 5 bits of TL0. The upper

3bits of TL0 are indeterminate and should be ignored. Setting the run flag (TR0) does not

clear the registers. Mode 0 operation is the same for Timer 0 as for Timer 1. There are two

different GATE bits, one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).

Timer/Counter x (x = 0 or 1) in Mode 0

Figure 2-4 Timer/Counter in Mode 0

Mode 1 (16-bitTimer)

Mode 1 is the same as Mode 0, except that the Timer register is being run with all

16bits.Mode 1 configures timer 0 as a 16-bit timer with the TH0 and TL0 registers connected

in cascade. The selected input increments the TL0 register.

DEPT OF ECE, SSNEC Page 22

Page 23: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Timer/Counter x (x = 0 or 1) in Mode 1

Figure 2-5 Timer/counter in mode1

Mode 2 (8-bit Timer with Auto-Reload)

Mode 2 configures timer 0 as an 8-bit timer (TL0 register) that automatically reloads

from the TH0 register. TL0 overflow sets TF0 flag in the TCON register and reloads TL0

with the contents of TH0, which is preset by software.

When the interrupt request is serviced, hardware clears TF0. The reload leaves

TH0unchanged. The next reload value may be changed at any time by writing it to the

TH0register.Mode 2 operation is the same for Timer/Counter 1.

Timer/Counter x (x = 0 or 1) in Mode 2

Figure 2-6 Timer/Counter in mode2

Mode 3 (Two 8-bitTimers)

Mode 3 configures timer 0 so that registers TL0 and TH0 operate as separate 8-bit

timers. This mode is provided for applications requiring an additional 8-bittimer or counter.

DEPT OF ECE, SSNEC Page 23

Page 24: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

TL0 uses the timer 0 control bits C/T0# and GATE0 in the TMOD register, and TR0

and TF0 in the TCON register in the normal manner. TH0 is locked into a timer function

(counting FPER /6) and takes over use of the timer 1 interrupt (TF1) and run control (TR1)

bits. Thus, operation of timer 1 is restricted when timer 0 is in mode 3.

Timer/Counter 0 in Mode 3: Two 8-bit Counters

Figure 2-7 Timer/Counter in Mode 3

Timer 1:

Timer 1 is identical to timer 0, except for mode 3, which is a hold-count mode. The

following comments help to understand the differences:

• Timer 1 functions as either a timer or event counter in three modes of operation.

Timer1’s mode 3 is a hold-count mode.

• Timer 1 is controlled by the four high-order bits of the TMOD register and bits 2, 3,

6 and 7 of the TCON register.

The TMOD register selects the method of timer gating (GATE1), timer or counter

operation (C/T1#) and mode of operation (M11 and M01). The TCON register provides timer

1 control functions: overflow flag (TF1), run control bit (TR1), interrupt flag (IE1) and

interrupt type control bit (IT1).

Timer 1 can serve as the baud rate generator for the serial port. Mode 2 is best suited

for this purpose.

For normal timer operation (GATE1 = 0), setting TR1 allows TL1 to be incremented

by the selected input. Setting GATE1 and TR1 allows external pin INT1# to control

timer operation.

DEPT OF ECE, SSNEC Page 24

Page 25: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Timers 1 overflow (count rolls over from all 1s to all 0s) sets the TF1 flag generating

an interrupt request.

When timer 0 is in mode 3, it uses timer 1’s overflow flag (TF1) and run control bit

(TR1). For this situation, use timer 1 only for applications that do not require an

interrupt (such as a baud rate generator for the serial port) and switch timer 1 in and

out of mode 3 to turn it off and on.

It is important to stop timer/counter before changing modes.

Mode 0 (13-bitTimer)

Mode 0 configures Timer 1 as a 13-bit timer, which is set up as an 8-bit timer (TH1

register)with a modulo-32 prescaler implemented with the lower 5 bits of the TL1 register.

The upper 3 bits of the TL1 register are ignored. Prescaler overflowincrements the TH1

register.

Mode 1 (16-bitTimer)

Mode 1 configures Timer 1 as a 16-bit timer with the TH1 and TL1 registers

connected in cascade. The selected input increments the TL1 register.

Mode 2 (8-bit Timer with Auto Reload)

Mode 2 configures Timer 1 as an 8-bit timer (TL1 register) with automatic reload

from the TH1 register on overflow. TL1 overflow sets the TF1 flag in the TCON register and

reloads TL1 with the contents of TH1, which is preset by software. The reload leaves TH1

unchanged.

Mode 3 (Halt)

Placing Timer 1 in mode 3 causes it to halt and hold its count. This can be used to halt

Timer 1 when TR1 run control bit is not available i.e., when Timer 0 is in mode 3.

DEPT OF ECE, SSNEC Page 25

Page 26: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Timer 2

Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event

counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has three

operating modes: capture, auto-reload (up or down counting), and baud rate generator. The

modes are selected by bits in T2CON. Timer 2 consists of two 8-bit registers, TH2 and TL2.

In the Timer function, the TL2 register is incremented every machine cycle. Since a machine

cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.

Table 2-4 Timer 2 Operating Modes

In the Counter function, the register is incremented in response to a 1-to-0 transition at

its corresponding external input pin, T2. In this function, the external input is sampled during

S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the

next cycle, the count is incremented. The new count value appears in the register during S3P1

of the cycle following the one in which the transition was detected. Since two machine cycles

(24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is

1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it

changes, the level should be held for at least one full machine cycle.

DEPT OF ECE, SSNEC Page 26

Page 27: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

CHAPTER -3

DESCRIPTION OF MODULES

3.1 BLOCK DIAGRAM

DEPT OF ECE, SSNEC Page 27

gsm 8051 rfid

Page 28: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

3.2 POWER SUPPLY

There are many types of power supply. Most are designed to convert high voltage AC

mains electricity to a suitable low voltage supply for electronics circuits and other devices. A

power supply can by broken down into a series of blocks, each of which performs a particular

function.

For example a 5V regulated supply:

Figure 3-1 Block Diagram of a Regulated power Supply System

Each of the blocks is described in more detail below:

Transformer - steps down high voltage AC mains to low voltage AC.

Rectifier - converts AC to DC, but the DC output is varying.

Smoothing - smoothes the DC from varying greatly to a small ripple.

Regulator - eliminates ripple by setting DC output to a fixed voltage.

Power supplies made from these blocks are described below with a circuit diagram and a

graph of their output:

Transformer only

Transformer + Rectifier

Transformer + Rectifier + Smoothing

Transformer + Rectifier + Smoothing + Regulator

DEPT OF ECE, SSNEC Page 28

Page 29: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

3.2.1 DUAL SUPPLIES

Some electronic circuits require a power supply with positive and negative outputs as

well as zero volts (0V). This is called a 'dual supply' because it is like two ordinary supplies

connected together as shown in the diagram. Dual supplies have three outputs, for example a

±9V supply has +9V, 0V and -9V outputs

TRANSFORMER ONLY

The low voltage AC output is suitable for lamps, heaters and special AC motors. It is

not suitable for electronic circuits unless they include a rectifier and a smoothing capacitor.

Transformer + Rectifier

The varying DC output is suitable for lamps, heaters and standard motors. It is not

suitable for electronic circuits unless they include a smoothing capacitor.

DEPT OF ECE, SSNEC Page 29

Page 30: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Transformer + Rectifier + Smoothing

The smooth DC output has a small ripple. It is suitable for most electronic circuits.

TRANSFORMER + RECTIFIER + SMOOTHING + REGULATOR

The Regulated DC output is very smooth with no ripple. It is suitable for all

electronic circuits.

3.2.2 TRANSFORMER

Transformers convert AC electricity from one voltage to another with little loss of

power. Transformers work only with AC and this is one of the reasons why mains electricity

is AC. Step-up transformers increase voltage, step-down transformers reduce voltage. Most

power supplies use a step-down transformer to reduce the dangerously high mains voltage

(230V in UK) to a safer low voltage.

The input coil is called the primary and the output coil is called the secondary. There

is no electrical connection between the two coils, instead they are linked by an alternating

DEPT OF ECE, SSNEC Page 30

Page 31: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

magnetic field created in the soft-iron core of the transformer. The two lines in the middle of

the circuit symbol represent the core.

Transformers waste very little power so the power out is (almost) equal to the power

in. Note that as voltage is stepped down current is stepped up. The ratio of the number of

turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down

transformer has a large number of turns on its primary (input) coil which is connected to the

high voltage mains supply, and a small number of turns on its secondary (output) coil to give

a low output voltage.

  turns ratio = Vp

 = Np

   and   power out = power in   

Vs Ns Vs × Is = Vp × Ip

Figure 3-2 Transformer circuit symbol

3.2.3 RECTIFIER

DEPT OF ECE, SSNEC Page 31

Vp = primary (input) voltage

Np = number of turns on primary coil

Ip  = primary (input) current

   

Vs = secondary (output) voltage

Ns = number of turns on secondary coil

Is  = secondary (output) current

Page 32: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

There are several ways of connecting diodes to make a rectifier to convert AC to DC.

The bridge   rectifier is the most important and it produces full-wave varying DC. A full-wave

rectifier can also be made from just two diodes if a centre-tap transformer is used, but this

method is rarely used now that diodes are cheaper. A single   diode can be used as a rectifier

but it only uses the positive (+) parts of the AC wave to produce half-wave varying DC.

3.2.4 BRIDGE RECTIFIER

A bridge rectifier can be made using four individual diodes, but it is also available in

special packages containing the four diodes required. It is called a full-wave rectifier because

it uses all the AC wave (both positive and negative sections). 1.4V is used up in the bridge

rectifier because each diode uses 0.7V when conducting and there are always two diodes

conducting, as shown in the diagram below. Bridge rectifiers are rated by the maximum

current they can pass and the maximum reverse voltage they can withstand (this must be at

least three times the supply RMS voltage so the rectifier can withstand the peak voltages).

Please see the Diodes page for more details, including pictures of bridge rectifiers.

Figure 3-3 Bridge rectifier

Output: full-wave varying DC

3.2.5 SINGLE DIODE RECTIFIER

A single diode can be used as a rectifier but this produces half-wave varying DC

which has gaps when the AC is negative. It is hard to smooth this sufficiently well to supply

DEPT OF ECE, SSNEC Page 32

Page 33: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

electronic circuits unless they require a very small current so the smoothing capacitor does not

significantly discharge during the gaps. Please see the Diodes page for some examples of

rectifier diodes.

Single diode rectifierOutput: half-wave varying DC

(using only half the AC wave)

Figure 3-4 Single diode rectifier

3.2.6 SMOOTHING

Smoothing is performed by a large value electrolytic capacitor connected across the

DC supply to act as a reservoir, supplying current to the output when the varying DC voltage

from the rectifier is falling. The diagram shows the unsmoothed varying DC (dotted line) and

the smoothed DC (solid line). The capacitor charges quickly near the peak of the varying DC,

and then discharges as it supplies current to the output.

Note that smoothing significantly increases the average DC voltage to almost the peak

value (1.4 × RMS value). For example 6V RMS AC is rectified to full wave DC of about

4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to almost the

peak value giving 1.4 × 4.6 = 6.4V smooth DC.

Smoothing is not perfect due to the capacitor voltage falling a little as it discharges,

giving a small ripple voltage. For many circuits a ripple which is 10% of the supply voltage

is satisfactory and the equation below gives the required value for the smoothing capacitor. A

DEPT OF ECE, SSNEC Page 33

Page 34: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

larger capacitor will give less ripple. The capacitor value must be doubled when smoothing

half-wave DC.

Figure 3-5 Smoothing circuit diagram

  Smoothing capacitor for 10% ripple, C = 5 × Io   

Vs × f

C  = smoothing capacitance in farads (F)

Io  = output current from the supply in amps (A)

Vs = supply voltage in volts (V), this is the peak value of the unsmoothed DC

f    = frequency of the AC supply in hertz (Hz), 50Hz in the UK

3.2.7 REGULATORS

Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable

output voltages. They are also rated by the maximum current they can pass. Negative voltage

regulators are available, mainly for use in dual supplies. Most regulators include some

automatic protection from excessive current ('overload protection') and overheating ('thermal

protection'). Many of the fixed voltage regulator ICs have 3 leads and look like power

transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for

attaching a heat sink if necessary.

DEPT OF ECE, SSNEC Page 34

Page 35: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Figure 3-6 Regulator circuit

3.3 LCD DISPLAY

Liquid Crystal Display also called as LCD is very helpful in providing user interface

as well as for debugging purpose. The most common type of LCD controller is HITACHI

44780 which provides a simple interface between the controller & an LCD. These LCD's are

very simple to interface with the controller as well as are cost effective.

The most commonly used ALPHANUMERIC displays are 1x16 (Single Line & 16

characters), 2x16 (Double Line & 16 character per line) & 4x20 (four lines & Twenty

characters per line).  The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines.

The number on data lines depends on the mode of operation.

If operated in 8-bit mode then 8 data lines + 3 control lines i.e. total 11 lines are

required. And if operated in 4-bit mode then 4 data lines + 3 control lines i.e. 7 lines are

required. How do we decide which mode to use? It’s simple if you have sufficient data lines

you can go for 8 bit mode & if there is a time constrain i.e. display should be faster then we

have to use 8-bit mode because basically 4-bit mode takes twice as more time as compared to

8-bit mode.

Most projects you create with the 8051 CPU require some form of  display.  The most

common way to accomplish this is with the LCD  (Liquid Crystal Display).  LCDs have

become a cheap and easy way to get text display for embedded system Common displays are

set up as 16 to 20 characters by 1 to 4 lines.

DEPT OF ECE, SSNEC Page 35

Page 36: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

When RS is low (0), the data is to be treated as a command. When RS is high (1), the

data being sent is considered as text data which should be displayed on the screen.

When R/W is low (0), the information on the data bus is being written to the LCD. When RW

is high (1), the program is effectively reading from the LCD. Most of the times there is no

need to read from the LCD so this line can directly be connected to Gnd thus saving one

controller line.

The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOW

signal is required to latch the data. The LCD interprets and executes our command at the

instant the EN line is brought low. If you never bring EN low, your instruction will never be

executed.

Figure 3-7 Pindiagram of LCD

UNDERSTANDING LCD

Pin outline

DEPT OF ECE, SSNEC Page 36

Page 37: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

• 8 data pins D7:D0

Bi-directional data/command pins.

Alphanumeric characters are sent in

ASCII format.

 

• RS:  Register Select

RS = 0 -> Command Register is selected

RS = 1 -> Data Register is selected

 

• R/W: Read or Write

0 -> Write, 1 -> Read

• E: Enable (Latch data)

Used to latch the data present on the data

pins. A high-to-low edge is needed to

latch the data.

• VEE: contrast control

 

NOTE: When writing to the display, data is transferred only on the high to low

transition of this signal. However, when reading from the display, data will become

available shortly after the low to high transition and remain available until the signal falls

low again.

3.3.1 Display Data RAM (DDRAM)

Display data RAM (DDRAM) is where you send the characters (ASCII code) you

want to see on the LCD screen. It stores display data represented in 8-bit character codes.

Its capacity is 80 characters (bytes).  Below you see DD RAM address layout of a 2*16

LCD.

In the above memory map, the area shaded in black is the visible display (For

16x2 displays). For first line addresses for first 15 characters is from 00h to 0Fh. But for

second line address of first character is 40h and so on up to 4Fh for the 16th character. So

if you want to display the text at specific positions of LCD , we require to manipulate

address and then to set cursor position accordingly .

3.3.2 Character Generator RAM (CGRAM)-User defined character RAM

DEPT OF ECE, SSNEC Page 37

Page 38: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

In the character generator RAM, we can define our  own character patterns by

program. CG RAM is 64 bytes ,allowing for eight 5*8 pixel, character patterns to be

defined. However how to define this and use it  is out of scope of this tutorial. So I will

not talk any more about CGRAM

3.3.3 Registers

The HD44780 has two 8-bit registers, an instruction register (IR) and a data

register (DR). The IR stores instruction codes. The DR temporarily stores data to be

written into DDRAM or CGRAM and temporarily stores data to be read from DDRAM

or CGRAM. Data written into the DR is automatically written into DDRAM or CGRAM

by an internal operation. . These two registers can be selected by the register selector

(RS) signal. See the table below:

    Register Selection

RS R/WOperation

0 0 IR write as an internal operation (display clear, etc.)

0 1 Read busy flag (DB7) and address counter (DB0 to DB6)

1 0 DR write as an internal operation (DR to DDRAM or CGRAM)

1 1 DR read as an internal operation (DDRAM or CGRAM to DR)

Table 3-1 Register selection

 Busy Flag (BF)

When the busy flag is 1, the LCD  is in the internal operation mode, and the next

instruction will not be accepted. When RS = 0 and R/W = 1 (see the table above), the

busy flag is output to DB7 (MSB of LCD data bus). The next instruction must be written

after ensuring that the busy flag is 0.

DEPT OF ECE, SSNEC Page 38

Page 39: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

3.3.4 LCD Commands 

The LCD’s internal controller accept several commands and modify the display

accordingly. These commands would be things like:

– Clear screen

– Return home

– Shift display right/left

Instruction Decimal HEX

Function set (8-bit interface, 2 lines, 5*7 Pixels) 56 38

Function set (8-bit interface, 1 line, 5*7 Pixels) 48 30

Function set (4-bit interface, 2 lines, 5*7 Pixels) 40 28

Function set (4-bit interface, 1 line, 5*7 Pixels) 32 20

Entry mode set See Below See Below

Scroll display one character right (all lines) 28 1E

Scroll display one character left (all lines) 24 18

Home (move cursor to top/left character position) 2 2

Move cursor one character left 16 10

Move cursor one character right 20 14

Turn on visible underline cursor 14 0E

Turn on visible blinking-block cursor 15 0F

Make cursor invisible 12 0C

Blank the display (without clearing) 8 08

DEPT OF ECE, SSNEC Page 39

Page 40: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

Restore the display (with cursor hidden) 12 0C

Clear Screen 1 01

Set cursor position (DDRAM address) 128 + addr 80+ addr

Set pointer in character-generator RAM (CG RAM address) 64 + addr 40+ addr

Table 3-1 Instructions

3.3.5 INTERFACING LCD TO 8051

Figure 3-8 Interfacing LCD to 8051

DEPT OF ECE, SSNEC Page 40

Page 41: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

 

Figure 3-9 Interfacing HD44780 LCD to 8051

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for

the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or

an 8-bit data bus.

If a 4-bit data bus is used, the LCD will require a total of 7 data lines.

If an 8-bit data bus is used, the LCD will require a total of 11 data lines.

The three control lines are EN, RS, and RW.

Note that the EN line must be raised/lowered before/after each instruction sent to

the LCD regardless of whether that instruction is read or write, text or instruction. In

short, you must always manipulate EN when communicating with the LCD. EN is the

LCD's way of knowing that you are talking to it. If you don't raise/lower EN, the LCD

doesn't know you're talking to it on the other lines.

3.3.6 CHECKING THE BUSY FLAG

 

You can use subroutine for checking busy flag  or just  a big (and safe) delay.

 

1. Set R/W Pin of the LCD HIGH(read from the LCD)

2. Select the instruction register by setting RS pin LOW

DEPT OF ECE, SSNEC Page 41

Page 42: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

3. Enable the LCD by Setting the enable pin HIGH

4. The most significant bit of the LCD data bus is the state of the busy

flag(1=Busy,0=ready to accept instructions/data). The other bits hold the current

value of the address counter.

If the LCD never come out from  "busy" status because of some problems ,The

program will  "hang," waiting for DB7 to go low. So in a real applications it would be

wise to put some kind of time limit on the delay--for example, a maximum of 100

attempts to wait for the busy signal to go low. This would guarantee that even if the LCD

hardware fails, the program would not lock up.

CODE EXAMPLE

 

It is easy (and clean tech. ) to make different subroutines and then call them as we

need.

Busy flag checking

ready:

setb P1.7 ;D7 as input

clr P3.6 ;RS=0 cmd

setb P3.5 ;RW=1 for read

 

again:

setb P3.7 ;H->L pulse on E

clr P3.7

jb P1.7, again

ret

 Data write Routine

DEPT OF ECE, SSNEC Page 42

Page 43: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

data:

mov P1, A ;move acc. data to port

setb P3.6 ;RS=1 data

clr P3.5 ;RW=0 for write

setb P3.7 ;H->L pulse on E

clr P3.7

lcall ready

ret

Command write Routine

command:

mov P1, A ;move acc. data to port

clr P3.6 ;RS=0 for cmd

clr P3.5 ;RW=0 for write

setb P3.7 ;H->L pulse on E

clr P3.7

lcall ready

ret

Initialization

mov A, #38H ; Initialize, 2-lines, 5X7

matrix.

lcall  Command

mov A, #0EH ; LCD on, cursor on

lcall  Command

mov A, #01H ; Clear LCD Screen

lcall  Command

mov A, #06H ; Shift cursor right

lcall  Command

 

 Display clear

clear:

setb p3.7 ;enable EN

clr 3.6 ;RS=0 for cmd.

mov DATA,#01h

clr p3.7 ;disable  EN

lcall  ready

RET

Note- As we need to clear the LCD

frequently and not the whole

initialisation , it is better to use this

routine separately.

Displaying "HI"

lcall initialization

lcall clear

mov A,#'H'

acall data

mov A,#'I'

lcall data

Let's now try code for displaying text at specific positions.

I want to display "MAHESH" in message "Hi MAHESH" at the right corner of first line

then I should start from 10th character.

DEPT OF ECE, SSNEC Page 43

Page 44: An Embedded Systems and Rfid Solution for Transport Related Issues

AN EMBEDDED SYSTEMS AND RFID SOLUTION FOR TRANSPORT RELATED ISSUES

So referring to table 80h+0Ah= 8Ah.

So below is code and I don's think that you will need explanation comments.

ASSEMBLY LANGUAGE

lcall Initialization

lcall clear

mov a,#'H'

lcall data

mov a,#'I'

lcall data

mov a,#8ah

lcall command

mov a,#'M'

lcall data

mov a,#'A'

lcall data

mov a,#'H'

lcall data

mov a,#'E'

lcall data

mov a,#'S'

lcall data

mov a,#'H'

lcall data

DEPT OF ECE, SSNEC Page 44

Page 45: An Embedded Systems and Rfid Solution for Transport Related Issues

3.4 MAX232

The MAX232 is an integrated circuit that converts signals from an RS-232 serial port

to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual

driver/receiver and typically converts the RX, TX, CTS and RTS signals.

The drivers provide RS-232 voltage level outputs (approx. ± 7.5 V) from a single

+ 5 V supply via on-chip charge pumps and external capacitors. This makes it useful for

implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V to

+ 5 V range, as power supply design does not need to be made more complicated just for

driving the RS-232 in this case. The receivers reduce RS-232 inputs (which may be as high as

± 25 V), to standard 5 V TTL levels. These receivers have a typical threshold of 1.3 V, and a

typical hysteresis of 0.5 V. The later MAX232A is backwards compatible with the original

MAX232 but may operate at higher baud rates and can use smaller external capacitors –

0.1 μF in place of the 1.0 μF capacitors used with the original device.

The newer MAX3232 is also backwards compatible, but operates at a broader voltage

range, from 3 to 5.5V.

3.4.1VOLTAGE LEVELS

Page 46: An Embedded Systems and Rfid Solution for Transport Related Issues

It is helpful to understand what occurs to the voltage levels. When a MAX232 IC

receives a TTL level to convert, it changes a TTL Logic 0 to between +3 and +15V, and

changes TTL Logic 1 to between -3 to -15V, and vice versa for converting from RS232 to

TTL. This can be confusing when you realize that the RS232 Data Transmission voltages at a

certain logic state are opposite from the RS232 Control Line voltages at the same logic state.

Figure 3-10 Pin diagram of MAX232

APPLICATIONS

Portable Computers

Low-Power Modems

Interface Translation

Battery-Powered RS-232 Systems

Multi drop RS-232 Networks

Page 47: An Embedded Systems and Rfid Solution for Transport Related Issues

3.5 INTERFACING THE SERIAL / RS232 PORT

The Serial Port is harder to interface than the Parallel Port. In most cases, any device

you connect to the serial port will need the serial transmission converted back to parallel so

that it can be used. This can be done using a UART. On the software side of things, there are

many more registers that you have to attend to than on a Standard Parallel Port. (SPP) So

what are the advantages of using serial data transfer rather than parallel?

1. Serial Cables can be longer than Parallel cables. The serial port transmits a '1' as -3 to -25

volts and a '0' as +3 to +25 volts where as a parallel port transmits a '0' as 0v and a '1' as 5v.

Therefore the serial port can have a maximum swing of 50V compared to the parallel port

which has a maximum swing of 5 Volts. Therefore cable loss is not going to be as much of

a problem for serial cables than they are for parallel.

2. You don't need as many wires than parallel transmission. If your device needs to be

mounted a far distance away from the computer then 3 core cable (Null Modem

Configuration) is going to be a lot cheaper that running 19 or 25 core cable. However you

must take into account the cost of the interfacing at each end.

3. Infra Red devices have proven quite popular recently. You may of seen many electronic

diaries and palmtop computers which have infra red capabilities build in. However could

you imagine transmitting 8 bits of data at the one time across the room and being able to

(from the devices point of view) decipher which bits are which? Therefore serial

transmission is used where one bit is sent at a time. IrDA-1 (The first infra red

specifications) was capable of 115.2k baud and was interfaced into a UART. The pulse

length however was cut down to 3/16th of a RS232 bit length to conserve power

considering these devices are mainly used on diaries, laptops and palmtops.

4. Microcontrollers have also proven to be quite popular recently. Many of these have in built

SCI (Serial Communications Interfaces) which can be used to talk to the outside world.

Serial Communication reduces the pin count of these MPU's. Only two pins are commonly

used, Transmit Data (TXD) and Receive Data (RXD) compared with at least 8 pins if you

use a 8 bit Parallel method

Devices which use serial cables for their communication are split into two categories.

These are DCE (Data Communications Equipment) and DTE (Data Terminal Equipment.)

Data Communications Equipment are devices such as your modem, TA adapter, plotter etc

Page 48: An Embedded Systems and Rfid Solution for Transport Related Issues

while Data Terminal Equipment is your Computer or Terminal. The electrical specification of

the serial port is contained in the EIA (Electronics Industry Association) RS232C standard. It

states many parameters such as –

1. A "Space" (logic 0) will be between +3 and +25 Volts.

2. A "Mark" (Logic 1) will be between -3 and -25 Volts.

3. The region between +3 and -3 volts is undefined.

4. An open circuit voltage should never exceed 25 volts. (In Reference to

GND)

5. A short circuit current should not exceed 500mA. The driver should be

able to handle this without damage. (Take note of this one!)

Above is no where near a complete list of the EIA standard. Line Capacitance,

Maximum Baud Rates etc are also included. For more information please consult the EIA

RS232-C standard. It is interesting to note however, that the RS232C standard specifies a

maximum baud rate of 20,000 BPS!, which is rather slow by today's standards. A new

standard, RS-232D has been recently released.

Serial Ports come in two "sizes", There are the D-Type 25 pin connector and the D-

Type 9 pin connector both of which are male on the back of the PC, thus you will require a

female connector on your device. Below is a table of pin connections for the 9 pin and 25 pin

D-Type connectors.

3.5.1 HARDWARE PROPERTIES

Devices which use serial cables for their communication are split into two categories.

These are DCE (Data Communications Equipment) and DTE (Data Terminal Equipment.)

Page 49: An Embedded Systems and Rfid Solution for Transport Related Issues

Data Communications Equipment are devices such as your modem, TA adapter, plotter etc

while Data Terminal Equipment is your Computer or Terminal.

The electrical specifications of the serial port is contained in the EIA (Electronics

Industry Association) RS232C standard. It states many parameters such as - Above is no

where near a complete list of the EIA standard. Line Capacitance, Maximum Baud Rates etc

are also included. For more information please consult the EIA RS232-C standard. It is

interesting to note however, that the RS232C standard specifies a maximum baud rate of

20,000 BPS!, which is rather slow by today's standards.

A new standard, RS-232D has been recently released.Serial Ports come in two "sizes",

There are the D-Type 25 pin connector and the D-Type 9 pin connector both of which are

male on the back of the PC, thus you will require a female connector on your device. Below is

a table of pin connections for the 9 pin and 25 pin D-Type connectors

3.5.2 DB9 CONNECTOR

1. A "Space" (logic 0) will be between +3 and +25 Volts.

2. A "Mark" (Logic 1) will be between -3 and -25 Volts.

3. The region between +3 and -3 volts is undefined.

4. An open circuit voltage should never exceed 25 volts. (In Reference to GND)

5. A short circuit current should not exceed 500mA. The driver should be able to handle

this without damage.

DB9 CONNECTOR

Page 50: An Embedded Systems and Rfid Solution for Transport Related Issues

Figure 3-11 RS232 DB9Connector Pin out

DB-9M Function Abbreviation Pin #1 Data Carrier Detect CD Pin #2 Receive Data RD or RX or RXD Pin #3 Transmitted Data TD or TX or TXD Pin #4 Data Terminal Ready DTR Pin #5 Signal Ground GND Pin #6 Data Set Ready DSR Pin #7 Request to Send RTS Pin #8 Clear To Send CTS Pin #9 Ring Indicator RI.

3.6 GSM Technology:

3.6.1 INTRODUCTION TO THE GSM STANDARD

Page 51: An Embedded Systems and Rfid Solution for Transport Related Issues

The GSM (Global System for Mobile communications) network is at the start of the

21st century, the most commonly used mobile telephony standard in Europe. It is called as

Second Generation (2G) standard because communications occur in an entirely digital mode,

unlike the first generation of portable telephones.

When it was first standardized in 1982, it was called as Group Special Mobile and

later, it became an international standard called "Global System for Mobile

communications" in 1991. In Europe, the GSM standard uses the 900 MHz and 1800 MHz

frequency bands. In the United States, however, the frequency band used is the 1900 MHz

band. For this reason, portable telephones that are able to operate in both Europe and the

United States are called tri-band while those that operate only in Europe are called bi-band.

The GSM standard allows a maximum throughput of 9.6 kbps which allows

transmission of voice and low-volume digital data like text messages (SMS, for Short

Message Service) or multimedia messages (MMS, for Multimedia Message Service).

GSM STANDARDS

GSM uses narrowband TDMA, which allows eight simultaneous calls on the same

radio frequency. There are three basic principles in multiple access, FDMA (Frequency

Division Multiple Access), TDMA (Time Division Multiple Access), and CDMA (Code

Division Multiple Access). All three principles allow multiple users to share the same

physical channel. But the two competing technologies differ in the way user sharing the

common resource.

TDMA allows the users to share the same frequency channel by dividing the signal

into different time slots. Each user takes turn in a round robin fashion for transmitting and

receiving over the channel. Here, users can only transmit in their respective time slot. CDMA

uses a spread spectrum technology that is it spreads the information contained in a particular

signal of interest over a much greater bandwidth than the original signal. Unlike TDMA, in

CDMA several users can transmit over the channel at the same time.

Page 52: An Embedded Systems and Rfid Solution for Transport Related Issues

DEFINITION OF GSM

GSM (Global System for Mobile communications) is an open, digital cellular

technology used for transmitting mobile voice and data services. GSM (Global System for

Mobile communication) is a digital mobile telephone system that is widely used in Europe

and other parts of the world. GSM uses a variation of Time Division Multiple Access

(TDMA) and is the most widely used of the three digital wireless telephone technologies

(TDMA, GSM, and CDMA). GSM digitizes and compresses data, then sends it down a

channel with two other streams of user data, each in its own time slot. It operates at either the

900 MHz or 1,800 MHz frequency band. It supports voice calls and data transfer speeds of up

to 9.6 kbit/s, together with the transmission of SMS (Short Message Service).

HISTORY

In 1982, the European Conference of Postal and Telecommunications Administrations

(ECPT) created the Group Special Mobile (GSM) to develop a standard for a mobile

telephone system that could be used across Europe. In 1987, a memorandum of

understanding was signed by 13 countries to develop a common cellular telephone system

across Europe. Finally the system created by SINTEF lead by Torleiv Maseng was selected.

In 1989, GSM responsibility was transferred to the European Telecommunications

Standards Institute (ETSI) and phase I of the GSM specifications were published in 1990. The

first GSM network was launched in 1991 by Radiolinja in Finland with joint technical

infrastructure maintenance from Ericsson.

By the end of 1993, over a million subscribers were using GSM phone networks being

operated by 70 carriers across 48 countries. As of the end of 1997, GSM service was available

in more than 100 countries and has become the de facto standard in Europe and Asia.

GSM FREQUENCIES

Page 53: An Embedded Systems and Rfid Solution for Transport Related Issues

GSM networks operate in a number of different frequency ranges (separated into GSM

frequency ranges for 2G and UMTS frequency bands for 3G). Most 2G GSM networks

operate in the 900 MHz or 1800 MHz bands. Some countries in the Americas (including

Canada and the United States) use the 850 MHz and 1900 MHz bands because the 900 and

1800 MHz frequency bands were already allocated. Most 3G GSM networks in Europe

operate in the 2100 MHz frequency band. The rarer 400 and 450 MHz frequency bands are

assigned in some countries where these frequencies were previously used for first-generation

systems.

GSM-900 uses 890–915 MHz to send information from the mobile station to the base

station (uplink) and 935–960 MHz for the other direction (downlink), providing 124 RF

channels (channel numbers 1 to 124) spaced at 200 kHz. Duplex spacing of 45 MHz is used.

In some countries the GSM-900 band has been extended to cover a larger frequency range.

This 'extended GSM', E-GSM, uses 880–915 MHz (uplink) and 925–960 MHz (downlink),

adding 50 channels (channel numbers 975 to 1023 and 0) to the original GSM-900 band.

Time division multiplexing is used to allow eight full-rate or sixteen half-rate speech

channels per radio frequency channel. There are eight radio timeslots (giving eight burst

periods) grouped into what is called a TDMA frame. Half rate channels use alternate frames

in the same timeslot. The channel data rate for all 8 channels is 270.833 Kbit/s, and the frame

duration is 4.615 ms.

The transmission power in the handset is limited to a maximum of 2 watts in

GSM850/900 and 1 watt in GSM1800/1900. GSM operates in the 900MHz and 1.8GHz

bands in Europe and the 1.9GHz and 850MHz bands in the US. The 850MHz band is also

used for GSM and 3G in Australia, Canada and many South American countries. By having

harmonized spectrum across most of the globe, GSM’s international roaming capability

allows users to access the same services when travelling abroad as at home. This gives

consumers seamless and same number connectivity in more than 218 countries.

Page 54: An Embedded Systems and Rfid Solution for Transport Related Issues

Terrestrial GSM networks now cover more than 80% of the world’s population. GSM

satellite roaming has also extended service access to areas where terrestrial coverage is not

available.

Mobile Telephony Standards

Standard Generation Frequency band Throughput

GSM 2GAllows transfer of voice or low-volume digital data. 9.6 kbps

9.6 kbps

GPRS 2.5GAllows transfer of voice or moderate-volume digital data.

21.4-171.2 kbps

48 kbps

EDGE 2.75GAllows simultaneous transfer of voice and digital data.

43.2-345.6 kbps

171 kbps

UMTS 3GAllows simultaneous transfer of voice and high-speed digital data. 0.144-2 Mbps

384 kbps

Table 3-3 Mobile telephony standards

3.6.2 1G

The first generation of mobile telephony (written 1G) operated using analogue

communications and portable devices that were relatively large. It used primarily the

following standards:

AMPS (Advanced Mobile Phone System), which appeared in 1976 in the United

States, was the first cellular network standard. It was used primarily in the Americas,

Russia and Asia. This first-generation analogue network had weak security

mechanisms which allowed hacking of telephones lines.

TACS (Total Access Communication System) is the European version of the AMPS

model. Using the 900 MHz frequency band, this system was largely used in England

and then in Asia (Hong-Kong and Japan).

ETACS (Extended Total Access Communication System) is an improved version of

the TACS standard developed in the United Kingdom that uses a larger number of

communication channels.

Page 55: An Embedded Systems and Rfid Solution for Transport Related Issues

The first-generation cellular networks were made obsolete by the appearance of an entirely

digital second generation.

3.6.3 SECOND GENERATION OF MOBILE NETWORKS (2G)

The second generation of mobile networks marked a break with the first generation of

cellular telephones by switching from analogue to digital. The main 2G mobile telephony

standards are:

GSM  (Global System for Mobile communications) is the most commonly used

standard in Europe at the end of the 20th century and supported in the United States.

This standard uses the 900 MHz and 1800 MHz frequency bands in Europe. In the

United States, however, the frequency band used is the 1900 MHz band. Portable

telephones that are able to operate in Europe and the United States are therefore

called tri-band.

CDMA (Code Division Multiple Access) uses a spread spectrum technique that allows

a radio signal to be broadcast over a large frequency range.

TDMA (Time Division Multiple Access) uses a technique of time division of

communication channels to increase the volume of data transmitted simultaneously.

TDMA technology is primarily used on the American continent, in New Zealand and

in the Asia-Pacific region.

With the 2G networks, it is possible to transmit voice and low volume digital data, for

example text messages (SMS, for Short Message Service) or multimedia messages (MMS,

for Multimedia Message Service). The GSM standard allows a maximum data rate of 9.6

kbps.

Extensions have been made to the GSM standard to improve throughput. One of these

is the GPRS (General Packet Radio System) service which allows theoretical data rates on the

Page 56: An Embedded Systems and Rfid Solution for Transport Related Issues

order of 114 Kbit/s but with throughput closer to 40 Kbit/s in practice. As this technology

does not fit within the "3G" category, it is often referred to as 2.5G

The EDGE (Enhanced Data Rates for Global Evolution) standard, billed as 2.75G,

quadruples the throughput improvements of GPRS with its theoretical data rate of 384 Kbps,

thereby allowing the access for multimedia applications. In reality, the EDGE standard allows

maximum theoretical data rates of 473 Kbit/s, but it has been limited in order to comply with

the IMT-2000(International Mobile Telecommunications-2000) specifications from the ITU

(International Telecommunications Union).

3.6.4 3G

The IMT-2000 (International Mobile Telecommunications for the year 2000)

specifications from the International Telecommunications Union (ITU) defined the

characteristics of 3G (third generation of mobile telephony). The most important of these

characteristics are:

1. High transmission data rate.

2. 144 Kbps with total coverage for mobile use.

3. 384 Kbps with medium coverage for pedestrian use.

4. 2 Mbps with reduced coverage area for stationary use.

5. World compatibility.

6. Compatibility of 3rd generation mobile services with second generation networks.

3G offers data rates of more than 144 Kbit/s, thereby allowing the access to

multimedia uses such as video transmission, video-conferencing or high-speed internet

access. 3G networks use different frequency bands than the previous networks: 1885-2025

MHz and 2110-2200 MHz.

The main 3G standard used in Europe is called UMTS (Universal Mobile

Telecommunications System) and uses WCDMA (Wideband Code Division Multiple Access)

encoding. UMTS technology uses 5 MHz bands for transferring voice and data, with data

rates that can range from 384 Kbps to 2 Mbps. HSDPA (High Speed Downlink Packet

Access) is a third generation mobile telephony protocol, (considered as "3.5G"), which is able

Page 57: An Embedded Systems and Rfid Solution for Transport Related Issues

to reach data rates on the order of 8 to 10 Mbps. HSDPA technology uses the 5 GHz

frequency band and uses WCDMA encoding.

THE CONCEPT OF CELLULAR NETWORK

Mobile telephone networks are based on the concept of cells, circular zones that

overlap to cover a geographical area.

Figure 3-12 Cellular Network

Cellular networks are based on the use of a central transmitter-receiver in each cell,

called a "base station" (or Base Transceiver Station, written BTS). The smaller the radius of

a cell, the higher is the available bandwidth. So, in highly populated urban areas, there are

cells with a radius of a few hundred meters, while huge cells of up to 30 kilometers provide

coverage in rural areas. In a cellular network, each cell is surrounded by 6 neighbouring cells

(thus a cell is generally drawn as a hexagon). To avoid interference, adjacent cells cannot use

the same frequency. In practice, two cells using the same frequency range must be separated

by a distance of two to three times the diameter of the cell.

3.6.5 ARCHITECTURE OF THE GSM NETWORK

In a GSM network, the user terminal is called a mobile station. A mobile station is

made up of a SIM (Subscriber Identity Module) card allowing the user to be uniquely

identified and a mobile terminal. The terminals (devices) are identified by a unique 15-digit

Page 58: An Embedded Systems and Rfid Solution for Transport Related Issues

identification number called IMEI (International Mobile Equipment Identity). Each SIM card

also has a unique (and secret) identification number called IMSI (International Mobile

Subscriber Identity). This code can be protected using a 4-digit key called a PIN code.

The SIM card therefore allows each user to be identified independently of the terminal

used during communication with a base station. Communications occur through a radio link

(air interface) between a mobile station and a base station.

Figure 3-13 Architecture of the GSM Network

All the base stations of a cellular network are connected to a base station

controller (BSC) which is responsible for managing distribution of the resources. The system

consisting of the base station controller and its connected base stations is called the Base

Station Subsystem (BSS).

Finally, the base station controllers are themselves physically connected to the Mobile

Switching Centre (MSC), managed by the telephone network operator, which connects them

to the public telephone network and the Internet. The MSC belongs to a Network Station

Subsystem (NSS), which is responsible for managing user identities, their location and

establishment of communications with other subscribers. The MSC is generally connected to

databases that provide additional functions:

Page 59: An Embedded Systems and Rfid Solution for Transport Related Issues

1. The Home Location Register (HLR) is a database containing information

(geographic position, administrative information etc.) of the subscribers registered in

the area of the switch (MSC).

2. The Visitor Location Register (VLR) is a database containing information of users

other than the local subscribers. The VLR retrieves the data of a new user from the

HLR of the user's subscriber zone. The data is maintained as long as the user is in the

zone and is deleted when the user leaves or after a long period of inactivity (terminal

off).

3. The Equipment Identify Register (EIR) is a database listing the mobile terminals.

4. The Authentication Centre (AUC) is responsible for verifying user identities.

5. The cellular network formed in this way is designed to support mobility via

management of handovers (movements from one cell to another).

Finally, GSM networks support the concept of roaming i.e., movement from one operator

network to another.

Figure 3-14 GSM Modem

A GSM modem can be an external device or a PC Card / PCMCIA Card. Typically, an

external GSM modem is connected to a computer through a serial cable or a USB cable. A

GSM modem in the form of a PC Card / PCMCIA Card is designed for use with a laptop

Page 60: An Embedded Systems and Rfid Solution for Transport Related Issues

computer. It should be inserted into one of the PC Card / PCMCIA Card slots of a laptop

computer.

Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless carrier in

order to operate.

A SIM card contains the following information:

Subscriber telephone number (MSISDN)

International subscriber number (IMSI, International Mobile Subscriber Identity)

State of the SIM card

Service code (operator)

Authentication key

PIN (Personal Identification Code)

PUK (Personal Unlock Code)

Computers use AT commands to control modems. Both GSM modems and dial-up

modems support a common set of standard AT commands. In addition to the standard AT

commands, GSM modems support an extended set of AT commands. These extended AT

commands are defined in the GSM standards. With the extended AT commands, the

following operations can be performed:

Reading, writing and deleting SMS messages.

Sending SMS messages.

Monitoring the signal strength.

Monitoring the charging status and charge level of the battery.

Reading, writing and searching phone book entries.

Page 61: An Embedded Systems and Rfid Solution for Transport Related Issues

Figure 3-15 Connection between PC and GSM Modem

The number of SMS messages that can be processed by a GSM modem per minute is very

low i.e., about 6 to 10 SMS messages per minute.

3.6.6 Introduction to AT Commands

AT commands are instructions used to control a modem. AT is the abbreviation of

ATtention. Every command line starts with "AT" or "at". That's the reason, modem

commands are called AT commands. Many of the commands that are used to control wired

dial-up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return

to online data state) are also supported by GSM modems and mobile phones.

Besides this common AT command set, GSM modems and mobile phones support an

AT command set that is specific to the GSM technology, which includes SMS-related

commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from

storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS messages).

Page 62: An Embedded Systems and Rfid Solution for Transport Related Issues

It should be noted that the starting "AT" is the prefix that informs the modem about

the start of a command line. It is not part of the AT command name. For example, D is the

actual AT command name in ATD and +CMGS is the actual AT command name in

AT+CMGS. Some of the tasks that can be done using AT commands with a GSM modem or

mobile phone are listed below:

Get basic information about the mobile phone or GSM modem. For example, name of

manufacturer (AT+CGMI), model number (AT+CGMM), IMEI number (International

Mobile Equipment Identity) (AT+CGSN) and software version (AT+CGMR).

Get basic information about the subscriber. For example, MSISDN (AT+CNUM) and

IMSI number (International Mobile Subscriber Identity) (AT+CIMI).

Get the current status of the mobile phone or GSM/GPRS modem. For example,

mobile phone activity status (AT+CPAS), mobile network registration status

(AT+CREG), radio signal strength (AT+CSQ), battery charge level and battery

charging status (AT+CBC).

Establish a data connection or voice connection to a remote modem (ATD, ATA, etc).

Send and receive fax (ATD, ATA, AT+F*).

Send (AT+CMGS, AT+CMSS), read (AT+CMGR, AT+CMGL), write (AT+CMGW)

or delete (AT+CMGD) SMS messages and obtain notifications of newly received

SMS messages (AT+CNMI).

Read (AT+CPBR), write (AT+CPBW) or search (AT+CPBF) phonebook entries.

Perform security-related tasks, such as opening or closing facility locks (AT+CLCK),

checking whether a facility is locked (AT+CLCK) and changing

passwords(AT+CPWD).

(Facility lock examples: SIM lock [a password must be given to the SIM card every

time the mobile phone is switched on] and PH-SIM lock [a certain SIM card is

Page 63: An Embedded Systems and Rfid Solution for Transport Related Issues

associated with the mobile phone. To use other SIM cards with the mobile phone, a

password must be entered.])

Control the presentation of result codes / error messages of AT commands. For

example, the user can control whether to enable certain error messages (AT+CMEE)

and whether error messages should be displayed in numeric format or verbose format

(AT+CMEE=1 or AT+CMEE=2).

Get or change the configurations of the mobile phone or GSM/GPRS modem. For

example, change the GSM network (AT+COPS), bearer service type (AT+CBST),

radio link protocol parameters (AT+CRLP), SMS center address (AT+CSCA) and

storage of SMS messages (AT+CPMS).

Save and restore configurations of the mobile phone or GSM/GPRS modem. For

example, save (AT+CSAS) and restore (AT+CRES) settings related to SMS

messaging such as the SMS center address.

It should be noted that the mobile phone manufacturers usually do not implement all AT

commands, command parameters and parameter values in their mobile phones. Also, the

behavior of the implemented AT commands may be different from that defined in the

standard. In general, GSM modems, designed for wireless applications, have better support of

AT commands than ordinary mobile phones.

3.6.7 BASIC CONCEPTS OF SMS TECHNOLOGY

1. Validity Period of an SMS Message

An SMS message is stored temporarily in the SMS center if the recipient mobile

phone is offline. It is possible to specify the period after which the SMS message will be

deleted from the SMS center so that the SMS message will not be forwarded to the recipient

mobile phone when it becomes online. This period is called the validity period. A mobile

phone should have a menu option that can be used to set the validity period. After setting it,

the mobile phone will include the validity period in the outbound SMS messages

automatically.

2. Message Status Reports

Page 64: An Embedded Systems and Rfid Solution for Transport Related Issues

Sometimes the user may want to know whether an SMS message has reached the

recipient mobile phone successfully. To get this information, you need to set a flag in the

SMS message to notify the SMS center that a status report is required about the delivery of

this SMS message. The status report is sent to the user mobile in the form of an SMS

message. A mobile phone should have a menu option that can be used to set whether the

status report feature is on or off. After setting it, the mobile phone will set the corresponding

flag in the outbound SMS messages for you automatically. The status report feature is turned

off by default on most mobile phones and GSM modems.

3. Message Submission Reports

After leaving the mobile phone, an SMS message goes to the SMS center. When it

reaches the SMS center, the SMS center will send back a message submission report to the

mobile phone to inform whether there are any errors or failures (e.g. incorrect SMS message

format, busy SMS center, etc). If there is no error or failure, the SMS center sends back a

positive submission report to the mobile phone. Otherwise it sends back a negative

submission report to the mobile phone. The mobile phone may then notify the user that the

message submission was failed and what caused the failure.

If the mobile phone does not receive the message submission report after a period of

time, it concludes that the message submission report has been lost. The mobile phone may

then send the SMS message again to the SMS center. A flag will be set in the new SMS

message to inform the SMS center that this SMS message has been sent before. If the

previous message submission was successful, the SMS center will ignore the new SMS

message but send back a message submission report to the mobile phone. This mechanism

prevents the sending of the same SMS message to the recipient multiple times. Sometimes the

message submission report mechanism is not used and the acknowledgement of message

submission is done in a lower layer.

4. Message Delivery Reports

After receiving an SMS message, the recipient mobile phone will send back a message

delivery report to the SMS center to inform whether there are any errors or failures (example

causes: unsupported SMS message format, not enough storage space, etc). This process is

transparent to the mobile user. If there is no error or failure, the recipient mobile phone sends

back a positive delivery report to the SMS center. Otherwise it sends back a negative delivery

Page 65: An Embedded Systems and Rfid Solution for Transport Related Issues

report to the SMS center. If the sender requested a status report earlier, the SMS center sends

a status report to the sender when it receives the message delivery report from the recipient. If

the SMS center does not receive the message delivery report after a period of time, it

concludes that the message delivery report has been lost. The SMS center then ends the SMS

message to the recipient for the second time.

Sometimes the message delivery report mechanism is not used and the

acknowledgement of message delivery is done in a lower layer.

3.7 RFID READER & TAG

3.7.1 What is RFID?

RFID stands for Radio-Frequency Identification. The acronym refers to small

electronic devices that consist of a small chip and an antenna. The chip typically is capable of

carrying 2,000 bytes of data or less. The RFID device serves the same purpose as a bar code

or a magnetic strip on the back of a credit card or ATM card; it provides a unique identifier

for that object. And, just as a bar code or magnetic strip must be scanned to get the

information, the RFID device must be scanned to retrieve the identifying information.

“RFID Works Better Than Barcodes”

A significant advantage of RFID devices over the others mentioned above is that the

RFID device does not need to be positioned precisely relative to the scanner. We're all

familiar with the difficulty that store checkout clerks sometimes have in making sure that a

barcode can be read. And obviously, credit cards and ATM cards must be swiped through a

special reader.

In contrast, RFID devices will work within a few feet (up to 20 feet for high-frequency

devices) of the scanner. For example, you could just put all of your groceries or purchases in a

Page 66: An Embedded Systems and Rfid Solution for Transport Related Issues

bag, and set the bag on the scanner. It would be able to query all of the RFID devices and total

your purchase immediately. (Read a more detailed article on RFID compared to barcodes.)

RFID technology has been available for more than fifty years. It has only been

recently that the ability to manufacture the RFID devices has fallen to the point where they

can be used as a "throwaway" inventory or control device. Alien Technologies recently sold

500 million RFID tags to Gillette at a cost of about ten cents per tag.

One reason that it has taken so long for RFID to come into common use is the lack of

standards in the industry. Most companies invested in RFID technology only use the tags to

track items within their control; many of the benefits of RFID come when items are tracked

from company to company or from country to country.

“Common Problems with RFID’

Some common problems with RFID are reader collision and tag collision. Reader

collision occurs when the signals from two or more readers overlap. The tag is unable to

respond to simultaneous queries. Systems must be carefully set up to avoid this problem. Tag

collision occurs when many tags are present in a small area; but since the read time is very

fast, it is easier for vendors to develop systems that ensure that tags respond one at a time.

3.7.2 How does RFID work?

A Radio-Frequency Identification system has three parts:

A scanning antenna

A transceiver with a decoder to interpret the data

A transponder - the RFID tag - that has been programmed with information.

The scanning antenna puts out radio-frequency signals in a relatively short range. The RF

radiation does two things: It provides a means of communicating with the transponder (the

RFID tag) AND it provides the RFID tag with the energy to communicate (in the case of

passive RFID tags).

Page 67: An Embedded Systems and Rfid Solution for Transport Related Issues

This is an absolutely key part of the technology; RFID tags do not need to contain

batteries, and can therefore remain usable for very long periods of time (maybe decades). The

scanning antennas can be permanently affixed to a surface; handheld antennas are also

available. They can take whatever shape you need; for example, you could build them into a

door frame to accept data from persons or objects passing through.

When an RFID tag passes through the field of the scanning antenna, it detects the

activation signal from the antenna. That "wakes up" the RFID chip, and it transmits the

information on its microchip to be picked up by the scanning antenna. In addition, the RFID

tag may be of one of two types. Active RFID tags have their own power source; the advantage

of these tags is that the reader can be much farther away and still get the signal. Even though

some of these devices are built to have up to a 10 year life span, they have limited life spans.

Passive RFID tags, however, do not require batteries, and can be much smaller and have a

virtually unlimited life span.

RFID tags can be read in a wide variety of circumstances, where barcodes or other

optically read technologies are useless. The tag need not be on the surface of the object (and

is therefore not subject to wear) The read time is typically less than 100 milliseconds Large

numbers of tags can be read at once rather than item by item.

3.7.3 Is RFID Technology Secure and Private?

Unfortunately, not very often in the systems to which consumers are likely to be

exposed. Anyone with an appropriately equipped scanner and close access to the RFID device

can activate it and read its contents. Obviously, some concerns are greater than others. If

someone walks by your bag of books from the bookstore with a 13.56 Mhz "sniffer" with an

RF field that will activate the RFID devices in the books you bought, that person can get a

complete list of what you just bought. That's certainly an invasion of your privacy, but it

could be worse. Another scenario involves a military situation in which the other side scans

vehicles going by, looking for tags that are associated with items that only high-ranking

officers can have, and targeting accordingly.

Companies are more concerned with the increasing use of RFID devices in company

badges. An appropriate RF field will cause the RFID chip in the badge to "spill the beans" to

Page 68: An Embedded Systems and Rfid Solution for Transport Related Issues

whomever activates it. This information can then be stored and replayed to company scanners,

allowing the thief access - and your badge is the one that is "credited" with the access.

The smallest tags that will likely be used for consumer items don't have enough

computing power to do data encryption to protect your privacy. The most they can do is PIN-

style or password-based protection.

3.7.4 Next-Generation Uses of RFID?

Some vendors have been combining RFID tags with sensors of different kinds. This

would allow the tag to report not simply the same information over and over, but identifying

information along with current data picked up by the sensor. For example, an RFID tag

attached to a leg of lamb could report on the temperature readings of the past 24 hours, to

ensure that the meat was properly kept cool.

Over time, the proportion of "scan-it-yourself" aisles in retail stores will increase.

Eventually, we may wind up with stores that have mostly "scan-it-yourself" aisles and only a

few checkout stations for people who are disabled or unwilling.

3.7.5 Problems with RFID

RFID problems can be divided into several categories:

Technical problems with RFID

Privacy and ethics problems with RFID

Technical problems with RFID

Problems with RFID Standards

RFID has been implemented in different ways by different manufacturers; global

standards are still being worked on. It should be noted that some RFID devices are never

meant to leave their network (as in the case of RFID tags used for inventory control within a

company). This can cause problems for companies.

Page 69: An Embedded Systems and Rfid Solution for Transport Related Issues

Consumers may also have problems with RFID standards. For example, ExxonMobil's

Speed Pass system is a proprietary RFID system; if another company wanted to use the

convenient Speed Pass (say, at the drive-in window of your favorite fast food restaurant) they

would have to pay to access it - an unlikely scenario. On the other hand, if every company had

their own "Speed Pass" system, a consumer would need to carry many different devices with

them.

3.7.6 RFID systems can be easily disrupted

Since RFID systems make use of the electromagnetic spectrum (like Wi-Fi networks

or cell phones), they are relatively easy to jam using energy at the right frequency. Although

this would only be an inconvenience for consumers in stores (longer waits at the checkout), it

could be disastrous in other environments where RFID is increasingly used, like hospitals or

in the military in the field. Also, active RFID tags (those that use a battery to increase the

range of the system) can be repeatedly interrogated to wear the battery down, disrupting the

system.

3.7.7 RFID Reader Collision

Reader collision occurs when the signals from two or more readers overlap. The tag is

unable to respond to simultaneous queries. Systems must be carefully set up to avoid this

problem; many systems use an anti-collision protocol (also called a singulation protocol.

Anti-collision protocols enable the tags to take turns in transmitting to a reader. (Learn more

about RFID reader collision.)

3.7.8 RFID Tag Collision

Tag collision occurs when many tags are present in a small area; but since the read

time is very fast, it is easier for vendors to develop systems that ensure that tags respond one

at a time. (Learn more about RFID tag collision.) Security, privacy and ethics problems with

RFID.

The following problems with RFID tags and readers have been reported.

Page 70: An Embedded Systems and Rfid Solution for Transport Related Issues

The contents of an RFID tag can be read after the item leaves the supply chain. An

RFID tag cannot tell the difference between one reader and another. RFID scanners are very

portable; RFID tags can be read from a distance, from a few inches to a few yards. This

allows anyone to see the contents of your purse or pocket as you walk down the street. Some

tags can be turned off when the item has left the supply chain; see zombie RFID tags.

3.7.9 RFID tags are difficult to remove

RFID tags are difficult to for consumers to remove; some are very small (less than a

half-millimeter square, and as thin as a sheet of paper) - others may be hidden or embedded

inside a product where consumers cannot see them. New technologies allow RFID

tags to be "printed" right on a product and may not be removable at all (see Printing RFID

Tags With Magic Ink).

3.7.10 RFID tags can be read without your knowledge

Since the tags can be read without being swiped or obviously scanned (as is the case

with magnetic strips or barcodes), anyone with an RFID tag reader can read the tags

embedded in your clothes and other consumer products without your knowledge. For

example, you could be scanned before you enter the store, just to see what you are carrying.

You might then be approached by a clerk who knows what you have in your backpack or

purse, and can suggest accessories or other items.

3.7.11 RFID tags can be read greater distances with a high-gain antenna

For various reasons, RFID reader/tag systems are designed so that distance between

the tag and the reader is kept to a minimum (see the material on tag collision above).

However, a high-gain antenna can be used to read the tags from much further away, leading to

privacy problems.

RFID tags with unique serial numbers could be linked to an individual credit card number

At present, the Universal Product Code (UPC) implemented with barcodes allows

each product sold in a store to have a unique number that identifies that product. Work is

Page 71: An Embedded Systems and Rfid Solution for Transport Related Issues

proceeding on a global system of product identification that would allow each individual item

to have its own number. When the item is scanned for purchase and is paid for, the RFID tag

number for a particular item can be associated with a credit card number.

3.8 Advantages of RFID versus Barcodes

RFID tags and barcodes both carry information about products. However, there are

important differences between these two technologies:

Barcode readers require a direct line of sight to the printed barcode; RFID readers do

not require a direct line of sight to either active RFID tags or passive RFID tags.

RFID tags can be read at much greater distances; an RFID reader can pull information

from a tag at distances up to 300 feet. The range to read a barcode is much less,

typically no more than fifteen feet.

RFID readers can interrogate, or read, RFID tags much faster; read rates of forty or

more tags per second are possible. Reading barcodes is much more time-consuming;

due to the fact that a direct line of sight is required, if the items are not properly

oriented to the reader it may take seconds to read an individual tag. Barcode readers

usually take a half-second or more to successfully complete a read.

Line of sight requirements also limit the ruggedness of barcodes as well as the

reusability of barcodes. (Since line of sight is required for barcodes, the printed barcode

must be exposed on the outside of the product, where it is subject to greater wear and tear.)

RFID tags are typically more rugged, since the electronic components are better protected in a

plastic cover. RFID tags can also be implanted within the product itself, guaranteeing greater

ruggedness and reusability.

Page 72: An Embedded Systems and Rfid Solution for Transport Related Issues

Barcodes have no read/write capability; that is, you cannot add to the information written

on a printed barcode. RFID tags, however, can be read/write devices; the RFID reader can

communicate with the tag, and alter as much of the information as the tag design will allow.

RFID tags are typically more expensive than barcodes, in some cases, much more so.

3.9 Contactless Credit Card Advantages

Credit card companies are claiming the following advantages for contactless credit cards:

The card is faster to use. To make a purchase, the card owner just waves his card over

the RFID reader, waits for the acceptance indicator - and goes on his way. American Express,

Visa and MasterCard have all agreed to waive the signature requirement for contactless credit

card transactions under $25. If you want to look at the numbers, here is where this technology

is taking us in our need for speed (average transaction speeds):

Contactless credit card transaction: 15 seconds

Magnetic strip card transaction: 25 seconds

Cash transaction: 34 seconds

The contactless cards use highly secure data transmission standards.

Contactless cards make use of the most secure encryption standards practical with current

technology. 128-bit and triple DES encryptions make it nearly impossible for thieves to steal

your data. The contactless card never transmits your card number

Instead, the RFID chip within the card creates a unique number for the transaction; if a

criminal intercepted the number, it would be useless even if successfully decrypted.

Contactless cards probably use other measures although this is just speculation, there are

certainly other ways to secure the data on the card. For example, the RFID reader that sits on

Page 73: An Embedded Systems and Rfid Solution for Transport Related Issues

the merchant's counter may use some sort of special signal, or offer a special set of

frequencies, that would be difficult for a thief with an off-the-shelf reader to duplicate.

One additional fact that is known about contactless cards is definitely an advantage for

merchants - consumers may feel otherwise. In a 2004 study, the average number of

transactions at a retail location rose by about one percent, and the average "spend" rose fifteen

percent for all contactless credit card users. So, it appears that there is a correlation between

ease of use and total spending. Consumers, take note!

3.10 Contactless Credit Card Disadvantages

The following disadvantages have been noted with contactless credit cards:

Contactless cards are more exposed than regular credit cards.

If you want to keep your credit card secure, you could keep it safely in an enclosed

wallet or purse; thieves would have absolutely no way to even know if you have a

credit card. However, a thief armed with a suitable reader, within a few feet of you,

would be able to interrogate all of the cards in your wallet or purse without your

knowledge.

Also, a regular credit card transaction is fairly secure; the magnetic strip is swiped at

very close range (less than a millimeter). However, a thief with a suitable reader could

monitor your contactless card transaction while standing at the counter with you, or

just behind you.

These concerns have, of course, been carefully noted by credit card companies. The

RFID chip in the contactless credit card responds to the merchant reader with a unique

number used for that transaction only; it does not simply transmit the consumer's

account number. This number is also encrypted.

Page 74: An Embedded Systems and Rfid Solution for Transport Related Issues

It is easier to spend. Studies have demonstrated that consumers will be more likely to

spend, and will spend more frequently, with contactless credit cards.

Privacy advocates are particularly concerned about this technology; it is feared that

having this muchc information available "in the open air" will lead inevitably to problems.

CHAPTER -4

SOFTWARE USAGE

4.1 KEIL

This software is used to write the microcontroller code and to simulate it on the

computer itself. It is also used to generate the hex code for the code written in ALP or C.

User Vs machine (microcontroller): as the microcontroller know only about the digital

value (i.e. either logic zero or one), so we need to convert the written code in the sets of zero n

one. The KEIL environment provide us the facility to convert the code written in C or ALP to

sets of zero n one (i.e. called hex code).

Keil Vision2

Open the Keil Vision2

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

Page 75: An Embedded Systems and Rfid Solution for Transport Related Issues

Go to Project – Select Device for Target ‘Target1’

Select 8052(all variants) and click OK

Page 76: An Embedded Systems and Rfid Solution for Transport Related Issues

Now we need to check the oscillator frequency:

Go to project – Options for Target ‘Target1’

Page 77: An Embedded Systems and Rfid Solution for Transport Related Issues

Make sure that the oscillator frequency is 12MHz.

Building the Target

Build the target as illustrated in the figure below

RUNNING THE SIMULATION

Page 78: An Embedded Systems and Rfid Solution for Transport Related Issues

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

First start a debug session

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

Page 79: An Embedded Systems and Rfid Solution for Transport Related Issues

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

Page 80: An Embedded Systems and Rfid Solution for Transport Related Issues

Go to Debug – Go

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

Page 81: An Embedded Systems and Rfid Solution for Transport Related Issues

Go to Debug – Performance Analyzer and click on it

Page 82: An Embedded Systems and Rfid Solution for Transport Related Issues

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

Here we need to change the ‘Xtal (MHz): ‘. Here fill the frequency of crystal which

we are going to use. For the microcontroller which we are using the crystal that we are

Page 83: An Embedded Systems and Rfid Solution for Transport Related Issues

using is having crystal frequency 12MHz.and click the option for ‘Use On-chip

ROM(0x0-0xFFFF)’.then click the option ‘Output’ where we have to select the option

‘Create HEX File’. After that we can translate the current file n built target will

generate the HEX code automatically.

4.2 Flash magic

Flash Magic is Windows software from that microcontroller is easyly programmed

using In-System Programming technology to all the ISP feature empowered devices.

Page 84: An Embedded Systems and Rfid Solution for Transport Related Issues

After installing the software when we click on the icon of the software the window

will open on the screen as shown in figure. We need to change the device and have to select

the device 89V51RD2, and then we set to ‘erase all flash’ option on the flash magic window.

If we need to verify the proper dumping of the program in the microcontroller then we

need to set the ‘verify after program’ option.

Loading of hex file: After selecting device we load the hex file in the given block by using

the ‘browse’ option on the ‘FLASH MAGIC’ window..

Programming of device

After loading the file next step is dumping of code in microcontroller. For that we

first connect the computer’s serial port to your controller board through serial cable. Then

after give the power supply to the controller board..

Now its time to dump the code in controller.. Press the start option on your flash magic

window. Then your microcontroller will be programmed in few seconds..

CHAPTER-5

Page 85: An Embedded Systems and Rfid Solution for Transport Related Issues

CIRCUIT DIAGRAM AND CODE

5.1CIRCUIT DIAGRAM

5.2 CODE

#include<reg51.h>void UART_init(void);

Page 86: An Embedded Systems and Rfid Solution for Transport Related Issues

void send_to_modem (unsigned char s[]);void enter (void);void ch_send_to_modem (unsigned char single_char);

void UART_init(void) { TMOD=0x20; TH1=0xFD; SCON=0x50; TR1=1; }

void send_to_modem (unsigned char s[]) { unsigned char r;

for(r=0;s[r]!='\0';r++) // to send the command to GSM modem to avoid echo signal { // the command is "ate0", SBUF=s[r]; while(TI==0); TI=0; delay(20); } // enter(); }

void enter (void) { SBUF=13; // Enter ASC values are 13 and 10, while(TI==0); // After sending commands to GSM modem you must be send Enter's ASC values. TI=0; SBUF=10; while(TI==0); TI=0; }

void ch_send_to_modem (unsigned char single_char) {

SBUF=single_char; while(TI==0); TI=0; delay(10); } //#include<reg51.h>

Page 87: An Embedded Systems and Rfid Solution for Transport Related Issues

#define lcd_data P1#define lcd_cont() ((lcd_en=1),(delay(3)),(lcd_en=0))

sbit lcd_rs = P1^2; // Here we are using LCD in four bit mode that's why LCD's Data pins and control sbit lcd_en = P1^3; void lcd_init (void); void lcdcmd (unsigned char value); void lcddata (unsigned char value); void msgdisplay (unsigned char b[]); void delay (unsigned int value);

void lcd_init (void){ lcdcmd(0x02); lcdcmd(0x02); lcdcmd(0x02); lcdcmd(0x28); lcdcmd(0x28); lcdcmd(0x28); lcdcmd(0x0e); lcdcmd(0x06); lcdcmd(0x01);

}

void lcdcmd (unsigned char value) // LCD COMMAND { lcd_data=value&(0xf0); lcd_rs=0; lcd_cont(); lcd_data=((value<<4)&(0xf0)); lcd_rs=0; lcd_cont(); }

void lcddata(unsigned char value)

{ lcd_data=value&(0xf0);

Page 88: An Embedded Systems and Rfid Solution for Transport Related Issues

lcd_rs=1; lcd_cont(); delay(3); lcd_data=((value<<4)&(0xf0)); lcd_rs=1; lcd_cont(); delay(3); }

void msgdisplay(unsigned char b[]) {unsigned char s,count=0;for(s=0;b[s]!='\0';s++) { if(s==16) lcdcmd(0xc0); lcddata(b[s]); }}

void delay(unsigned int value)

{ unsigned int x,y; for(x=0;x<200;x++) for(y=0;y<value;y++); }

/*******************/ #include<reg51.h> #include"lcddisplay.h" #include"UART.h"

Page 89: An Embedded Systems and Rfid Solution for Transport Related Issues

#include<string.h> #include<intrins.h>

sbit buz = P3^4;

sbit gsm = P3^3;sbit rfid = P3^2;

sbit accidentsw = P2^7;

unsigned char mobilenum[]="9985784340"; //user number

unsigned char msg[10],rfiddata[15];unsigned char XX,newmsg=0,a,j,msgtype;

/****** interrupt function to recieve the data from GSM or RFID *****/

void serintr(void) interrupt 4{if(RI==1){ XX=SBUF; if(XX=='+') newmsg=1; else rfiddata[j]=XX;j=j+1;

RI=0;

}

}

void main(){ delay(50); lcd_init(); /*****lcd intialization**/

Page 90: An Embedded Systems and Rfid Solution for Transport Related Issues

UART_init(); ////////UART intialization for 9600 baud rate lcdcmd(0x85); gsm=0; //selcet gsm modem rfid=1; //deselcet rfid modem RI=0; lcdcmd(0x01); msgdisplay("searching for"); lcdcmd(0xc0); msgdisplay("GSM modem"); delay(300); send_to_modem("ate0"); //to avoid echo signals, enter();again: send_to_modem("at"); // TO CHECKING GSM MODEM... enter(); if(!RI) // Here we are waiting for data whitch is sending by GSM modem goto again;

RI=0; EA=1;

ES=1; lcdcmd(0x01); msgdisplay("SYSTEM"); lcdcmd(0xc3); msgdisplay("CONNECTED"); delay(100); send_to_modem("at+creg=0"); // enter(); delay(300);

xxx: lcdcmd(0x01); msgdisplay("CHEKING SIM"); send_to_modem("AT+CPIN?"); // enter();

delay(500); if(newmsg==0) goto xxx; lcdcmd(0xC0);

msgdisplay("SIM CONNECTED"); delay(500);

send_to_modem("at+cmgf=1"); // tr set message format astext mode enter();

Page 91: An Embedded Systems and Rfid Solution for Transport Related Issues

st: RI=0; lcdcmd(0x01);

msgdisplay(" Accident "); lcdcmd(0xC0); msgdisplay("Intmation Systm"); delay(500);

newmsg=0; rfid=0;

gsm=1; RI=0;

while(1){ while(j==0) //check for switch till we get data from RFID { if(accidentsw==0) //if switch is pressed then send message goto sendmsg; } if(!strcmp(rfiddata,"25001C01B4")) //compare the rFId data {

msgtype=0;

lcdcmd(0x01); msgdisplay("authorized");

delay(500); lcdcmd(0x01);

msgdisplay("expiry date "); lcdcmd(0xc0);

msgdisplay("20/12/2012"); delay(500);

} else { buz=0;

msgtype=1; lcdcmd(0x01); msgdisplay("unauthorized");

lcdcmd(0xc0);

Page 92: An Embedded Systems and Rfid Solution for Transport Related Issues

msgdisplay("Card Expired");delay(500);

} goto st; } sendmsg:gsm=0;lcdcmd(0x01);msgdisplay("sending message");send_to_modem("at+cmgs=");send_to_modem(mobilenum);enter();delay(100);send_to_modem("vehicle met with an accident!!!"); ch_send_to_modem(0x1a);lcdcmd(0x01);msgdisplay("MESSAGE SENT");delay(500);goto st;}

APPLICATIONS

Through GSM we control the house hold appliances.

We can control the devices from remote places

We can use in industrial appliances also.

RFID applications help in tracking goods in the supply chain and during the

manufacturing process. Another useful RFID application is one that allows controlled

access to buildings and networks. Low frequency RFID applications are ideal for

Page 93: An Embedded Systems and Rfid Solution for Transport Related Issues

scanning objects with high water content at close range. UHF tags are best for

scanning boxes of goods. Any company seeking to implement RFID applications must

choose the right frequency. RFID applications extend to triggering equipment deep

down in the oil wells as well as reusable containers and high value tools.

CONCLUSION

The main aim of the project is to develop a module that helps in controlling the devices using

the GSM technology. In this project we control the operation of the devices remotely Here

when we type the MESSAGE to the system.

Page 94: An Embedded Systems and Rfid Solution for Transport Related Issues

In terms of tracking capabilities, though, by employing GSM and using detailed street

level mapping system it would be possible to obtain geographical location accuracy within

about 300 metres. Ongoing development within the mobile telephone networks is expected to

reduce this to 50 metres soon. In the case of the theft of a valuable item or a kidnapping, for

example, the radio beacon contained within the tracking device can be activated by SMS and

tracking can begin.

Of course the distance at which the radio signal may be picked up by the receiver

depends on topographical conditions. Under normal conditions the signal may be received 2 -

3 kilometres away from the tracking device. But if height can be gained (using a tall building

or a helicopter, for example) the distance can be increased greatly. Using radio detection

methods the accuracy of such devices are very accurate, generally within 1 metre or less.