Top Banner
LI-FI TECHNOLOGY FOR DATA COMMUNICATION IN INDUSTRIAL NETWORKING A PROJECT REPORT Submitted by Ms. R.KRITHIGA - 821311106019 Ms. N.TAMILMAGAL - 821311106048 Ms. R.VINOTHA - 821311106055 Mr. M. ARUN - 821311106703 In partial fulfillment for the award of the degree Of BACHELOR OF ENGINEERING IN ELECTRONICS AND COMMUNICATION ENGINEERING PARISUTHAM INSTITUTE OF TECHNOLOGY AND SCIENCE, THANJAVUR. ANNA UNIVERSITY: CHENNAI 600 025 APRIL – 2015
92
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: LIFI Document

LI-FI TECHNOLOGY FOR DATA COMMUNICATION IN INDUSTRIAL NETWORKING

A PROJECT REPORT

Submitted by

Ms. R.KRITHIGA - 821311106019

Ms. N.TAMILMAGAL - 821311106048

Ms. R.VINOTHA - 821311106055

Mr. M. ARUN - 821311106703In partial fulfillment for the award of the degree

Of

BACHELOR OF ENGINEERING

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

PARISUTHAM INSTITUTE OF TECHNOLOGY AND SCIENCE,

THANJAVUR.

ANNA UNIVERSITY: CHENNAI 600 025

APRIL – 2015

Page 2: LIFI Document

LI-FI TECHNOLOGY FOR DATA COMMUNICATION IN INDUSTRIAL NETWORKING

A PROJECT REPORT

Submitted by

Ms. R.KRITHIGA - 821311106019

Ms. N.TAMILMAGAL - 821311106048

Ms. R.VINOTHA - 821311106055

Mr. M. ARUN - 821311106703In partial fulfillment for the award of the degree

Of

BACHELOR OF ENGINEERING

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

PARISUTHAM INSTITUTE OF TECHNOLOGY AND SCIENCE,

THANJAVUR.

ANNA UNIVERSITY: CHENNAI 600 025

APRIL – 2015

Page 3: LIFI Document

ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report “LI-FI TECHNOLOGY FOR DATA

COMMUNICATION IN INDUSTRIAL NETWORKING” is the bonafide work

of KRITHIGA.R (821311106019), TAMILMAGAL.N (821311106048), and

VINOTHA.R (821311106055), ARUN.M (82131116703) who carried out the

project work under my supervision.

SIGNATURE SIGNATURE

Dr .G. Mary Amirtha Sagayee Mrs.S.Bhuvaneswari

HEAD OF THE DEPARTMENT SUPERVISOR

Professor Assistant Professor

Department of ECE Department of ECE

Parisutham Institute of Parisutham Institute of Technology and Science , Technology and Science,

Thanjavur. Thanjavur.

This Project report was submitted for the Viva-Voce held on …………………

INTERNAL EXAMINER EXTERNAL EXAMINER

Page 4: LIFI Document

ACKNOWLEDGEMENT

The success of any work lies in the involvement and commitment of its

makers, this being no exception. At this juncture I would like to acknowledge the

many minds that made this project to be a reality.

My grateful thanks to our beloved Chairman Mr. S. P. ANTHONISAMY,

M.A., B.L., for the continuous help during our course period by arranging various

activities.

I extend my grateful thanks to our lovable Dean Mrs. J.NIRMALA, M.Tech,

(Ph.D) for providing her hands to us to successfully complete the course.

The Encouragement and support of our Head Dr. G. MARY AMIRTHA

SAGAYEE, B.E, M.S, M.E, M.B.A, (PhD), Department of Electronics and

Communication Engineering as always guiding with spirit throughout the course

period. Whenever clouds of disappointment hung above, I always had one never

failing ray of hope that showed the path, time and again, in the form of our Head of

the Department.

The field being a new one I was exposed to a lot of uncertainties, which kept

me, puzzled on many occasions. Thanks to the valuable suggestions and interest

showed in my project given by my internal guide Mrs. S.BHUVANESWARI, M.E,

Assistant Professor, Department of Electronics and Communication Engineering.

I would be failing in my duty if I do not mention the wholehearted support and

technical assistance extended to me by all the FACULTY MEMBERS AND

TECHNICAL STAFFS of the Electronics and Communication Engineering

Department, Parisutham Institute of Technology and Science, Thanjavur.

Page 5: LIFI Document

ABSTRACT

This Project is about the data communication in Industrial networking using

Visible Light Communication based on White LED’s. To establish this process, it is

needed to integrate the visible light communication. So a new method is developed

by using LI-FI as wireless communication medium. This is the smart way of

providing data communication for Industrial networking.

In this project microcontrollers and sensors are used. The Visible Light

Communication is used to transmit the data. The photo detector will act as a receiver.

LI-FI act as a wireless medium between the transmitter and the receiver.

Li-Fi technology works on a simple digital principle which is nothing but an

led is ON a digital data 1 can be transmitted and if it is OFF digital data 0 can be

transmitted. So, in this project work the LEDs were switched very quickly. These

fast switching can be achieved by PWM technique to transmit digital data stream

containing strings. To acquire this, it needs programming the microcontroller to

varies the duty cycle of the PWM signal which has the task of regulating the current

in the LED. The biased current is fed to LED driver unit. The power of LED is

varied according to the waveform of data signal. At the receiver side photodiode

sensor produces a current proportional to the received instantaneous power. From

this data can be filtered and it can be displayed on PC .

Page 6: LIFI Document

CHAPTER-1

INTRODUCTION

 Li-Fi is the term some have used to label the fast and cheap wireless-communication

system, which is the optical version of WI-FI.  The term was first used in this context

by Harald Haas in his TED Global talk on Visible Light Communication (VLC). 

The technology was demonstrated at the 2012 Consumer Electronics Show in Las

Vegas using a pair of Casio smartphones to exchange data using light of varying

intensity given off from their screens, detectable at a distance of up to ten meter.

In October 2011 a number of companies and industry groups formed the Li-Fi

Consortium, to promote high-speed optical wireless systems and to overcome the

limited amount of radio-based wireless spectrum available by exploiting a

completely different part of the electromagnetic spectrum.      The consortium

believes it is possible to achieve more than 10 Gbps, theoretically allowing a high-

definition film to be downloaded in 30 seconds.  Li-Fi has the advantage of being

able to be used in sensitive areas such as in aircraft without causing interference.

However, the light waves used cannot penetrate walls. Later in 2012, VLC, a firm set

up to commercialize Li-Fi, will bring out Li-Fi products for firms installing LED-

lighting systems. In future data for laptops, Smartphone's, and tablets can be

transmitted through the light in a room by using Li-Fi.

Li-Fi or Light Fidelity is a high speed, bidirectional and fully networked subsets of

visual light communications (VLC). It uses visible light communication instead of

radio frequency (RF) waves which carry more information. Thus Li-Fi is an emergent

technology that has the potential to deliver enormous bandwidth. As data

transmission through radio waves approaches its limits, a new medium presents itself.

Most of us are familiar with WI-FI (Wireless Fidelity) uses 2.4-5 GHz RF to deliver

Page 7: LIFI Document

wireless data, information or internet access around. It can cover up a large area, but

it fails to cover up all the area as its bandwidth is typically limited to 50-100 mega-

bits per second (Mbps). This is a good match to the speed of internet services, but

insufficient for moving large data files like HDTV movies, music libraries and video

games. The bandwidth and speed is directly proportional medium of communication.

Therefore RF-based technologies such as to-day’s WI-FI are not the optimal way. In

addition to that WI-FI fails to provide new desired capabilities such as precision in-

door positioning and gesture recognition.

To this a new trend has come in technology that overcomes these flaws, that is Li-Fi

or Light Fidelity informally known as optical wireless technology, a vivid

permutation of speed, reliability, flexibility and usability.

Li-Fi is transmission of data through illumination by taking the fiber out of fiber

optics by sending data through a LED light bulb that varies in intensity faster than the

human eye can follow. Li-Fi is the term some used to label the fast and cheap wireless

communication system which is the optical version of WI-FI. It is possible to encode

data in the light by varying the rate at which the LEDs flicker on and off to give

different strings of 0s and 1s. The LED intensity is modulated so rapidly that human

eye cannot notice, so the output appears constant. More sophisticated techniques and

ways could dramatically increase visible communication data rate.

Transfer of data from one place to a different place is one of the most important day‐to‐day manners. The current wireless networks that attach us to the internet are

extremely slow when numerous devices are connected. As the amount of devices that

access the internet increases, the fixed bandwidth accessible makes it extra and extra

tricky to enjoy high data transfer rates and attach to a secure network. But, radio

waves are just a minute part of the band available for data transfer.

With the wide use of wireless gadgets, the demand of wireless internet is increasing at

a very high pace and stealing it from the guy next door, or competing for bandwidth

at a conference, the slow speeds you face when more than one device is tapped into

Page 8: LIFI Document

the network. When many devices access wireless internet, clogged airwaves are going

to make it. To over come this there is a solution known as “Data through

illumination”. This technology is known as “LI-FI” Li-Fi is a technology that makes

use of LED light which helps in the transmission of data much faster and flexible than

data that can be transmitted through Wi-Fi. Light reaches nearly everywhere so

communication can also go along with light freely. Light Fidelity is a branch of

optical wireless communication which is an emerging technology. By using visible

light as transmission medium, Li-Fi provides wireless indoor communication. The bit

rate achieved by Li-Fi cannot be achieved by Wi-Fi. Li-Fi is the transfer of data

through light by taking fiber out of fiber optics and sending data through LED light.

In this paper we are concerned with the use of li-fi in the field of medicine. As the

Wi-Fi cannot be used along with the medical equipment’s due to the radio waves we

implement li-fi in those places.

Heart of this technology lies in the intensity and the potential of the light emitting

diodes. Major reason that leads to the development of the LI-FI is confinement of WI-

FI to comparatively small distance. As many devices are coming up in day to day

life’s the signals are being clogged up due to heavy traffic, so there is a need for error

free transmission technology. And the remedy for this problem is li-fi technology. It

has been designed in such a way so that it can overcome the disadvantages of WI-FI.

In Industrial networking since from beginning, data can be transferred through the

wireless devices like Bluetooth, ZigBee, WI-FI etc.., But apart from these

technologies LI-FI has made these Industrial networking free from environmental as

well as health issues due to RF radiations. Though this technology may has short

coverage area this also can be eradicated by installing more number of VLC

transmitters since it consists of only LED’s, power consumption will be low and cost

is also reduced.

This LI-FI technology probably produces high data rate transmission even with less

intensity. When the LED’s becoming dim it will not affect the data rate those

intensities for LED can also hence, it is easy to monitor the industrial environment

conditions via Visible Light Communication.

Page 9: LIFI Document

CHAPTER-2

EXPERIMENTAL SETUP

2.1 LITERATURE SURVEY

2.1.1 [1] Title: Smart Parking Information System Exploiting Visible Light

communication.

Abstract- In this paper, we propose a smart parking information system exploiting

visible light communication (VLC) technology to help drivers getting the real-time

parking information as well as direction guide. By providing accurate information on

available parking spaces, drivers save time and fuel and increase efficiency of the

parking process. The effectiveness of the proposed scheme is validated through

experiments in an indoor environment.

Authors- Nammoon Kim, Changqiang Jing, Biao Zhou and Youngok Kim.

Year and Publication- IJSN 2014.

Technology used- A novel smart parking information system exploiting the real-

time parking information as well as the direction guide. In the parking entrance, VLC

module of safety bar, ground or ceiling and head light or installed VLC module in

car are communicating. In this process, the vehicle and light module of celling

exchange number of vehicle and ID of light. Thus, the smart parking lot system can

guide the driver to the nearest empty parking space by using direction indicator

based on location information of vehicles. Digital encodings such as Non Return to

Zero (NRZ), Return to Zero (RZ), Manchester encoding for data transmission.

Merits- Low Pass Filter (LPF) was applied to eliminate external noise and light from

other light source.

Page 10: LIFI Document

Demerits- Reception ratio is rapidly decreased after 1.7m. Overlapping part is

generated because of the position and intensity angle.

2.1.2 [2] Title: Reading Lamp-Based Visible Light Communication System for In-

flight Entertainment.

Abstract- This paper explores the use of a reading lamp as an access point for a

Visible Light Communication (VLC) downlink channel. We have established an

infrared uplink channel based on a network adapter, supporting both a VLC receiver

and an infrared emitter. The optical signal power distribution over the passenger area

has been also studied using a Monte Carlo Ray-Tracing algorithm. The hardware

implementation and testing results are also presented.

Authors- C. Quintana, V. Guerra, J. Rufo, J. Rabadan and R. Perez-Jimenez.

Year and publication- IEEE MARCH 2013.

Technology used- In this paper we propose a full optical wireless strategy for

passenger connectivity in planes during flight. It uses a VLC system as a downlink,

while an infrared link provides the uplink channel. A network adapter was

introduced to improve the performance. And also OOK and PPM provides better

performance against AWGN. Using Ethernet as a distribution network inside the

aircraft and the use of a Power over Ethernet (PoE) system to feed them up, and so

the shielded twisted pair cable will be used to power the lamps.

Merits- Use of optical lenses for collimating the light beam in the passenger’s table .

A simulation based on a Monte Carlo-Ray tracing algorithm has been performed in

order to calculate the signal to noise ratio at different points of the user’s table.

Demerits- OOK does not guarantee the absence of flickering and both of them

(OOK and PPM) have lower spectral efficiency.

Page 11: LIFI Document

2.1.3 [3] Title: Design of an Integrated Optical Receiver for Mobile Visible Light Communications.

Abstract- This paper presents a project to design and implement, an optical receiver

system for a visible light communications (VLC). The link is capable of receiving

on-off keying non-return zero data (OOK NRZ) at speeds up to 10 Mbit/s and it be

interfaced with a PC, Notebook or mobile phone through a USB 2.0 port. The paper

shows the practical implementation and the experiment results of the designed

receiver.

Authors- A. Burton, C. Amiot, H. Le Minh and Z. Ghassemlooy.

Year and publication- 2011 PGNet.

Technology used - This paper presents the design and analysis of a mobile VLC

receiver with an interface for a PC or Note Book via the USB 2.0 port capable of

receiving OOK NRZ data at 10Mbit/s error free. The Band-pass filter is required to

remove the high frequency components of the signal above the required 10 MHz

level as signals above this will contribute towards the noise. The next stage of the

receiver will be to realize the band-pass filter and connect the FT232R USB UART

I.C. This will enable full connectivity to a PC or Notebook.

Merits- The received arbitrary OOK NRZ data (length 210-1) at speeds of 1, 2, 3

and 4 Mbit/s after the TIA. The eyes are clear thus show error free performance.

Demerits- The ‘bottle-neck’ to the system currently restricting the bandwidth is tied

to the unequalized modulation bandwidth of the LED.

Page 12: LIFI Document

2.1.4 [4] Title: A Study on Realization of Visible Light Communication System for

Power Line Communication Using 8-bit Microcontroller.

Abstract- To solve the problems of the current wireless communications system, a

visible light communications system for power line communication (PLC) via 8-bit

Micro controller is created and the capacity is analyzed. The exclusive PLC chip

PLC-485MA, an 8-bit ATmega16 microcontroller, high brightness 5pi light emitting

diodes (LEDs), and the LLS08-A1 visible light-receiving sensor were used for the

transmitter and receiver.

Authors- Ji-Hun Yun, Geun-Bin Hong, and Yong-kab Kim.

Year and Publication- 2010 KIEEME.

Technology used- Visible light communication technology, which has gotten notice

as a next generation communication technology, is particularly attractive for home

networks. Among the technologies, the visible light communication system is

designed and brought into a network using PLC to study application of the LED

system that is necessarily relevant for living.

Merits- The voltage loss of the green LED is 1.46 V, and the voltage loss of the blue

LED is 0.47 V, which shows the best performance among the LEDs.

Demerits- At a distance of 50 cm, the voltage was 3.26 V, so that 1.06 V was

confirmed as the voltage loss.

Page 13: LIFI Document

2.2 EXISTING APPROACH

In this Existing method, assume that medical WPAN has a centralized polling

topology. The base station is a heavy weight expensive medical device (such as

multi-parameter monitor, surgical robot etc.) that can be equipped with software-

defined radio. Under such assumptions, we propose WiCop, a novel policing

framework different from the aforementioned three categories of solutions. WiCop

addresses the WPAN-WI-FI coexistence problem by effectively controlling the

temporal white-spaces (gaps) between consecutive WI-FI transmissions. Though

temporal whitespaces are abundant in light to medium loaded WI-FI networks, they

are scarce in heavy loaded WI-FI networks and tend to be irregular. Our approach

“engineers” the intervals and lengths of WI-FI temporal white-spaces, and utilizes

them to deliver low duty cycle medical WPAN traffic with minimum impacts on WI-

FI. WiCop exploits the Clear Channel Assessment (CCA) mechanisms in the WI-FI

standard.

Fig. 3. Experiment Layout.

Experiment Results and Observations:

With the layout in Fig. 3, we let Host-I transmit at an application layer rate of

27Mbps to the Wi-Fi AP to emulate Wi-Fi interference. We set d2 to 4ft. As the

distance from Host-I to Mote-B (i.e., d1) changes from 12ft to 4ft, the PRR decreases

from 98% to 67% (see Fig. 4). At 67% PRR, the MTTF is around 2.8s. In other

words, on average every 2.8s, an ECG sample chunk may be lost, which is a serious

Page 14: LIFI Document

problem. The MTTR performance shows a similar trend. As the distance from Host-I

to Most-B changes from 12ft to 4ft, MTTR increases 15%.

Experimental Evaluation in Medical Environments:

Some researchers deployed wireless monitoring network in real medical units.

However, few of these works considers the interference from other wireless

technologies. Garudadri applied Compressed Sensing to ECG. This approach uses

the redundancy in periodic ECG trace, to mitigate distortion under high packet

losses. This approach is orthogonal to WiCop and can be used in conjunction with

WiCop to further improve the robustness of ECG monitoring. Finally, it should be

noted that WiCop is a general mechanism to regulate temporal white-spaces in Wi-Fi

transmissions.

Page 15: LIFI Document

2.3 PROPOSED APPROACH

Overall Block Diagram

Fig 2 Overall Block Diagram

Power supply

Micro controller

VLC Transmitter

Photo detector

PC

Pressure sensor

Humidity sensor

Temperature sensor

RS232

LED Light Fixtures

Motor

Page 16: LIFI Document

In this proposed system, it is implemented that wireless data transfer through light

medium. First the sensor module consists of different sensors of industries like

Temperature, Pressure, Gas sensors these analog devices produce analog output

which is given to microcontroller(ARM7LPC2148) a 32 bit controller which has

inbuilt ADC in it. Then those analog values will be converted to digital values and it

will be received by the VLC Transmitter ie. Array of LEDs. This Visible light

module again converts the output of Microcontroller to Light signals with binary

values which actually changes the intensity of light that cannot be identified through

human eyes.

These Binary Light signals will be received by the photo-detector which can act as

light sensor this again converts signals to decimal values which will be displayed in

PC through Visual B.6.

Page 17: LIFI Document

2.3.1 Circuit Diagram

Fig

Page 18: LIFI Document

2.4 HARDWARE COMPONENTS

2.4.1 Micro controller (ARM LPC2148)

2.4.1.1 DESCRIPTION:

The LPC2141/2/4/6/8 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU

with real-time emulation and embedded trace support, that combines the

microcontroller with embedded high speed flash memory ranging from 32 kB to 512

kB. A 128-bit wide memory interface and a unique accelerator architecture enable

32-bit code execution at the maximum clock rate. For critical code size applications,

the alternative 16-bit Thumb mode reduces code by more than 30 % with minimal

performance penalty.

Due to their tiny size and low power consumption, LPC2141/2/4/6/8 are ideal for

applications where miniaturization is a key requirement, such as access control and

Point-of-sale. A blend of serial communications interfaces ranging from a USB 2.0

Full Speed device, multiple UARTS, SPI, SSP to I2Cs and on-chip SRAM of 8 kB

up to 40 kB, make these devices very well suited for communication gateways and

protocol converters, soft modems, voice recognition and low end imaging, providing

both large buffer size and high processing power. Various 32-bit timers, single or

dual 10-bit ADC(s), 10-bit DAC, PWM channels and 45 fast GPIO lines with up to

nine edge or level sensitive external interrupt pins make these microcontrollers

particularly suitable for industrial control and medical systems.

2.4.1.2 FEATURES:

16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.

8 to 40 kB of on-chip static RAM and 32 to 512 kB of on-chip flash program

memory.128 bit wide interface/accelerator enables high speed 60 MHz

operation.

Page 19: LIFI Document

In-System/In-Application Programming (ISP/IAP) via on-chip boot-loader

software. Single flash sector or full chip erase in 400 ms and programming of

256 bytes in 1 ms.

Embedded ICE RT and Embedded Trace interfaces offer real-time debugging

with the on-chip Real Monitor software and high speed tracing of instruction

execution.

USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM.

In addition, the LPC2146/8 provide 8 kB of on-chip RAM accessible to USB

by DMA.

One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a

total of 6/14 analog inputs, with conversion times as low as 2.44 μs per

channel.

Single 10-bit D/A converter provides variable analog output.

Two 32-bit timers/external event counters (with four capture and four compare

channels each), PWM unit (six outputs) and watchdog.

Low power real-time clock with independent power and dedicated 32 kHz

clock input.

Multiple serial interfaces including two UARTs (16C550), two Fast I2C-

bus(400 kbit/s), SPI and SSP with buffering and variable data length

capabilities.

Vectored interrupt controller with configurable priorities and vector addresses.

Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64

package.

Up to nine edge or level sensitive external interrupt pins available.

60 MHz maximum CPU clock available from programmable on-chip PLL

with settling time of 100 μs.

On-chip integrated oscillator operates with an external crystal in range from 1

MHz to 30 MHz and with an external oscillator up to 50 MHz.

Power saving modes include Idle and Power-down.

Page 20: LIFI Document

Individual enable/disable of peripheral functions as well as peripheral clock

scaling for additional power optimization.

Processor wake-up from Power-down mode via external interrupt, USB,

Brown-Out Detect (BOD) or Real-Time Clock (RTC).

Single power supply chip with Power-On Reset (POR) and BOD circuits:–

CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V

tolerant I/O pads.

2.4.1.3 PIN DIAGRAM:

Fig

Page 21: LIFI Document

2.4.1.3.1 PIN DESCRIPTION:

VSS: Ground: 0 V reference. Connected to the pin 6, 18, 42, 25, 50.

VDD: 3.3 V Power Supply: This is the power supply voltage for the core and I/O

Ports. Connected to the pin 23, 43, 51.

VSSA: Analog Ground: 0 V reference. This should nominally be the same voltage

as VSS, but should be isolated to minimize noise and error. Connected the pin 59.

VDDA: Analog 3.3 V Power Supply: This should be nominally the same voltage as

VDD but should be isolated to minimize noise and error. This voltage is used to

power the ADC(s).Connected to the pin 7.

VREF: A/D Converter Reference: This should be nominally the same voltage as

VDD but should be isolated to minimize noise and error. Level on this pin is

used as a reference for A/D convertor. Connected to the pin 63.

VBAT: RTC Power Supply: 3.3 V on this pin supplies the power to the RTC.

Connected to the pin 49.

XTAL1: Input to the oscillator circuit and internal clock generator circuits.

Connected to the pin 62.

XTAL2: Output from the oscillator amplifier. Connected to the pin 61.

RTXC1: Input to the RTC oscillator circuit. . Connected to the pin 5.

RTXC2: Output from the RTC oscillator circuit. Connected to the pin 3.

D+: I/O USB bidirectional D+ line. Connected to the pin 10.

D-: I/O USB bidirectional D- line. Connected to the pin 10.

RESET: External reset input: A LOW on this pin resets the device, causing I/O

ports and peripherals to take on their default states, and processor execution to

begin at address 0. TTL with hysteresis, 5 V tolerant. Connected to the pin 57.

PORT 0:

Page 22: LIFI Document

Port 0: Port 0 is a 32-bit I/O port with individual direction controls for each bit.

Total of 28 pins of the Port 0 can be used as a general purpose bi-directional digital

I/O’s while P0.31 provides digital output functions only. The operation of port 0 pins

depends upon the pin function selected via the pin connect block. Pins P0.24, P0.26

and P0.27 are not available.

PORT PIN FUNCTION

P0.0 19 TXD0 — Transmitter output for UART0

PWM1 — Pulse Width Modulator output 1

P0.1 21 RxD0 — Receiver input for UART0

PWM3 — Pulse Width Modulator output 3

EINT0 — External interrupt 0 input

P0.2 22 SCL0 — I2C0 clock input/output. Open drain output

(for I2C compliance)

CAP0.0 — Capture input for Timer 0, channel 0

P0.3 26 SDA0 — I2C0 data input/output. Open drain output (for

I2C compliance)

MAT0.0 — Match output for Timer 0, channel 0

EINT1 — External interrupt 1 input

P0.4 27 SCK0 — Serial clock for SPI0. SPI clock output from

master or input to slave

CAP0.1 — Capture input for Timer 0, channel 0

AD0.6 — A/D converter 0, input 6.

Page 23: LIFI Document

P0.5 29 MISO0 — Master In Slave OUT for SPI0. Data input to

SPI master or data output from SPI slave

MAT0.1 — Match output for Timer 0, channel 1

AD0.7 — A/D converter 0, input 7.

P0.6 30 MOSI0 — Master Out Slave In for SPI0. Data output

from SPI master or data input to SPI slave

CAP0.2 — Capture input for Timer 0, channel 2

AD1.0 — A/D converter 1, input 0.

P0.8 33 TXD1 — Transmitter output for UART1

PWM4 — Pulse Width Modulator output 4

AD1.1 — A/D converter 1, input 1.

P0.9 34 RxD1 — Receiver input for UART1

PWM6 — Pulse Width Modulator output 6

EINT3 — External interrupt 3 input

P0.10 35 RTS1 — Request to Send output for UART1.

CAP1.0 — Capture input for Timer 1, channel 0

AD1.2 — A/D converter 1, input 2.

P0.11 37 CTS1 — Clear to Send input for UART1.

Page 24: LIFI Document

CAP1.1 — Capture input for Timer 1, channel 1.

SCL1 — I2C1 clock input/output.

P0.12 38 DSR1 — Data Set Ready input for UART1.

MAT1.0 — Match output for Timer 1, channel 0.

AD1.3 — A/D converter input 3.

P0.13 39 DSR1 — Data Set Ready input for UART1.

MAT1.01— Match output for Timer 1, channel 1.

AD1.3 — A/D converter input 4.

P0.14 41 DCD1 — Data Carrier Detect input for UART1

EINT1 — External interrupt 1 input

I/O SDA1 — I2C1 data input/output

P0.15 45 RI1 — Ring Indicator input for UART1.

EINT2 — External interrupt 2 input.

AD1.5 — A/D converter 1, input 5.

P0.16 46 EINT0 — External interrupt 0 input.

MAT0.2 — Match output for Timer 0, channel 2.

CAP0.2 — Capture input for Timer 0, channel 2.

P0.17 47 EINT0 — External interrupt 0 input.

MAT0.2 — Match output for Timer 0, channel 2.

CAP0.2 — Capture input for Timer 0, channel 2.

P0.18 53 CAP1.3 — Capture input for Timer 1, channel 3.

Page 25: LIFI Document

MISO1 — Master In Slave Out for SSP. Data input to

SPI master or data output from SSP slave.

MAT1.3 — Match output for Timer 1, channel 3.

P0.19 54 MAT1.2 — Match output for Timer 1, channel 2.

MOSI1 — Master Out Slave In for SSP. Data output

from SSP master or data input to SSP slave.

CAP1.2 — Capture input for Timer 1, channel 2.

P0.20 55 MAT1.3 — Match output for Timer 1, channel 3.

SSEL1 — Slave Select for SSP. Selects the SSP

interface as a slave.

EINT3 — External interrupt 3 input.

P0.21 1 PWM5 — Pulse Width Modulator output 5. AD1.6 —

A/D converter 1, input 6.

CAP1.3 — Capture input for Timer 1, channel 3.

P0.22 2 AD1.7 — A/D converter 1, input 7.

CAP0.0 — Capture input for Timer 0, channel 0.

P0.23 58 VBUS — Indicates the presence of USB bus power.

P0.25 9 AD0.4 — A/D converter 0, input 4.

Page 26: LIFI Document

Aout — D/A converter output.

P0.28 13 AD0.1 — A/D converter 0, input 1.

CAP0.2 — Capture input for Timer 0, channel 2.

MAT0.2 — Match output for Timer 0, channel 2.

P0.29 14

AD0.3 — A/D converter 0, input 3.

EINT3 — External interrupt 3 input.

CAP0.0 — Capture input for Timer 0, channel 0.

P0.30 15 AD0.3 — A/D converter 0, input 3. This analog input is

always connected to

its pin.

EINT3 — External interrupt 3 input.

CAP0.0 — Capture input for Timer 0, channel 0.

P0.31 17 UP_LED — USB Good Link LED indicator. It is LOW

when device is configured (non-control endpoints

enabled). It is HIGH when the device is not configured

or during global suspend.

CONNECT — Signal used to switch an external 1.5 kΩ

resistor under the software control (active state for this

signal is LOW). Used with the Soft Connect USB

Page 27: LIFI Document

feature.

PORT1: Port 1: Port 1 is a 32-bit bi-directional I/O port with individual direction

controls for each bit. The operation of port 1 pins depends upon the pin function

selected via the pin connect block. Pins 0 through 15 of port 1 are not available.

PORT PIN FUNCTION

P1.16 16 TRACEPKT0 — Trace Packet, bit 0. Standard I/O port with internal pull-up.

P1.17 12 TRACEPKT1— Trace Packet, bit 1. Standard I/O port with internal pull-up.

P1.18 8 TRACEPKT2-Trace Packet, bit 2. Standard I/O port with internal pull-up.

P1.20 48 TRACESYNC — Trace Synchronization. Standard I/O port with internal pull-up.

P1.21 44 PIPESTAT0 — Pipeline Status, bit 0. Standard I/O port with internal pull-up.

P1.22 40 PIPESTAT1 — Pipeline Status, bit 1. Standard I/O port with internal pull-up.

P1.23 36 PIPESTAT2 — Pipeline Status, bit 2. Standard I/O port with internal pull-up.

P1.24 32 TRACECLK — Trace Clock. Standard I/O port with internal pull-up.

P1.25 28 EXTIN0 — External Trigger Input. Standard I/O with internal pull-up.

P1.26 24 RTCK — Returned Test Clock output. Extra signal added to the JTAG port.

Assists debugger synchronization when processor frequency varies.

Bi-directional pin with internal pull-up.

P1.27 64 TDO — Test Data out for JTAG interface.

Page 28: LIFI Document

P1.28 60 TDI — Test Data in for JTAG interface.

P1.29 56 TCK — Test Clock for JTAG interface.

P1.30 52 TMS — Test Mode Select for JTAG interface.

P1.31 20 TRST — Test Reset for JTAG interface

2.4.1.4 OPERATING MODES:

ARM7TDMI supports seven modes of operation:

• User (usr):

The normal ARM program execution state

• FIQ (fiq):

Designed to support a data transfer or channel process

• IRQ (irq):

Used for general-purpose interrupt handling

• Supervisor (svc):

Protected mode for the operating system

• Abort mode (abt):

Entered after a data or instruction prefetch abort

• System (sys):

A privileged user mode for the operating system

Page 29: LIFI Document

• Undefined (und):

Entered when an undefined instruction is executed.

Mode changes may be made under software control, or may be brought about by

external interrupts or exception processing. Most application programs will execute

in User mode. The non-user modes - known as privileged modes - are entered in

order to service interrupts or exceptions, or to access protected resources. Each

operating mode has dedicated banked registers for fast exception handling. The FIQ

mode has five additional banked working registers, r8_fiq to r12_fiq, to enhance

interrupt processing speed.

2.4.1.5 ARM7TDMI Architecture

The ARM7TDMI is a 3-stage pipeline, 32-bit RISC processor.The processor

architecture is Von Neumann load/store architecture, which is characterized by a

single data and address bus for instructions and data. The CPU has two instruction

sets, the ARM and the Thumb instruction set.

The ARM instruction set has 32-bit wide instructions and provides maximum

performance. Thumb instructions are 16-bits wide and give maximum code-density.

Instructions operate on 8-, 16-, and 32-bit data types.

The THUMB state register set is a subset of the ARM state set. The programmer has

direct access to eight general registers, R0-R7, as well as the Program Counter (PC),

a stack pointer register (SP), a link register (LR), and the CPSR. There are banked

Stack Pointers, Link Registers and Saved Process Status Registers (SPSRs) for each

privileged mode.

The ARM7TDMI processor employs a unique architectural strategy known as

THUMB, which makes it ideally suited to high-volume applications with memory

restrictions, or applications where code density is an issue. The key idea behind

Page 30: LIFI Document

THUMB is that of a super-reduced instruction set. Essentially, the ARM7TDMI

processor has two instruction sets:

•The standard 32-bit ARM set

• A 16-bit THUMB set

The THUMB set’s 16-bit instruction length allows it to approach twice the density of

standard ARM code while retaining most of the ARM’s performance advantage over

a traditional 16-bit processor using 16-bit registers. This is possible because

THUMB code operates on the same 32- bit register set as ARM code.

THUMB code is able to provide up to 65% of the code size of ARM, and 160% of

the performance of an equivalent ARM processor connected to a 16-bit memory

system.

In Thumb state, the Program Counter (PC) uses bit 1 to select between alternate half

words. Transition between ARM and Thumb states does not affect the processor

mode or the register contents.

All exception handling is performed in ARM state. If an exception occurs in Thumb

state, the processor reverts to ARM state. The transition back to Thumb state occurs

automatically on return.

The operating state of the ARM7TDMI-S core can be switched between ARM state

and Thumb state using the BX instruction.

2.4.1.5.1 The Advantages of THUMB:

THUMB instructions operate with the standard ARM register configuration,

allowing excellent interoperability between ARM and THUMB states. Each 16-bit

THUMB instruction has a corresponding 32-bit ARM instruction with the same

effect on the processor model.

Page 31: LIFI Document

The major advantage of a 32-bit (ARM) architecture over a 16-bit architecture is its

ability to manipulate 32-bit integers with single instructions, and to address a large

address space efficiently. When processing 32-bit data, a 16-bit architecture will take

at least two instructions to perform the same task as a single ARM instruction.

2.4.1.5.2 Memory map concepts and operating modes:

The basic concept on the LPC2141/2/4/6/8 is that each memory area has a "natural"

location in the memory map. This is the address range for which code residing in that

area is written. The bulk of each memory space remains permanently fixed in the

same location, eliminating the need to have portions of the code designed to run in

different address ranges.

Because of the location of the interrupt vectors on the ARM7 processor (at addresses

0x0000 0000 through 0x0000 001C,) a small portion of the Boot Block and SRAM

spaces need to be re-mapped in order to allow alternative uses of interrupts in the

different operating modes  Re-mapping of the interrupts is accomplished via the

Memory Mapping Control feature.

2.4.1.5.3 Memory formats:

The processor views memory as a linear collection of bytes numbered in ascending

order from zero. For example, bytes 0-3 in memory hold the first stored word, and

bytes 4-7 hold the second stored word.

There are two types of formats:

Big Endian format:

In byte-invariant big-endian format, the processor stores the most significant byte of

a word at the lowest-numbered byte, and the least significant byte at the highest-

numbered byte. Therefore, byte 0 of the memory system connects to data.

Little Endian Format:

Page 32: LIFI Document

In little-endian format, the lowest-numbered byte in a word is the least significant

byte of the word and the highest-numbered byte is the most significant. Therefore,

byte 0 of the memory system connects to data lines.

 

2.4.1.62GPIO:

General Purpose Input/output (GPIO) is an interface available on some devices. A

microprocessor, microcontroller or interface device may have one or more GPIO

connections to interface with external devices and peripherals. These can act as

input, to read digital signals from other parts of a circuit, or output, to control or

signal to other devices. GPIOs are often arranged into groups, typically of 8 pins - a

GPIO port - that usually have individual GPIOs configurable either as input or

outputs. In some cases, GPIOs may be configurable to produce CPU interrupts and

be able to use Direct Memory Access to move large quantities of data efficiently into

or out of the device.

GPIO peripherals vary quite widely. In some cases, they are very simple, a group of

pins that can be switched as a group to either input or output. In others, each pin can

be setup flexibly to accept or source different logic voltages, with configurable drive

strengths and pull up/downs. The input and output voltages are typically, though not

universally limited to the supply voltage of the device with the GPIOs on, and may

be damaged by greater voltages.

Page 33: LIFI Document

The GPIO peripheral provides dedicated general-purpose pins that can be configured

as either inputs or outputs.

When configured as an output, you can write to an internal register to control the

state driven on the output pin. When configured as an input, you can detect the state

of the input by reading the state of an internal register.

2.4.1.6.1 Purpose of the Peripheral

Most system on a chip (SoC) devices require some general-purpose input/output

(GPIO) functionality in order to interact with other components in the system using

low-speed interface pins. The control and use of the GPIO capability on this device

is grouped together in the GPIO peripheral and is described in the following sections.

2.4.1.6.2 Features

The GPIO peripheral consists of the following features.

• Output set/clear functionality through separate data set and clear registers allows

multiple software

processes to control GPIO signals without critical section protection.

• Set/clear functionality through writing to a single output data register is also

supported.

• Separate input/output registers

– Output register can be read to reflect output drive status.

– Input register can be read to reflect pin status.

• All GPIO signals can be used as interrupt sources with configurable edge detection.

• All GPIO signals can be used to generate events to the EDMA.

• Programmable debounce circuit provided on GPIO.

The purpose of the Pin Connect Block is to configure the microcontroller pins to the

desired functions. The pin connect block allows selected pins of the microcontroller

to have more than one function. Configuration registers control the multiplexers to

Page 34: LIFI Document

allow connection between the pin and the on chip peripherals. The Pin Control

Module contains registers as shown below:

Name Description Access Reset value Address

PINSEL0 Pin function select register 0. Read/Write 0x0000 0000 0xE002 C000

PINSEL1 Pin function select register 1. Read/Write 0x0000 0000 0xE002 C004

PINSEL2 Pin function select register 2. Read/Write   0xE002 C014

Interrupt latency:

The amount of time between the assertion of an interrupt signal and the start of the

associated interrupt service routine. Factors that affect interrupt latency include the

length of time that interrupts are disabled during normal program execution,

processor speed, and preemption of the processor by higher priority interrupts.

Interrupt service routine:

A small piece of software executed in response to a particular interrupt. Abbreviated

ISR.

Interrupt type:

A unique number associated with each interrupt. The interrupt type is typically the

processor's index into the interrupt vector.

Interrupt vector:

The address of an interrupt service routine. This term is sometimes used incorrectly

to refer to either the interrupt type or the address of the interrupt vector.

External Interrupts:

Page 35: LIFI Document

External interrupts are a mechanism for I/O devices that communicate infrequently

with the CPU to get the attention of the CPU. Rather than have the CPU constantly

check to see if the I/O device needs attention (this is polling), the device interrupts

the CPU.

There's a protocol between device and CPU that allows the device to indicate what

kind of service it wants from the CPU. Usually, this is done using an interrupt

number. The CPU then locates an interrupt handler based on this number, runs the

code for the handler, and tells the device it's done.

Dealing with I/O devices can slow down the CPU a lot because devices are often as

slow as hard drives, in response time. However, such interrupts are infrequent, so the

CPU only has to manage the interrupts when needed.

At this point, you should know what an external interrupt is, and be able to

summarize the protocol between the CPU and the interrupting device.

Vector interrupts:

This is the fastest system. The onus is placed on the requesting device to request the

interrupt, and identify itself. The identity could be a branching address for the

desired interrupt-handling routine.

If the device just supplies an identification number, this can be used in conjunction

with a lookup table to determine the address of the required service routine.

Response time is best when the device requesting service also supplies a branching

address.

Priority Interrupt Controller Chips (PIC's) are hardware chips designed to make the

task of a device presenting its own address to the CPU simple. The PIC also assesses

the priority of the devices connected to it. Modern PIC's can also be programmed to

prevent the generation of interrupts which are lower than a desired level.

Page 36: LIFI Document

The decoded location is connected to the output of a priority encoder. The input of

the priority encoder is connected to each device. When a device requests service, the

priority encoder presents a special code combination (unique for each device) to the

decoded memory location. The port thus holds the value or address associated with

the highest device requesting service.

The priority encoder arranges all devices in a list, devices given a lower priority are

serviced when no other higher priority devices need servicing. This simplifies the

software required to determine the device, resulting in an increase in speed.

2.4.1.7 ADC Converter:

ARM7 LPC2148 has 14 channel 10 bit ADC. It give the digital outputs with 10bit

resolution. The ADC channels are classified into two types ADC0 and ADC1. ADC0

has six channels (ADC0.0 – ADC0.5) and ADC1 has 8 channels (ADC1.0 to 1.7).

The ADC control register (ADCR) and ADC Data Register (ADDR) and ADGDR

(ADC Global Data Register) are used to develop the code in ARM7 2148.in the

ADGDR the digital output is stored.

Additional features:

• Power-down mode.

• Measurement range 0 V to VREF (typically 3 V; not to exceed VDDA voltage

level).

• 10 bit conversion time ≥ 2.44 μs.

• Burst conversion mode for single or multiple inputs.

• Optional conversion on transition on input pin or Timer Match signal.

• Global Start command for both converters is also available in LPC214x series

Page 37: LIFI Document

UART: ARM7 2148 have 2 UART channels UART0 and UART1. P0.0 and P0.1 are

used for UART0 TX and Rx pins. And P0.8 and P0.9 is used for UART1.

2.4.2 POWER SUPPLY

BLOCK DIAGRAM

The ac Voltage, typically 220V RMS is connected to a transformer, which steps that

ac voltage down to the level of desired dc output. A diode rectifier then provides a

full-wave rectified voltage that is initially filtered by a simple capacitor filter to

produce a dc voltage. This resulting dc voltage usually has some ripple or ac voltage

variation.

Block diagram of power supply

A regulator circuit removes the ripples and also remains the same as dc value even if

the input dc voltage varies, or the load connected to the output dc voltage changes.

This voltage regulation is usually obtained using one of the popular voltage regular

IC units.

2.4.2.1 Working principle

2.4.2.1.1 Transformer

The potential transformer will step down the power supply voltage (0-230) level.

Then the secondary of the potential transformer will be connected to the precision

rectifier, which is constructed with the help of op-amp. The advantages of using

precision rectifier are it will give peak voltage output as dc, rest of the circuit will

give only RMS output.

2.4.2.1.2 Bridge rectifier

Page 38: LIFI Document

When four diodes are connected as shown in fig .the circuit is called as bridge

rectifier. The input to the circuit applied to the diagonal opposite corners of the

network, and the output is taken from the remaining two corners. Let as assume that

the transformer is working properly and there is a positive potential, at a point A and

a negative potential at point B. The positive potential at point a will forward bias D3

and reverse bias D4.The negative potential at point B will forward bias D1 and

reverse D2.At this time D3 and D1 re forward biased and we allow current flow to

pass through them,D4 and D4 are reverse biased and will block current flow.

One advantage of a bridge rectifier over a conventional full-wave rectifier is that

with a given transformer the bridge rectifier produces a voltage output that is nearly

twice that of conventional full-wave circuit .

This may be shown by assigning values to some of the components shown in views

A and B. Assume that the same transformer is used in both circuits the peak voltage

developed between points X and Y is 1000V in both circuits.

2.4.2.1.3 IC Voltage Regulators

Voltage regulators comprises a class of widely used Ic’s. Regulator IC units contain

the circuitry for reference source, comparator, amplifier, control device and overload

protection all in a single IC. IC units provide regulation of either a fixed positive

voltage. The regulators can be selected for operations with load currents from

hundreds of milli amperes to tens of amperes, corresponding to power ratings from

milli watts to tens of watts.

Page 39: LIFI Document

Fig circuit diagram of power supply

A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi,

applied to one input terminal, a regulator dc output voltage, Vo, from a second

terminal with the third terminal connected to ground.

The series 78 regulators provide fixed positive regulated voltages from 5 to 24 volts.

Similarly, the series 79 regulators provide fixed negative regulated voltages from 5

to 24 volts.

2.4.3 SERIAL COMMUNICATION

INTRODUCTION:

Serial communication is basically the transmission or reception of data one bit at a

time. Today's computers generally address data in bytes or some multiple thereof. A

byte contains 8 bits. A bit is basically either a logical 1 or zero. Every character on

this page is actually expressed internally as one byte. The serial port is used to

convert each byte to a stream of ones and zeroes as well as to convert a stream of

ones and zeroes to bytes. The serial port contains a electronic chip called a Universal

Asynchronous Receiver/Transmitter (UART) that actually does the conversion.

The serial port has many pins. We will discuss the transmit and receive pin first.

Electrically speaking, whenever the serial port sends a logical one (1) a negative

voltage is effected on the transmit pin. Whenever the serial port sends a logical zero

(0) a positive voltage is affected. When no data is being sent, the serial port's

Page 40: LIFI Document

transmit pin's voltage is negative (1) and is said to be in a MARK state. Note that the

serial port can also be forced to keep the transmit pin at a positive voltage (0) and is

said to be the SPACE or BREAK state. (The terms MARK and SPACE are also used

to simply denote a negative voltage (1) or a positive voltage (0) at the transmit pin

respectively).

When transmitting a byte, the UART (serial port) first sends a START BIT which is

a positive voltage (0), followed by the data (general 8 bits, but could be 5, 6, 7, or 8

bits) followed by one or two STOP Bits which is a negative(1) voltage. The sequence

is repeated for each byte sent. Figure 1 shows a diagram of what a byte transmission

would look like.

At this point you may want to know what the duration of a bit is. In other words,

how long does the signal stay in a particular state to define a bit. The answer is

simple. It is dependent on the baud rate. The baud rate is the number of times the

signal can switch states in one second. Therefore, if the line is operating at 9600

baud, the line can switch states 9,600 times per second. This means each bit has the

duration of 1/9600 of a second or about 100µsec.

When transmitting a character there are other characteristics other than the baud rate

that must be known or that must be setup. These characteristics define the entire

interpretation of the data stream. The first characteristic is the length of the byte

that will be transmitted. This length in general can be anywhere from 5 to 8 bits.

The second characteristic is parity. The parity characteristic can be even, odd, mark,

space, or none. If even parity, then the last data bit transmitted will be a logical 1 if

the data transmitted had an even amount of 0 bits. If odd parity, then the last data bit

transmitted will be a logical 1 if the data transmitted had an odd amount of 0 bits. If

MARK parity, then the last transmitted data bit will always be a logical 1. If SPACE

parity, then the last transmitted data bit will always be a logical 0. If no parity then

there is no parity bit transmitted.

Page 41: LIFI Document

The third characteristic is the amount of stop bits. This value in general is 1 or 2.

Assume we want to send the letter 'A' over the serial port. The binary representation

of the letter 'A' is 01000001. Remembering that bits are transmitted from least

significant bit (LSB) to most significant bit (MSB), the bit stream transmitted would

be as follows for the line characteristics 8 bits, no parity, 1 stop bit and 9600 baud.

LSB (0 1 0 0 0 0 0 1 0 1) MSB

The above represents (Start Bit) (Data Bits) (Stop Bit). To calculate the actual byte

transfer rate simply divide the baud rate by the number of bits that must be

transferred for each byte of data. In the case of the above example, each character

requires 10 bits to be transmitted for each character. As such, at 9600 baud, up to 960

bytes can be transferred in one second.

The above discussion was concerned with the "electrical/logical" characteristics of

the data stream. We will expand the discussion to line protocol. Serial

communication can be half duplex or full duplex. Full duplex communication means

that a device can receive and transmit data at the same time. Half duplex means that

the device cannot send and receive at the same time. It can do them both, but not at

the same time. Half duplex communication is all but outdated except for a very small

focused set of applications.

Half duplex serial communication needs at a minimum two wires, signal ground and

the data line. Full duplex serial communication needs at a minimum three wires,

signal ground, transmit data line, and receive data line. The RS232 specification

governs the physical and electrical characteristics of serial communications. This

specification defines several additional signals that are asserted (set to logical 1) for

information and control beyond the data signal .

Page 42: LIFI Document

These signals are the Carrier Detect Signal (CD), asserted by modems to signal a

successful connection to another modem, Ring Indicator (RI), asserted by modems to

signal the phone ringing, Data Set Ready (DSR), asserted by modems to show their

presence, Clear To Send (CTS), asserted by modems if they can receive data, Data

Terminal Ready (DTR), asserted by terminals to show their presence, Request To

Send (RTS), asserted by terminals if they can receive data. The section RS232

Cabling describes these signals and how they are connected.

The above paragraph alluded to hardware flow control. Hardware flow control is a

method that two connected devices use to tell each other electronically when to send

or when not to send data. A modem in general drops (logical 0) its CTS line when it

can no longer receive characters. It re-asserts it when it can receive again. A terminal

does the same thing instead with the RTS signal. Another method of hardware flow

control in practice is to perform the same procedure in the previous paragraph except

that the DSR and DTR signals.

Note that hardware flow control requires the use of additional wires. The benefit to

this however is crisp and reliable flow control. Another method of flow control used

is known as software flow control. This method requires a simple 3 wire serial

communication link, transmit data, receive data, and signal ground. If using this

method, when a device can no longer receive, it will transmit a character that the two

devices agreed on. This character is known as the XOFF character. This character is

generally a hexadecimal 13. When a device can receive again it transmits an XON

character that both devices agreed to. This character is generally a hexadecimal 11.

2.4.4 RS232:

When we look at the connector pin out of the RS232 port, we see two pins which are

certainly used for flow control. These two pins are RTS, request to send and CTS,

clear to send. With DTE/DCE communication (i.e. a computer communicating with

a modem device) RTS is an output on the DTE and input on the DCE. CTS are the

answering signal coming from the DCE.

Page 43: LIFI Document

Before sending a character, the DTE asks permission by setting its RTS output. No

information will be sent until the DCE grants permission by using the CTS line.

If the DCE cannot handle new requests, the CTS signal will go low. A simple but

useful mechanism allowing flow control in one direction. The assumption is that the

DTE can always handle incoming information faster than the DCE can send it. In

the past, this was true. Modem speeds of 300 baud were common and 1200 baud was

seen as a high speed connection.

For further control of the information flow, both devices have the ability to signal

their status to the other side. For this purpose, the DTR data terminal ready and DSR

data set ready signals are present. The DTE uses the DTR signal to signal that it is

ready to accept information, whereas the DCE uses the DSR signal for the same

purpose. Using these signals involves not a small protocol of requesting and

answering as with the RTS/CTS handshaking. These signals are in one direction

only.

The last flow control signal present in DTE/DCE communication is the CD carrier

detect. It is not used directly for flow control, but mainly an indication of the ability

of the modem device to communicate with its counterpart. This signal indicates the

existence of a communication link between two modem devices.

2.4.5 SENSORS:

2.4.5.1TEMPERATURE SENSOR:

The silicon band gap temperature sensor is an extremely common form of

temperature sensor (thermometer) used in electronic equipment. Its main advantage

is that it can be included in a silicon integrated circuit at very low cost. The principle

of the sensor is that the forward voltage of a silicon diode is temperature-dependent,

according to the following equation:

Page 44: LIFI Document

Where,

T = temperature in kelvins

T0 = reference temperature

VG0 = band gap voltage at absolute zero

VBE0 = band gap voltage at temperature T0 and current IC0

K = Boltzmann's constant

q = charge on an electron

n = a device-dependent constant

By comparing the band gap voltages at two different currents, IC1 and IC2, many of

the variables in the above equation can be eliminated, resulting in the relationship:

An electronic circuit, such as the Brokaw band gap reference, that measures ΔVBE can

therefore be used to calculate the temperature of the diode. The result remains valid

up to about 200 °C to 250 °C, when leakage currents become large enough to corrupt

the measurement. Above these temperatures, materials such as silicon carbide can be

used instead of silicon.

If high precision is not required it is enough to bias a diode with any constant low

current and use its −2 mV/˚C thermal coefficient for temperature calculation,

however this requires calibration for each diode type. This method is common in

monolithic temperature sensors.

Page 45: LIFI Document

Pin

No

Function Name

1 Supply voltage; 5V (+35V to -2V) Vcc

2 Output voltage (+6V to -1V) Output

3 Ground (0V) Ground

2.4.5.2 GAS SENSOR:

Electrochemical gas sensors are gas detectors that measure the concentration

of a target gas by oxidizing or reducing the target gas at an electrode and measuring

the resulting current. The sensors contain two or three electrodes, occasionally four,

in contact with an electrolyte. The electrodes are typically fabricated by fixing a high

surface area precious metal on to the porous hydrophobic membrane. The working

electrode contacts both the electrolyte and the ambient air to be monitored usually

via a porous membrane. The electrolyte most commonly used is a mineral acid, but

organic electrolytes are also used for some sensors. The electrodes and housing are

usually in a plastic housing which contains a gas entry hole for the gas and electrical

contacts.

2.4.5.2.1THEORY OF OPERATION:

Page 46: LIFI Document

The gas diffuses into the sensor, through the back of the porous membrane to the

working electrode where it is oxidized or reduced. This electrochemical reaction

results in an electric current that passes through the external circuit. In addition to

measuring, amplifying and performing other signal processing functions, the external

circuit maintains the voltage across the sensor between the working and counter

electrodes for a two electrode sensor or between the working and reference

electrodes for a three electrode cell. At the counter electrode an equal and opposite

reaction occurs, such that if the working electrode is an oxidation, then the counter

electrode is a reduction.

2.4.5.2.2DIFFUSION CONTROLLED RESPONSE:

The magnitude of the current is controlled by how much of the target gas is oxidized

at the working electrode. Sensors are usually designed so that the gas supply is

limited by diffusion and thus the output from the sensor is linearly proportional to

the gas concentration. This linear output is one of the advantages of electrochemical

sensors over other sensor technologies, (e.g. infrared), whose output must be

linearized before they can be used. A linear output allows for more precise

measurement of low concentrations and much simpler calibration (only baseline and

one point are needed).

Diffusion control offers another advantage. Changing the diffusion barrier allows the

sensor manufacturer to tailor the sensor to a particular target gas concentration range.

In addition, since the diffusion barrier is primarily mechanical, the calibration of

electrochemical sensors tends to be more stable over time and so electrochemical

sensor based instruments require much less maintenance than some other detection

technologies. In principle, the sensitivity can be calculated based on the diffusion

properties of the gas path into the sensor, though experimental errors in the

measurement of the diffusion properties make the calculation less accurate than

calibrating with test gas.

2.4.5.2.3 CROSS SENSITIVITY:

Page 47: LIFI Document

For some gases such as ethylene oxide, cross sensitivity can be a problem because

ethylene oxide requires a very active working electrode catalyst and high operating

potential for its oxidation. Therefore gases which are more easily oxidized such as

alcohols and carbon monoxide will also give a response. Cross sensitivity problems

can be eliminated though through the use of a chemical filter, for example filters that

allows the target gas to pass through unimpeded, but which reacts with and removes

common interferences.

While electrochemical sensors offer many advantages, they are not suitable for every

gas. Since the detection mechanism involves the oxidation or reduction of the gas,

electrochemical sensors are usually only suitable for gases which are

electrochemically active, though it is possible to detect electrochemically inert gases

indirectly if the gas interacts with another species in the sensor that then produces a

response. Sensors for carbon dioxide are an example of this approach and they have

been commercially available for several years.

2.4.6 MAX 3232:

INTRODUCTION:

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

port to signals suitable for use in TTL compatible digital logic circuits. The

MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS

signals.

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

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

for implementing RS-232 in devices that otherwise do not need any voltages outside

the 0 V to + 5 V range, as power supply design does not need to be made more

complicated just for driving the RS-232 in this case.

Page 48: LIFI Document

The receivers reduce RS-232 inputs (which may be as high as ± 25 V), to standard

5 V TTL levels. These receivers have a typical threshold of 1.3 V, and a typical

hysteresis of 0.5 V.

The later MAX232A is backwards compatible with the original MAX232 but may

operate at higher baud rates and can use smaller external capacitors – 0.1 μF in place

of the 1.0 μF capacitors used with the original device.

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

voltage range, from 3 to 5.5 V. Pin to pin compatible: ICL232, ST232, ADM232,

and HIN232.

2.4.7 VOLTAGE LEVELS:

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

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

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

RS232 to TTL. This can be confusing when you realize that the RS232 Data

Transmission voltages at a certain logic state are opposite from the RS232 Control

Line voltages at the same logic state. To clarify the matter, see the table below. For

more information see RS-232 Voltage Levels.

RS232 Line Type &

Logic Level

RS232 Voltage TTL Voltage to/from MAX232

Data Transmission

(Rx/Tx) Logic 0

+3 V to +15 V 0 V

Data Transmission

(Rx/Tx) Logic 1

-3 V to -15 V 5 V

Control Signals

(RTS/CTS/DTR/DSR)

Logic 0

-3 V to -15 V 5 V

Page 49: LIFI Document

Control Signals

(RTS/CTS/DTR/DSR)

Logic 1

+3 V to +15 V 0 V

Figure: Max232 Pin Diagram

2.4.8 Relays

A relay is an electrically operated switch. Many relays use an

electromagnet to mechanically operate a switch, but other operating principles

are also used, such as solid-state relays. Relays are used where it is necessary to

control a circuit by a low-power signal (with complete electrical isolation between

control and controlled circuits), or where several circuits must be controlled by one

signal. The first relays were used in long distance telegraph circuits as amplifiers.

They repeated the signal coming in from one circuit and re-transmitted it on

another circuit. Relays were used extensively in telephone exchanges and early

computers to perform logical operations.

Page 50: LIFI Document

Figure 2.20: Relay Pin Diagram

Each channel or Darlington pair in ULN2003is rated at 500mA and can withstand

peak current of 600mA. The inputs and outputs are provided opposite to each other

in the pin layout. Each driver also contains a suppression diode to dissipate

voltage spikes while driving inductive loads. The schematic for each driver is

given below:

Figure : Internal Diagram of Relay

Page 51: LIFI Document

2.4.8.1 FEATURES

500 mA rated collector current (single output)

50 V output

Includes output fly back diodes

Inputs compatible with various types of logic

2.4.8.2APPLICATIONS

Drive relays

LED displays or lamp

Stepper motors

It was invented by Joseph Henry in 1835. “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.

Figure 2.22: Relay

One such product is the ‘sugar cube’ relay, shown in the figure above, which has

proved useful to many designers who needed to switch up to 10A, whilst using

relatively little PCB area Since relays are switches, the terminology applied to

Page 52: LIFI Document

Switches is also applied to relays. A relay will switch one or more poles, each of

whose contacts can be thrown by energizing the coil in one of three ways:

1. Normally - open (NO)

2. Normally - closed (NC)

3. Change-over or double-throw

All relays contain a sensing unit, the electric coil, which is powered by AC or DC

current. When the applied current or voltage exceeds a threshold value, the coil

activates the armature, which operates either to close the open contacts or to open

the closed contacts. When a power is supplied to the coil, it generates a magnetic

force that actuates the switch mechanism. The magnetic force is, in effect,

relaying the action from one circuit to another. The first circuit is called the

control circuit; the second is called the load circuit.

Electromechanical Relays

In our project we will be using an electromechanical relay, which will be a 5 pin

relay and the working of the relay will be like as. The general-purpose relay is

rated by the amount of current its switch contacts can handle. Most versions of the

general-purpose relay have one to eight poles and can be single or double throw.

These are found in computers, copy machines, and other consumer electronic

equipment and appliances.

Relay Driver (Uln2003):

The ULN2001A, ULN2002A, ULN2003 and ULN2004Aare high Voltage, high

current Darlington arrays each containing seven open collector Darlington pairs

with common emitters. Each channel rated at 500mAand can withstand peak

currents of 600mA.Suppressiondiodesare included for inductive load driving and

the inputs are pinned opposite the outputs to simplify board layout. These versatile

devices are useful for driving a wide range of loads including solenoids, relays DC

Page 53: LIFI Document

Motors; LED displays filament lamps, thermal print heads and high power buffers.

The ULN2001A/2002A/2003A and 2004A are supplied in 16 pin plastic DIP

packages with a copper lead frame to reduce thermal resistance. They are available

also in small outline package (SO-16) as ULN2001D/2002D/2003D/2004D.

2.5 SOFTWARE COMPONENTS

2.5.1 KEIL Software

Keil compiler is software used where the machine language code is written and

compiled. After compilation, the machine source code is converted into hex code

which is to be dumped into the microcontroller for further processing. Keil

compiler also supports C language code.

STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN

KEIL AND HOW TO COMPILE IT:

Install the Keil Software in the PC in any of the drives.

After installation, an icon will be created with the name “Keil uVision3”.

Just drag this icon onto the desktop so that it becomes easy whenever you

try to write programs in Keil.

Double click on this icon to start the Keil compiler.

A page opens with different options in it showing the project workspace

at the leftmost corner side, output window in the bottom and an ash

colored space for the program to be written.

Now to start using the Keil, click on the option “project”.

A small window opens showing the options like new project, import

Page 54: LIFI Document

project, open project etc. Click on “New project”.

A small window with the title bar “Create new project” opens. The

window asks the user to give the project name with which it should be

created and the destination location. The project can be created in any of

the drives available. You can create a new folder and then a new file or can

create directly a new file.

After the file is saved in the given destination location, a window

opens where a list of vendors will be displayed and you have to select

the device for the target you have created.

The most widely used vendor is Atmel. So click on Atmel and now

the family of microcontrollers manufactured by Atmel opens. You can

select any one of the microcontrollers according to the requirement.

When you click on any one of the microcontrollers, the features of

that particular microcontroller will be displayed on the right side of the

page. The most appropriate microcontroller with which most of the

projects can be implemented is the AT89C51. Click on this

microcontroller and have a look at its features. Now click on “OK” to

select this microcontroller.

A small window opens asking whether to copy the startup code into the

file you have created just now. Just click on “No” to proceed further.

Now you can see the TARGET and SOURCE GROUP created in the

project workspace.

Now click on “File” and in that “New”. A new page opens and you can

start writing program in it.

Page 55: LIFI Document

After the program is completed, save it with any name but with the

.asm extension. Save the program in the file you have created earlier.

You can notice that after you save the program, the predefined

keywords will be highlighted in bold letters.

Now add this file to the target by giving a right click on the source group.

A list of options open and in that select “Add files to the source group”.

Check for this file where you have saved and add it.

Right click on the target and select the first option “Options for target”.

A window opens with different options like device, target, output etc.

First click on “target”.

Since the set frequency of the microcontroller is 11.0592 MHz to

interface with the PC, just enter this frequency value in the Xtal (MHz)

text area and put a tick on the Use on-chip ROM. This is because the

program what we write here in the Keil will later be dumped into the

microcontroller and will be stored in the inbuilt ROM in the

microcontroller.

Now click the option “Output” and give any name to the hex file to

be created in the “Name of executable” text area and put a tick to the

“Create HEX file” option present in the same window.

The hex file can be created in any of the drives. You can change the

folder by clicking on “Select folder for Objects”.

Now to check whether the program you have written is errorless or not,

click on the icon exactly below the “Open file” icon which is nothing but

Build Target icon.

Page 56: LIFI Document

You can even use the shortcut key F7 to compile the program written.

To check for the output, there are several windows like serial

window, memory window, project window etc.

Depending on the program you have written, select the appropriate

window to see the output by entering into debug mode.

The icon with the letter “d” indicates the debug mode.

Click on this icon and now click on the option “View” and select

the appropriate window to check for the output.

After this is done, click the icon “debug” again to come out of the

debug mode.

The hex file created as shown earlier will be dumped into

the microcontroller with the help of another software called Flash magic.

Embedded C:

An embedded system is an application that contains at least one programmable

computer (typically in the form of a microcontroller, a microprocessor or digital

signal processor chip) and which is used by individuals who are, in the main,

unaware that the system is computer-based.

Typical examples of embedded applications that are constructed using the

techniques discussed in this book include:

Mobile phone systems (including both customer handsets and base stations).

Automotive applications (including braking systems, traction control, airbag

Page 57: LIFI Document

release systems, engine-management units, steer-by-wire systems and cruise

control Applications).

Domestic appliances (including dishwashers, televisions, washing machines,

microwave ovens, video recorders, security systems, garage door controllers).

Aerospace applications (including flight control systems, engine controllers,

autopilots and passenger in-flight entertainment systems).

Medical equipment (including anesthesia monitoring systems, ECG monitors,

drug delivery systems and MRI scanners).

Defense systems (including radar systems, fighter aircraft flight control systems,

radio systems and missile guidance systems).

Please note that our definition of embedded systems excludes applications such as

‘personal digital assistants’ (PDAs) running versions of Windows or similar

operating systems: from a developer’s perspective, these are best viewed as a cut-

down version of a desktop computer system. This type of application makes up a

very small percentage of the overall ‘embedded’ market.

CODING:

Embedded C:

#include <lpc214x.h>

#include <stdio.h>

#include "Utility.h"

#define DONE 0x80000000

#define START 0x01000000

#define PRESET 0x00230600

Page 58: LIFI Document

void delay(int);

unsigned char Temp[10],Pre[10],Gas[10];

//------------------------------

// Serial Port Initialize

//------------------------------

void serial init(void)

{

PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */

U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */

U0DLL = 195; /* 9600 Baud Rate @ 12MHz VPB Clock */

U0LCR = 0x03; /* DLAB = 0 */

}

//------------------------

//Delay Routine start here

//------------------------

void delay(int n)

{

int i,j;

for(i=0;i<n;i++)

Page 59: LIFI Document

{

for(j=0;j<0x5000;j++)

{;}

}

}

//Main program starts here

int main(void)

{

unsigned long val[4],T,G;

unsigned int ADC_CH,i=0;

float T_F;

PINSEL0 = 0x00000005; //Enable RXD0 and TXD0

PINSEL1 |= 0x01 << 24; //Enable ADC0.1

PINSEL1 |= 0x01 << 26-; //Enable ADC0.2

PINSEL1 |= 0x01 << 28; //Enable ADC0.3

VPBDIV = 0x02; //Set the cclk to 30 Mhz

AD0CR = 0x00250602; //ADC configuration bits CLK

= 9clks/8Bit | BURST=1 | CLKDIV = 0x06

AD0CR |= 0x01000000; //start ADC now

Page 60: LIFI Document

serial_init(); //serial initialization

//Enable UART0 Interrupt

IODIR0 |= 0xff << 16;

IODIR1 |= 0xf << 20;

while(1)

{

while (ADC_CH <4)

{

do

{

val[ADC_CH] = AD0GDR; // Read A/D Data Register

}

while ((val[ADC_CH] & 0x80000000) == 0); //Wait for the conversion

to complete

val[ADC_CH] = ((val[ADC_CH] >> 6) & 0x03FF);

ADC_CH++; delay(10);

AD0CR = PRESET | (1<<ADC_CH);

AD0CR |= START;

} //Temperature

Page 61: LIFI Document

U0THR = 0xAB; delay(5);

U0THR = 0xB1; delay(5);

T = (AD0DR1 >> 6) & 0x03FF; delay(5);

T_F = T;

U0THR = T;

//PRE

U0THR = 0xAB; delay(5);

U0THR = 0xB2; delay(5);

G = (AD0DR2 >> 6) & 0x03FF; delay(5);

U0THR =G;

 

//GAS

U0THR = 0xAB; delay(5);

U0THR = 0xB3; delay(5);

G = (AD0DR2 >> 6) & 0x03FF; delay(5);

U0THR =P;

 

}

    

}

Page 62: LIFI Document

 

Page 63: LIFI Document