password-authenticated key agreement using smart cards for campus management
#2
Fast General purpose Parallel I/O:
Device pins that are not connected to a specific peripheral function are controlled by the GPIO registers. Pins may be dynamically configured as inputs or outputs. Separate registers allow the setting or clearing of any number of outputs simultaneously. The value of the output register may be read back, as well as the current state of the port pins. LPC2141/42/44/46/48 introduces accelerated GPIO functions over prior LPC2000 devices:

¢ GPIO registers are relocated to the ARM local bus for the fastest possible I/O timing
¢ Mask registers allow treating sets of port bits as a group, leaving other bits unchanged
¢ All GPIO registers are byte addressable
¢ Entire port value can be written in one instruction

¢ Bit-level set and clear registers allow a single instruction to set or clear any number of bits in one port
¢ Direction control of individual bits
¢ Separate control of output set and clear
¢ All I/O default to inputs after reset
10 bit ADC:
The LPC2141/42 contain one and the LPC2144/46/48 contain two analog to digital converters. These converters are single 10-bit successive approximation analog to digital converters. While ADC0 has six channels, ADC1 has eight channels. Therefore, total number of available ADC inputs for LPC2141/42 is 6 and for LPC2144/46/48 is 14.
10 bit DAC:
The DAC enables the LPC2141/42/44/46/48 to generate a variable analog output. The maximum DAC output voltage is the VREF voltage.
USB 2.0 Device controller:

The USB is a 4-wire serial bus that supports communication between a host and a number (127 max) of peripherals. The host controller allocates the USB bandwidth to
Attached devices through a token based protocol. The bus supports hot plugging, unplugging, and dynamic configuration of the devices. All transactions are initiated by the host controller.

The LPC2141/42/44/46/48 is equipped with a USB device controller that enables 12 Mbit/s data exchange with a USB host controller. It consists of a register interface, serial interface engine, endpoint buffer memory and DMA controller. The serial interface engine decodes the USB data stream and writes data to the appropriate end point buffer memory. The status of a completed USB transfer or error condition is indicated via status registers. An interrupt is also generated if enabled. A DMA controller (available in LPC2146/48 only) can transfer data between an endpoint buffer and the USB RAM.


UARTS:
The LPC2141/42/44/46/48 each contains two UARTs. In addition to standard transmit and receive data lines, the LPC2144/46/48 UART1 also provide a full modem control handshake interface. Compared to previous LPC2000 microcontrollers, UARTs in LPC2141/42/44/46/48 introduce a fractional baud rate generator for both UARTs, enabling these microcontrollers to achieve standard baud rates such as 115200 with any crystal frequency above 2 MHz. In addition, auto-CTS/RTS flow-control functions are fully implemented in hardware (UART1 in LPC2144/46/48 only).
I2C Bus Serial I/O Controller

The LPC2141/42/44/46/48 each contains two I2C-bus controllers.
The I2C-bus is bidirectional, for inter-IC control using only two wires: a serial clock line (SCL), and a serial data line (SDA). Each device is recognized by a unique address and can operate as either a receiver-only device (e.g., an LCD driver or a transmitter with the capability to both receive and send information (such as memory)). Transmitters and/or receivers can operate in either master or slave mode, depending on whether the chip has to initiate a data transfer or is only addressed. The I2C-bus is a multi-master bus; it can be controlled by more than one bus master connected to it. The I2C-bus implemented in LPC2141/42/44/46/48 supports bit rates up to 400 kbit/s (Fast I2C-bus).

SPI Serial I/O Controller:

The LPC2141/42/44/46/48 each contain one SPI controller. The SPI is a full duplex serial interface, designed to handle multiple masters and slaves connected to a given bus. Only a single master and a single slave can communicate on the interface during a given data transfer. During a data transfer the master always sends a byte of data to the slave, and the slave always sends a byte of data to the master.

SSP Serial I/O Controller

The LPC2141/42/44/46/48 each contains one SSP. The SSP controller is capable of operation on a SPI, 4-wire SSI, or Micro wire bus. It can interact with multiple masters and slaves on the bus. However, only a single master and a single slave can communicate on the bus during a given data transfer. The SSP supports full duplex transfers, with data frames of 4 bits to 16 bits of data flowing from the master to the slave and from the slave to the master. Often only one of these data flows carries meaningful data.
General Purpose timers/external event counters

The Timer/Counter is designed to count cycles of the peripheral clock (PCLK) or an externally supplied clock and optionally generate interrupts or perform other actions at specified timer values, based on four match registers. It also includes four capture inputs to trap the timer value when an input signals transitions, optionally generating an interrupt. Multiple pins can be selected to perform a single capture or match function, providing an application with Ëœorâ„¢ and Ëœandâ„¢, as well as Ëœbroadcastâ„¢ functions among them. The LPC2141/42/44/46/48 can count external events on one of the capture inputs if the minimum external pulse is equal or longer than a period of the PCLK. In this configuration, unused capture lines can be selected as regular timer capture inputs, or used as external interrupts.

Watchdog Timer
The purpose of the watchdog is to reset the microcontroller within a reasonable amount of time if it enters an erroneous state. When enabled, the watchdog will generate a system reset if the user program fails to Ëœfeedâ„¢ (or reload) the watchdog within a predetermined amount of time.
Real Time Clock:
The RTC is designed to provide a set of counters to measure time when normal or idle operating mode is selected. The RTC has been designed to use little power, making it suitable for battery powered systems where the CPU is not running continuously (Idle mode).
Pulse width modulator
The PWM is based on the standard timer block and inherits all of its features, although only the PWM function is pinned out on the LPC2141/42/44/46/48. The timer is designed to count cycles of the peripheral clock (PCLK) and optionally generate interrupts or perform other actions when specified timer values occur, based on seven match registers. The PWM function is also based on match register events.

The ability to separately control rising and falling edge locations allows the PWM to be used for more applications. For instance, multi-phase motor control typically requires three non-overlapping PWM outputs with individual control of all three pulse widths and positions.

Two match registers can be used to provide a single edge controlled PWM output. One match register (MR0) controls the PWM cycle rate, by resetting the count upon match. The other match register controls the PWM edge position. Additional single edge controlled PWM outputs require only one match register each, since the repetition rate is the same for all PWM outputs. Multiple single edge controlled PWM outputs will all have a rising edge at the beginning of each PWM cycle, when an MR0 match occurs.

Three match registers can be used to provide a PWM output with both edges controlled. Again, the MR0 match register controls the PWM cycle rate. The other match registers control the two PWM edge positions. Additional double edge controlled PWM outputs require only two matches registers each, since the repetition rate is the same for all PWM outputs. With double edge controlled PWM outputs, specific match registers control the rising and falling edge of the output. This allows both positive going PWM pulses (when the rising edge occurs prior to the falling edge), and negative going PWM pulses (when the falling edge occurs prior to the rising edge).

System Control

1. Crystal Oscillator:

On-chip integrated oscillator operates with external crystal in range of 1 MHz to 25 MHz. The oscillator output frequency is called fosc and the ARM processor clock frequency is referred to as CCLK for purposes of rate equations, etc. fosc and CCLK are the same value unless the PLL is running and connected.
2. PLL:
The PLL accepts an input clock frequency in the range of 10 MHz to 25 MHz. The input frequency is multiplied up into the range of 10 MHz to 60 MHz with a Current Controlled Oscillator (CCO). The multiplier can be an integer value from 1 to 32 (in practice, the multiplier value cannot be higher than 6 on this family of microcontrollers due to the upper frequency limit of the CPU). The CCO operates in the range of 156 MHz to 320 MHz, so there is an additional divider in the loop to keep the CCO within its frequency range while the PLL is providing the desired output frequency. The output divider may be set to divide by 2, 4, 8, or 16 to produce the output clock. Since the minimum output divider value is 2, it is insured that the PLL output has a 50 % duty cycle. The PLL is turned off and bypassed following a chip reset and may be enabled by software. The program must configure and activate the PLL, wait for the PLL to Lock, then connect to the PLL as a clock source. The PLL settling time is 100 ms.

3. Reset and Wake up Timer:

Reset has two sources on the LPC2141/42/44/46/48: the RESET pin and watchdog reset. The RESET pin is a Schmitt trigger input pin with an additional glitch filter. Assertion of chip reset by any source starts the Wake-up Timer (see Wake-up Timer description below), causing the internal chip reset to remain asserted until the external reset is de-asserted, the oscillator is running, a fixed number of clocks have passed, and the on-chip flash controller has completed its initialization.

When the internal reset is removed, the processor begins executing at address 0, which is the reset vector. At that point, all of the processor and peripheral registers have been initialized to predetermined values.

The Wake-up Timer ensures that the oscillator and other analog functions required for chip operation are fully functional before the processor is allowed to execute instructions. This is important at power on, all types of reset, and whenever any of the aforementioned functions are turned off for any reason. Since the oscillator and other functions are turned off during Power-down mode, any wake-up of the processor from Power-down mode makes use of the Wake-up Timer.

The Wake-up Timer monitors the crystal oscillator as the means of checking whether it is safe to begin code execution. When power is applied to the chip, or some event caused the chip to exit Power-down mode, some time is required for the oscillator to produce a signal of sufficient amplitude to drive the clock logic. The amount of time depends on many factors, including the rate of VDD ramp (in the case of power on), the type of crystal and its electrical characteristics (if a quartz crystal is used), as well as any other external circuitry (e.g. capacitors), and the characteristics of the oscillator itself under the existing ambient conditions.

4. Brown out Detector

The LPC2141/42/44/46/48 includes 2-stage monitoring of the voltage on the VDD pins. If this voltage falls below 2.9 V, the BOD asserts an interrupt signal to the VIC. This signal can be enabled for interrupt; if not, software can monitor the signal by reading dedicated register.

The second stage of low voltage detection asserts reset to inactivate the LPC2141/42/44/46/48 when the voltage on the VDD pins falls below 2.6 V. This reset prevents alteration of the flash as operation of the various elements of the chip would otherwise become unreliable due to low voltage. The BOD circuit maintains this reset down below 1 V, at which point the POR circuitry maintains the overall reset.
Both the 2.9 V and 2.6 V thresholds include some hysteresis. In normal operation, this hysteresis allows the 2.9 V detection to reliably interrupt, or a regularly-executed event loop to sense the condition.

5. Code Security

This feature of the LPC2141/42/44/46/48 allows an application to control whether it can be debugged or protected from observation. If after reset on-chip boot loader detects a valid checksum in flash and reads 0x8765 4321 from address 0x1FC in flash, debugging will be disabled and thus the code in flash will be protected from observation. Once debugging is disabled, it can be enabled only by performing a full chip erase using the ISP.

6. External Interrupt Inputs:


The LPC2141/42/44/46/48 include up to nine edge or level sensitive External Interrupt Inputs as selectable pin functions. When the pins are combined, external events can be processed as four independent interrupt signals. The External Interrupt Inputs can optionally be used to wake-up the processor from Power-down mode. Additionally capture input pins can also be used as external interrupts without the option to wake the device up from Power-down mode.

7. Memory Mapping Control

The Memory Mapping Control alters the mapping of the interrupt vectors that appear beginning at address 0x0000 0000. Vectors may be mapped to the bottom of the on-chip flash memory, or to the on-chip static RAM. This allows code running in different memory spaces to have control of the interrupts.

8. Power Control


The LPC2141/42/44/46/48 supports two reduced power modes: Idle mode and
Power-down mode.

In Idle mode, execution of instructions is suspended until either a reset or interrupt occurs. Peripheral functions continue operation during idle mode and may generate interrupts to cause the processor to resume execution. Idle mode eliminates power used by the processor itself, memory systems and related controllers, and internal buses.
In Power-down mode, the oscillator is shut down and the chip receives no internal clocks. The processor state and registers, peripheral registers, and internal SRAM values are preserved throughout Power-down mode and the logic levels of chip output pins remain static. The Power-down mode can be terminated and normal operation resumed by either a reset or certain specific interrupts that are able to function without clocks. Since all dynamic operation of the chip is suspended, Power-down mode reduces chip power consumption to nearly zero. Selecting an external 32 kHz clock instead of the PCLK as a clock-source for the on-chip RTC will enable the microcontroller to have the RTC active during Power-down mode. Power-down current is increased with RTC active. However, it is significantly lower than in Idle mode. A Power Control for Peripherals feature allows individual peripherals to be turned off if they are not needed in the application, resulting in additional power savings during active and Idle mode.
9. VPB BUS:


The VPB divider determines the relationship between the processor clock (CCLK) and the clock used by peripheral devices (PCLK). The VPB divider serves two purposes. The first is to provide peripherals with the desired PCLK via VPB bus so that they can operate at the speed chosen for the ARM processor. In order to achieve this, the VPB bus may be slowed down to 1¤2 to 1¤4 of the processor clock rate. Because the VPB bus must work properly at power-up (and its timing cannot be altered if it does not work since the VPB divider control registers reside on the VPB bus), the default condition at reset is for the VPB bus to run at 1¤4 of the processor clock rate. The second purpose of the VPB divider is to allow power savings when an application does not require any peripherals to run at the full processor rate. Because the VPB divider is connected to the PLL output, the PLL remains active (if it was running) during Idle mode.
10. Emulation and Debugging:

The LPC2141/42/44/46/48 support emulation and debugging via a JTAG serial port. A trace port allows tracing program execution. Debugging and trace functions are multiplexed only with GPIOs on Port 1. This means that all communication, timer and interface peripherals residing on Port0 are available during the development and debugging phase as they are when the application is run in the embedded system
11. Embedded ICE

Standard ARM Embedded ICE logic provides on-chip debug support. The debugging of the target system requires a host computer running the debugger software and an Embedded ICE protocol converter. Embedded ICE protocol converter converts the remote debug protocol commands to the JTAG data needed to access the ARM core.

The ARM core has a Debug Communication Channel (DCC) function built-in. The DCC allows a program running on the target to communicate with the host debugger or another separate host without stopping the program flow or even entering the debug state. The DCC is accessed as a co-processor 14 by the program running on the ARM7TDMI-S core. The DCC allows the JTAG port to be used for sending and receiving data without affecting the normal program flow. The DCC data and control registers are mapped in to addresses in the Embedded ICE logic.

12. Embedded Trace:


Since the LPC2141/42/44/46/48 have significant amounts of on-chip memory, it is not possible to determine how the processor core is operating simply by observing the external pins. The Embedded Trace Macro cell (ETM) provides real-time trace capability for deeply embedded processor cores. It outputs information about processor execution to the trace port. The ETM is connected directly to the ARM core and not to the main AMBA system bus. It compresses the trace information and exports it through a narrow trace port. An external trace port analyzer must capture the trace information under software debugger control. Instruction trace (or PC trace) shows the flow of execution of the processor and provides a list of all the instructions that were executed. Instruction trace is significantly compressed by only broadcasting branch addresses as well as a set of status signals that indicate the pipeline status on a cycle by cycle basis. Trace information generation can be controlled by selecting the trigger resource. Trigger resources include address comparators, counters and sequencers. Since trace information is compressed the software debugger requires a static image of the code being executed. Self-modifying code can not be traced because of this restriction.

13. Real Monitor:

Real Monitor is a configurable software module, developed by ARM Inc., which enables real-time debug. It is a lightweight debug monitor that runs in the background while users debug their foreground application. It communicates with the host using the DCC, which is present in the Embedded ICE logic. The LPC2141/42/44/46/48 contains a specific configuration of Real Monitor software programmed into the on-chip flash memory



CHAPTER 4

RFID, RELAY & LCD

RFID MODULE

Radio frequency identification is a powerful emerging technology that enables companies to achieve total business visibility. By knowing the identity, location and conditions of assets, tools, inventory, people and more, companies can optimize business processes and reduce operational costs. Radio frequency identification (RFID) is a generic term that is used to describe a system that transmits the identity (in the form of a unique serial number) of an object or person wirelessly, using radio waves.

RFID reader module, are also called as interrogators. They convert radio waves returned form the RFID tag into a form that can be pressed on to controllers, which can make use of it. RFID tags and readers have to be tuned to the same frequency in order to communicate. RFID systems use many different frequencies, but the most common and widely used and supported by our Reader 125 KHz.

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


RFID READER

RFID TAG

COMPONENTS:


A basic RFID system consists of three components:

¢ An antenna or coil
¢ A transceiver (with decoder)
¢ A transponder (RF tag) electronically programmed with unique information.

The antenna emits radio signals to activate the tag and read and write data to it. Antennas are available in a variety of shapes and sizes; they can be built into a doorframe to receive tag data from persons or things passing through the door, or mounted on an interstate tollbooth to monitor traffic passing by on a freeway. Antennas can also be mounted on mobile devices and under print heads.


Transceiver:
Often the antenna is packaged with the transceiver and decoder to become a reader (a.k.a. interrogator), which can be configured either as a handheld or a fixed-mount device. The reader emits radio waves in ranges of anywhere from one inch to 100 feet or more, depending upon its power output and the radio frequency used. When an RFID tag passes through the electromagnetic zone, it detects the readerâ„¢s activation signal. The reader decodes the data encoded in the tagâ„¢s integrated circuit (silicon chip) and the data is passed to the host computer for processing.


The purpose of an RFID system is to enable data to be transmitted by a portable device, called a tag, which is read by an RFID reader and processed according to the needs of a particular application. The data transmitted by the tag may provide identification or location information, or specifics about the product tagged, such as price, color, date of purchase, etc. RFID technology has been used by thousands of companies for a decade or more. . RFID quickly gained attention because of its ability to track moving objects. As the technology is refined, more pervasive - and invasive - uses for RFID tags are in the works.
A typical RFID tag consists of a microchip attached to a radio antenna mounted on a substrate. The chip can store as much as 2 kilobytes of data.

To retrieve the data stored on an RFID tag, you need a reader. A typical reader is a device that has one or more antennas that emit radio waves and receive signals back from the tag. The reader then passes the information in digital form to a computer system.

More About Antennas

Antennas are the conduits between the tag and the transceiver, which controls the system's data acquisition and communication. Antennas are available in a variety of shapes and sizes; they can be built into a door frame to receive tag data from persons or things passing through the door, or mounted on an interstate toll booth to monitor traffic passing by on a freeway. The electromagnetic field produced by an antenna can be constantly present when multiple tags are expected continually. If constant interrogation is not required, the field can be activated by a sensor device.
Often the antenna is packaged with the transceiver and decoder to become a reader (a.k.a. interrogator), which can be configured either as a handheld or a fixed-mount device.
RFID Tags
RFID tags come in a wide variety of shapes and sizes. Animal tracking tags, inserted beneath the skin, can be as small as a pencil lead in diameter and one-half inch in length. Tags can be screw-shaped to identify trees or wooden items, or credit-card shaped for use in access applications. The anti-theft hard plastic tags attached to merchandise in stores are RFID tags. In addition, heavy-duty 5- by 4- by 2-inch rectangular transponders used to track intermodal containers or heavy machinery, trucks, and railroad cars for maintenance and tracking applications are RFID tags.

There are a variety of RFID tag types. Selecting the correct tag will be imperative to ensure a proper functioning system. Selecting the proper tag will be discussed later. Tags can be placed on wooden or plastic pallets, clothing, embedded into traditional barcode labels, animals, metal surfaces, and much more.

A tag is comprised of:

¢ Silicon chip: Integrated circuit (IC chip) that contains the data.
¢ Antenna: An antenna is attached to the chip in order to receive and transmit its data.
¢ Substrate: This is the paper or plastic film or housing that the chip and antenna are mounted on.

The data associated with a tag is programmed into the chip. The tag is placed on merchandise and is activated and read when it is energized by the reader and antenna system.

The IC contains an actual microchip where data is stored. Chips are available in many sizes and configurations. They can be extremely small to be incorporated into small form factor RFID tags. The chips' capability to carry data and have that data amended is defined by their Read/Write characteristics.

An RFID tag can take on many form factors and power levels. The unique identifier is encoded onto the integrated circuit and travels with this data. The data on the RFID IC is transmitted to a reader through the antenna incorporated onto the tag. RFID tags can be as tiny as an ant's head, larger than the palm of an adult hand, or any size in between. The form factor that the RFID tag takes is dictated by factors including power, durability, and lifetime requirements. Tag characteristics are defined by the application, and can vary in power requirements, read/write capability, and frequency. RFID tags are developed using a frequency according to the needs of the system including read range and the environment in which the tag will be read.

Active or Passive RFID ¦

RFID tags are categorized as either active or passive. Active RFID tags are powered by an internal battery and are typically read/write, i.e., tag data can be rewritten and/or modified. An active tag's memory size varies according to application requirements; some systems operate with up to 1MB of memory. In a typical read/write RFID work-in-process system, a tag might give a machine a set of instructions, and the machine would then report its performance to the tag. This encoded data would then become part of the tagged part's history. The battery-supplied power of an active tag generally gives it a longer read range. The trade off is greater size, greater cost, and a limited operational life (which may yield a maximum of 10 years, depending upon operating temperatures and battery type).
Passive RFID tags operate without a separate external power source and obtain operating power generated from the reader. Passive tags are consequently much lighter than active tags, less expensive, and offer a virtually unlimited operational lifetime. The trade off is that they have shorter read ranges than active tags and require a higher-powered reader. Read-only tags are typically passive and are programmed with a unique set of data (usually 32 to 128 bits) that cannot be modified. Read-only tags most often operate as a license plate into a database, in the same way as linear barcodes reference a database containing modifiable product-specific information.
Frequencies
RFID systems are also distinguished by their frequency ranges.
¢ Low-frequency or LF (30 KHz to 500 KHz) systems have short reading ranges and lower system costs. They are most commonly used in security access, asset tracking, and animal identification applications.
¢ High-frequency or HF (850 MHz to 950 MHz and 2.4 GHz to 2.5 GHz) systems, offering long read ranges (greater than 90 feet) and high reading speeds, are used for such applications as railroad car tracking and automated toll collection. However, the higher performance of high-frequency RFID systems incurs higher system costs.
¢ Ultra high frequency or UHF
Advantages
The significant advantage of all types of RFID systems is the noncontact, non-line-of-sight nature of the technology. Tags can be read through a variety of substances such as snow, fog, ice, paint, crusted grime, and other visually and environmentally challenging conditions, where bar codes or other optically read technologies would be useless. RFID tags can also be read in challenging circumstances at remarkable speeds, in most cases responding in less than 100 milliseconds. The read/write capability of an active RFID system is also a significant advantage in interactive applications such as work-in-process or maintenance tracking. Though it is a costlier technology (compared with bar code), RFID has become indispensable for a wide range of automated data collection and identification applications that would not be possible otherwise.
Developments in RFID technology continue to yield larger memory capacities, wider reading ranges, and faster processing. It is highly unlikely that the technology will ultimately replace bar code ” even with the inevitable reduction in raw materials coupled with economies of scale, the integrated circuit in an RF tag will never be as cost-effective as a barcode label. However, RFID will continue to grow in its established niches where bar code or other optical technologies are not effective.

Inventory efficiency - Because line of sight is not required to read RFID tags, inventory can be performed in a highly efficient method. For example, pallets in a warehouse can be read, inventoried, and their location can be determined no matter where the tag is placed on the pallet. This is because the radio waves from the reader are strong enough for the tag to respond regardless of location.

Return on investment - Though the cost may be high at first, the total cost of ownership should go down over the years and provide a return on investment (ROI), if the implementation provides a significant method to improve business processes.
Vulnerability to damage minimized - barcodes can be damaged in many ways. Although, 2D barcode types such as Data Matrix can be read even when up to 40% of the barcode is damaged.




Relay

A relay is an electrical switch that opens and closes under the control of another electrical circuit. In the original form, the switch is operated by an electromagnet to open or close one or many sets of contacts. Because a relay is able to control an output circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier.
Small relay as used in electronics
A simple electromagnetic relay, such as the one taken from a car in the first picture, is an adaptation of an electromagnet. It consists of a coil of wire surrounding a soft iron core, an iron yoke, which provides a low reluctance path for magnetic flux, a moveable iron armature, and a set, or sets, of contacts; two in the relay pictured. The armature is hinged to the yoke and mechanically linked to a moving contact or contacts. It is held in place by a spring so that when the relay is de-energised there is an air gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay pictured is closed, and the other set is open. Other relays may have more or fewer sets of contacts depending on their function. The relay in the picture also has a wire connecting the armature to the yoke. This ensures continuity of the circuit between the moving contacts on the armature, and the circuit track on the Printed Circuit Board (PCB) via the yoke, which is soldered to the PCB.
When an electric current is passed through the coil, the resulting magnetic field attracts the armature, and the consequent movement of the movable contact or contacts either makes or breaks a connection with a fixed contact. If the set of contacts was closed when the relay was de-energised, then the movement opens the contacts and breaks the connection, and vice versa if the contacts were open. When the current to the coil is switched off, the armature is returned by a force, approximately half as strong as the magnetic force, to its relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in industrial motor starters. Most relays are manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high current application, this is to reduce arcing.
If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage spike dangerous to circuit components. Some automotive relays already include that diode inside the relay case. Alternatively a contact protection network, consisting of a capacitor and resistor in series, may absorb the surge. If the coil is designed to be energized with AC, a small copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the minimum pull on the armature during the AC cycle.[1]
By analogy with the functions of the original electromagnetic device, a solid-state relay is made with a thyristor or other solid-state switching device. To achieve electrical isolation an optocoupler can be used which is a light-emitting diode (LED) coupled with a photo transistor.



Types of relay
¢ Latching relay

A latching relay has two relaxed states (bistable). These are also called 'keep' or 'stay' relays. When the current is switched off, the relay remains in its last state. This is achieved with a solenoid operating a ratchet and cam mechanism, or by having two opposing coils with an over-center spring or permanent magnet to hold the armature and contacts in position while the coil is relaxed, or with a remnant core. In the ratchet and cam example, the first pulse to the coil turns the relay on and the second pulse turns it off. In the two coil example, a pulse to one coil turns the relay on and a pulse to the opposite coil turns the relay off. This type of relay has the advantage that it consumes power only for an instant, while it is being switched, and it retains its last setting across a power outage.
¢ Reed relay
A reed relay has a set of contacts inside a vacuum or inert gas filled glass tube, which protects the contacts against atmospheric corrosion. The contacts are closed by a magnetic field generated when current passes through a coil around the glass tube. Reed relays are capable of faster switching speeds than larger types of relays, but have low switch current and voltage ratings. See also reed switch.
¢ Mercury-wetted relay

A mercury-wetted reed relay is a form of reed relay in which the contacts are wetted with mercury. Such relays are used to switch low-voltage signals (one volt or less) because of its low contact resistance, or for high-speed counting and timing applications where the mercury eliminates contact bounce. Mercury wetted relays are position-sensitive and must be mounted vertically to work properly. Because of the toxicity and expense of liquid mercury, these relays are rarely specified for new equipment. See also mercury switch.
¢ Polarized relay

A Polarized Relay placed the armature between the poles of a permanent magnet to increase sensitivity. Polarized relays were used in middle 20th Century telephone exchanges to detect faint pulses and correct telegraphic distortion. The poles were on screws, so a technician could first adjust them for maximum sensitivity and then apply a bias spring to set the critical current that would operate the relay.
¢ Machine tool relay

A machine tool relay is a type standardized for industrial control of machine tools, transfer machines, and other sequential control. They are characterized by a large number of contacts (sometimes extendable in the field) which are easily converted from normally-open to normally-closed status, easily replaceable coils, and a form factor that allows compactly installing many relays in a control panel. Although such relays once were the backbone of automation in such industries as automobile assembly, the programmable logic controller (PLC) mostly displaced the machine tool relay from sequential control applications.
¢ Contactor relay

A contactor is a very heavy-duty relay used for switching electric motors and lighting loads. High-current contacts are made with alloys containing silver. The unavoidable arcing causes the contacts to oxidize and silver oxide is still a good conductor. Such devices are often used for motor starters. A motor starter is a contactor with overload protection devices attached. The overload sensing devices are a form of heat operated relay where a coil heats a bi-metal strip, or where a solder pot melts, releasing a spring to operate auxiliary contacts. These auxiliary contacts are in series with the coil. If the overload senses excess current in the load, the coil is de-energized. Contactor relays can be extremely loud to operate, making them unfit for use where noise is a chief concern.
¢ Solid-state relay

Solid state relay, which has no moving parts 25 amp or 40 amp solid state contactors
A solid state relay (SSR) is a solid state electronic component that provides a similar function to an electromechanical relay but does not have any moving components, increasing long-term reliability. With early SSR's, the tradeoff came from the fact that every transistor has a small voltage drop across it. This voltage drop limited the amount of current a given SSR could handle. As transistors improved, higher current SSR's, able to handle 100 to 1,200 amps, have become commercially available. Compared to electromagnetic relays, they may be falsely triggered by transients.
¢ Solid state contactor relay

A solid state contactor is a very heavy-duty solid state relay, including the necessary heat sink, used for switching electric heaters, small electric motors and lighting loads; where frequent on/off cycles are required. There are no moving parts to wear out and there is no contact bounce due to vibration. They are activated by AC control signals or DC control signals from Programmable logic controller (PLCs), PCs, Transistor-transistor logic (TTL) sources, or other microprocessor controls.
¢ Buchholz relay

A Buchholz relay is a safety device sensing the accumulation of gas in large oil-filled transformers, which will alarm on slow accumulation of gas or shut down the transformer if gas is produced rapidly in the transformer oil.
¢ Forced-guided contacts relay

A forced-guided contacts relay has relay contacts that are mechanically linked together, so that when the relay coil is energized or de-energized, all of the linked contacts move together. If one set of contacts in the relay becomes immobilized, no other contact of the same relay will be able to move. The function of forced-guided contacts is to enable the safety circuit to check the status of the relay. Forced-guided contacts are also known as "positive-guided contacts", "captive contacts", "locked contacts", or "safety relays".
¢ Overload protection relay

One type of electric motor overload protection relay is operated by a heating element in series with the electric motor . The heat generated by the motor current operates a bi-metal strip or melts solder, releasing a spring to operate contacts. Where the overload relay is exposed to the same environment as the motor, a useful though crude compensation for motor ambient temperature is provided.


LCD INTERFACING

Introduction

The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other which are compatible with HD44580. In this tutorial, we will discuss about character based LCDs, their interfacing with various microcontrollers, various interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with these simple looking LCDs which can give a new look to your application.

Pin Description

The most commonly used LCDâ„¢s found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 characters, whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers.

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are extra in both for back-light LED connections). Pin description is shown in the table below.

Pin No. Name Description
Pin no. 1 VSS Power supply (GND)
Pin no. 2 VCC Power supply (+5V)
Pin no. 3 VEE Contrast adjust
Pin no. 4 RS 0 = Instruction input
1 = Data input
Pin no. 5 R/W 0 = Write to LCD module
1 = Read from LCD module
Pin no. 6 EN Enable signal
Pin no. 7 D0 Data bus line 0 (LSB)
Pin no. 8 D1 Data bus line 1
Pin no. 9 D2 Data bus line 2
Pin no. 10 D3 Data bus line 3
Pin no. 11 D4 Data bus line 4
Pin no. 12 D5 Data bus line 5
Pin no. 13 D6 Data bus line 6
Pin no. 14 D7 Data bus line 7 (MSB)

DDRAM - Display Data RAM

Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that is not used for display can be used as general data RAM. So whatever you send on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only 16 characters are visible, so whatever you write after 16 chars is written in DDRAM but is not visible to the user.

CGROM - Character Generator ROM

Now you might be thinking that when you send an ASCII value to DDRAM, how the character is displayed on LCD So the answer is CGROM. The character generator ROM generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes (see Figure 5 and Figure 6 for more details). It can generate 208 5 x 8 dot character patterns and 32 5 x 10 dot character patterns. User defined character patterns are also available by mask-programmed ROM.

As you can see in both the code maps, the character code from 0x00 to 0x07 is occupied by the CGRAM characters or the user defined characters. If user wants to display the fourth custom character then the code to display it is 0x03 i.e. when user sends 0x03 code to the LCD DDRAM then the fourth user created character or pattern will be displayed on the LCD.
CGRAM - Character Generator RAM

As clear from the name, CGRAM area is used to create custom characters in LCD. In the character generator RAM, the user can rewrite character patterns by program. For 5 x 8 dots, eight character patterns can be written, and for 5 x 10 dots, four character patterns can be written.

BF - Busy Flag

Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount of delay for the LCD processing.

To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will not accept next command or data and BF = 0 means LCD is ready for the next command or data to process.

Instruction Register (IR) and Data Register (DR)

There are two 8-bit registers in HD44780 controller Instruction and Data register. Instruction register corresponds to the register where you send commands to LCD e.g. LCD shift command, LCD clear, LCD address etc. and Data register is used for storing data which is to be displayed on LCD. When send the enable signal of the LCD is asserted, the data on the pins is latched in to the data register and data is then moved automatically to the DDRAM and hence is displayed on the LCD.
Data Register is not only used for sending data to DDRAM but also for CGRAM, the address where you want to send the data, is decided by the instruction you send to LCD.

4-bit programming of LCD

In 4-bit mode the data is sent in nibbles, first we send the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to follow special sequence of initialization that tells the LCD controller that user has selected 4-bit mode of operation. We call this special sequence as resetting the LCD. Following is the reset sequence of LCD.
Wait for about 20mS
Send the first init value (0x30)
Wait for about 10mS
Send second init value (0x30)
Wait for about 1mS
Send third init value (0x30)
Wait for 1mS
Select bus width (0x30 - for 8-bit and 0x20 for 4-bit)
Wait for 1mS

The busy flag will only be valid after the above reset sequence. Usually we do not use busy flag in 4-bit mode as we have to write code for reading two nibbles from the LCD. Instead we simply put a certain amount of delay usually 300 to 600uS. This delay might vary depending on the LCD you are using, as you might have a different crystal frequency on which LCD controller is running. So it actually depends on the LCD module you are using.

In 4-bit mode, we only need 6 pins to interface an LCD. D4-D7 are the data pins connection and Enable and Register select are for LCD control pins. We are not using Read/Write (RW) Pin of the LCD, as we are only writing on the LCD so we have made it grounded permanently. If you want to use it, then you may connect it on your controller but that will only increase another pin and does not make any big difference. Potentiometer RV1 is used to control the LCD contrast. The unwanted data pins of LCD i.e. D0-D3 are connected to ground.

Sending data/command in 4-bit Mode
We will now look into the common steps to send data/command to LCD when working in 4-bit mode. In 4-bit mode data is sent nibble by nibble, first we send higher nibble and then lower nibble. This means in both command and data sending function we need to separate the higher 4-bits and lower 4-bits.

The common steps are:

Mask lower 4-bits
Send to the LCD port
Send enable signal
Mask higher 4-bits
Send to LCD port
Send enable signal

CHAPTER 5
WORKING FLOW
BLOCK DIAGRAM:


BLOCK DAIGRAM EXPLANATION:

Mainly the block diagram consists of following parts:

¢ Power supply circuit
¢ ARM controller
¢ RFID Module
¢ Relay
¢ LCD

This project Robust and efficient password authenticated key agreement using smart card for campus management will give the best and security solution for entry of authenticated people into restricted and security areas. This project will consists of RFID module(Tag as well as the reader ), keypad, and ARM7 based microcontroller module. i.e., LPC2148. The students are given with unique RFID tag. And at the time of issuing the tag person details will be added to the database of the LPC2148 microcontroller which is stored in its flash memory.
Whenever the person wants to enter the campus he has to put the tag at the entrance of the campus. RFID reader which is connected to the microcontroller module will read the data and gives the information to the microcontroller module. After that using the keypad the person has to enter the password provided to him. Then microcontroller module will compare the passwords of the person entered with the password of the this person which is stored in its data base. If he is authenticated to enter in to the campus then the gate will be open which is demonstrated here with glowing of LED for authenticated persons.

Hardware & Schematic:-

REGULATED POWER SUPPLY

A variable regulated power supply, also called a variable bench power supply, is one where you can continuously adjust the output voltage to your requirements. Varying the output of the power supply is the recommended way to test a project after having double checked parts placement against circuit drawings and the parts placement guide.
This type of regulation is ideal for having a simple variable bench power supply. Actually this is quite important because one of the first projects a hobbyist should undertake is the construction of a variable regulated power supply. While a dedicated supply is quite handy ,it's much handier to have a variable supply on hand, especially for testing.
Mainly the ARM controller needs 3.3 volt power supply. To use these parts we need to build a regulated 3.3 volt source. Usually you start with an unregulated power To make a 3.3 volt power supply, we use a LM317 voltage regulator IC (Integrated Circuit). The IC is shown below.

.

CIRCUIT FEATURES:-

Vout range 1.25V - 37V
Vin - Vout difference 3V - 40V
Operation ambient temperature 0 - 125°C
Output Imax <1.5A
Minimum Load Currentmax 10mA

A current-limiting circuit constructed with LM317


Part pinout of LM317 showing its constant voltage reference
LM317 is the standard part number for an integrated three-terminal adjustable linear voltage regulator. LM317 is a positive voltage regulator supporting input voltage of 3V to 40V and output voltage between 1.25V and 37V. A typical current rating is 1.5A although several lower and higher current models are available. Variable output voltage is achieved by using a potentiometer or a variable voltage from another source to apply a control voltage to the control terminal. LM317 also has a built-in current limiter to prevent the output current from exceeding the rated current, and LM317 will automatically reduce its output current if an overheat condition occurs under load. LM317 is manufactured by many companies, including National Semiconductor, Fairchild Semiconductor, and STMicroelectronics.
Although LM317 is an adjustable regulator, it is sometimes preferred for high-precision fixed voltage applications instead of the similar LM78xx devices because the LM317 is designed with superior output tolerances. For a fixed voltage application, the control pin will typically be biased with a fixed resistor network, a Zener diode network, or a fixed control voltage from another source. Manufacturer datasheets provide standard configurations for achieving various design applications, including the use of a pass transistor to achieve regulated output currents in excess of what the LM317 alone can provide.
LM317 is available in a wide range of package forms for different applications including heat sink mounting and surface-mount applications. Common form factors for high-current applications include TO-220 and TO-3. LM317 is capable of dissipating a large amount of heat at medium to high current loads and the use of a heat sink is recommended to maximize the lifespan and power-handling capability.
LM337 is the negative voltage complement to LM317 and the specifications and function are essentially identical, except that the regulator must receive a control voltage and act on an input voltage that are below the ground reference point instead of above it.

BLOCK DIAGRAM

WE CAN EVEN USE A USB CONNECTOR FOR THE REQUIRED SUPPLY INSTEAD OF THE ABOVE CIRCUIT
CHAPTER 6
SOURCE CODE
Code:
#include <LPC21xx.h>
#include <string.h>
#include "lcd.h"
#include "uart.h"
#include "switch.h"

int admin_mode(void);
int user_mode(void);
int compare(unsigned char *);
int receive_char (void);
unsigned char value[5][12];
int main()
{
    unsigned char sw;
    unsigned char *str1="RFID based";
    unsigned char *str2="Campus Managemnt";
unsigned char *str3="Invalid option";
    int i;

    lcd_init();
    init_serial0();
    init_serial1();

    lcd_clear();
    lcd_First_line();
    lcd_print(str1);
    lcd_next_line();
    lcd_print(str2);
    for(i=0;i<5;i++)
        delay();
    
    while(1)
    {
        sw = options();
        if(sw == 1)
            admin_mode();
        
        else if(sw == 2)
            user_mode();

        else        
        {
            lcd_clear();
            lcd_First_line();
            lcd_print(str3);
            delay();
            delay();
            lcd_clear();
            lcd_First_line();
            lcd_print(str1);
            lcd_next_line();
            lcd_print(str2);
            delay();
            delay();
            delay();
        }
            
    }
            
}
int admin_mode(void)
{
    int i,j,x,z;
    unsigned char *str0 = " Enter";
    unsigned char *str1 = "card bar code:";
    unsigned char *str2 = "Continue ";
    unsigned char *str3 = " 1.yes 2.No";
    unsigned char *str9 = "ur option :";
    unsigned char sw = 0x01;
    
    
    for(i=0;i<5;i++)
        delay();
    Receive_Pwd();
    x = Check_Pwd();
    delay();
    delay();    
    if(x == 1)
        return 1;
    else if(x == 0)
    {
            
    
            for(i=0;((i<5) && (sw == 1));i++)
            {
                lcd_clear();
                lcd_First_line();
                lcd_print(str0);
                lcd_next_line();
                lcd_print(str1);
    
                for(z=0;z<5;z++)
                    delay();
                
                if(i>0)
                {
                    while(!(U0LSR & 0x01));
                        value[i][j]=U0RBR;
                    for(j=0;j<10;j++)
                    {
                        while(!(U0LSR & 0x01));
                        value[i][j]=U0RBR;
                    }
                }
                else if(i == 0)
                {
                     for(j=0;j<10;j++)
                    {
                        while(!(U0LSR & 0x01));
                        value[i][j]=U0RBR;
                    }
                }
                value[i][j]='\0';

                 lcd_clear();
                lcd_First_line();
                lcd_print(value[i]);
         
                for(z=0;z<10;z++)
                    delay();

                lcd_clear();
                lcd_First_line();
                lcd_print(str2);
                lcd_next_line();
                lcd_print(str3);
                
                for(z=0;z<20;z++)
                    delay();
                
                lcd_clear();
                lcd_First_line();
                lcd_print(str9);    
                sw = get_option();
                
                for(z=0;z<10;z++)
                    delay();
                
            
            }
    }
    return 0;
}
                        
int user_mode(void)
{
    int x;
    unsigned char c;
    while(!(U0LSR & 0x01));
    c = U0RBR;
    x = receive_char();
    if(x == 1)
        return 1;
    return 0;
}

int compare(unsigned char *string)
{
    unsigned char *str0 = "Accepted";
    unsigned char *str1 = "Denied";
    unsigned int z = 0;
    int i;

    for(i=0;i<5;i++)
    {
        if(!(strcmp((const char *)string,(const char *)value[i])))
            z = 1;
    }
    if(z == 1)
    {
        lcd_clear();
        lcd_First_line();
        lcd_print(str0);
        for(i=0;i<10;i++)
            delay();
        return 0;
    }
    else
    {
        lcd_clear();
        lcd_First_line();
        lcd_print(str1);
        for(i=0;i<10;i++)
            delay();
        return 1;
    }
}
int receive_char (void)
{
    int i,x;
    unsigned char value[11];
    unsigned char *str0 = " Enter";
    unsigned char *str1 = "card bar code:";
    unsigned char *str2 = "wrong PWD";
    unsigned char *string;
    
    
    IO0DIR |= 0x00000800;
    IO0SET |= 0x00000800;
             
    string = value;
    lcd_clear();
    lcd_First_line();
    lcd_print(str0);
    lcd_next_line();
    lcd_print(str1);
    for(i=0;i<20;i++)
        delay();
    for(i=0;i<10;i++)
    {
        while(!(U0LSR & 0x01));
        value[i]=U0RBR;

    }
    value[i]='\0';
    
    lcd_clear();
    lcd_First_line();
    lcd_print(value);     

    lcd_clear();
    lcd_First_line();
            
    x = compare(string);
    
    if(x == 0)
    {
        Receive_Pwd();
        x = Check_Pwd();
        if(x == 1)
        {
            lcd_clear();
            lcd_First_line();
            lcd_print(str2);
            for(i=0;i<20;i++)
                delay();
            return 1;
        }
        IO0CLR |= 0x00000800;
        
        for(i=0;i<20;i++)
            delay();
        
        IO0SET |= 0x00000800;
    }
    else if(x == 1)
    {
        return 1;
    }
    return 0;        
}
/***************************************/
/* LCD routines for OLIMEX LPC-2148 */
/* 16x2 Character LCD 1602K */
/* 4-bit mode operation     */
/*Devoloped by NARESH & SURESH */
/***************************************/
/* DEFINE IOMASK */
#define LCD_D4 0x10 //P0.04     /*THESE DATA LINES ARE INITIALIZED TO PORT 0.4 TO 0.7 */
#define LCD_D5 0x20 //P0.05
#define LCD_D6 0x40 //P0.06
#define LCD_D7 0x80 //P0.07
#define LCD_EN 0x400000 //P0.22
#define LCD_RS 0x800000 //P0.23
/* RW PIN IS CONNECTED AS GROUND */

#define LCD_DATA (LCD_D4|LCD_D5|LCD_D6|LCD_D7)
#define LCD_IOALL (LCD_D4|LCD_D5|LCD_D6|LCD_D7|LCD_EN|LCD_RS)

#define LCD_GPIO_SEL0 0x000000F0 //MASK for P0.04-P0.07
#define LCD_GPIO_SEL1 0x00C00000 //MASK for P0.22-P0.24
/* Functions Header */
/* internal I/O functions */
#define lcd_rs_set() IO0SET |= LCD_RS
#define lcd_rs_clr() IO0CLR |= LCD_RS
#define lcd_en_set() IO0SET |= LCD_EN
#define lcd_en_clr() IO0CLR |= LCD_EN
/* wait until lcd controller is free */
void lcd_wait(void);
void lcd_out_data4(unsigned char);
void lcd_write_nibbles(unsigned char);
void lcd_write_control(unsigned char);

/* initialize both the GPIO of lpc and LCD */
void lcd_init(void);

#define lcd_clear() lcd_write_control(0x01)
#define lcd_cursor_home() lcd_write_control(0x02)

#define lcd_display_on() lcd_write_control(0x0E)
#define lcd_display_off() lcd_write_control(0x08)

#define lcd_cursor_blink() lcd_write_control(0x0F)
#define lcd_cursor_on() lcd_write_control(0x0E)
#define lcd_cursor_off() lcd_write_control(0x0C)

#define lcd_cursor_left() lcd_write_control(0x10)
#define lcd_cursor_right() lcd_write_control(0x14)
#define lcd_display_sleft() lcd_write_control(0x18)
#define lcd_display_sright() lcd_write_control(0x1C)
#define lcd_next_line() lcd_write_control(0xC0)    

#define lcd_First_line() lcd_write_control(0x80)     //Oct23
#define lcd_Second_line() lcd_write_control(0xC0)     //Oct23
/* put a character out to lcd */
void lcd_putchar(unsigned char);
/* print a string */
void lcd_print(unsigned char*);

/*TO PRINT DECIMAL ON LCD */
void lcd_dec(unsigned char);

void lcd_dec_nibble(unsigned char);
void lcd_dec_nibble1(unsigned char);
void lcd_dec_int(unsigned int num);

#define RSIR (*((volatile unsigned char *) 0xE01FC180))

void lcd_wait(void)
{
int loop=30000;

while(loop--);
}

void lcd_out_data4(unsigned char val)
{
IO0CLR |= (LCD_DATA);
IO0SET |= (val<<8);
}
void lcd_write_nibbles(unsigned char val)
{
     unsigned char temp;
     temp=val;
//higher-order byte
lcd_en_set();
lcd_out_data4((temp>>8)&0xF0);
lcd_en_clr();

lcd_wait();

//lower-order byte
lcd_en_set();
lcd_out_data4((val)&0xF0);
lcd_en_clr();

lcd_wait();
}

void lcd_write_control(unsigned char val){
lcd_rs_clr();
lcd_write_nibbles(val);
}

void lcd_init(void){

PINSEL0 &= (~LCD_GPIO_SEL0);
PINSEL1 &= (~LCD_GPIO_SEL1);
/* we only work on OUTPUT so far */
IO0DIR |= LCD_IOALL;

/* IO init complete, init LCD */

/* init 4-bit ops*/
lcd_rs_clr();
//lcd_rw_clr();
lcd_en_clr();
//wait VDD raise > 4.5V
lcd_wait();

//dummy inst


lcd_en_set();
lcd_out_data4(0x2);
lcd_en_clr();
lcd_wait();


lcd_write_nibbles(0x01);

lcd_write_nibbles(0x06);

}    

void lcd_putchar(unsigned char c)
{
lcd_rs_set();
lcd_write_nibbles(c);

}
void lcd_print(unsigned char *str){

    unsigned char ch;
    while(*str!='\0')
    {    ch=*str;
    lcd_putchar(ch);
        str++;
    }
}
void lcd_dec(unsigned char num)         /* TRANSFERS DECIMAL DATA TO LCD */
{            
    unsigned char x,d1,d2;
     x=num/10;
     d1=num%10;
     d2= x%10;

void lcd_dec_nibble(unsigned char num) {
                             
    unsigned char d1;
//     x=num/10;
     d1=num%10;
//     d2= x%10;

}

void lcd_dec_nibble1(unsigned char num) {
                             
    unsigned char d1,x,d2;
     x=num/10;
     d1=num%10;
     d2= x%10;
    
}

void lcd_dec_int(unsigned int num)         /* TRANSFERS DECIMAL DATA TO LCD */
{            
    unsigned char x,d1,d2;
     x=num/10;
     d1=num%10;
     d2= x%10;
    
}
unsigned char options(void);
void Receive_Pwd(void);
unsigned char get_option(void);
int Check_Pwd(void);

unsigned long Read_IOPin = 0x00;
unsigned char IO_Val = 0x00;
unsigned char Pswd[5];
//Gives the options......and receives the one option from user or admin
unsigned char options(void)
{
    unsigned char *str1 = "1.Administrator";
    unsigned char *str2 = "2.User";
    unsigned char *str3 = "Choose one mode";
    unsigned char *str4 = "option : ";
    unsigned char sw;
    int i;

    lcd_clear();
    lcd_First_line();
    lcd_print(str1);
    lcd_next_line();
    lcd_print(str2);
    for(i=0;i<20;i++)
        delay();

    lcd_clear();
    lcd_First_line();
    lcd_print(str3);
    lcd_next_line();
    lcd_print(str4);
    sw = get_option();
    delay();
    delay();
    return(sw);

}
void Receive_Pwd(void)
{
        
        unsigned int cnt = 0;
        unsigned char sw = 0x00;
        unsigned char i = 0x00;
        unsigned char *str1 = "Enter ur PWD:";

        lcd_clear();
        lcd_First_line();
        lcd_print(str1);
        lcd_next_line();
        
        
        for(cnt = 0; cnt < 3; cnt ++)
        {

        while( (IOPIN1 & 0x00010000) && (IOPIN1 & 0x00020000) && (IOPIN1 & 0x00040000) );
    
        Read_IOPin = IOPIN1;     
        IO_Val = ( (Read_IOPin >> 16) & 0x07);
        
        if(i > 2)
        {
            i = 0;
        }

        switch(IO_Val)
        {

            case 0x06:                      // p1.16 is pressed        
                Pswd[i++] = 0x06;
                delay();
                delay();
                delay();
                sw = 1;                     
                lcd_dec_nibble(sw);
                delay();
                delay();
                delay();
                break;

            case 0x05:                       // p1.17 is pressed
                Pswd[i++] = 0x05;
                delay();
                delay();
                delay();
                sw = 2;                     
                lcd_dec_nibble(sw);
             delay();
                delay();
                delay();
                break;

            case 0x03:                      //// p1.18 is pressed    
                Pswd[i++] = 0x03;
                delay();
                delay();
                delay();
                sw = 3;                     
                lcd_dec_nibble(sw);
                delay();
                delay();
                delay();
                break;
        }
    }
} // End of Receive_Pwd()...                
int Check_Pwd(void)
{

    unsigned char *str0 = "Accepted";
    unsigned char *str1 = "Wrong Pwd";

    if((Pswd[0] == 0x06) && (Pswd[1] == 0x05) && (Pswd[2] == 0x03) ) // Correct Password
    {        
        lcd_clear();
        lcd_First_line();
        lcd_print(str0);
        return 0;
    }
    
    else
    {                                 //Wrong password
        lcd_clear();
        lcd_First_line();
        lcd_print(str1);                                
        return 1;
    }
}    // End of Check_Pwd()...    
    

unsigned char get_option(void)
{
    
        unsigned char sw = 0x00;

        while( (IOPIN1 & 0x00010000) && (IOPIN1 & 0x00020000) && (IOPIN1 & 0x00040000) );
    
        Read_IOPin = IOPIN1;     
        IO_Val = ( (Read_IOPin >> 16) & 0x07);
        
        switch(IO_Val)
        {

            case 0x06:                      // p1.16 is pressed        
                        sw = 1;
                        lcd_clear();
                        lcd_First_line();
                        lcd_dec_nibble(sw);
                        break;

            case 0x05:                       // p1.17 is pressed
                        sw = 2;
                        lcd_clear();
                        lcd_First_line();                     
                        lcd_dec_nibble(sw);
                        break;

        }
        
        return (sw);        
        
}
            
void Send_String_Uart0(unsigned char *);
void Send_char_Uart0(unsigned char);
void Send_char_Uart1(unsigned char );
void Send_String_Uart1(unsigned char* );
void init_serial_gsm(void);
unsigned char getchar1(void);
unsigned char getchar0(void);
void init_serial(void)
{

    PINSEL0 |= 0x00050005;
    U0LCR = 0x03;
    U1LCR = 0x03;
    U0DLL = 92;
    U1DLL = 92;
    U0LCR = 0x01;
    U1LCR = 0X01;
    U0DLM = 0;
    U1DLM = 0;
    U0FCR = 1;
    U1FCR = 1;
}
void Send_String_Uart0(unsigned char* string)
{

    while(*string!='\0')
    {
        while(!(U0LSR & 0x20)) ;
        U0THR = *string;
        string++;
    
    }
}

void Send_String_Uart1(unsigned char* string)
{

    while(*string!='\0')
    {
        while(!(U1LSR & 0x10)) ;
        U1THR = *string;
        string++;
    
    }
}

void Send_char_Uart0(unsigned char ch)
{

    while(!(U0LSR & 0x10)) ;
    U0THR = ch;
    
}

void Send_char_Uart1(unsigned char ch)
{

    while(!(U1LSR & 0x10)) ;
    U1THR = ch;
    
}

void delay()
{
    int i;
    for(i=0;i<1000000;i++);
}

unsigned char getchar0(void)
{
while (!(U0LSR & 0x02));
return (U0RBR);
}

unsigned char getchar1 (void)
{
     while (!(U1LSR & 0x02));
     return (U1RBR);
}
CHAPTER 7
KEIL SOFTWARE



Introduction to Micro vision Keil (IDE)


Keil is a cross compiler. So first we have to understand the concept of compilers and cross compilers. After then we shall learn how to work with keil.

Concept of compiler: -


Compilers are programs used to convert a High Level Language to object code. Desktop compilers produce an output object code for the underlying microprocessor, but not for other microprocessors. I.E the programs written in one of the HLL like ËœCâ„¢ will compile the code to run on the system for a particular processor like x86 (underlying microprocessor in the computer). For example compilers for Dos platform is different from the Compilers for Unix platform

So if one wants to define a compiler then compiler is a program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instruction. See there is a bit little difference between compiler and an interpreter. Interpreter just interprets whole program at a time while compiler analyzes and execute each line of source code in succession, without looking at the entire program.

The advantage of interpreters is that they can execute a program immediately. Secondly programs produced by compilers run much faster than the same programs executed by an interpreter. However compilers require some time before an executable program emerges. Now as compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language.

Concept of cross compiler: -


A cross compiler is similar to the compilers but we write a program for the target processor (like 8051 and its derivatives) on the host processors (like computer of x86)
It means being in one environment you are writing a code for another environment is called cross development. And the compiler used for cross development is called cross compiler

So the definition of cross compiler is a compiler that runs on one computer but produces object code for a different type of computer. Cross compilers are used to generate software that can run on computers with a new architecture or on special-purpose devices that cannot host their own co
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: mp sangra id num, define intermittent, student management agreement, internet cards, ppt for campus recruitment management system, authentication and key agreement ppt, gsm authenticated operated appliancea using dtmf,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Messages In This Thread
RE: password-authenticated key agreement using smart cards for campus management - by computer science topics - 24-06-2010, 11:40 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  DEVELOPMENT OF SOFTWARE & HARDWARE FOR MICROCONTROLLER BASED SMART NOTICE BOARD (US Electrical Fan 3 3,874 09-08-2016, 11:27 AM
Last Post: jaseela123d
  Speech based password enabled devices switching system seminar class 1 2,627 24-01-2015, 05:23 AM
Last Post: Guest
  Password based door locking system vinaysingri 4 7,951 10-11-2014, 11:25 PM
Last Post: jaseela123d
  smart card based projects computer science technology 7 8,262 26-01-2013, 01:57 PM
Last Post: Redsasa
  Wireless Power Transmission: The Key To Solar Power Satellites seminar class 1 1,295 01-11-2012, 02:28 PM
Last Post: seminar details
  DEVELPOMENT OF WEB ENABLED EMBEDDED SYSTEM FOR HOME APPLIANCES WITH PASSWORD PROTECTE seminar topics 1 2,494 27-02-2012, 09:31 AM
Last Post: seminar paper
  A SMART HOME SECURITY SYSTEM smart paper boy 1 1,439 25-02-2012, 11:19 AM
Last Post: seminar paper
  Smart Terminal Technology for the 4G Mobile Communication Systems smart paper boy 1 1,162 11-02-2012, 11:07 AM
Last Post: seminar addict
  Smart mobile charger’ seminar class 1 1,826 30-01-2012, 09:51 AM
Last Post: seminar addict
  smart antennas for wireless systems full report computer science technology 2 4,341 21-01-2012, 10:36 AM
Last Post: seminar addict

Forum Jump: