Final Hard Bound Copy

62
Chapter-1 Introduction 1.1 Introduction This pr oj ect report des cr ibes about des ign, devel opment and fa brication of  demonstration unit of the project work “Wireless Automation Using Low Power Embedded Web Servers” followed by detailed discussion of design consideration and design veri ficat ion. This proj ect work is aimed in using the Elec troni cs in home front or any companies through low power embedded web servers (wireless). With the advancement of technology, electronics has entered in to every field. To make more innovative and more comfortable living, it is decided to develop a  project in home electronics using low power embedded web servers.  Nowadays, with the advancement of technology, all the activities in our day to day living have become a part of information and we find micro-controllers in each and every application. Thus, the trend is directing towards the microcontroller based applica tio ns. In this projec t mic ro controlle r is used for controlling various  pa ramete rs. The term Automati on ref ers to mea ns of contro l of elect ric al and mechanical operations without human interference. In our project the automation can be done from remote places through low power embedded web servers. Internet and Computer commu nicati on systems are playi ng an impor tant role in the daily life. Many applications are possible to implement using this knowledge. Home automation, utility meters, appliances, security systems, card readers, and building controls, which can be easily, controlled using either special front-end software or a standard internet browser client from anywhere around the world. A web server in the device provides access to the user interface functions for the device through a device web page. A web server can be embedded into any appliance and connected to the Internet so the appliance can be monitored and controlled from remote places through the browser in a desktop. 1

Transcript of Final Hard Bound Copy

Page 1: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 1/62

Chapter-1

Introduction

1.1 Introduction

This project report describes about design, development and fabrication of 

demonstration unit of the project work “Wireless Automation Using Low Power 

Embedded Web Servers” followed by detailed discussion of design consideration

and design verification. This project work is aimed in using the Electronics in

home front or any companies through low power embedded web servers (wireless).

With the advancement of technology, electronics has entered in to every field. To

make more innovative and more comfortable living, it is decided to develop a

 project in home electronics using low power embedded web servers.

 Nowadays, with the advancement of technology, all the activities in our day to day

living have become a part of information and we find micro-controllers in each and

every application. Thus, the trend is directing towards the microcontroller based

applications. In this project micro controller is used for controlling various

 parameters. The term Automation refers to means of control of electrical and

mechanical operations without human interference. In our project the automation

can be done from remote places through low power embedded web servers.

Internet and Computer communication systems are playing an important role in the

daily life. Many applications are possible to implement using this knowledge. Home

automation, utility meters, appliances, security systems, card readers, and building

controls, which can be easily, controlled using either special front-end software or a

standard internet browser client from anywhere around the world.

A web server in the device provides access to the user interface functions for the

device through a device web page. A web server can be embedded into any appliance

and connected to the Internet so the appliance can be monitored and controlled from

remote places through the browser in a desktop.

1

Page 2: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 2/62

1.2 Aim of the project

The aim of the project is to control the devices or equipment’s from the remote place

through a web page. Here all the devices, which are to be controlled, are connected to

the relays (acts as switches) on the web server circuit board. The web-server circuit is

connected to LAN or Internet. The client or a person on the PC is also connected to

same LAN or Internet. By typing the IP-address of LAN on the web browser, the

user gets a web page on screen; this page contains all the information about the status

of the devices (whether they are ON or OFF). On this page the user is provided with

checkboxes to check or uncheck the boxes in order switch OFF or switch ON the

devices.

1.3 Motivation of the project

Controlling the home or any company appliances manually requires a lot of effort.

When we are outside the office/home we can’t even maintain them properly. This

may lead to power wastage and may reduce equipment life time thereby it may

reduce the system efficiency. Hence, we are going for this project.

In our project we are making use of a PIC micro controller, which use less power 

when compared to other micro controllers. Here, we can access the control

information of devices through web page from remote places. This will reduce the

human effort to a great extent. By this way we can reduce the power usage and can

 properly maintain the devices efficiently.

1.4. Literature survey

Lot of research has been carried out in the area of home automation which helps in

 providing flexibility in handling home appliances from distant places. The web site

which we mostly referred is  www.en.wikepedia.com. We also referred other web

sites such as www.microchip.com,  www.flashmagic.com and

www.national.com/pf/LM/LM2825.html

 

2

Page 3: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 3/62

We also referred text books such as Programming and Customizing PIC

microcontroller by Myke Predko, Serial Communication by Roger L.Stevens,

Embedded Ethernet and Internet complete by Jan Axelson etc and we had also

referred journals like EURASIP and some other articles related to our topic.

1.5. Technical approach

Our main intension here is to control the devices or equipment’s from the remote

 place through a web page. Here all the devices, which are to be controlled, are

connected to the relays (acts as switches) on the web server circuit board. The web-

server circuit is connected to LAN or Internet. The client or a person on the PC is

also connected to same LAN or Internet. By typing the IP-address of LAN on the

web browser, the user gets a web page on screen; this page contains all the

information about the status of the devices. The user can also control the devices

interfaced to the web server by pressing a button provided in the web page.

SPI communication: Devices communicate using a master/slave relationship, in

which the master initiates the data frame. When the master generates a clock and

selects a slave device, data may be transferred in either or both directions

simultaneously. In fact, as far as SPI is concerned, data are always transferred in

 both directions. It is up to the master and slave devices to know whether a received

 byte is meaningful or not. So a device must discard the received byte in a "transmit

only" frame or generate a dummy byte for a "receive only" frame.

3

Page 4: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 4/62

  Fig 1.1: Block diagram.

4

10 Base

TEthernet

ENC28J60

ETHERNET

CONTROLLER 

PICPROCESSOR 

Sensor I

LAN

 

Client

Sensor II

ADC

PROTOCOL

S

P

I

SPI

COMMUNICATION

RJ45

5V SUPPLY

3.3V SUPPY

DRIVER UNIT

DRIVER UNIT

DEVICEI

DEVICE

II

DEVICE

STATUSREADER 

L

A

 N 

C

O

 N N

E

CT

I

O N

Page 5: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 5/62

1.6. Application of the project

As the technology advances, changing lifestyles patterns and willingness to spend in

automation may lead this project to be used in many applications.

Using the Internet many applications are implemented such as home automation,

utility meters, appliances, security systems, card readers, and building controls,

which can be easily, controlled using either special front-end software or a standard

internet browser client from anywhere around the world.

A wireless Automation Using Low Power Embedded Web server is used to provide

control of appliances from remote places through webpage. This finds applications in

automation of home or any company from remote places. This can also be used in

large industries to control required devices.

1.7. Organization of the project report

This project report consists of six chapters including introduction and conclusion.

Introduction about the project, aim and motivation are included in the first chapter.

Chapter 2 gives detailed description of the circuit diagram and chapter 3 contains

details about relays and temperature sensors used in the project. Serial

communication is discussed in chapter 4 and chapter 5 includes details of all the

embedded soft wares used to develop this project. Finally Results and Conclusions

are discussed in chapter 6.

5

Page 6: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 6/62

Chapter-2

Circuit analysis

Introduction

In this chapter we are going to discuss about the PIC microcontroller and its

features, power supply unit, ADC module, Ethernet Controller, oscillator, voltage

regulator and also about the RJ45.

2.1. Micro controller

A micro-controller-based physiological sensing unit has been designed, prototyped,

and field-tested for recording galvanic skin response data and relaying them to a

computer for physiological analysis. Data flow coordination and timing control are

enabled by a PIC micro-controller. The embedded block is connected with the

computer through serial port and the client can automatically give messages and can

control different appliances from remote places. [4], [13]

PIC16F877A microcontroller is used for this project

• It is 8-bit Microcontroller 

• System is RISC Architecture

• It has Small set of Instruction set

• It has 35-Instructions only

• Compatibility: avail 28/40 Pin ICs

Operating Speed Max 20 MHz, Voltage-(2-5.5)v

• Flash Program memory 8Kx14 Words,

• RAM memory 368 Bytes,

• EEPROM Data Memory 256 Bytes

6

Page 7: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 7/62

• Low power, High speed Flash/EEPROM Technology

2.1.1. Features

• It has 5 Ports for Internal and External usage

• It has on chip Timers. 3 Timers are avail

• It has in built Analog to Digital Converter 

• In built Multiplexer availability for signal Selection

• It has serial as well as Parallel Communication facilities

• In built Capture, Compare and Pulse width modulation[14]

Fig 2.1: Pin diagram of PIC16F877A [16]

2.1.2. PORTA and the TRISA Register

PORTA is a 6-bit wide, bi-directional port. The corresponding data direction

register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA

7

Page 8: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 8/62

 pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode).

Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e.,

 put the contents of the output latch on the selected pin). Reading the PORTA

register reads the status of the pins, whereas writing to it will write to the port latch.

All write operations are read-modify-write operations. Therefore, a write to a port

implies that the port pins are read, the value is modified and then written to the port

data latch. Pin RA4 is multiplexed with the Timer0 module clock input to become

the RA4/T0CKI pin. The RA4/T0CKI pin is a Schmitt Trigger input and an open

drain output. All other PORTA pins have TTL input levels and full CMOS output

drivers. Other PORTA pins are multiplexed with analog inputs and analog VREF

input. The operation of each pin is selected by clearing/setting the control bits in the

ADCON1 register (A/D Control Register1).

2.1.3. PORTB and the TRISB Register

PORTB is an 8-bit wide, bi-directional port. The corresponding data direction

register is TRISB. Setting a TRISB bit (= 1) will make the corresponding PORTB

 pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode).

Clearing a TRISB bit (= 0) will make the corresponding PORTB pin an output (i.e.,

 put the contents of the output latch on the selected pin). Three pins of PORTB are

multiplexed with the Low Voltage Programming function: RB3/PGM, RB6/PGC

and RB7/PGD. The alternate functions of these pins are described in the Special

Features Section. Each of the PORTB pins has a weak internal pull-up. A single

control bit can turn on all the pull-ups. This is performed by clearing bit RBPU

(OPTION_REG<7>). The weak pull-up is automatically turned off when the port

 pin is configured as an output. The pull-ups are disabled on a Power-on Reset.

Four of the PORTB pins, RB7:RB4, have an interrupt on- change feature. Only pins

configured as inputs can cause this interrupt to occur. The input pins (of RB7:RB4)

are compared with the old value latched on the last read of PORTB. The

8

Page 9: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 9/62

“mismatch” outputs of RB7:RB4 are OR’ed together to generate the RB Port

Change Interrupt with flag bit RBIF (INTCON<0>).

2.1.4. PORT C

PORTC is an 8-bit wide, bi-directional port. The corresponding data direction

register is TRISC. Setting a TRISC bit (= 1) will make the corresponding PORTC

 pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode).

Clearing a TRISC bit (= 0) will make the corresponding PORTC pin an output (i.e.,

 put the contents of the output latch on the selected pin). PORTC is multiplexed with

several peripheral functions (Table 3-5). PORTC pins have Schmitt Trigger input

 buffers. When the I2C module is enabled, the PORTC<4:3> pins can be configured

with normal I2C levels or with SMBus levels by using the CKE bit

(SSPSTAT<6>). When enabling peripheral functions, care should be taken in

defining TRIS bits for each PORTC pin. Some peripherals override the TRIS bit to

make a pin an output, while other peripherals override the TRIS bit to make a pin an

input. Since the TRIS bit override is in effect while the peripheral is enabled, read-

modify write instructions (BSF, BCF, XORWF) with TRISC as destination, should

 be avoided. The user should refer to the corresponding peripheral section for the

correct TRIS bit settings.

2.1.5. PORTD and TRISD Registers

PORTD and TRISD are not implemented on the PIC16F873 or PIC16F876.

PORTD is an 8-bit port with Schmitt Trigger input buffers. Each pin is individually

configurable as an input or output. PORTD can be configured as an 8-bit wide

microprocessor port (parallel slave port) by setting control bit PSPMODE

(TRISE<4>). In this mode, the input buffers are TTL. [9]

9

Page 10: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 10/62

V D D

M C L R

R XT X

R A 0

R BR BR BR BR BR BR BR B

R DR DR DR DR DR DR DR D

R C 2R C 3R C 4R C 5R C 6

R C 7

R E 2R E 1

R E 0R A 5R A 4R A 3R A 2R A 1

R C 0R C 1

R A 0

C 92 7 p F

C 82 7 p F

C 1 00 . 1 u F

P I C 1 6 F 8 7 7U 3

123456

               1

               1

               3

               2

               1

               2

               3

               1

78

91 0

1 31 4

1 51 61 71 8

1 92 0

3 33 43 53 63 73 83 94 0

2 82 93 0

2 12 2

2 42 5

2 6

2 7

2 3

M C L R / V p pR A 0 / A N 0R A 1 / A N 1R A 2 / A N 2 / V r e f -R A 3 / A N 3 / V r e f +R A 4 / T 0 C K I

               V

               D

               D

               V

               D

               D

               V

               S

               S

               V

               S

               S

R A 5 / A N 4 / S SR E 0 / A N 5 / R DR E 1 / A N 6 / W RR E 2 / A N 7 / C S

O S C 1 / C L K I NO S C 2 / C L K O U T

R C 0 / T 1 O S O / T 1 C K IR C 1 / T 1 O S I / C C P 2R C 2 / C C P 1R C 3 / S C K / S C L

R D 0 / P S P 0R D 1 / P S P 1

R B 0 / I N TR B 1R B 2

R B 3 / P G MR B 4R B 5

R B 6 / P G CR B 7 / P G D

R D 5 / P S P 5R D 6 / P S P 6R D 7 / P S P 7

R D 2 / P S P 2R D 3 / P S P 3

R C 5 / S D OR C 6 / T X / C K

R C 7 / R X / D T

R D 4 / P S P 4

R C 4 / S D I / S D A

Y 1

4 M h z

R 6

1 k

R 5

2 2 0 o h m

S W 2

R E S E T

Fig 2.2: Circuit diagram of PIC micro controller.

2.2. Power supply

The ac voltage, typically 220V rms, is connected to a transformer, which steps that ac

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

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

10

Page 11: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 11/62

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

variation.

A regulator circuit removes the ripples and also remains the same 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 regulator IC

units.

Fig 2.3: Block diagram of Power supply

2.2.1. Transformer

Potential Transformers

PTs or VTs are the most common devices used. These devices are conventionaltransformers with two or three windings (one primary with one or two secondary).

They have an iron core and magnetically couple the primary and secondary. The

high side winding is constructed with more copper turns than the secondary(ies),

and any voltage impressed on the primary winding is reflected on the secondary

windings in direct proportion to the turns ratio or PT ratio.

Current Transformers

A current transformer (CT) is a type of instrument transformer designed to

 provide a current in its secondary winding proportional to the alternating current

flowing in its primary. They are commonly used in metering and protective relaying

in the electrical power industry where they facilitate the safe measurement of large

currents, often in the presence of high voltages. The current transformer safely

11

TRANSFORMER RECTIFIER FILTER ICREGULATOR 

LOAD

Page 12: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 12/62

isolates measurement and control circuitry from the high voltages typically present

on the circuit being measured. The potential transformer will step down the power 

supply voltage (0-230V) to (0-6V) 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 circuits will give only RMS output.[7]

2.2.2. Bridge rectifier

When four diodes are connected as shown in figure, the circuit is called as bridge

rectifier. The input to the circuit is applied to the diagonally opposite corners of the

network, and the output is taken from the remaining two corners.

Let us assume that the transformer is working properly and there is a positive

 potential, at 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 are forward biased and will allow current flow to pass through them; D4

and D2 are reverse biased and will block current flow.

The path for current flow is from point B through D1, up through RL, through D3,

through the secondary of the transformer back to point B. this path is indicated by

the solid arrows. Waveforms (1) and (2) can be observed across D1 and D3.

One-half cycle later the polarity across the secondary of the transformer reverse,

forward biasing D2 and D4 and reverse biasing D1 and D3. Current flow will now

 be from point A through D4, up through RL, through D2, through the secondary of 

T1, and back to point A. This path is indicated by the broken arrows. Waveforms

(3) and (4) can be observed across D2 and D4. The current flow through RL is

always in the same direction. In flowing through RL this current develops a voltage

corresponding to that shown waveform (5). Since current flows through the load

12

Page 13: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 13/62

(RL) during both half cycles of the applied voltage, this bridge rectifier is a full-

wave rectifier.

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 nearlytwice that of the 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 1000 volts in both circuits. In the

conventional full-wave circuit shown—in view A, the peak voltage from the center 

tap to either X or Y is 500 volts. Since only one diode can conduct at any instant,

the maximum voltage that can be rectified at any instant is 500 volts.

The maximum voltage that appears across the load resistor is nearly-but never 

exceeds-500 v0lts, as result of the small voltage drop across the diode. In the bridge

rectifier shown in view B, the maximum voltage that can be rectified is the full

secondary voltage, which is 1000 volts. Therefore, the peak output voltage across

the load resistor is nearly 1000 volts. With both circuits using the same transformer,

the bridge rectifier circuit produces a higher output voltage than the conventional

full-wave rectifier circuit.

2.2.3. IC voltage regulators

Voltage regulators comprise a class of widely used ICs. 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, a fixed negative voltage, or an adjustably set voltage. The

regulators can be selected for operation with load currents from hundreds of milli

amperes to tens of amperes, corresponding to power ratings from milli watts to tensof watts.

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

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

terminal, with the third terminal connected to ground. The series 78 regulators

13

Page 14: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 14/62

 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.

• For ICs, microcontroller, LCD --------- 5 volts

• For alarm circuit, op-amp, relay circuits ---------- 12 volts

V D D

V D

C 7

0 . 1 u F

J P 2

2 2 0 V A C

1

2- +

D 11

4

                     3

2

U 27 8 0 5

1

                     3

2V I N

                     G

                    N

                    D

V O U T

C 6

1 0 0 u F

C 5

4 7 0 u F

R 4

2 2 0

D 2

L E D

Fig 2.4: Circuit diagram of Power Supply

The operation of power supply circuits built using filters, rectifiers, and then

voltage regulators. Starting with an AC voltage, a steady DC voltage is obtained by

rectifying the AC voltage, then filtering to a DC level, and finally, regulating to

obtain a desired fixed DC voltage. The regulation is usually obtained from an IC

voltage regulator Unit, which takes a DC voltage and provides a somewhat lower 

14

Page 15: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 15/62

DC voltage, which remains the same even if the input DC voltage varies, or the

output Load connected to the DC voltage changes.

2.3. ADC module

The conversion technique based on a successive-approximation register (SAR), also

known as bit-weighing conversion, employs a comparator to weigh the applied

input voltage against the output of an N-bit digital-to-analog converter (DAC).

Using the DAC output as a reference, this process approaches the final result as a

sum of N weighting steps, in which each step is a single-bit conversion.[8]

Initially all bits of SAR are set to 0. Then, beginning with the most significant bit,

each bit is set to 1 sequentially. If the DAC output does not exceed the input signal

voltage, the bit is left as a 1. Otherwise it is set back to 0. It is kind of a binary

search. For an n-bit ADC, n steps are required.

Fig 2.5: Block diagram of ADC

A successive approximation converter provides a fast conversion of a momentary

value of the input signal. It works by first comparing the input with a voltage which

is half the input range. If the input is over this level it compares it with three-

quarters of the range, and so on. Twelve such steps give 10-bit resolution. While

these comparisons are taking place the signal is frozen in a sample and hold circuit.

After A-D conversion the resulting bytes are placed into either a pipeline or buffer 

15

Page 16: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 16/62

store. A pipeline store enables the A-D converter to do another conversion while the

 previous data is transferred to the computer. [8]

Fig.2.6: ADC module

2.3.1. Details about PIC16F877A – ADC

The conversion of an analog input signal results in a corresponding 10-bit digital

number. The A/D module has high and low-voltage reference input that is software

selectable to some combination of VDD, VSS RA2 or RA3.

The A/D module has four registers.

16

Page 17: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 17/62

o A/D Result High Register (ADRESH)

o A/D Result Low Register(ADRESL)

o A/D Control Register 0 (ADCON0)

o A/D Control Register 1 (ADCON1)

 

The ADCON0 register controls the operation of the A/D module. The ADCON1

register configures the functions of the port pins. The port pins can be configured as

analog inputs (RA3 can also be the voltage reference) or as digital I/O.

2.3.2. ADC Registers

• ADCON 0 Register 

• ADCON 1 Register:

2.4. Ethernet controller (ENC28J60)

2.4.1. Introduction

Ethernet is a family of frame-based computer networking technologies for local

area networks (LANs). The name comes from the physical concept of the ether. It

defines a number of wiring and signaling standards for the Physical Layer of the

OSI networking model, through means of network access at the Media Access

Control (MAC) /Data Link Layer, and a common addressing format.

Ethernet is standardized as IEEE 802.3. The combination of the twisted pair 

versions of Ethernet for connecting end systems to the network, along with the fiber 

optic versions for site backbones, is the most widespread wired LAN technology. It

17

Page 18: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 18/62

has been in use from around 1980 to the present, largely replacing competing LAN

standards such as token ring, FDDI, and ARCNET. [2]

2.4.2. Overview

The ENC28J60 is a stand-alone Ethernet controller with an industry standard Serial

Peripheral Interface (SPI). It is designed to serve as an Ethernet network interface

for any controller equipped with SPI. The ENC28J60 meets all of the IEEE 802.3

specifications. It incorporates a number of packet filtering schemes to limit

incoming packets. [3]It also provides an internal DMA module for fast data

throughput and hardware assisted checksum calculation, which is used in various

network protocols. Communication with the host controller is implemented via an

interrupt pin and the SPI, with clock rates of up to 20 MHz.

The ENC28J60 consists of seven major functional blocks:

1. An SPI interface that serves as a communication channel between the host

controller and the ENC28J60.

2. Control registers which are used to control and monitor the ENC28J60.

3. A dual port RAM buffer for received and transmitted data packets.

4. An arbiter to control the access to the RAM buffer when requests are made from

DMA, transmit and receive blocks.

5. The bus interface that interprets data and commands received via the SPI

interface.

6. The MAC (Medium Access Control) module that implements IEEE 802.3

compliant MAC logic.

7. The PHY (Physical Layer) module that encodes and decodes the analog data that

is present on the twisted pair interface. [11]

18

Page 19: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 19/62

 

2.4.3. Features

• IEEE 802.3 compatible Ethernet controller 

• Integrated MAC and 10BASE-T PHY

• Receiver and collision squelch circuit

• Supports one 10BASE-T port with automatic polarity detection and correction

• Supports Full and Half-Duplex modes

• Programmable automatic retransmit on collision

• Programmable padding and CRC generation

• Programmable automatic rejection of erroneous packets

• SPI™ Interface with speeds up to 10 Mb/s

2.4.4. Ethernet IC

19

Page 20: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 20/62

Fig 2.7: Ethernet IC [12]

Fig 2.8: Interface with controller 

20

Page 21: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 21/62

Fig.2.9: Basic circuit diagram of Ethernet

2.5. Oscillator

The ENC28J60 is designed to operate at 25MHZ with a crystal connected to the

OSC1 and OSC2 pins. The ENC28J60 design requires the use of a parallel cut

crystal. Use of a series cut crystal may give a frequency out of the crystal

manufacturer specifications.

21

Page 22: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 22/62

Fig 2.10: Circuit diagram of oscillator 

2.6. Voltage regulator

2.6.1. Description

The LM1117 is a series of low dropout voltage regulators with a dropout of 1.2V at

800mA of load current. It has the same pin-out as National Semiconductor's

industry standard LM317.

The LM1117 is available in an adjustable version, which can set the output voltage

from 1.25V to 13.8V with only two external resistors. In addition, it is also

available in five fixed voltages, 1.8V, 2.5V, 2.85V, 3.3V, and 5V.

The LM1117 offers current limiting and thermal shutdown. Its circuit includes a

zener trimmed band gap reference to assure output voltage accuracy to within ±1%.

The LM1117 series is available in LLP, TO-263, SOT-223, TO-220, and TO-252

D-PAK packages. A minimum of 10µF tantalum capacitor is required at the output

to improve the transient response and stability. [14]

  2.6.2. Features

• Available in 1.8V, 2.5V, 2.85V, 3.3V, 5V, and Adjustable Versions

• Current Limiting and Thermal Protection

• Output current – 800 mA

22

Page 23: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 23/62

• Line regulation – 0.2% (max)

• Load regulation – 0.4% (max)

• Temperature Range - 0°C to 125°C

• 2.6.3. Applications:

• 2.85V Model for SCSI-2 Active Termination

• Post Regulator for Switching DC/DC Converter 

• High Efficiency Linear Regulators

• Battery Charger 

Fig 2.11: LM1117 Voltage regulator [17]

2.7. RJ 45

RJ45 is a standard type of connector for network cables. RJ45 connectors are most

commonly seen with Ethernet cables and networks. RJ 45 is also known as

Registered Jack 45.

23

Page 24: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 24/62

RJ45 connectors feature eight pins to which the wire strands of a cable interface

electrically. Standard RJ-45 pin outs define the arrangement of the individual wires

needed when attaching connectors to a cable. [22]

Several other kinds of connectors closely resemble RJ45 and can be easily confusedfor each other. The RJ-11 connectors used with telephone cables, for example, are

only slightly smaller (narrower) than RJ-45 connectors.

Fig 2.12: Circuit diagram of RJ 45

24

Page 25: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 25/62

Fig 2.13: Circuit diagram of Microcontroller and Device Section

25

Page 26: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 26/62

Fig 2.14: Circuit diagram of Ethernet Controller Section

26

Page 27: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 27/62

Fig 2.15: Flow chart

Conclusions

Start

Switch on the power supply and connect the LAN to the demonstration kit

Initialize ports A, C & E as input ports and ports B and D as output ports

ADC conversion

Processed in PIC microcontroller 

If RD1=1

Relay on

&Alarmon

Relay off &Light is

turned off  Relay off &Alarm off 

If RD2/RD3/RD4

/RD5/RD6/RD

7=1

 No No

Yes

Yes

27

Interface PIC microcontroller with Ethernet via Ethernet controller 

Enter the IP address of Ethernet and enter the user choice

If 

RD0=1

Relay on &

Light is turned

n Turn off thecorrespondin

g leds

Turn on thecorrespondi

ng leds

Yes

 No

Page 28: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 28/62

The details about PIC microcontroller and its features, power supply unit, ADC

module, Ethernet Controller, oscillator, voltage regulator and also about the RJ45

have been discussed in this chapter.

Chapter-3

28

Page 29: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 29/62

Relays and temperature sensors

Introduction

In this chapter, we are going to discuss about the relays & its types and also aboutthe temperature sensors in detail.

3.1. Relays

3.1.1. Introduction

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

1835. 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.[10]

Fig 3.1: Basic design of relay [10]

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

29

Page 30: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 30/62

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-energized, 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. [1], [10]

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.

3.1.2. Types of relays

1. Latching relay

Fig 3.2: Latching relay

30

Page 31: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 31/62

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.

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

3. Mercury-wetted relay

A mercury-wetted reed relay is a form of reed relay in which contacts are wettedwith mercury. Such relays are used to switch low-voltage signals 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.

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

31

Page 32: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 32/62

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

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

7. Solid-state relay

Fig 3.3: A Solid state relay [10]

32

Page 33: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 33/62

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.

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

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

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

33

Page 34: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 34/62

3.1.3. Poles and Throws

• SPST - Single Pole Single Throw. These have two terminals which can be

connected or disconnected. Including two for the coil, such a relay has four terminals

in total. It is ambiguous whether the pole is normally open or normally closed. The

terminology "SPNO" and "SPNC" is sometimes used to resolve the ambiguity.

• SPDT - Single Pole Double Throw. A common terminal connects to either of 

two others. Including two for the coil, such a relay has five terminals in total.

• DPST - Double Pole Single Throw. These have two pairs of terminals.

Equivalent to two SPST switches or relays actuated by a single coil. Including two for 

the coil, such a relay has six terminals in total. The poles may be Form A or Form B

(or one of each).

• DPDT - Double Pole Double Throw. These have two rows of change-over 

terminals. Equivalent to two SPDT switches or relays actuated by a single coil. Such a

relay has eight terminals, including the coil.[1]

3.1.4. Relay Operation

Diagram that a relay uses an electromagnet. This is a device consisting of a coil of 

wire wrapped around an iron core. When electricity is applied to the coil of wire it

 becomes magnetic, hence the term electromagnet. The A B and C terminals are an

SPDT switch controlled by the electromagnet. When electricity is applied to V1

and V2, the electromagnet acts upon the SPDT switch so that the B and C terminals

are connected. When the electricity is disconnected, then the A and C terminals are

connected. It is important to note that the electromagnet is magnetically linked to

the switch but the two are NOT linked electrically

34

Page 35: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 35/62

Fig 3.4: Relay operation

 Normally-open (NO) contacts connect the circuit when the relay is activated; the

circuit is disconnected when the relay is inactive. It is also called a Form A contact

or "make" contact.

 Normally-closed (NC) contacts disconnect the circuit when the relay is activated;

the circuit is connected when the relay is inactive. It is also called a Form B contact

or "break" contact.[6]

3.1.5. Relay Applications

Relays are quite common in home appliances where there is an electronic control

turning on something like a motor or a light. They are also common in cars, where

the 12V supply voltage means that just about everything needs a large amount of 

current. In later model cars, manufacturers have started combining relay panels into

the fuse box to make maintenance easier. In places where a large amount of power 

needs to be switched, relays are often cascaded. In this case, a small relay switches

the power needed to drive a much larger relay, and that second relay switches the

 power to drive the load. Relays can also be used to implement Boolean logic.[10]

35

Page 36: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 36/62

3.2. Relay driver IC (ULN2803)

The eight NPN Darlington connected transistors in this family of arrays are ideally

suited for interfacing between low logic level digital circuitry (such as TTL, CMOS

or PMOS/NMOS) and the higher current/voltage requirements of lamps, relays,

 printer hammers or other similar loads for a broad range of computer, industrial,

and consumer applications. All devices feature open–collector outputs and free

wheeling clamp diodes for transient suppression.

The ULN2803 is designed to be compatible with standard TTL families while the

ULN2804 is optimized for 6 to 15 volt high level CMOS or PMOS.

Fig 3.5: ULN 2803 IC

3.2.1. Driver circuit description

 NPN transistor 2N2222 is being used to control the relay. The transistor is driven

into saturation (turned ON) when a LOGIC 1 is written on the PORT PIN thus

turning ON the relay. The relay is turned OFF by writing LOGIC 0 on the port pin.

A diode (1N4007/1N4148) is connected across the relay coil, this is done so as to

 protect the transistor from damage due to the BACK EMF generated in the relay's

inductive coil when the transistor is turned OFF.

When the transistor is switched OFF the energy stored in the inductor is dissipated

through the diode & the internal resistance of the relay coil.

36

Page 37: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 37/62

Fig.3.6: Relay driver circuit

3.3. Temperature sensor

The LM35 series are precision integrated-circuit temperature sensors, whose output

voltage is linearly proportional to the Celsius (Centigrade) temperature

Fig 3.7: LM35 temperature sensor [18]

37

Page 38: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 38/62

3.3.1. Features

o Calibrated directly in ° Celsius (Centigrade)

o Linear + 10.0 mV/°C scale factor 

o 0.5°C accuracy guaranteeable (at +25°C)

o Rated for full −55° to +150°C range

o Suitable for remote applications

o Low cost due to wafer-level trimming

o Operates from4 to 30 volts

o Less than 60 μA current drain

o Low self-heating, 0.08°C in still air 

o  Nonlinearity only ±1⁄4°C typical

o Low impedance output, 0.1 W for 1 mA load

3.3.2 Importance of LM35 sensor

o You can measure temperature more accurately than a using a thermistor.

o The sensor circuitry is sealed and not subject to oxidation, etc.

o The LM35 generates a higher output voltage than thermocouples

o May not require that the output voltage be amplified.[18]

Conclusions

The detailed description about the relays & its types and also about the temperature

sensors have been provided in this chapter.

38

Page 39: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 39/62

Chapter-4

Serial communicationIntroduction

Here in this chapter, we are going to discuss in detail about the SPI communication

which includes the description about RS232 pins and MAX232.

Choose a PIC microcontroller and write the code to initialize the USART and use it

to send and receive data. We need to transmit data and it will do the rest. It

transmits data at standard speeds of 9600, 19200 bps etc.The advantage of hardware

USART is that you just need to write the data to one of the registers of USART and

your done, you are free to do other things while USART is transmitting the

 byte.USART automatically senses the start of transmission of RX line and then

inputs the whole byte and when it has the byte it informs us (CPU) to read that data

from one of its registers.

4.1. Introduction

o RS232 standard is an asynchronous serial communication method.

o The word serial means, that the information is sent one bit at a time.

o Asynchronous tells us that the information is not sent in predefined time slots.

o Data transfer can start at any given time and it is the task of the receiver to

detect when a message starts and ends.[20]

39

Page 40: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 40/62

Fig 4.1: Basic view of RS232 cable [21]

4.2. RS232 pins

Fig 4.2: DB-9 9-Pin Connector 

40

Page 41: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 41/62

Fig 4.3: Null modem connection

Table 4.1: IBM PC DB-9 Signals

4.2.1. Voltages

o The USART input/output uses 0V for logic 0 and 5V for logic 1.

41

Page 42: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 42/62

o The RS-232 standard (& the COM port) use +12V for logic 0 &–12V for logic

1

o To convert between these voltages levels we need an additional integrated

circuit

o (Such as Maxim’s MAX232).

4.3. MAX232

4.3.1. Introduction

MAX-232 is primary used for people building electronics with an RS-232 interface.

Serial RS-232 communication works with voltages (-15V ... -3V for high) and

+3V ... +15V for low) which are not compatible with normal computer logicvoltages. To receive serial data from an RS-232 interface the voltage has to be

reduced, and the low and high voltage level inverted. In the other direction (sending

data from some logic over RS-232) the low logic voltage has to be "bumped up",

and a negative voltage has to be generated, too.

42

Page 43: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 43/62

Page 44: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 44/62

The standard does not define such elements as character encoding (for example,

ASCII, Baudot or EBCDIC), or the framing of characters in the data stream (bits

 per character, start/stop bits, parity). The standard does not define protocols for error detection or algorithms for data compression.

The standard does not define bit rates for transmission, although the standard says it

is intended for bit rates lower than 20,000 bits per second. Many modern devices

can exceed this speed (38,400 and 57,600 bit/s being common, and 115,200 and

230,400 bit/s making occasional appearances) while still using RS-232 compatible

signal levels.

Details of character format and transmission bit rate are controlled by the serial port

hardware, often a single integrated circuit called a UART that converts data from

 parallel to serial form. A typical serial port includes specialized driver and receiver 

integrated circuits to convert between internal logic levels and RS-232 compatible

signal levels.

 

4.3.3. Circuit Working Description

In this circuit the MAX 232 IC used as level logic converter. The MAX232 is a dual

driver/receiver that includes a capacitive voltage generator to supply EIA 232

voltage levels from a single 5v supply. Each receiver converts EIA-232 to 5v

TTL/CMOS levels. Each driver converts TLL/CMOS input levels into EIA-232

levels.

44

Page 45: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 45/62

Fig 4.6: Logic diagram and function tables

In this circuit shown below the microcontroller transmitter pin is connected in the

MAX232 T2IN pin which converts input 5v TTL/CMOS level to RS232 level.

Then T2OUT pin is connected to reviver pin of 9 pin D type serial connector which

is directly connected to PC.

In PC the transmitting data is given to R2IN of MAX232 through transmitting pin

of 9 pin D type connector which converts the RS232 level to 5v TTL/CMOS level.

The R2OUT pin is connected to receiver pin of the microcontroller. Likewise the

data is transmitted and received between the microcontroller and PC or other device

vice versa.

45

Page 46: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 46/62

V D D

R

T XT 2 O U T

R 2 I N

U 1

M A X 2 3 2

1 3

8

1 1

1 0

1

3

4

5

             2

6

1 2

9

1 4

7

             1

             6

             1

             5

R 1 I N

R 2 I N

T 1 I N

T 2 I N

C +

C 1 -

C 2 +

C 2 -

             V

           +

V -

R 1 O U T

R 2 O U T

T 1 O U T

T 2 O U T

             V

             C

             C

             G

             N

             D

C 1 1 0 u F

C 4

1 0 u F

C 3

1 0 u F

C 2

1 0 u F

Fig 4.7: Circuit Diagram of MAX232

The MAX232 is a dual driver/receiver that includes capacitive voltage generator EIA-232 voltage levels from a single 5V supply. Each receiver converts EIA-232

inputs to 5V TTL/CMOS levels. These receivers have a typical threshold of 1.3V

and a typical hysterisis of 0.5V, and can accept +or – 30V inputs. Each driver 

converts TTL/CMOS input levels into EIA-232 levels. The driver, receiver, and

voltage generator functions are available as cells in the Texas Instruments LinASIC

library.

4.4. SPI Communication

Devices communicate using a master/slave relationship, in which the master 

initiates the data frame. When the master generates a clock and selects a slave

device, data may be transferred in either or both directions simultaneously. In fact,

as far as SPI is concerned, data are always transferred in both directions. It is up to

46

Page 47: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 47/62

the master and slave devices to know whether a received byte is meaningful or not.

So a device must discard the received byte in a "transmit only" frame or generate a

dummy byte for a "receive only" frame.

Fig 4.8: Interfacing of MAX232 with microcontroller [19]

Conclusions

Here in this chapter, a detailed description about SPI communication which

includes the description about RS232 pins and MAX232 have been discussed.

Chapter-5

Embedded Software

Introduction

In this chapter, we are going to discuss about the Embedded C and software tools

like MPLAB IDE, Flash magic and ORCAD-PCB design and their features.

47

Page 48: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 48/62

5.1. Introduction

In this chapter all the software’s used to develop the embedded system are

discussed in detail. Firstly the code is written in Embedded C language and it is

converted into machine level language by using MPLAB IDE. The code is

assembled, simulated and debugged using this software. Then finally the code is

dumped into PIC microcontroller by using flash magic programmer. The software

named ORCAD is used mainly to create electronic prints for manufacturing

of printed circuit board (PCB).

5.2. Embedded C

Embedded C is designed to bridge the performance mismatch between Standard C

and the embedded hardware and application architecture. It extends the C language

with the primitives that are needed by signal-processing applications and that are

commonly provided by DSP processors. The Embedded C specification extends the

C language to support free standing embedded processors in exploiting the multiple

address space functionality, user-defined named address spaces, and direct access to

 processor and I/O registers. Previously, it was common practice that each of the tool

  providers supported these features using functionally similar, but syntactically

different, implementations. [9] For the Embedded C specifications, the functionality

from the various tool providers was used and a common, extensible syntax was

defined. Specific embedded-systems deficiencies in C have been addressed to

reduce application dependence on assembly code. Embedded C makes life easier 

for application programmers. The Embedded C extensions to C unlock the high-

 performance feature of embedded processors for C programmers.

5.3. MPLAB IDE

48

Page 49: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 49/62

Fig 5.1: Screen view of MPLAB IDE

5.3.1. Overview

MPLAB Integrated Development Environment (IDE) is an integrated toolset for the

development of embedded applications employing PIC microcontrollers. MPLAB

IDE runs as a 32-bit application on MS Windows, is easy to use and includes a host

of free software components for fast application development and super-charged

debugging.It is called an Integrated Development Environment, or IDE, because it

  provides a single integrated “environment” to develop code for embedded

microcontrollers.[14]

5.3.2. Components of MPLAB IDE

The built-in components consist of-

• Project Manager: The project manager provides integration and communication

 between the IDE and the language tools.

• Editor: The editor is a full-featured programmer's text editor that also serves as a

window into the debugger.

49

Page 50: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 50/62

• Assembler/Linker and Language Tools: The assembler can be used standalone

to assemble a single file, or can be used with the linker to build a project from

separate source files, libraries and recompiled objects. The linker is responsible for 

 positioning the compiled code into memory areas of the target microcontroller.

• Debugger: The Microchip debugger allows breakpoints, single-stepping, watch

windows and all the features of a modern debugger for the MPLAB IDE. It works

in conjunction with the editor to reference information from the target being

debugged back to the source code.

5.3.3. MPLAB project manager

The project manager organizes the files to be edited and other associated files so

they can be sent to the language tools for assembly or compilation, and ultimately to

a linker. The linker has the task of placing the object code fragments from the

assembler, compiler and libraries into the proper memory areas of the embedded

controller, and ensures that the modules function with each other (or is “linked”).

This entire operation from assembly and compilation through the link process is

called a project “build”.

Fig 5.2: MPLAB project manager 

5.4. Flash Magic

50

e

es

r gcutablele

idual built

ptions

gtable

r script

mbler compiler 

Source

File

Individual built

options ObjectFile

Libraries

Linker script

Linker 

DebugFile

 ExecutableFile

Assembler compiler 

Page 51: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 51/62

It is used to dump the generated code into the microcontroller. The following steps

are followed to dump the code into microcontroller-

1. Power on the board to be programmed is switched off.

2. Jumper must be in ISP position.

3. Serial cable from PC must be connected to serial connector on the board to be

 programmed.

4. Then power on the board to be programmed is turned on.

5. Start flash magic.

6. If we are using program for the first time we need to set up it. Set the COM port

to serial port connected to board of the program, baud rate to 9600, device to89v51RD2. go to options>advanced options…and click on hardware configuration tab.

make sure that check box is checked so that program will use DTR and RTS lines to

enter ISP mode. Then click OK.

7. Flash needs to be erased before it is reprogrammed. Highlight the blocks to be

erased in step 2. We can also check the box marked “erase blocks used for hex file.”

8. Browse for the file to be programmed into the board.

9. In step 4 nothing needs to be set.

10. Click on start.

11. After board has been programmed, status bar will display finished. Board can be

turned off and disconnect from serial cable. Move the jumper from ISP to RUN.

12. Turn the board on to execute the program.

51

Page 52: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 52/62

Fig 5.3: Screen view of Flash Magic [15]

5.5. ORCAD-PCB design

The capability to provide fast and universal design entry makes orcad capture

design entry the most widely used schematic entry system in electronic design

today. Whether used to design a new analog circuit, revise a schematic diagram for 

an existing printed circuit board (PCB), or design a digital block diagram with an

HDL module, orcad capture provides the tools needed to enter, modify, and verify

the PCB design. Orcad Capture CIS integrates the Orcad Capture schematic design

application with the features of a component information system (CIS).

52

Page 53: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 53/62

5.5.1. ORCAD PCB design technologies

ORCAD products have a proven track record of innovation in the PCB personal

 productivity market. Available as stand-alone tools or in comprehensive suites, they

allow designers to realize products from conception to manufacturing output. Easyto use and intuitive, they offer exceptional value, and orcad technology provides

easy migration to the platform.

5.5.2. ORCAD capture

ORCAD Capture is a complete solution for design creation, management, and

reuse. Its ease-of-use allows designers to focus their creativity on design

development rather than tool operation.  The hierarchical Schematic Page Editor 

combines a windows user interface with functionality and features specifically for 

design entry tasks and for publishing design data.

Centralized project management provides seamless interchange of schematic data

for circuit simulation, board layout, and signal integrity analysis. A configurable

design rule check (DRC) mechanism helps eliminate costly engineering change

orders (ECOs). Basic bill of materials (BOMs) outputs are created from data

schematic data for circuit simulation, board layout, and signal integrity analysis. A

configurable design rule check (DRC) mechanism helps eliminate costlyengineering change orders (ECOs).

5.5.3. ORCAD capture CIS

ORCAD capture CIS is designed to reduce production delays and cost overruns

through efficient management of components. It reduces the time spent searching

existing parts for reuse, manually entering part information content, and

maintaining component data.

Users search parts based on their electrical characteristics and orcad capture CIS

automatically retrieves the associated part. Flexible and scalable, the solution is

quickly implemented.

Orcad capture CIS is ideal for individual design teams or multi-site teams who need

to collaborate across multiple locations, orcad capture CIS gives designers access to

53

Page 54: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 54/62

correct a part of data early in the design process and enables complete component

specifications to be passed to board designers and other members of the design

team, reducing the potential for downstream errors. It provides access to cost

information so designers can use preferred, lower cost, and in stock parts.

 5.5.4. Features:

Schematic editor

The full-featured schematic editor allows users to view and edit multiple schematic

designs in a single session. Design data is easily reused by copying and pasting

within or between schematics. Parts are quickly selected from a comprehensive set

of functional part libraries. Configurable design and electrical rule checkers ensure

design integrity. In-line editing of parts allows pin name and number movement. A

user interface has been provided to add critical constraints for users of the orcad

capture to orcad PCB editor flow.

Project manager

The Project Manager simplifies organizing and tracking the various types of data

generated in the design process. An expanding tree diagram makes it easy to

structure and navigate design files, including those generated by pspice simulators,

orcad capture CIS, and other plug-in. A Creation Wizard guides users through all

the resources available for a specific design flow. Users can navigate the entire

schematic structure and instantly open specific elements a schematic page, part, or 

net with the hierarchy browser.

Hierarchical design and reuse

Orcad capture boosts schematic editing efficiency by enabling sub circuit reuse

without having to make multiple copies. Using hierarchical blocks, simply

reference the same sub circuit multiple times. Automatic creation of hierarchical

 ports eliminates potential design connection errors. Ports and pins can be updated

dynamically for hierarchical blocks and underlying schematics. Added navigation

utilities recognize block boundaries and accessibility using keyboard shortcuts.

54

Page 55: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 55/62

 

Libraries and part editor

The library editor is accessed directly from the orcad capture user interface. Users

can create and edit parts in the library or directly from the schematic page without

interrupting workflow. Intuitive graphical controls speed schematic part creation

and editing. New parts are created quickly by modifying existing ones. New parts

can also be created from spread sheets. A library part generator automates the

integration of field programmable gate arrays (FPGAs) and programmable logic

devices (PLDs) into the system schematic.

Easy data entry

Designers can access all part, net, pin, and title block properties, or any subset, and

make changes quickly through the orcad capture spreadsheet property editor. It

simply requires selecting a circuit element, grouped area, or entire page, and then

selecting add/edit/delete part, net, or pin properties.

 5.5.5. Benefits

• Provides fast, intuitive schematic editing

• Boosts schematic editing efficiency by design reuse

• Automates the integration of FPGA and PLD devices

• Imports and exports virtually every commonly used design file format

• Reduces delays caused by out-of-stock parts (CIS)

• Promotes reuse of preferred components (CIS)

• Makes reuse of duplicate circuitry easy through hierarchical blocks (CIS)

55

Page 56: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 56/62

Fig 5.4: Screen view of ORCAD

Conclusions

The details about Embedded C, MPLAB IDE, Flash magic and ORCAD-PCB

design and their features are discussed in detail in this chapter.

56

Page 57: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 57/62

Chapter 6

Results and Conclusions

Introduction

Here in this chapter, we are going to discuss in detail about the testing process and

results, conclusions and future scope.

6.1. Testing process and Results

For testing purpose, we are using two systems which are connected through a LAN.

The process of testing involves the following steps:

1. Switch on the power supply.

2. Remove the LAN connection from one computer system and connect it to the

demonstration kit.

3. Make sure that all devices are properly working and the connections are

 properly done.

4. Take another system and enter the IP address of Ethernet, which we have

used.

5. Then, we will get a page consisting of information about the devices which

we want to control.

6. Then by simply toggling the Port D pins ON/OFF, we can control the devices

from remote places.

7. We can also get the information about the changes that have been made by

anyone at the host area.

8. This page will also contain the information about the Port B pins.

57

Page 58: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 58/62

 

Fig 6.1: Snap shot of our project when it is switched on

Fig 6.2: Snap shot of our project when light is turned on

58

Page 59: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 59/62

Fig 6.3: Snap shot of web page consisting of control information

 

6.2. Conclusions

The project work titled “Wireless Automation Using Low Power Embedded Web

Servers” is been designed successfully and also for the demonstration purpose,

 prototype module is constructed and tested, results are found satisfactory. Since it is

a demonstration unit, only a few parameters have been taken for automation.

Similarly only some features are added, but in practice just adding sufficient

hardware and changing the program to suit the parameters added, we can add any

number of parameters. Also in this prototype module the actual ratings of the

equipment used are very small but in real time the required ratings have to be

chosen based on the application.

59

Page 60: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 60/62

6.3. Future scope

As the technology develops, we find the concept of wireless automation through

web servers becomes available to masses on a large scale. In future, as the Internet

 becomes available on a large scale and broadband usage becomes more popular we

can even control the appliances in large industries and offices from remote places

through web servers. If a patient needs observation regularly, the doctor can

monitor the patient’s condition from any remote place.

60

Page 61: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 61/62

References

[1]  Vladimir Gurevich,  Electrical Relays: Principles and Applications, CRC Press(Taylor & Francis group), London - New York, 2005, 704 pp.

[2] Howard W. Johnson, Fast Ethernet: Dawn of a new network , Prentice Hall, 1996.

[3] Charles E.Spurgeon, Ethernet: The Definitive Guide, O'Reilly and Associates.

[4] Bates M.,  PIC Microcontrollers: An Introduction to Microelectronic, (2nd ed.).

Burlington, Massachusetts: Elsevier: Newnes, 2004.

[5] Cady F. M., Software and Hardware Engineering , Motorola M68HC1. New

York: Oxford University Press, 1994.

[6] Rao, Power system protection: Static Relays with Microprocessor Applications,

second edition, India, Tata Mc Graw Hill, 2003.

[7] Emerson G. Reed, Transformer Construction and Operation, McGraw-Hill

Company, Inc., New York, 1928

[8] R. J. Baker, CMOS Circuit Design, Layout, and Simulation, Revised Second

Edition, Wiley-IEEE, 2008.

[9] Richard H.Barnett, Larry O.Cull,   Embedded C Programming and Microchip

 PIC , 2004

[10] http://en.wikipedia.org/wiki/Relay

[11] http://en.wikipedia.org/wiki/Ethernet

[12] http://www.ethermanage.com/ethernet/ethernet.html

[13] http://en.wikipedia.org/wiki/PIC_microcontroller 

[14] http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf 

[15] http://www.flashmagictool.com

[16] http://microcontrollershop.com/product_info.php?products_id=992

61

Page 62: Final Hard Bound Copy

8/8/2019 Final Hard Bound Copy

http://slidepdf.com/reader/full/final-hard-bound-copy 62/62