Total Document (1)

107
Smart card System for Rail Way Ticket Abstract The objective of the project is to design a microcontroller based smart card processor for rail way ticket that upon inserting the card and entering the ticket no should deduct the amount present in the card and grant the appropriate ticket. A smart card, chip card, or integrated circuit card (ICC), is in any pocket-sized plastic card with an embedded integrated circuit built into it which can process data. This implies that it can receive input which is processed by way of the ICC applications and delivered as an output. There are two broad categories of Ices Memory cards and Microprocessor card. Memory cards s contain only non- volatile memory storage components, and perhaps some specific security logic like EEPROM where as Microprocessor card contain ROM, RAM CPU and microprocessor components. The card may embed a hologram to avoid counterfeiting. Using smartcards also is a form of strong security authentication for single sign-on within large companies and organizations. Our system consists of a microcontroller a smart card reader module keypad and a LCD; all these peripherals are interfaced to the microcontroller. When the power is

Transcript of Total Document (1)

Page 1: Total Document (1)

Smart card System for Rail Way TicketAbstract

The objective of the project is to design a microcontroller based smart card

processor for rail way ticket that upon inserting the card and entering the ticket no should

deduct the amount present in the card and grant the appropriate ticket.

A smart card, chip card, or integrated circuit card (ICC), is in any pocket-

sized plastic card with an embedded integrated circuit built into it which can process data.

This implies that it can receive input which is processed by way of the ICC applications

and delivered as an output. There are two broad categories of Ices Memory cards and

Microprocessor card. Memory cards s contain only non-volatile memory storage

components, and perhaps some specific security logic like EEPROM where as

Microprocessor card contain ROM, RAM CPU and microprocessor components. The

card may embed a hologram to avoid counterfeiting. Using smartcards also is a form of

strong security authentication for single sign-on within large companies and

organizations.

Our system consists of a microcontroller a smart card reader module keypad and a

LCD; all these peripherals are interfaced to the microcontroller. When the power is

switched on the microcontroller enables all its peripherals, the moment the user inserts

the smart card into the module the reader reads the data present in the card and asks the

user to enter the password if the entered password matches with the card’s password then

a message of authentication is displayed on the LCD and allows the user to conform the

ticket for and deducts the cost of the ticket from the amount in the card simultaneously

displaying related message on the LCD. Thus the process of rail way ticketing is carried

out.

Used technology:

Microcontroller,Smart card reading module,Key pad.

External Guide: Nazeem

Page 2: Total Document (1)

CONTENTS

TOPIC

Chapter 1: Introduction

History

Characteristics of Embedded system

Peripherals

Debugging

Chapter 2: General discription

Chapter 3:

Block diagram

Circuit diagram

Operation

Chapter 4: Microcontroller

Introduction to Philips Microcontroller

Block Diagram

Memory Organization

Interrupts

Timers and Counters

Serial Port Set-up

Page 3: Total Document (1)

Chapter 5: Software

Overview of KEIL C cross Compiler

Simulator / Debugger

Source Code

Conclusion

Future Scope

Bibliography

Page 4: Total Document (1)

INTRODUCTION TO EMBEDDED SYSTEMS

An embedded system is a special-purpose system in which the computer

is completely encapsulated by or dedicated to the device or system it controls. Unlike a

general-purpose computer, such as a personal computer, an embedded system performs

one or a few pre-defined tasks, usually with very specific requirements. Since the system

is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost

of the product. Embedded systems are often mass-produced, benefiting from economies

of scale.

Personal digital assistants (PDAs) or handheld computers are generally considered

embedded devices because of the nature of their hardware design, even though they are

more expandable in software terms. This line of definition continues to blur as devices

expand.

Physically, embedded systems range from portable devices such as digital watches and

MP3 players, to large stationary installations like traffic lights, factory controllers, or the

systems controlling nuclear power plants.

In terms of complexity embedded systems can range from very simple with a single

microcontroller chip, to very complex with multiple units, peripherals and networks

mounted inside a large chassis or enclosure.

Examples of embedded systems

Automatic teller machines (ATMs)

Avionics, such as inertial guidance systems, flight control hardware/software and

other integrated systems in aircraft and missiles

Cellular telephones and telephone switches

engine controllers and antilock brake controllers for automobiles

Home automation products, such as thermostats, air conditioners, sprinklers, and

security monitoring systems

Handheld calculators

Page 5: Total Document (1)

Handheld computers

Household appliances, including microwave ovens, washing machines, television

sets, DVD players and recorders

Medical equipment

Personal digital assistant

Videogame consoles

Computer peripherals such as routers and printers

Industrial controllers for remote machine operation.

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

Page 6: Total Document (1)

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 perfom 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.

Characteristics

Embedded systems are designed to do some specific task, rather than be a general-

purpose computer for multiple tasks. Some also have real-time performance constraints

that must be met, for reason such as safety and usability; others may have low or no

performance requirements, allowing the system hardware to be simplified to reduce costs.

An embedded system is not always a separate block - very often it is physically built-in to

the device it is controlling

The software written for embedded systems is often called firmware, and is stored in

read-only memory or Flash memory chips rather than a disk drive. It often runs with

limited computer hardware resources: small or no keyboard, screen, and little memory.

User interfaces

Page 7: Total Document (1)

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.

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. This in contrast to the desktop computer market, which is

currently limited to just a few competing architectures.

Page 8: Total Document (1)

PC/104 and PC/104+ are a typical base for small, low-volume embedded and rugged

system design. These often use DOS, Linux, NetBSD, or an embedded real-time

operating system such as QNX or VxWorks.

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.

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, LonWorks, etc

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

Discrete IO: aka General Purpose Input Output (GPIO)

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.

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 Mathematica to simulate the mathematics.

Page 9: Total Document (1)

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

Debugging

Embedded Debugging may be performed at different levels, depending on the facilities

available, ranging from assembly- or source-level debugging with an in-circuit emulator

or in-circuit debugger, to output from serial debug ports or JTAG/Nexus interfaces, to an

emulated environment running on a personal computer.

As the complexity of embedded systems grows, higher level tools and operating systems

are migrating into machinery where it makes sense. For example, cell phones, personal

digital assistants and other consumer computers often need significant software that is

purchased or provided by a person other than the manufacturer of the electronics. In these

systems, an open programming environment such as Linux, NetBSD, OSGi or Embedded

Java is required so that the third-party software provider can sell to a large market.

Reliability

Embedded systems often reside in machines that are expected to run continuously for

years without errors, and in some cases recover by themselves if an error occurs.

Page 10: Total Document (1)

Therefore the software is usually developed and tested more carefully than that for

personal computers, and unreliable mechanical moving parts such as disk drives,

switches or buttons are avoided.

Recovery from errors may be achieved with techniques such as a watchdog timer that

resets the computer unless the software periodically notifies the watchdog.

Specific reliability issues may include:

1. The system cannot safely be shut down for repair, or it is too inaccessible to

repair. Solutions may involve subsystems with redundant spares that can be

switched over to, or software "limp modes" that provide partial function.

Examples include space systems, undersea cables, navigational beacons, bore-

hole systems, and automobiles.

2. The system must be kept running for safety reasons. "Limp modes" are less

tolerable. Often backups are selected by an operator. Examples include aircraft

navigation, reactor control systems, safety-critical chemical factory controls, train

signals, engines on single-engine aircraft.

3. The system will lose large amounts of money when shut down: Telephone

switches, factory controls, bridge and elevator controls, funds transfer and market

making, automated sales and service.

High vs Low Volume

For high volume systems such as portable music players or mobile phones, minimizing

cost is usually the primary design consideration. Engineers typically select hardware that

is just “good enough” to implement the necessary functions.

For low-volume or prototype embedded systems, general purpose computers may be

adapted by limiting the programs or by replacing the operating system with a real-time

operating system.

Embedded software architectures

Page 11: Total Document (1)

There are several different types of software architecture in common use.

Simple control loop

In this design, the software simply has a loop. The loop calls subroutines, each of which

manages a part of the hardware or software.

Interrupt controlled system

Some embedded systems are predominantly interrupt controlled. This means that tasks

performed by the system are triggered by different kinds of events. An interrupt could be

generated for example by a timer in a predefined frequency, or by a serial port controller

receiving a byte.

These kinds of systems are used if event handlers need low latency and the event

handlers are short and simple.

Usually these kinds of systems run a simple task in a main loop also, but this task is not

very sensitive to unexpected delays. The tasks performed in the interrupt handlers should

be kept short to keep the interrupt latency to a minimum.

Some times longer tasks are added to a queue structure in the interrupt handler to be

processed in the main loop later. This method brings the system close to a multitasking

kernel with discrete processes.

[Edit] Cooperative multitasking

A no preemptive multitasking system is very similar to the simple control loop scheme,

except that the loop is hidden in an API. The programmer defines a series of tasks, and

each task gets its own environment to "run" in. Then, when a task is idle, it calls an idle

routine (usually called "pause", "wait", "yield", etc.).

The advantages and disadvantages are very similar to the control loop, except that adding

new software is easier, by simply writing a new task, or adding to the queue-interpreter.

Page 12: Total Document (1)

Preemptive multitasking

In this type of system, a low-level piece of code switches between tasks based on a timer.

This is the level at which the system is generally considered to have an "operating

system", and introduces all the complexities of managing multiple tasks running

seemingly at the same time.

Any piece of task code can damage the data of another task; they must be precisely

separated. Access to shared data must be controlled by some synchronization strategy,

such as message queues, semaphores or a non-blocking synchronization scheme.

Because of these complexities, it is common for organizations to buy a real-time

operating system, allowing the application programmers to concentrate on device

functionality rather than operating system services.

********************

Page 13: Total Document (1)

Liquid crystal display

Reflective twisted nematic liquid crystal display.

1. Vertical filter film to polarize the light as it enters. 2. Glass substrate with ITO electrodes. The shapes of

these electrodes will determine the dark shapes that will appear when the LCD is turned on or off. Vertical ridges etched on the surface are smooth.

3. Twisted nematic liquid crystals. 4. Glass substrate with common electrode film (ITO)

with horizontal ridges to line up with the horizontal filter.

5. Horizontal filter film to block/allow through light. 6. Reflective surface to send light back to viewer. (In

a backlit LCD, this layer is replaced with a light source.)

A liquid crystal display (commonly abbreviated LCD) is a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector. It is often utilized in battery-powered electronic devices because it uses very small amounts of electric power.

Overview

Each pixel of an LCD typically consists of a layer of molecules aligned between two transparent electrodes, and two polarizing filters, the axes of transmission of which are (in most of the cases) perpendicular to each other. With no liquid crystal between the polarizing filters, light passing through the first filter would be blocked by the second (crossed) polarizer.

The surface of the electrodes that are in contact with the liquid crystal material are treated so as to align the liquid crystal molecules in a particular direction. This treatment typically consists of a thin polymer layer that is unidirectionally rubbed using, for example, a cloth. The direction of the liquid crystal alignment is then defined by the direction of rubbing.

Before applying an electric field, the orientation of the liquid crystal molecules is determined by the alignment at the surfaces. In a twisted nematic device (still the most common liquid crystal device), the surface alignment directions at the two electrodes are perpendicular to each other, and so the molecules arrange themselves in a helical

Page 14: Total Document (1)

structure, or twist. Because the liquid crystal material is birefringent, light passing through one polarizing filter is rotated by the liquid crystal helix as it passes through the liquid crystal layer, allowing it to pass through the second polarized filter. Half of the incident light is absorbed by the first polarizing filter, but otherwise the entire assembly is transparent.

When a voltage is applied across the electrodes, a torque acts to align the liquid crystal molecules parallel to the electric field, distorting the helical structure (this is resisted by elastic forces since the molecules are constrained at the surfaces). This reduces the rotation of the polarization of the incident light, and the device appears gray. If the applied voltage is large enough, the liquid crystal molecules in the center of the layer are almost completely untwisted and the polarization of the incident light is not rotated as it passes through the liquid crystal layer. This light will then be mainly polarized perpendicular to the second filter, and thus be blocked and the pixel will appear black. By controlling the voltage applied across the liquid crystal layer in each pixel, light can be allowed to pass through in varying amounts thus constituting different levels of gray.

The optical effect of a twisted nematic device in the voltage-on state is far less dependent on variations in the device thickness than that in the voltage-off state. Because of this, these devices are usually operated between crossed polarizers such that they appear bright with no voltage (the eye is much more sensitive to variations in the dark state than the bright state). These devices can also be operated between parallel polarizers, in which case the bright and dark states are reversed. The voltage-off dark state in this configuration appears blotchy, however, because of small thickness variations across the device.

Both the liquid crystal material and the alignment layer material contain ionic compounds. If an electric field of one particular polarity is applied for a long period of time, this ionic material is attracted to the surfaces and degrades the device performance. This is avoided either by applying an alternating current or by reversing the polarity of the electric field as the device is addressed (the response of the liquid crystal layer is identical, regardless of the polarity of the applied field).

When a large number of pixels is required in a display, it is not feasible to drive each directly since then each pixel would require independent electrodes. Instead, the display is multiplexed. In a multiplexed display, electrodes on one side of the display are grouped and wired together (typically in columns), and each group gets its own voltage source. On the other side, the electrodes are also grouped (typically in rows), with each group getting a voltage sink. The groups are designed so each pixel has a unique, unshared combination of source and sink. The electronics or the software driving the electronics then turns on sinks in sequence, and drives sources for the pixels of each sink.

Specifications

Important factors to consider when evaluating an LCD monitor:

Page 15: Total Document (1)

Resolution: The horizontal and vertical size expressed in pixels (e.g., 1024x768). Unlike CRT monitors, LCD monitors have a native-supported resolution for best display effect.

Dot pitch: The distance between the centers of two adjacent pixels. The smaller the dot pitch size, the less granularity is present, resulting in a sharper image. Dot pitch may be the same both vertically and horizontally, or different (less common).

Viewable size: The size of an LCD panel measured on the diagonal (more specifically known as active display area).

Response time: The minimum time necessary to change a pixel's color or brightness. Response time is also divided into rise and fall time.

Matrix type: Active or Passive. Viewing angle: (coll., more specifically known as

viewing direction). Color support: How many types of colors are

supported (coll., more specifically known as color gamut).

Brightness: The amount of light emitted from the display (coll., more specifically known as luminance).

Contrast ratio: The ratio of the intensity of the brightest bright to the darkest dark.

Aspect ratio: The ratio of the width to the height (for example, 4:3, 16:9 or 16:10).

Input ports (e.g., DVI, VGA, LVDS, or even S-Video and HDMI).

Color displays

In color LCDs each individual pixel is divided into three cells, or sub pixels, which are colored red, green, and blue, respectively, by additional filters (pigment filters, dye filters and metal oxide filters). Each subpixel can be controlled independently to yield thousands or millions of possible colors for each pixel. Older CRT monitors employ a similar 'subpixel' structures via the use of phosphors, although the analog electron beam employed in CRTs do not hit exact 'subpixels'.

Color components may be arrayed in various pixel geometries, depending on the monitor's usage. If software knows which type of geometry is being used in a given LCD,

Page 16: Total Document (1)

this can be used to increase the apparent resolution of the monitor through subpixel rendering. This technique is especially useful for text anti-aliasing.

Passive-matrix and active-matrix addressed LCDs

LCDs with a small number of segments, such as those used in digital watches and pocket calculators, have individual electrical contacts for each segment. An external dedicated circuit supplies an electric charge to control each segment. This display structure is unwieldy for more than a few display elements.

Small monochrome displays such as those found in personal organizers, or older laptop screens have a passive-matrix structure employing super-twisted nematic (STN) or double-layer STN (DSTN) technology (DSTN corrects a color-shifting problem with STN), and (CSTN) color-STN (a technology where color is added by using an internal color filter). Each row or column of the display has a single electrical circuit. The pixels are addressed one at a time by row and column addresses. This type of display is called passive-matrix addressed because the pixel must retain its state between refreshes without the benefit of a steady electrical charge. As the number of pixels (and, correspondingly, columns and rows) increases, this type of display becomes less feasible. Very slow response times and poor contrast are typical of passive-matrix addressed LCDs.

High-resolution color displays such as modern LCD computer monitors and televisions use an active matrix structure. A matrix of thin-film transistors (TFTs) is added to the polarizing and color filters. Each pixel has its own dedicated transistor, allowing each column line to access one pixel. When a row line is activated, all of the column lines are connected to a row of pixels and the correct voltage is driven onto all of the column lines. The row line is then deactivated and the next row line is activated. All of the row lines are activated in sequence during a refresh operation. Active-matrix addressed displays look "brighter" and "sharper" than passive-matrix addressed displays of the same size, and generally have quicker response times, producing much better images.

Active matrix technologies

Twisted nematic (TN)

Twisted nematic displays contain liquid crystal elements which twist and untwist at varying degrees to allow light to pass through. When no voltage is applied to a TN liquid crystal cell, the light is polarized to pass through the cell. In proportion to the voltage applied, the LC cells twist up to 90 degrees changing the polarization and blocking the light's path. By properly adjusting the level of the voltage almost any grey level or transmission can be achieved.

Page 17: Total Document (1)

For a more comprehensive description refer to the section on the twisted nematic field effect.

In-plane switching (IPS)

In-plane switching is an LCD technology which aligns the liquid crystal cells in a horizontal direction. In this method, the electrical field is applied through each end of the crystal, but this requires two transistors for each pixel instead of the single transistor needed for a standard thin-film transistor (TFT) display. This result in blocking more transmission area, thus requiring a brighter backlight, which will consume more power, making this type of display less desirable for notebook computers.

Vertical alignment (VA)

Vertical alignment displays are a form of LC displays in which the liquid crystal material naturally exists in a horizontal state removing the need for extra transistors (as in IPS). When no voltage is applied the liquid crystal cell, it remains perpendicular to the substrate creating a black display. When voltage is applied, the liquid crystal cells shift to a horizontal position, parallel to the substrate, allowing light to pass through and create a white display. VA liquid crystal displays provide some of the same advantages as IPS panels, particularly an improved viewing angle and improved black level.

Quality control

Some LCD panels have defective transistors, causing permanently lit or unlit pixels which are commonly referred to as stuck pixels or dead pixels respectively. Unlike integrated circuits, LCD panels with a few defective pixels are usually still usable. It is also economically prohibitive to discard a panel with just a few defective pixels because LCD panels are much larger than ICs. Manufacturers have different standards for determining a maximum acceptable number of defective pixels. The maximum acceptable number of defective pixels for LCD varies greatly. At one point, Samsung held a zero-tolerance policy for LCD monitors sold in Korea. Currently, though, Samsung adheres to the less restrictive ISO 13406-2 standard. Other companies have been known to tolerate as many as 11 dead pixels in their policies. Dead pixel policies are often hotly debated between manufacturers and customers. To regulate the acceptability of defects and to protect the end user, ISO released the ISO 13406-2 standard. However, not every LCD manufacturer conforms to the ISO standard and the ISO standard is quite often interpreted in different ways.

Examples of defects in LCDs

LCD panels are more likely to have defects than most ICs due to their larger size. In this example, a 300 mm SVGA LCD has 8 defects and a 150 mm wafer has only 3 defects. However, 134 of the 137 dies on the wafer will be acceptable, whereas rejection of the

Page 18: Total Document (1)

LCD panel would be a 0% yield. The standard is much higher now due to fierce competition between manufacturers and improved quality control. An SVGA LCD panel with 4 defective pixels is usually considered defective and customers can request an exchange for a new one. Some manufacturers, notably in South Korea where some of the largest LCD panel manufacturers, such as LG, are located, now have "zero defective pixel guarantee" and would replace a product even with one defective pixel. Even where such guarantees do not exist, the location of defective pixels is important. A display with only a few defective pixels may be unacceptable if the defective pixels are near each other. Manufacturers may also relax their replacement criteria when defective pixels are in the center of the viewing area.

LCD panels also have defects known as mura, which look like a small-scale crack with very small changes in luminance or color.

Zero-power (bistable) displays

The zenithal bistable device (ZBD), developed by QinetiQ (formerly DERA), can retain an image without power. The crystals may exist in one of two stable orientations (Black and "White") and power is only required to change the image. ZBD Displays is a spin-off company from QinetiQ who manufacture both grayscale and color ZBD devices.

A French company, Nemoptic, has developed another zero-power, paper-like LCD technology which has been mass-produced since July 2003. This technology is intended for use in applications such as Electronic Shelf Labels, E-books, E-documents, E-newspapers, E-dictionaries, Industrial sensors, Ultra-Mobile PCs, etc. Zero-power LCDs are a category of electronic paper.

Kent Displays has also developed a "no power" display that uses Polymer Stabilized Cholesteric Liquid Crystals (ChLCD). The major drawback to the ChLCD is slow refresh rate, especially with low temperatures.

In 2004 researchers at the University of Oxford also demonstrated two new types of Zero Power bistable LCDs based on Zenithal bistable techniques.

Several bistable technologies, like the 360° BTN and the bistable cholesteric, depend mainly on the bulk properties of the liquid crystal (LC) and use standard strong anchoring, with alignment films and LC mixtures similar to the traditional monostable materials. Other bistable technologies (i.e. Binem Technology) are based mainly on the surface properties and need specific weak anchoring materials.

Drawbacks

Laptop LCD screen viewed at an extreme angle.

Page 19: Total Document (1)

LCD technology still has a few drawbacks in comparison to some other display technologies:

While CRTs are capable of displaying multiple video resolutions without introducing artifacts, LCDs produce crisp images only in their "native resolution" and, sometimes, fractions of that native resolution. Attempting to run LCD panels at non-native resolutions usually results in the panel scaling the image, which introduces blurriness or "blockiness" and is susceptible in general to multiple kinds of HDTV Blur. Many LCDs are incapable of displaying very low resolution screen modes (such as 320x200) due to these scaling limitations.

Although LCDs typically have more vibrant images and better "real-world" contrast ratios (the ability to maintain contrast and variation of color in bright environments) than CRTs, they do have lower contrast ratios than CRTs in terms of how deep their blacks are. A contrast ratio is the difference between a completely on (white) and off (black) pixel, and LCDs can have "backlight bleed" where light (usually seen around corners of the screen) leaks out and turns black into gray. Nowadays the very best LCDs can approach the contrast ratios of plasma displays in terms of delivering a deep black, but most LCDs still lag behind. The very best plasma displays such as the Pioneer Kuro models still lead the way with black levels, which are simply not possible with todays LCD technology.

LCDs which use cheap parts cannot "truly" display as many colors as their CRT and plasma counterparts, typically ones that have lower-end panel types (see List of LCD matrices) such as Twisted Nematic panels (TN).

LCDs typically have longer response times than their plasma and CRT counterparts, especially older displays, creating visible ghosting when images rapidly change. For example, when moving the mouse quickly on an LCD, multiple cursors can sometimes be seen.

Some LCDs have significant input lag. If the lag delay is large enough, such displays can be unsuitable for fast and time-precise mouse operations (CAD, FPS gaming) as compared to

Page 20: Total Document (1)

CRT displays or smaller LCD panels with negligible amounts of input lag. Short lag times are sometimes emphasized in marketing.

LCD panels tend to have a limited viewing angle relative to CRT and plasma displays. This reduces the number of people able to conveniently view the same image – laptop screens are a prime example. As this lack of ambient radiation is what gives LCDs their reduced power consumption in comparison to CRTs and plasma displays, it is unavoidable.

o While improved viewing angles mean that grossly incorrect color is now uncommon in normal use, viewing an LCD at ranges typical of computer use still allows small shifts in the user's posture, and even the difference in position between their eyes, to produce noticeable color distortion from even the best LCDs on the market.

Some LCD monitors can cause migraines and eyestrain problems due to flicker from fluorescent backlights fed at 50 or 60 Hz.

A small percentage of LCD screens suffer from image persistence, which is similar to screen burn on CRT and plasma displays, though in LCD monitors, this condition can be repaired very easily.

Consumer LCD monitors tend to be more fragile than their CRT counterparts. The screen may be especially vulnerable due to the lack of a thick glass shield as in CRT monitors.

Dead pixels are a common occurrence and few manufacturers replace screens with dead pixels for free.

Horizontal and/or vertical banding is a problem in some LCD screens. This flaw occurs as part of the manufacturing process, and cannot be repaired (short of total replacement of the screen). Banding can vary substantially even among LCD screens of the same make and model. The degree is determined by the manufacture's quality control procedures.

Color metering is a common problem often not thought about. For a realistic image the frequency range of each of the 3 colors should match the color perception (frequency range) of the human eye.

Page 21: Total Document (1)

CRT monitors generally do a better job than that of LCD screens

Smart card

A smart card, chip card, or integrated circuit card (ICC), is defined as

any pocket-sized card with embedded integrated circuits which can process information.

This implies that it can receive input which is processed - by way of the ICC applications

- and delivered as an output. There are two broad categories of ICCs. Memory cards

contain only non-volatile memory storage components, and perhaps some specific

security logic. Microprocessor cards contain volatile memory and microprocessor

components. The card is made of plastic, generally PVC, but sometimes ABS. The card

may embed a hologram to avoid counterfeiting.

Overview

A "smart card" is also characterized as follows:

Dimensions are normally credit card size. The ID-1

of ISO 7810 standard defines them as 85.60 ×

53.98 mm. Another popular size is ID-000 which is

25 x 15 mm. Both are .76 mm thick.

Contains a security system - tamper-resistant

properties (e.g. a secure cryptoprocessor,secure file

system, human-readable features) and is capable of

providing security services (e.g. confidentiality of

information in the memory).

Asset managed by way of a central administration

system which interchanges information and

configuration settings with the card through the

Page 22: Total Document (1)

security system. The latter includes card hotlisting,

updates for application data.

Card data is transferred to the central

administration system through card reading

devices, such as ticket readers, ATMs etc.

Benefits

Smart cards provide a means of effecting business transactions in a flexible, secure way

with minimal human intervention and in a standard way.

History

The chip card was invented by German rocket scientist Helmut Gröttrup and his

colleague Jürgen Dethloff in 1968; the patent was finally approved in 1982. The first

mass use of the cards was for payment in French pay phones, starting in 1983 (Télécarte).

Roland Moreno actually patented his first concept of the memory card in 1974. In 1977,

Michel Ugon from Honeywell Bull invented the first microprocessor smart card. In 1978,

Bull patented the SPOM (Self Programmable One-chip Microcomputer) that defines the

necessary architecture to auto-program the chip. Three years later, the very first "CP8"

based on this patent was produced by Motorola. Today, Bull has 1200 patents related to

smart cards.

Page 23: Total Document (1)

A Finnish smart card, combining credit card and debit card properties. The 3 by 5 mm

security chip embedded in the card is shown enlarged in the inset. The gold contact pads

on the card enables electronic access to the chip.

The second use was with the integration of microchips into all French debit cards (Carte

Bleue) completed in 1992. When paying in France with a Carte Bleue, one inserts the

card into the merchant's terminal, then types the PIN, before the transaction is accepted.

Only very limited transactions (such as paying small autoroute tolls) are accepted without

PIN.

Smart-card-based electronic purse systems (in which value is stored on the card chip, not

in an externally recorded account, so that machines accepting the card need no network

connectivity) were tried throughout Europe from the mid-1990s, most notably in

Germany (Geldkarte), Austria (Quick), Belgium (Proton), the Netherlands (Chipknip and

Chipper), Switzerland ("Cash"), Sweden ("Cash"), Finland ("Avant"), UK ("Mondex"),

Denmark ("Danmønt") and Portugal ("Porta-moedas Multibanco").

The major boom in smart card use came in the 1990s, with the introduction of the smart-

card-based SIM used in GSM mobile phone equipment in Europe. With the ubiquity of

mobile phones in Europe, smart cards have become very common.

The international payment brands MasterCard, Visa, and Europay agreed in 1993 to work

together to develop the specifications for the use of smart cards in payment cards used as

either a debit or a credit card. The first version of the EMV system was released in 1994.

In 1998 a stable release of the specifications was available. EMVco, the company

responsible for the long-term maintenance of the system, upgraded the specification in

2000 and most recently in 2004. The goal of EMVco is to assure the various financial

institutions and retailers that the specifications retain backward compatibility with the

1998 version.

With the exception of countries such as the United States of America and Australia there

has been significant progress in the deployment of EMV-compliant point of sale

equipment and the issuance of debit and or credit cards adhering the EMV specifications.

Page 24: Total Document (1)

Typically, a country's national payment association, in coordination with MasterCard

International, Visa International, American Express and JCB, develop detailed

implementation plans assuring a coordinated effort by the various stakeholders involved.

The backers of EMV claim it is a paradigm shift in the way one looks at payment

systems. In countries where banks do not currently offer a single card capable of

supporting multiple account types, there may be merit to this statement. Though some

banks in these countries are considering issuing one card that will serve as both a debit

card and as a credit card, the business justification for this is still quite elusive. Within

EMV a concept called Application Selection defines how the consumer selects which

means of payment to employ for that purchase at the point of sale.

For the banks interested in introducing smart cards the only quantifiable benefit is the

ability to forecast a significant reduction in fraud, in particular counterfeit, lost and

stolen. The current level of fraud a country is experiencing, coupled with whether that

country's laws assign the risk of fraud to the consumer or the bank, determines if there is

a business case for the financial institutions. For example, in Australia the consumer

bears the risk of credit card fraud, possibly explaining the lack of progress the banks have

made in rolling out smartcards. Some critics claim that the savings are far less than the

cost of implementing EMV, and thus many believe that the USA payments industry will

opt to wait out the current EMV life cycle in order to implement new, contactless

technology.

Smart cards with contactless interfaces are becoming increasingly popular for payment

and ticketing applications such as mass transit. Visa and MasterCard have agreed to an

easy-to-implement version currently being deployed (2004-2006) in the USA. Across the

globe, contactless fare collection systems are being implemented to drive efficiencies in

public transit. The various standards emerging are local in focus and are not compatible,

though the MIFARE card from Philips has a considerable market share in the US and

Europe.

Page 25: Total Document (1)

Smart cards are also being introduced in personal identification and entitlement schemes

at regional, national, and international levels. Citizen cards, drivers’ licenses, and patient

card schemes are becoming more prevalent, and contactless smart cards are being

integrated into ICAO biometric passports to enhance security for international travel.

Smart card reader

A smart card is an integrated circuit card that forms a part of a circuit or system when

engaged with a smart card interface. Smart cards are used for a variety of

applications including electronic game cards, identification badges, and data storage

media such as electronic books. Smart cards are becoming increasingly more popular for

security and personal identification applications. For example, smart cards are currently

being used for storing sensitive data such as medical records, banking information, etc.

Smart cards have one or more microcontrollers embedded in them which manage access

to, and storage of, sensitive data that is actually stored in memory devices on the smart

card. The smart chip included on a smart card provides a means for secured electronic

transactions and a means for identification. The embedded chip includes memory and

enables the reading and writing of data onto the chip. Data that might be stored in a smart

card includes bank account numbers, personal data as well as a complete medical history,

or the electronic equivalent of currency. The integrated chip is embedded in the smart

card and operates to process specific transactions. The data may be encrypted for security

purposes and, thus, enable the user to use the card within a multitude of applications,

such as credit card transactions, computer access capabilities, wireless communications,

banking, satellite TV and government identification. The smart card uses a serial

interface and receives its power from an external source such as a smart card reader.

There are various types of smart cards including contact type smart cards, contactless

type smart cards and hybrid type (both contact and contactless) smart cards. A contactless

type smart card system includes a contactless card reader and a contactless smart card.

The contactless card reader generates an electromagnetic signal having a predetermined

frequency. A contact type smart card is placed in a position of full insertion, in which the

card is electrically connected, and the card extracted by the user after use using ejection

means built into a connector. The connector is mounted on a circuit board, with the

Page 26: Total Document (1)

contacts having tails soldered to traces on the board. Most contacts carry signals, and

usually one contact is a ground contact.

Contact smart card

Contact smart cards have a small gold chip about 1cm by 1cm on the front. When

inserted into a reader, the chip makes contact with electrical connectors that can read

information from the chip and write information back.

The ISO/IEC 7816 and ISO/IEC 7810 series of standards define:

the physical shape

the positions and shapes of the electrical connectors

the electrical characteristics

the communications protocols

the format of the commands sent to the card and the

responses returned by the card

robustness of the card

the functionality

The cards do not contain batteries; energy is supplied by the card reader.

Contact smart card reader

Contact smart card readers are used as a communications medium between the smart card

and a host, e.g. a computer, a point of sale terminal, or a mobile telephone.

Since the chips in the financial cards are the same as those used for mobile phone

Subscriber Identity Module(SIM) cards, just programmed differently and embedded in a

different shaped piece of PVC, the chip manufacturers are building to the more

demanding GSM/3G standards. So, for instance, although EMV allows a chip card to

draw 50mA from its terminal, cards are normally well inside the telephone industry's

Page 27: Total Document (1)

6mA limit. This is allowing financial card terminals to become smaller and cheaper, and

moves are afoot to equip every home PC with a card reader and software to make internet

shopping more secure.

Contact less smart card

A second type is the contact less smart card, in which the chip communicates with the

card reader through RFID induction technology (at data rates of 106 to 848 kbit/s). These

cards require only close proximity to an antenna to complete transaction. They are often

used when transactions must be processed quickly or hands-free, such as on mass transit

systems, where smart cards can be used without even removing them from a wallet.

The standard for contact less smart card communications is ISO/IEC 14443, dated 2001.

It defines two types of contact less cards ("A" and "B"), allows for communications at

distances up to 10 cm. There had been proposals for ISO 14443 types C, D, E and F that

have been rejected by the International Organization for Standardization. An alternative

standard for contact less smart cards is ISO 15693, which allows communications at

distances up to 50 cm.

Example of widely used contact less smart cards are Hong Kong's Octopus card, Paris'

Calypso/Navigo card and Lisbon' LisboaViva card, which predate the ISO/IEC 14443

standard. The following tables list smart cards used for public transportation and other

electronic purse applications.

A related contact less technology is RFID (radio frequency identification). In certain

cases, it can be used for applications similar to those of contact less smart cards, such as

for electronic toll collection. RFID devices usually do not include writeable memory or

microcontroller processing capability as contact less smart cards often do.

There are dual-interface cards that implement contact less and contact interfaces on a

single card with some shared storage and processing. An example is Porto's multi-

application transport card, called Andante, that uses a chip in contact and contact less

(ISO 14443B).

Page 28: Total Document (1)

Like smart cards with contacts, contact less cards do not have a battery. Instead, they use

a built-in inductor to capture some of the incident radio-frequency interrogation signal,

rectify it, and use it to power the card's electronics.

Communication protocols

Communication protocols

Nam

eDescription

T=0 Byte-level transmission protocol

T=1 Block-level transmission protocol

T=CL APDU transmission via contact less interface ISO 14443

Cryptographic smart cards

Most advanced smart cards are equipped with specialized cryptographic hardware that let

you use algorithms such as RSA and DSA on board. Today's cryptographic smart cards

are also able to generate key pairs on board, to avoid the risk of having more than one

copy of the key (since by design there usually isn't a way to extract private keys from a

smart card).

Such smart cards are mainly used for digital signature and secure identification (see

applications section).

Page 29: Total Document (1)

The most common way to access cryptographic smart card functions on a computer is to

use a PKCS#11 library provided by the vendor. On Microsoft Windows platforms the

CSP API is also adopted.

The most widely used crypto graphics in smart cards (excluding the GSM so-called

"crypto algorithm") are 3DES (Triple DES) and RSA. The key set is usually loaded

(DES) or generated (RSA) on the card at the personalization stage.

Applications

Financial

The applications of smart cards include their use as credit or ATM cards, in a fuel card,

SIMs for mobile phones, authorization cards for pay television, pre-pay utilities in

household, high-security identification and access-control cards, and public transport and

public phone payment cards.

Smart cards may also be used as electronic wallets. The smart card chip can be loaded

with funds which can be spent in parking meters and vending machines or at various

merchants. Cryptographic protocols protect the exchange of money between the smart

card and the accepting machine.

Other

Smart cards are widely used to protect digital television streams. See television

encryption for an overview, and Video Guard for a specific example of how smartcard

security worked (and was cracked).

Page 30: Total Document (1)

Problems

Another problem of smart cards may be the failure rate. The plastic card in which the

chip is embedded is fairly flexible, and the larger the chip, the higher the probability of

breaking. Smart cards are often carried in wallets or pockets — a fairly harsh

environment for a chip. However, for large banking systems, the failure-management cost

can be more than offset by the fraud reduction. A card enclosure might be a good idea.

Smart cards used for client-side identification and authentication are the most secure way

for eg. internet banking applications, but the security is never 100% sure. In the example

of internet banking, if the PC is infected with any kind of malware, the security model is

broken. Theoritically a malware can override the communication (both input via

keyboard and output via application screen) between the user and the internet banking

application (eg. browser). This would result in modifying transactions by the malware

and unnoticed by the user.

POWER SUPPLY & CIRCUIT DIAGRAM

Page 31: Total Document (1)
Page 32: Total Document (1)

CONTROLLER

PHILIPS MICRO CONTROLLER

INTRODUCTION

The 89c51RD2xx is a low-power, high-performance CMOS 8-bit

microcomputer with 4K bytes of Flash programmable and erasable read only memory

(PEROM). The device is manufactured using Philips high-density nonvolatile memory

technology and is compatible with industry-standard MCS-51 instruction set and pin out.

The on-chip Flash allows the program memory to be reprogrammed in-system or by a

conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with

Flash on a monolithic chip, the P89C51RD2xx is a powerful microcomputer which

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

applications.

Features

Compatible with MCS-51 Products

4K Bytes of In-System Reprogrammable Flash Memory – Endurance: 1000

Write/Erase Cycles.

Fully Static Operation: 0Hz to 24MHz

Three-level Program Memory Lock

128 x 8- bit Internal RAM

32 Programmable I/O Lines

Two 16-bit Timer/Counters

Six Interrupt Sources

Programmable Serial Channel

Low-power Idle and Power-down Modes

Page 33: Total Document (1)

Figure.1 Block Diagram of the AT89C core

For more information on the individual devices and features, refer to the Hardware

Descriptions and Data Sheets of the specific device.

COUNTERINPUTS

EXTERNALINTERRUPT

S

INTERRUPTCONTROL

ON-CHIPFLASH ON-CHIP

RAM

ON-CHIPRAM

TIMER 1

TIMER 0

CPU

OSC BUSCONTROL

4 I/O PORTS

SERILPORT

PO P2 P1 P3 TXD RXD

Page 34: Total Document (1)

NC

EXTERIOR OSCILLATORSIGNAL

XTAL2

XTAL1

GND

Fig.1 Oscillator Connection.

The P89C51 provides the following standard features: 4K bytes of Flash, 128

bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector two-level interrupt

architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition,

the P89C51 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.

Fig.2 External Clock Drive Configuration

Page 35: Total Document (1)

Fig.3 Memory Structure of the 8051.

Memory Organization

Program Memory

Figure 4 shows a map of the lower part of the program memory. After

reset, the CPU begins execution from location 0000H. As shown in fig.4, each interrupt is

assigned a fixed location in program memory. The interrupt causes the CPU to jump to

that location, where it executes the service routine. External Interrupt 0, for example, is

assigned to location 0003H. If External Interrupt 0 is used, its service routine must begin

at location 0003H. If the interrupt is not used, its service location is available as general

purpose.

External

EA = 0

External

EA = 1

External

FFFFH

0000

INTERNAL

FF

00

EXTERNAL

FFFFH

PROGRAM MEMORY DATA MEMORY

RD WRPSEN

Page 36: Total Document (1)

(0033)H

002BH

0023H

001BH

0013H

000BH

0003H

0000H

8 bytesINTERRUPT LOCATIONS

RESET

Fig. 4 Program Memory.

Program memory addresses are always 16 bits wide, even though the actual amount o

program memory used may be less than 64Kbytes. External program execution sacrifices

two of the 8-bit ports, P0 and P2, to the function of addressing the program memory.

Data Memory

The right half of Figure 3 shows the internal and external data memory spaces

available on Philips Flash microcontrollers. Fig.6 shows a hardware configuration for

accessing up to 2K bytes of external RAM. In this case, the CPU executes from internal

flash. Port0 serves as a multiplexed address/data bus to the RAM, and 3 lines of Port 2

are used to page the RAM. The CPU generates RD and WR signals as needed during

external RAM accesses. You can assign up to 64K bytes of external data memory.

External data memory addresses can be either 1 or 2bytes wide. One-byte addresses are

often used in conjunction with one or more other I/O lines to page the RAM, as shown in

Fig.6. Two-byte addresses can also be used, in which case the high address byte is

emitted at Port2.

Page 37: Total Document (1)

ACCESSIBLE BY INDIRECT ADDRESSING ONLY.ACCESSIBLE BY DIRECT ADDRESSING ONLY

ACCESSIBLE BY INDIRECT ADDRESSING AND DIRECT ADDRESSING

Fig.5 Internal Data Memory.

Upper 128

Lower 128

80H7FH

00

FFH FFH

80H

Special register function

PortsStatus and control bitsTimersRegistersStack pointerAccumulator(etc)

Internal data memory addresses are always 1 byte wide, which implies an address

space of only 256bytes. However, the addressing modes for internal RAM can infact

accommodate 384 bytes. Direct addresses higher than 7FH access one memory space and

indirect addresses higher than 7FH access a different memory space. Thus, Figure.7

shows the Upper 128 and SFR space occupying the same block of addresses, 80H

through FFH, although they are physically separate entities. Figure.8 shows how the

lower 128 bytes of RAM are mapped. The lowest 32 bytes are grouped into 4 banks of 8

registers. Program instructions call out these registers as R0 through R7. Two bits in the

Program Status Word (PSW) select which register bank is in use. This architecture allows

more efficient use of code space, since register instructions are shorter than instructions

that use direct addressing.

Page 38: Total Document (1)

Fig.6 The lower 128 bytes of Internal RAM

The next 16 bytes above the register banks form a block of bit-addressable memory

space. The microcontroller instruction set includes a wide selection of single-bit

instructions, and these instructions can directly address the 128 bits in this area. These bit

addresses are 00H through 7FH. All of the bytes in the Lower 128 can be accessed by

either direct or indirect addressing.

Page 39: Total Document (1)

Special Function Register Map

8 Bytes

F8 FF

F0 B F7E8 EFE0 ACC E7D8 DFD0 PSW(1) D7C8 T2C0N(1) T2MOD(2) RCAP2L(2) RCAP2H(2) TL2(2) TH2(2) CFC0 C7B8 IP(1) BFB0 P3 B7A8 IE(1) AFA0 P2 A798 SCON(1) SBUF 9F90 PI 9788 TCON(1) TMOD(1) TLO TLI THO TH1 BF80 PO SP DPL DPH PCON(1) 87

Bit Addressable

Notes: 1. SFRs converting mode or control bits

2. AT89C52only

Power-on Reset

The reset input is the RST pin, which is the input to a Schmitt Trigger. A

reset is accomplished by holding the RST pin high for at least two machine cycles (24

oscillator periods), while the oscillator is running. The CPU responds by generating an

internal reset.

The external reset signal is asynchronous to the internal clock. The RST

pin is sampled during State 5 Phase 2 of every machine cycle. The port pins will maintain

their current activities for 19 oscillator periods after a logic 1 has been sampled at the

RST pin; that is, for 19 to 31 oscillator periods after the external reset signal has been

applied to the RST pin.

The internal reset algorithm writes 0s to all the SFRs except the port

latches, the Stack Pointer and SBUF. The port latches are initialized to FFH, the Stack

Page 40: Total Document (1)

Pointer to 07H, and SBUF is indeterminate. The internal RAM is not affected by reset.

On power up the RAM content is indeterminate.

REGISTER REST VALUE

-------------------------------------------------------------------------

PC 0000H

ACC 00H

B 00H

PSW 00H

SP 07H

DPTR 0000H

P0-P3 FFH

IP XXX0000B

IE 0XX0000B

TMOD 00H

TCON 00H

TH0 00H

TL0 00H

TH1 00H

SCON 00H

SBUF Indeterminate

PCON (NMOS) 0XXXXXXXB

PCON (CMOS) 0XXX0000B

Interrupts

The P89C51 provides 5 interrupt sources. The External Interrupts INT0 and

INT1 can each be either level-activated or transition-activated, depending on bits IT0 and

IT1 in Register TCON. The flags that actually generate these interrupts are bits IE0 and

IE1 in TCON. When an external interrupt is generated, the flag that generated it is

cleared by the hardware when the service routine is vectored to only if the interrupt was

Page 41: Total Document (1)

transition-activated. If the interrupt was level-activated, then the external requesting

source is what controls the request flag, rather than the on-chip hardware.

The Timer0 and Timer 1 Interrupts are generated by TF0 and TF1, which are set

by a rollover in their respective Timer/Counter registers (except see Timer0 in Mode3).

When a timer interrupt is generated, the flag that generated it is cleared by the on-chip

hardware when the service routine is vectored to.

The Serial Port Interrupt is generated by the logical OR of RI and TI. Neither of

these flags is cleared by hardware when the service routine is vectored to. In fact, the

service routine will normally have to determine whether it was RI or TI that generated the

interrupt, and the bit will have to be cleared in software.

All of the bits that generate interrupts can be set or cleared by software, with the

same result as thought it had been set or cleared by hardware. This is, interrupts can be

generated or pending interrupts can be canceled in software.

Each of these interrupt sources can be individually enabled or disabled by

setting or clearing a bit in Special Function Register IE. IE also contains a global disable

bit, EA, which disables all interrupts at once.

The interrupt flags are sampled a S5P2 of every machine cycle. The samples are

polled during the following machine cycle. If one of the flags was in a set condition at

S5P2 of the preceding cycle, the polling cycle will find it and the interrupt system will

generate an LCALL to the appropriate service routine, provided this hardware-generated

LCALL is not blocked by any of the following conditions:

1. An interrupt of equal or higher priority level is already in progress.

2. The current (polling) cycle is not the final cycle in the execution of the

instruction in progress.

3. The instruction in progress is RET1 or any write to the IE or IP registers.

Any of these three conditions will block the generation of the LCALL to the

interrupt service routine. Condition 2 ensures that instruction in progress will be

completed before vectoring to any service routine. Condition 3 ensures that if the

instruction in progress is RET1 or any access to IE or IP, then at least one more

instruction will be executed before any interrupt is vectored to.

Page 42: Total Document (1)

The poling cycle is repeated with each machine cycle, and the values polled are

the values that were present at S5P2 of the previous machine cycle. Note that if any

interrupt flag is active but not being responded for one of the above conditions, if the flag

is not still active when the blocking condition is removed, the denied interrupt will not be

serviced. In other words, the fact that the interrupt flag was once active but not serviced is

not remembered. Every polling cycle is new.

The processor acknowledges an interrupt request by executing hardware

generated LCALL to the appropriate servicing routine. In some cases it also clears the

flag that generated the interrupt, and in other cases it doesn’t. It never clears the Serial

Port flag. This has to be done in the user’s software. It clears an external interrupt flag

(IE0 or IE1) only if it was transition-activated. The hardware generated LCALL pushes

the contents of the Program Counter onto the Stack (but it does not save the PSW) and

reloads the PC with an address that depends on the source of the interrupt being vectored

to. Execution proceeds from that location until the RET1 instruction is encountered. The

RET1 instruction informs the processor that this interrupt routine is no longer in progress,

then pops the top two bytes from the stack and reloads the Program Counter. Exception

of the interrupted program continues fro where it left off.

Note that a simple RET instruction would also have returned execution to

the interrupted program, but it would have left the interrupt control system thinking an

interrupt was still in progress, making future interrupts impossible.

External Interrupts

The external sources can be programmed to be level-activated or

transition-activated by setting or clearing bit IT1 or IT0 in Register TCON. If ITx=0,

external interrupt x is triggered by a detected low at the INTX pin. If ITx=1, external pin

x is edge triggered. In this mode if successive samples of the INTX pin show a high in

one cycle and a low in the next cycle, interrupt request flag IEx in TCON is set. Flag bit

IEx then request the interrupt.

Page 43: Total Document (1)

Since the external interrupt pins are sampled once each machine cycle, an

input high or low should hold for at least 12 oscillator periods to ensure sampling. If the

external interrupt is transition-activated, the external source has to hold the request pin

high for at least once cycle, and then hold it low for at least one cycle. This is done to

ensure that transition is seen so that interrupt request flag IEx will be set. The CPU will

automatically clear IEx when the service routine is called.

If the external interrupt is level-activated, the external source has to hold

the request active until the requested interrupt is actually generated. Then it has to

deactivate the request before the interrupt service routine is completed, or else another

interrupt will be generated.

To use any of the interrupts in the 89C51 Family, the following

three steps must be taken.

1. Set the EA (enable all) bit in the IE register to 1.

2. Set the corresponding individual interrupt enable bit in the IE register to 1.

3. Begin the interrupt service routine at the corresponding vector.

Address of that interrupt. See Table below.

Interrupt Source Vector Address

----------------------------------------------------------------

IE0 0003H

TF0 000BH

IE1 0013H

TF1 001BH

RI & TI 0023H

----------------------------------------------------------------

In addition, for external interrupts, pins INT0 and INT1(P3.2 and P3.3) must be set to 1,

and depending on whether the interrupt is to be level or transition activated, bits IT0 or

IT1 in the TCON register may need to be set to 1.

ITx=0 level activated

Page 44: Total Document (1)

ITx=1 transition activated Priority within level is only to resolve

simultaneous requests of the same priority level. Form high to low, interrupt sources are

listed below:

IE0 highest priority

TF0

IE1

TF1R1 or T1 lowest priority

Timer Set-Up

The tables below give some values for TMOD which can be used to set up

Timer 0 and Timer 1 in different modes. It is assumed that only one timer is being used at

a time. If it is desired to run Timers 0 and 1 simultaneously, in any mode the value in the

TMOD for timer 0 must be ORed with value shown for Timer 1. For example, if it is

desired to run Timer 0 in mode 1 GATE (external control), and Timer 1 in mode 2

COUNTER, then value that must be loaded into TMOD is 69H (09H from the table for

Timer0, ORed with 60H from the table for Timer 1).

Moreover, it is assumed that the user, at this point, is not ready to turn the

timers on and will do that at a different point in the program by setting bit TRx (in

TCON) to 1.

TIMER/COUNTER 0

As a Timer:

Mode Function TMOD (internal control) TMOD (external control)

0 13-bit Timer 00H 08H

1 16-bit Timer 01H 09H

2 8-bit Auto-Reload 02H 0AH

3 Two 8-bit Timers 03H 0BH

Page 45: Total Document (1)

As a Counter:

Mode Function TMOD (internal control) TMOD (external control)

0 13-bit Counter 04H 0CH

1 16-bit Counter 05H 0DH

2 8-bit Auto-Reload 06H 0EH

3 One 8-bit Counter 07H 0FH

TIMER/COUNTER 1

As a Timer:

Mode Function TMOD (internal control) TMOD (external control)

0 13-bit Timer 00H 80H

1 16-bit Timer 10H 90H

2 8-bit Auto-Reload 20H A0H

3 Does not run 30H B0H

As a Counter

Mode Function TMOD (internal control) TMOD (external control)

0 13-bit Counter 40H C0H

1 16-bit Counter 50H D0H

2 8-bit Auto-Reload 60H A0H

3 Not available --- ---

Page 46: Total Document (1)

Serial Port Set-Up

The serial port is full duplex, meaning it can transmit and receive

simultaneously. It is also receive-buffered, meaning it can commence reception of a

second byte before a previously received byte has been read form the register. (However,

if the first byte still hasn’t been read by the time reception of the second byte is complete,

one of the bytes will be lost.) The serial port receive and transmit registers are both

accessed at Special Function Register SBUF. Writing to SBUF loads the transmit

register, and reading SBUF accesses a physically separate receive register.

The serial port can operate in 4 modes:

Mode 0: Serial data enters and exits through RxD. TxD outputs the shift clock. 8 bits are

transmitted/received (LSB first). The baud rate is fixed at 1/12th oscillator frequency.

Mode 1: 10 bits are transmitted (through TxD) or received (through RxD): a start bit (0),

8 data bits (LSB first), and a stop bit (1). On receive; the stop bit goes into RB8 in

Special Function Register SCON. The baud rate is variable.

Mode 2: 11 bits are transmitted (trough TxD) or received (through RxD): start bit (0), 8

data bits (LSB first), a programmable 9th data bit, and a stop bit (1). On transmit, the 9th

data bit (TB is SCON) can be assigned the value of 0 or 1. Or, for example, the parity bit

(P, in the PSW) could be moved into TB8. On receive; the 9 th data bit goes into RB8 in

Special Function Register SCON, while the stop bit is ignored. The baud rate is

programmable to either 1/32 or 1/64th oscillator frequency.

Mode 3: 11 bits are transmitted (through TxD) or received (through RxD): a start bit (0),

8 data bits (LSB first), a programmable 9th data bit, and a stop bit (1). In fact, Mode 3 is

the same as Mode2 in all aspects except baud rate. The baud rate in Mode 3 is variable.

Page 47: Total Document (1)

Timer 1 Generated Commonly Used Baud Rages

The values for the different modes of operation of the serial port are shown in the table

below:

MODESCON SM2 Variation

0 10H Single Processor

1 50H Environment

2 90H (SM2 = 0)

3 D0H

0 Not Available Multiprocessor

1 70H Environment

2 B0H (SM2 =1)

3 F0H -------------

GENERATING BAUD RAGES

Serial Port in Mode 0:

Mode 0 has a fixed baud rate, which is 1/12 th oscillator frequency. To

run the serial port in this mode none of the Timer/Counters need to be set up. Only the

SCON register needs to be defined.

Baud Rate = Oscillator Frequency /12

Serial Port in Mode 1:

Mode1 has a variable baud rate. The baud rate is generated by Timer 1.

For this purpose, Timer 1 is used in mode2 (Auto-Reload).

Baud Rate = (K x Osc.Freq) / (32 x 12 x [256 – (TH1)])

If SMOD =0, then K=1.

If SMOD =1, then K =2 (SMOD is in the PCON register).

Page 48: Total Document (1)

Most of the time the user knows the baud rate and needs to know the reload value for

TH1.

TH1 = 256 – (K x Osc.Freq) / (384 x baud rate)

TH1 must be an integer value. Rounding off TH1 to the nearest integer may not produce

the desired baud rate. In this case, the user may have to choose another crystal frequency.

Since the PCON register is not bit addressable, one way to set the bit is

logical ORing the PCON register (i.e. ORL PCON, #80H). The address of PCON is 87H.

Serial Port in Mode2:

The baud rate is fixed in this mode and is 1/32 or 1/64 of the oscillator frequency,

depending on the value of the SMOD bit in the PCON register.

In this mode none of the Timers are used and the clock comes form the internal phase 2

clock.

SMOD = 1, Baud Rate = 1/32 Osc.Freq.

SMOD =0, Baud Rate = 1/64 Osc.Freq.

Circuit of 8051.

********************

COMMAND SET FOR SLE4442– 256 bytes Memory

Page 49: Total Document (1)

Steps Command Comd to SR90 Prompt from SR90 Reader

1. Set Device Type #0203! #83! (Positive Ack)#8A! (Invalid Device Type set )

2. Send Card Status #01! #80! (Card Present)#81! (Card Absent)

3. ATR #03! #88A2131091!

4. Read Data #10AANN! #87AANNDDD…D!( DDD = Data )

#86! (Invalid Command)#82! (No Device Type set )#8D! (Memory Over Flow)

5. Write Data #11AANNFFFFFF DD..D! #82! (No Device Type set )

#83! (Positive Ack)#89! (Invalid Security Code)#86! (Invalid Command)#85! (Invalid Parameters#8D! (Memory Over Flow)#90!(Already Protected)

6. Protect Data #12AANNFFFFFF DD! #83! (Positive Ack)

#82! (No Device Type)#89! (Invalid Security Code)#86! (Invalid Command)#85! (Invalid Parameters#8D! (Memory Over Flow)

AA = Address location of the chip in Hex NN = Number of bytes to read or to writeFFFFFF = Security CodeDD = Data to read / write or protect in BCD format

7. Change Securtiy Code #53FFFFFF555555 #83! (Positive Ack)#89! (Invalid Security Code)#86! (Invalid Command)#85! (Invalid Parameters

8.Locations Which can’t write : 0,1,2,3,6,7

Page 50: Total Document (1)

9. Communication Protocol: Baud Rate :9,600 bps

Parity :None

Stop Bit :1

Start Bit :0

Data :8 bits

Note: Please give correct security code while writing your cards other wise they will damage. This card will allow 3 times of writing false security code later it won’t accept to write the card but you can read.

SOFTWARE

Overview of KEIL CROSS C COMPILER

It is possible to create the source files in a text editor such as Notepad, run the

Compiler on each C source file, specifying a list of controls, run the Assembler on each

Assembler source file, specifying another list of controls, run either the Library Manager

or Linker (again specifying a list of controls) and finally running the Object-HEX

Converter to convert the Linker output file to an Intel Hex File. Once that has been

completed the Hex File can be downloaded to the target hardware and debugged.

Alternatively KEIL can be used to create source files; automatically compile, link and

covert using options set with an easy to use user interface and finally simulate or perform

debugging on the hardware with access to C variables and memory. Unless you have to

use the tolls on the command line, the choice is clear. KEIL Greatly simplifies the

process of creating and testing an embedded application.

Projects

The user of KEIL centers on “projects”. A project is a list of all the source files

required to build a single application, all the tool options which specify exactly how to

Page 51: Total Document (1)

build the application, and – if required – how the application should be simulated. A

project contains enough information to take a set of source files and generate exactly the

binary code required for the application. Because of the high degree of flexibility

required from the tools, there are many options that can be set to configure the tools to

operate in a specific manner. It would be tedious to have to set these options up every

time the application is being built; therefore they are stored in a project file. Loading the

project file into KEIL informs KEIL which source files are required, where they are, and

how to configure the tools in the correct way. KEIL can then execute each tool with the

correct options. It is also possible to create new projects in KEIL. Source files are added

to the project and the tool options are set as required. The project can then be saved to

preserve the settings. The project also stores such things as which windows were left

open in the simulator/debugger, so when a project is reloaded and the simulator or

debugger started, all the desired windows are opened. KEIL project files have the

extension

Simulator/Debugger

The simulator/ debugger in KEIL can perform a very detailed simulation of a

micro controller along with external signals. It is possible to view the precise execution

time of a single assembly instruction, or a single line of C code, all the way up to the

entire application, simply by entering the crystal frequency. A window can be opened for

each peripheral on the device, showing the state of the peripheral. This enables quick

trouble shooting of mis-configured peripherals. Breakpoints may be set on either

assembly instructions or lines of C code, and execution may be stepped through one

instruction or C line at a time. The contents of all the memory areas may be viewed along

with ability to find specific variables. In addition the registers may be viewed allowing a

detailed view of what the microcontroller is doing at any point in time.

The Keil Software 8051 development tools listed below are the programs you

use to compile your C code, assemble your assembler source files, link your program

together, create HEX files, and debug your target program. µVision2 for Windows™

Integrated Development Environment: combines Project Management, Source Code

Editing, and Program Debugging in one powerful environment.

Page 52: Total Document (1)

C51 ANSI Optimizing C Cross Compiler: creates relocatable object modules from

your C source code,

A51 Macro Assembler: creates relocatable object modules from your 8051

assembler source code,

BL51 Linker/Locator: combines relocatable object modules created by the compiler

and assembler into the final absolute object module,

LIB51 Library Manager: combines object modules into a library, which may be used

by the linker,

OH51 Object-HEX Converter: creates Intel HEX files from absolute object modules.

Program Code:

#include<reg51.h>#include<stdio.h>#include<intrins.h>

#define DATA P1

/***************lcd functions***************************/void busy_check();void init(unsigned char );void delay(unsigned int );void message(unsigned char ,unsigned char* );void write_lcd(unsigned char );void callenrs();void callen();void lcd_init();/*************serial functions*******************/void serial_init();void transmit(unsigned char *);void transmit1(unsigned char []);/*****************i2c functions*************/

/****************************************************/void write(unsigned int);

sbit RS=P1^0;sbit RW=P1^1;

Page 53: Total Document (1)

sbit EN=P1^2;

sbit up=P2^0;sbit down=P2^1;sbit ps=P2^2;sbit enter=P2^3;

sbit busy=P1^7;int destination=0,noseats=0;int VIJ_seat_var=9,VIZ_seat_var=9,avail_seat=0;

unsigned int i=0,k=0,amount=0,number=0;unsigned char m=0,str[5],a[13],b[4],amt[4],seats[3],j=0;unsigned char *tx_dat,*wr_dat,wr_val[6],wr[21];unsigned int x1=0,x2=0,a1=0,a2=0,b1=0,b2=0,l=0,n=0;/***************************************************************/

void main(){ P1=0x00; lcd_init(); serial_init();

while(1){

message(0x80,"Railway Ticket"); message(0xC0,"Insert Card");

transmit("#01!"); transmit(tx_dat);

init(0x01);k=0;while(k<16){

if((a[k]=='#')&&(a[k+3]=='!')) {

b[0]=a[k]; b[1]=a[k+1]; b[2]=a[k+2];

Page 54: Total Document (1)

b[3]=a[k+3]; break;

} k++; } if((b[0]=='#')&&(b[1]=='8')&&(b[2]=='0')&&(b[3]='!')) {

transmit("#0203!"); transmit("#104002!"); message(0xC0,"AIC:");

init(0xC4);i=0;

j=8; while(j<=10)

{ amt[i]=a[j]; write_lcd(a[j]); j++; i++; } delay(200);

amount=((amt[0]-48)*100)+((amt[1]-48)*10)+((amt[2]-48)*1); if(amount>300)

{init(0x01);message(0x80,"Enter destination:");delay(500);while(1)

{init(0x01);message(0x01,"VIJ-key1,VIZ-key2");if(up==0)

{while(up==0); destination=1; break;}

if(down==0){while(down==0); destination=2; break;}

}init(0x01);

Page 55: Total Document (1)

message(0x80,"Enter No.Of seats"); while(1)

{ if(up==0) {

while(up==0);noseats++;init(0xc0);write_lcd(noseats+0x30);if(noseats>9)noseats=0;

}if(down==0)

{while(down==0);noseats--;init(0xc0);write_lcd(noseats+0x30);if(noseats<0)noseats=9;}

if(ps==0){

while(ps==0);if(destination==1)

{VIJ_seat_var=VIJ_seat_var-

noseats;message(0x80,"Ticket

Conformed");amount= (amount-

(noseats*20));if( VIJ_seat_var==0){

init(0x01);message(0x80,"No Vacna");}

}if(destination==2){

VIZ_seat_var=VIZ_seat_var-noseats;

Page 56: Total Document (1)

amount= (amount-(noseats*10));

message(0x80,"Ticket Conformed");

if(VIZ_seat_var==0){

init(0x01);message(0x80,"No

Vacna");delay(100);

}}

break;

}if(enter==0){

while(enter==0);message(0x80,"Ticket Canceled");break;

}

delay(200);destination=0;} //nter Tickets

transmit("#01!");

transmit("#0203!"); write(amount); transmit("#104002!"); init(0x01);

message(0xC0,"AIC:"); init(0xC4); j=8;

while(j<=10) {

write_lcd(a[j]); j++; }

}

Page 57: Total Document (1)

}

else { message(0x80,"Card Absent"); message(0xc0,"Plz insert card"); } } }

/***************************************************/ void write(unsigned int am){ wr_dat="#114002FFFFFF0"; a1=0; a2=0; b1=0; a1=am/100; b1=am%100; a2=b1/10; b2=b1%10; wr_val[0]=a1+0x30; wr_val[1]=a2+0x30; wr_val[2]=b2+0x30; wr_val[3]='!'; wr_val[4]=' '; wr_val[5]='\0'; init(0x01); message(0x80,"Remaining Balance"); init(0xc0); write_lcd(wr_val[0]); write_lcd(wr_val[1]); write_lcd(wr_val[2]); l=0; n=0; while(*wr_dat) { wr[l]=*wr_dat++; l++; } while(n<6) {

Page 58: Total Document (1)

wr[l]=wr_val[n]; l++; n++; } transmit1(wr);}

/////////////////////////////////////////////////////////////////// void message(unsigned char loc,unsigned char *s){init(loc);

while(*s){

write_lcd(*s++);}

}////////////////////////////////////////////void delay(unsigned int x){int j;

while(x-->0){

for(j=0;j<=180;j++){;}

}} ///////////////////////////////////////// void init(unsigned char dbyte){unsigned char temp;

busy_check();DATA=dbyte;callen();temp=_cror_(dbyte,4);busy_check();DATA=temp;callen();delay(10);} //////////////////////////////////////////void write_lcd(unsigned char dbyte){unsigned char temp;busy_check();

Page 59: Total Document (1)

DATA=dbyte;callenrs();temp=_cror_(dbyte,4);busy_check();DATA=temp;callenrs();delay(2);}//////////////////////////////////////////void callenrs(){RW =0;EN=1;RS=1;delay(1);/*_nop_();_nop_();_nop_();_nop_();*/EN=0;_nop_();} //////////////////////////////////////////////

void callen(){RW = 0;RS= 0;EN=1;_nop_();_nop_();_nop_();_nop_();

EN=0;_nop_();}

//////////////////////////////////////////////void lcd_init(){init(0x30); init(0x20); init(0x28); init(0x0C); init(0x01);

Page 60: Total Document (1)

init(0x06);} void busy_check(){ busy=1; RS=0; RW=1; while(busy==1) { EN=0;

_nop_();_nop_();

_nop_();_nop_();EN=1;

}}

void serial_init(){ SCON=0X50; TMOD=0X20; TH1=0XFD; TR1=1; EA=1; ES=1; tx_dat=0x00;}void intr(void) interrupt 4{ if(RI) { RI=0; a[i]=SBUF; if(i==12) {

a[12]='\0'; i=0; } i++; }}

void transmit(unsigned char *tx){

Page 61: Total Document (1)

while(*tx) { SBUF=*tx++; delay(15); } SBUF=13; delay(2); TI=0; i=0;}void transmit1(unsigned char wr[]){ k=0; while(k<21) { SBUF=wr[k]; delay(15); k++; } SBUF=13; delay(2); TI=0; i=0;}

Power supplyA power supply (sometimes called a power supply unit or PSU) is a device or system that supplies electrical or other types of energy to an output load or group of loads. The term is most commonly applied to electrical energy supplies, less often to mechanical ones, and rarely to others.

Electrical power supplies

Page 62: Total Document (1)

This term covers the mains power distribution system together with any other primary or secondary sources of energy such as:

Conversion of one form of electrical power to another desired form and voltage. This typically involves converting 120 or 240 volt AC supplied by a utility company (see electricity generation) to a well-regulated lower voltage DC for electronic devices. For examples, see switched-mode power supply, linear regulator, rectifier and inverter (electrical).

Batteries Chemical fuel cells and other forms of energy

storage systems Solar power Generators or alternators (particularly useful in

vehicles of all shapes and sizes, where the engine has rotational power to spare, or in semi-portable units containing an internal combustion engine and a generator) (For large-scale power supplies, see electricity generation.) Low voltage, low power DC power supply units are commonly integrated with the devices they supply, such as computers and household electronics.

Constraints that commonly affect power supplies are the amount of power they can supply, how long they can supply it for without needing some kind of refueling or recharging, how stable their output voltage or current is under varying load conditions, and whether they provide continuous power or pulses.

The regulation of power supplies is done by incorporating circuitry to tightly control the output voltage and/or current of the power supply to a specific value. The specific value is closely maintained despite variations in the load presented to the power supply's output, or any reasonable voltage variation at the power supply's input. This kind of regulation is commonly categorised as a Stabilized power supply.

Computer power supply

Page 63: Total Document (1)

Computer power supply

A computer power supply typically is designed to convert 110-240 V AC power from the mains, to several low-voltage DC power outputs for the internal components of the computer. The most common computer power supplies are built to conform to the ATX form factor. The power rating of a PC power supply is not officially certified and is self-claimed by each manufacturer. The more reputable makers advertise "True Wattage Rated" to give consumers the idea that they can trust the wattage advertised.

Domestic mains adapter

A linear or (rarely) switched-mode power supply (or in some cases just a transformer) that is built into the top of a plug is known as a "wall wart", "power brick", "plug-in adapter", "adaptor block", "AC adaptor" or just "power adapter". They are even more diverse than their names; often with either the same kind of DC plug offering different voltage or polarity, or a different plug offering the same voltage. "Universal" adaptors attempt to replace missing or damaged ones, using multiple plugs and selectors for different voltages and polarities.

Because they consume standby power, they are sometimes known as "electricity vampires" and may be plugged into a power strip to allow turning them off. Expensive switched-mode power supplies can cut off leaky electrolyte-capacitors, use powerless MOSFETs, and reduce their working frequency to get a gulp of energy once in a while to power for example a clock, which would otherwise need a battery.

This type of power supply is popular among manufacturers of low cost electrical items because

1. Devices sold in the global marketplace don't need to be individually configured for 120 volt or 230 volt operation, just sold with the appropriate AC adapter.

2. The device itself doesn't need to be tested for compliance with electrical safety regulations. Only the adapter needs to be tested.

Linear power supply

A simple AC powered linear power supply usually uses a transformer to convert the voltage from the wall outlet (mains) to a different, usually a lower voltage. If it is used to produce DC a rectifier circuit is employed either as a single chip, an array of diodes sometimes called a diode bridge or Bridge Rectifier, both for fullwave rectification or a single diode yielding a half wave (pulsating) output. More elaborate configurations rectify the AC voltage at first to pulsating DC. Then a capacitor smooths out part of the pulses giving a type of DC voltage. The smaller pulses remaining are known as ripple. Because of a fullwave rectification they occur at twice the mains frequency (in USA it's

Page 64: Total Document (1)

60 Hz doubled to 120 Hz - or the UK, it's 50 Hz, doubled to 100 Hz). Finally, depending on the requirements of the load, a linear regulator may be used to reduce the ripple sometimes also allowing for adjustment of the output to the desired but lower voltage. More elaborate versions used by circuit designers are adjustable up to 30 volts and up to 5 amperes output. These often employ current limiting. Some can be driven by an external signal, for example, for applications requiring a pulsed output.

In the simplest case a single diode is connected directly to the mains and uses a resistor in series with a more or less fixed load to recharge a battery. This circuit is common in rechargeable flashlights.

Switched-Mode power supply

A switched-mode power supply (SMPS) works on a different principle. AC mains input is directly rectified, obtaining DC voltage. Then this voltage is changed back to AC by using electronic switches, but with a much higher frequency (typically 10 kHz — 1 MHz). Higher frequencies require smaller transformers. Then on the transformer secondary the AC is again rectified to DC. To keep output voltage constant, the power supply needs a sophisticated feedback controller - typically a single IC chip.

Polarity

Diagram explaining standard symbols for polarity.

AC-to-DC adaptors have polarity (positive or negative). It is necessary to use an adaptor with the correct polarity to avoid damage.

Uninterruptible power supply

An Uninterruptible Power Supply (UPS) takes its power from two or more sources simultaneously. It is usually powered directly from the AC mains, while simultaneously charging a storage battery. Should there be a dropout or failure of the mains, the battery instantly takes over so that the load never experiences an interruption. Such a scheme can supply power as long as the battery charge suffices, e.g., in a computer installation, giving the operator sufficient time to effect an orderly system shutdown without loss of data. Other UPS schemes may use an internal combustion engine or turbine to continuously supply power to a system in parallel with power coming from the AC mains. The engine-driven generators would normally be idling, but could come to full power in a matter of a few seconds in order to keep vital equipment running without interruption. Such a scheme might be found in hospitals or telephone central offices.

Power conversion

Page 65: Total Document (1)

The term "power supply" is sometimes restricted to those devices that convert some other form of energy into electricity (such as solar power and fuel cells and generators). A more accurate term for devices that convert one form of electric power into another form (such as transformers and linear regulators) is power converter. The most common conversion is AC-DC. This is a conversion from the household current AC, to the DC current that is used in your car, and most electronics.

Mechanical power supplies

Flywheels coupled to electrical generators or alternators

Compulsators Explosively pumped flux compression generators

Types of 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:

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.

Page 66: Total Document (1)

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

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

Page 67: Total Document (1)

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.

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.

Page 68: Total Document (1)

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 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 × IpVp = primary (input) voltageNp = number of turns on primary coilIp  = primary (input) current

   Vs = secondary (output) voltageNs = number of turns on secondary coilIs  = secondary (output) current

Rectifier

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

Transformercircuit symbol

Page 69: Total Document (1)

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.

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 the entire 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.

Page 70: Total Document (1)

Bridge rectifierAlternate pairs of diodes conduct,

changing overthe connections so the alternating

directions ofAC are converted to the one direction of

DC.

Output: full-wave varying DC(using all the AC wave)

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

Page 71: Total Document (1)

Single diode rectifierOutput: half-wave varying DC(using only half the AC wave)

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

Page 72: Total Document (1)

required value for the smoothing capacitor. A larger capacitor will give fewer ripples. The capacitor value must be doubled when smoothing half-wave DC.

 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

Regulator

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 regulators 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 heatsink if necessary.

Page 73: Total Document (1)

Zener diode regulator

For low current power supplies a simple voltage regulator can be made with a resistor and a zener diode connected in reverse as shown in the diagram. Zener diodes are rated by their breakdown voltage Vz and maximum power Pz (typically 400mW or 1.3W).

The resistor limits the current (like an LED resistor). The current through the resistor is constant, so when there is no output current all the current flows through the zener diode and its power rating Pz must be large enough to withstand this.

Choosing a zener diode and resistor:

1. The zener voltage Vz is the output voltage required 2. The input voltage Vs must be a few volts greater than Vz

(this is to allow for small fluctuations in Vs due to ripple) 3. The maximum current Imax is the output current required plus 10% 4. The zener power Pz is determined by the maximum current: 

Pz > Vz × Imax 5. The resistor resistance:  R = (Vs - Vz) / Imax 6. The resistor power rating:  P > (Vs - Vz) × Imax

RS-232In telecommunications, RS-232 (Recommended Standard 232) is a standard for serial binary data signals connecting between a DTE (Data terminal equipment) and a DCE (Data Circuit-terminating Equipment). It is commonly used in computer serial ports. A similar ITU-T standard is V.24.

Scope of the standard

The Electronic Industries Alliance (EIA) standard RS-232-C as of 1969 defines:

Electrical signal characteristics such as voltage levels, signaling rate, timing and slew-rate of signals, voltage withstand level, short-circuit behavior, maximum stray capacitance and cable length.

Interface mechanical characteristics, pluggable connectors and pin identification.

Functions of each circuit in the interface connector.

zener diodea = anode, k = cathode

Page 74: Total Document (1)

Standard subsets of interface circuits for selected telecom applications.

The standard does not define such elements as

character encoding (for example, ASCII, Baudot or EBCDIC)

the framing of characters in the data stream (bits per character, start/stop bits, parity)

Protocols for error detection or algorithms for data compression.

Bit rates for transmission, although the standard says it is intended for bit rates lower than 20,000 bits per second. Many modern devices support speeds of 115,200bps and above.

Power supply to external devices.

Details of character format and transmission bit rate are controlled by the serial port hardware, often a single integrated circuit called a UART that converts data from parallel to serial form. A typical serial port includes specialized driver and receiver integrated circuits to convert between internal logic levels and RS-232 compatible signal levels.

CONCLUSION

In terms of complexity embedded systems can range from very simple with a single

microcontroller chip, to very complex with multiple units, peripherals and networks

mounted inside a large chassis or enclosure, but the project falls under the former

category making it very simple to analyze.

This embedded system often resides in machines that are expected to run continuously

for years without errors and in some cases recover by themselves if an error occurs.

Therefore the software is usually developed and tested more carefully than that for

personal computers, and unreliable mechanical moving parts such as disk drives,

switches or buttons are avoided.

Page 75: Total Document (1)

Thus a digital stop watch that displays the time in hours minutes seconds and sixtieth

part of a second is being designed using the 89C51 as the main microcontroller.

Bibliography

The 8051 Microcontroller and Embedded Systems

- M.A Mazidi & J.G Mazidi

The Microcontroller Idea Book

- John Axelson

Page 76: Total Document (1)

The Microcontroller Application Cookbook

- Matt Gilliland

Digital design

-Morris Mano

Linear integrated circuits

- Roy choudary