Sie sind auf Seite 1von 77

INTRODUCTION

Leaner budgets, limited numbers of personnel, and an increasing demand for


more timely information from throughout entire enterprises, have all
combined to make supervisory control and data acquisition (SCADA) an
essential part of todays municipal utility and industrial operations. A critical
element in any SCADA network is communication. A reliable, cost effective
means for transporting data must be employed if the full benefits of SCADA
are to be realized.
Wireless communication presents an attractive option to many users
because it offers high availability, eliminates the payment of ongoing access
fees, and allows users to have direct control over their systems. It is often
the chosen medium when one or more sites are outside the coverage area of
a public telephone system, or where continuous monitoring of data is
required. This article discusses the various elements of wireless system
design. The elements are: system information collection and review, paper
planning, field testing, final system layout and installation, and system startup. It also touches on performance and preventive maintenance
requirements for radio-based SCADA systems.
In numerous industrial fields it is necessary to record the parameter
variations to which a product is subjected, in cases where, depending on
circumstances, one or more variations or the overstepping of predetermined
temperatures could make the product unsuitable for subsequent use. Such
device has many applications. One crucial application is to monitor and
control a process where fluids have to be handles at certain predefined
conditions like temperature and pressure control is necessary. SCADA system
includes a user interface which is usually called Human Machine Interface
(HMI). The HMI of a SCADA system is where data is processed and presented
to be viewed and monitored by a human operator. This interface usually
includes controls where the individual can interface with the SCADA system.
Wireless SCADA deals with the creation of an inexpensive, yet adaptable and
easy to use SCADA device and infrastructure using the wireless network.
The project design consists of a microcontroller which is connected with a
Temperature sensing devices. The data collected from the sensors are given
to the signal conditioning system for proper modification of the signal so that
the controller can process the data. The collected information is then passed
on to the computer which will be interface to the microcontroller. If the
1

measured parameters Goes above the set point or critical values, then
proper action will be taken by the control unit.

An Introduction to SCADA
The term SCADA stands for Supervisory Control And Data Acquisition. A
SCADA system is a common process automation system which is used to
gather data from sensors and instruments located at remote sites and to
transmit and display this data at a central site for either control or
monitoring purposes. The collected data is usually viewed on one or more
SCADA Host computers located at the central or master site.
A real world SCADA system can monitor and control hundreds to hundreds of
thousands of I/O points. A typical Water SCADA application would be to
monitor water levels at various water sources like reservoirs and tanks and
when the water level exceeds a preset threshold, activate the system of
pumps
to
move
water
to
tanks
with
low
tank
levels.
Common analog signals that SCADA systems monitor and control are levels,
temperatures, pressures, flow rate and motor speed. Typical digital signals to
monitor and control are level switches, pressure switches, generator status,
relays
&
motors.
There is typically another layer of equipment between the remote sensors
and instruments and the central computer. This intermediate equipment
exists on the remote side and connects to the sensors and field instruments.
Sensors typically have digital or analog I/O and these signals are not in a
form that can be easily communicated over long distances. The intermediate
equipment is used to digitize then packetize the sensor signals so that they
can be digitally transmitted via an industrial communications protocol over
long
distances
to
the
central
site.
Typical equipment that handles this function are PLC's (Programmable Logic
Controllers) and RTUs (Remote Terminal Units). These devices employ defacto standard industrial data communication protocols such as Modbus, ABDF1, and DNP3.0 to transmit the sensor data. Typical physical interface
standards
are
Bel
202
modem,
RS-485
&
RS-232.

The SCADA Host is usually an industrial PC running sophisticated SCADA MMI


(Man Machine Interface) or HMI (Human Machine Interface) software. This
software is used to poll the remote sites and store the collected data in its
centralized SQL or Oracle database. Logic can be configured in the SCADA
Host software which then monitors and controls plant or equipment. The
control may be automatic, or initiated by operator commands.
Data acquisition is accomplished firstly by the RTU's or PLC's scanning the
field inputs connected to the RTU / PLC. This data is usually collected at a
polling rate configured by the operator. The polling rate is determined by the
number of sites, the amount of data at each site, the maximum bandwidth of
the communication channel and the minimum required display and control
time.
Once the data has been acquired at sent to the SCADA Host, the MMI
software will scan the acquired data (usually at a slower rate.) The data is
then processed to detect preset alarm conditions, and if an alarm is present,
an alarm message will flash on the operator screen and added to an alarm
list. The operator must then acknowledge this alarm. There are 3 common
types of data collected:

Analog - used for trending

Digital (on/off) - used for alarming

Pulse (i.e. revolutions of some kind of meter) - accumulated /counted

The primary operator interface is a set of graphical screens which show a


representation of the equipment being monitored. Real-time data is
displayed numerically or graphically as changing bars, circles, lines or other
shapes
over
a
static
background.

As the acquired data changes in real-time, the bar, circle, line or other
representative shape is updated. For instance, an analog level increase may
be displayed as a lengthening of the representative vertical bar or a valve
graphic may look open to represent that it is open. A typical MMI will have a
nested tree structure of many such screens, usually with the many overview
screen on the first page with the most relevant data displayed. There are
then links that go to other pages. Users can easily configure the type of I/O
point, communication protocol driver, polling rate, alarm thresholds and
notifications, trend process data as well as configure the User and Operator
screens.

SCADA communications can employ a diverse range of both wired (lease


line, dial-up line, fiber, ADSL, cable) and wireless media (licensed radio,
spread spectrum, cellular, WLAN or satellite). The choice depends on a
number of factors that characterize the clients existing communication
infrastructure.
Factors such as existing communications infrastructure, available
communications at the remote sites, data rates and polling frequency,
remoteness of site, installation budget and ability to accommodate future
needs all impact the final decision. In complex SCADA architectures, there
can be a variety of both wired and wireless media and protocols involved to
get
data
back
to
the
central
monitoring
site.
SCADA systems differ from DCS's (Distributed Control Systems) which are
generally found in plant sites. While DCS's cover the plantsite, SCADA
systems cover much larger geographic areas. Often SCADA Systems are
required to interface to a plantsite DCS if there are remote sensors,
instruments or motors and pumps that must be controlled/monitored by the
plantsite
DCS.

WIRELESS SCADA
Wireless SCADA is required in those applications when wireline
communications to the remote site is prohibitively expensive or it is too time
consuming to construct wireline communications. In particular types of
industry like Oil & Gas or Water & Wastewater, wireless SCADA is often the
only solution due to the remoteness of the sites.

Wireless SCADA systems can be built on private radio (licensed or


unlicensed), cellular or satellite communications; each of these has its
unique set of characteristics. One major difference between Private Radio
and Cellular or Satellite is that Private radio has no associated monthly fees.
Once you build your hardware infrastructure, you own it. With Cellular or
Satellite Service providers, there is an associated monthly fee with these.
Certain types of applications like those in Oil & Gas, Electrical & Water
Utilities, Water & Wastewater and Environmental Monitoring inherently
require SCADA communications because of the remoteness of the assets (i.e.
Oil wells, water wells, generator stations). Furthermore, due to the
remoteness many of these often require the use of wireless communications.
In these cases, the traditional solution is to add a radio modem stage to the
standard
SCADA
architecture
shown
above.

PROJECT DESCRIPTION
The whole system consists of two Embedded Zigbee modules interfaced
to two micro controllers. One placed at the region from where devices are
controlled (say transmission-TX side) and the other at an area where the
devices are to be controlled (say receiving-rx) side. The transmitter side
module consists of a PC with front end where each button is meant for
controlling one device at the receiver side. When a button is clicked at TX
side data is wirelessly transmitted. The Zigbee module at receiver will
receive these signals and then the data is given to the rx side micro
controller. The devices at the receiver side will be controlled by decoding
these signals received as per the software program written.

Any industry has number of inputs and outputs such as switching of


electrical drives, motors, lights etc. The electrical data cannot be obtained
5

immediately when ever required. So the current design of data acquisition


system which will supervise and control multiple input sources in industrial
environment can be used. Data or information is obtained rapidly indicating
the status of the devices i.e. if the devices are presently on or off. In this way
the complete data of the industrial devices or sources can be obtained.

There are many ways to do so by using different wireless TX and


rx. But Zigbee makes this task very simple and reliable. The main highlight of
this design is data transmission without any wire. The frequency range of
Zigbee module that is being used here is 2.4GHz.

To control the devices from the PC end a front end is created on the desktop
of the system by using the LAB VIEW. In this front end we are having
different buttons to control the various devices. As soon as we click on to the
button, it generates a signal , and that signal is received by the micro
controller via serial interface RS 232 cable and MAX 232 IC. Hence a single
mouse click is sufficient for controlling the industrial devices.

BLOCK DIAGRAM OF THE PROJECT


Remote site unit

MICRO
Power
supply
CONTROLL
unit
ER UNIT

Devic
e1

Drivin
g unit

Devic
e
2

Devic
e
3

ZIGBEE
TRANSEIVER
UNIT

Control unit

Power
supply
unit

Micro
Controller
Unit
PC
ZIGBEE
TRANSEIVER
UNIT

Serial
driver

HARDWARE REQUIREMENTS

1. TRANSFORMER
2. VOLTAGE REGULATOR (LM7812 & LM7805)
3. RECTIFIER
4. MICROCONTROLLER (AT89C52)
5. LED
6. 1N4007
7. RESISTORS
8. CAPACITORS
9. RELAY WITH DRIVER
10.

MAX 232

11.

ZIGBEE

12.

TEMPERATURE SENSOR DS1621

13.

MOTOR DRIVER

14.

DC MOTOR

15.

WATER PUMP

16.

TRANSISTOR

17.

PC

HARDWARE DESIGN APPROACH

1. REMOTE SITE UNIT


Power Supply
Microcontroller
Temperature sensor
Transceiver
1. POWER SUPPLY

As we all know any invention of latest technology cannot be


activated without the source of power. So it this fast moving world we
deliberately need a proper power source which will be apt for a particular
requirement. All the electronic components starting from diode to Intel ICs
only work with a DC supply ranging from -+5v to
-+12v. We are utilizing
for the same, the cheapest and commonly available energy source of 230v50Hz and stepping down, rectifying, filtering and regulating the voltage. This
will be dealt briefly in the forth-coming sections.

STEP DOWN TRANSFORMER:


When AC is applied to the primary winding of the power transformer it
can either be stepped down or up depending on the value of DC needed. In
our circuit the transformer of 230v/15-0-15v is used to perform the step
10

down operation where a 230V AC appears as 15V AC across the secondary


winding. One alteration of input causes the top of the transformer to be
positive and the bottom negative. The next alteration will temporarily cause
the reverse. The current rating of the transformer used in our project is 2A.
Apart from stepping down AC voltages, it gives isolation between the power
source and power supply circuitries.

RECTIFIER UNIT:
In the power supply unit, rectification is normally achieved using a solid
state diode. Diode has the property that will let the electron flow easily in
one direction at proper biasing condition. As AC is applied to the diode,
electrons only flow when the anode and cathode is negative. Reversing the
polarity of voltage will not permit electron flow.
A commonly used circuit for supplying large amounts of DC power is
the bridge rectifier. A bridge rectifier of four diodes (4*IN4007) are used to
achieve full wave rectification. Two diodes will conduct during the negative
cycle and the other two will conduct during the positive half cycle. The DC
voltage appearing across the output terminals of the bridge rectifier will be
somewhat lass than 90% of the applied rms value. Normally one alteration of
the input voltage will reverse the polarities. Opposite ends of the transformer
will therefore always be 180 deg out of phase with each other.
For a positive cycle, two diodes are connected to the positive voltage
at the top winding and only one diode conducts. At the same time one of the
other two diodes conducts for the negative voltage that is applied from the
bottom winding due to the forward bias for that diode. In this circuit due to
positive half cycleD1 & D2 will conduct to give 10.8v pulsating DC. The DC
output has a ripple frequency of 100Hz. Since each altercation produces a
resulting output pulse, frequency = 2*50 Hz. The output obtained is not a
pure DC and therefore filtration has to be done.

FILTERING UNIT:
FILTER: Capacitive filter is used in this project. It removes the ripples from
the output of rectifier and smoothens the D.C. Output received from this
filter is constant until the mains voltage and load is maintained constant.
However, if either of the two is varied, D.C. voltage received at this point
11

changes. Therefore a regulator is applied at the output stage.

The simple capacitor filter is the most basic type of power supply filter.
The use of this filter is very limited. It is sometimes used on extremely highvoltage, low-current power supplies for cathode-ray and similar electron
tubes that require very little load current from the supply. This filter is also
used in circuits where the power-supply ripple frequency is not critical and
can be relatively high.
Capacitive filter is used in this project. It removes the ripples from the
output of rectifier and smoothens the D.C. Output received from this filter is
constant until the mains voltage and load is maintained constant. However, if
either of the two is varied, D.C. voltage received at this point changes.
Therefore a regulator is applied at the output stage.
The simple capacitor filter is the most basic type of power supply filter. The
use of this filter is very limited. It is sometimes used on extremely highvoltage, low-current power supplies for cathode-ray and similar electron
tubes that require very little load current from the supply. This filter is also
used in circuits where the power-supply ripple frequency is not critical and
can be relatively high.

Filter circuits which are usually capacitors acting as a surge arrester


always follow the rectifier unit. This capacitor is also called as a decoupling
capacitor or a bypassing capacitor, is used not only to short the ripple with
frequency of 120Hz to ground but also to leave the frequency of the DC to
appear at the output. A load resistor R1 is connected so that a reference to
the ground is maintained. C1R1 is for bypassing ripples. C2R2 is used as a
low pass filter, i.e. it passes only low frequency signals and bypasses high
frequency signals. The load resistor should be 1% to 2.5% of the load.

1000f/25v : for the reduction of ripples from the pulsating.


470f/25v : for maintaining the stability of the voltage at the load side.
100f/25v : for bypassing the high frequency disturbances.

12

VOLTAGE REGULATORS:
The voltage regulators play an important role in any power supply unit.
The primary purpose of a regulator is to aid the rectifier and filter circuit in
providing a constant DC voltage to the device. Power supplies without
regulators have an inherent problem of changing DC voltage values due to
variations in the load or due to fluctuations in the AC liner voltage. With a
regulator connected to the DC output, the voltage can be maintained within
a close tolerant region of the desired output. IC7812 and 7912 is used in this
project for providing +12v and 12v DC supply.
SPECIFICATIONS:
Resistors R1 and R2 maintain line load regulation.
At the secondary side of the transformer,
Applied voltage = 15v
Conducting drop across the diodes = 2*0.6= 1.2v.
Without capacitor:
Vavg = (15-1.2)v = 13.8c pulsating DC
Frequency = 100Hz
With capacitor:
V=Vavg *1.414(form factor) = 19.51v.
Frequency = 0Hz
With 7812 voltage regulator:
V0= +12v
With 7912 voltage regulator:
V0= -12v

TRANSCEIVER (XBEE)
The system used for the communication between the master mote and slave
mote used in the present work is Zigbee compliant MaxStreams XBee
transceiver. The XBee takes data and decides where it should be sent. This
involves looking at the data type and the destination to determine whether
the data should be sent over the radio or serial port. The XBee module is
responsible for encapsulating the data in the required packet format for
sending it to another XBee, or to the serial port. XBees UART protocol
performs tasks, such as timing and parity checking, that are needed for data
communications. As soon as serial data enters the RF module through the DI
pin (pin 3), the data is processed. Similarly When RF data is received, the
data enters the DO buffer and is sent out the serial port to a host device. It
13

has been seen that the data transmitted over the communication link is
uncorrupted. A traditional approach called as data warehousing is made to
collect the data from the sensor mote. Data extracted from sensor mote is
stored on base station.

Interfacing the DiGis Xbee with microcontroller


The DiGis ZigBee/ XBee RF modules have many characteristics that
are desired in wireless communication. MaxStream offers two different
versions of wireless modules, the XBee And the XBee-Pro. Both of these
modules have the same set of instructions and operate in the same manner,
but the XBee-Pro offers over more than double the range of XBee. In the
present work, to measure the office temperature Xbee is selected. Transmit
power output is rated at 1mW with an operating frequency of 2.5GHz with
operating current running around 45-50 mA and RF data rate of 250k bps.
While XBee-Pro edition runs at a 10mW output power, enabling it to transmit
much further. The implementation of adding wireless to any design can be
accomplished easily with the DiGis XBee module. The XBee module is
extremely effective in terms of short-range wireless communication. The
XBee module is low power, small, and easy to integrate into any project with
short-range wireless communication.
The interfacing of Xbee transceiver with the Atmel89C52 microcontroller can
be achieved by connecting the required pins. There are some considerations
that must be taken into account to accommodate the needs of the XBee
First, the pitch of the headings on the XBee is 2.0 mm and will not fit into
general purpose PC Boards required for prototyping designs. To overcome
this, a PC Board is designed using Protel CAD software for Xbee. Mounted
and soldered the Xbee over the designed PC Board. It has been placed over
the general purpose PC Board and required pins are connected to the pins of
Atmel89C52 microcontroller.
Second, XBee is designed to operate at 3.3V, whereas Atmel89C52
microcontrollers run at higher voltages. Voltage regulation can be easily
accounted for by using a LM317 voltage regulator. Figure shows the
schematic circuit diagram, to ensure regulated voltage supply to XBee
module.

14

INTERFACING OF XBEE MODULE WITH MICROCONTROLLER(89C52)

19
FREQ=11.0592MHz

18

C2
VCC=+5V

33PF

C3

XTAL1
XTAL2

RST

R1
10uF

8.2k

29
30
31

1
2
3
4
5
6
7
8

P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7

PSEN
ALE
EA

P1.0/T2
P1.1/T2EX
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7

A
T
8
9
C
5
2

P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15
P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD

U4
LM317EMP

39
38
37
36
35
34
33
32

VI

C4
0.1uF

21
22
23
24
25
26
27
28

VO
ADJ

U1

vcc=+5V

PIN20=Vss(0V)
PIN40=Vcc(+5V)

C5
1

C1

33PF

0.IuF

1
2
3
4
5
6
7
8
9
10

X
B
E
E

20
19
18
17
16
15
14
13
12
11

10
11
12
13
14
15
16
17

AT89C52

The interface between the Atmel89C52 and the XBee can be accomplished
quite easily because both communicate with a serial UART interface. To
communicate directly with the XBee module there are only four pins that
need to be connected:

15

Din (3), Dout (2), VDD (1) and GND (10). Pin 2 from the XBee needs to be
connected to the Rx (14) pin of the microcontroller. Pin 3 from the XBee
needs to be connected to the Tx (15) pin of the microcontroller. A schematic
diagram without voltage regulation can be seen in Figure 5. The Atmels
microcontroller can be configured to transmit and receive serial data.

THE TEMPERATURE SENSOR


To get the temperature reading we use the Dallas DS1620 integrated
circuit. It is an 8-pin chip, which has a built in system that measures the
temperature and converts the reading into a 9 bit binary value. It has an
accuracy of 0.5 degrees C and a range of -55 to 125 degree C. The
temperature reading is updated about once per second. A digital interface is
included in the chip, which facilitates to connect a microcontroller to the chip
and send it commands and receive the temperature data back from the chip.
It has three alarm outputs, so the device can also act as a thermostat. The
DS1620, which incorporates a 3-wire interface, is controlled using an
Atmel89C52 Microcontroller. The DS1620 is connected directly to the I/ O
port on Atmega16 microcontroller, and low-level software drivers handle the
3-wire handshaking and temperature readings. The temperature is received
in the microcontroller as 2 bytes. The second byte only contains a sign bit to
signify whether the temperature is above or below 0 degrees Celsius.

Interfacing the DS1620 with Microcontroller


The 3-wire bus comprise of three signals. These are the REST-bar (reset)
signal, the CLK (clock) signal, and the DQ (data) signal. All data transfers are
initiated by driving the RST- bar input high. Driving the RST-bar input low
terminates the communication. A clock cycle is a sequence of a falling edge
followed by a rising edge. For data inputs, the data must be valid during the
16

rising edge of the clock cycle. Data bits are output on the falling edge of the
clock and remain valid through the rising edge. When reading data from the
DS1620, the DQ pin goes to a high-impedance state while the clock is high.
Taking RST-bar low during a communication cycle will cause DQ to go to a
high-impedance state, thus ending the communication. Data over the 3-wire
interface is sent with LSB first. Figure illustrates the device connection to the
microcontroller programmable input/ output port.

2. CONTROL UNIT
The function of control unit is to gather the data process and display it if
required by the application. The master mote implemented in the present
work has the following component to carry out its functions.

Personnel Computer
Xbee Transceiver Module
MAX232 Driver/ Receiver
DB9 Connector

The control unit design is easy as compared to the remote terminal unit.
The idea of not using a microcontroller at control unit is that PC can be used
as a processor in place of microcontroller. Besides it will be helpful to
demonstrate the temperature data collected at control unit. Fig. shows the
block diagram for control unit.

17

Figure : Block Diagram of Master Mote

Personnel Computer
The PC has been used to display temperature data collected by the DS1620
and sent through wirelessly with the help of ZigBee compliant- Xbee
transceiver module from the slave unit. The Xbee module on the control unit
receives these datas and transfers to PC using RS-232 communication. The
PC uses the software drivers to communicate with the devices.

Interfacing the XBee module with PC

In order to set the computer side up with the XBee module, serial
communications needs to be setup. MAX232 and DB9 connector has been
used to set up a serial communication between the PC and Xbee.
The MAX232 is a line drivers/ receiver, which is intended for all EIA/
TIA-232E and V.28/ V.24 communications interfaces. It has a double charge
pump voltage doubler and a +10V to 10V voltage inverter. The voltages
outputs are used to generate the RS-232.
Serial cable has been used to connect the MAX232 to PC. Serial cable
has male/ female DB9 connector. Pins 13 and 14 on the MAX232 have been
connected to pin 3 and pin 2 respectively at DB9 port in order to transfer
information to a computer. Pin 11 on the MAX232 chip connects to the Tx
pin-2 on the XBee device while pin 12 connects to an Rx pin-3. The voltage
supply of 5 V for MAX232 can be achieved through the schematic circuit.

18

.
Figure: MAX232 Pin Configuration

Figure : Interfacing of MAX232 and XBee Module

In relation to the XBee module, the DIN pin is where data will come in from
the computer while the DOUT pin is where information can be transferred
back over to the computer once received from another XBee module. The
XBee module can only input voltage levels between 2.8V and 3.4V, therefore
if a 5V MAX232 chip is used, arrangements will need to be made in order to
adjust the levels so as not to burn out the module.

Schematic Circuit Diagram


The hardware implementation of the master mote can be divided in two
different sections as shown in Fig. 5.9
Interfacing Section
Power Supply Section

19

Interfacing Section

Power Supply Section


Figure : Block Diagram

The Jack has been placed/ soldered over the PCB. The power supply of 12V
adapter is given to the main circuit board by connecting the pin of adapter to
main circuit through jack. The LM317 voltage regulator then uses the power
supply. A detailed Schematic Circuit Diagram has been drawn to demonstrate
the connections between different devices.

Connection diagram :

20

TESTING THE CIRCUIT

21

CONTINUITY TEST:
In electronics, a continuity test is the checking of an electric circuit to see if
current flows (that it is in fact a complete circuit). A continuity test is
performed by placing a small voltage (wired in series with an LED or noiseproducing component such as a piezoelectric speaker) across the chosen
path. If electron flow is inhibited by broken conductors, damaged
components, or excessive resistance, the circuit is "open".
Devices that can be used to perform continuity tests include multi meters
which measure current and specialized continuity testers which are cheaper,
more basic devices, generally with a simple light bulb that lights up when
current flows.
An important application is the continuity test of a bundle of wires so as to
find the two ends belonging to a particular one of these wires; there will be a
negligible resistance between the "right" ends, and only between the "right"
ends.
This test is the performed just after the hardware soldering and
configuration has been completed. This test aims at finding any electrical
open paths in the circuit after the soldering. Many a times, the electrical
continuity in the circuit is lost due to improper soldering, wrong and rough
handling of the PCB, improper usage of the soldering iron, component
failures and presence of bugs in the circuit diagram. We use a multi meter to
perform this test. We keep the multi meter in buzzer mode and connect the
ground terminal of the multi meter to the ground. We connect both the
terminals across the path that needs to be checked. If there is continuation
then you will hear the beep sound.
POWER ON TEST:
This test is performed to check whether the voltage at different terminals is
according to the requirement or not. We take a multi meter and put it in
voltage mode. Remember that this test is performed without microcontroller.
Firstly, we check the output of the transformer, whether we get the required
12 v AC voltage.
Then we apply this voltage to the power supply circuit. Note that we do this
test without microcontroller because if there is any excessive voltage, this
may lead to damaging the controller. We check for the input to the voltage
regulator i.e., are we getting an input of 12v and an output of 5v. This 5v
output is given to the microcontrollers 40th pin. Hence we check for the
22

voltage level at 40th pin. Similarly, we check for the other terminals for the
required voltage. In this way we can assure that the voltage at all the
terminals is as per the requirement.

SOFTWARE DEVELOPMENT
Microcontroller has been programmed to test the hardware as well to
achieve the goal of WIRELESS SCADA application, which involved the
following steps.

Figure : Software Developments


CODING / DEBUGGING
Coding / Debugging in a high-level language (such as C, or Java) or
assembler.
A compiler for a high level language helps to reduce production time. To
program the microcontrollers the KEIL software was used. Although inline
assembly was possible, the programming was done strictly in the C
language. The source code has been commented to facilitate any occasional
future improvement and maintenance.
KEIL is a suite of executable, open source software development tools for the
Atmel AVR series of RISC microprocessors hosted on the Windows platform. It
includes the GNU GCC compiler for C and C++. KEIL contains all the tools for
developing on the AVR. This includes avr-gcc (compiler), avr-gdb (debugger)
etc.
Test Source Code has been written in C Language to test the microcontroller.
An LED will blink as soon as microcontrollers Flash memory is burned with
the test program. Using XTU software setting on COM port of PC Xbee
module has been checked.
23

The application source code is written in C language. This protocol generates


the real time temperature data. When master mote request for the data,
slave mote sends it back to master mote as soon as it gets the query. Master
mote displays it over the PCs monitor

CODE
#include<reg51.h>
#include<ser.h>
#include<temp.h>
#include<lcd.h>
sbit fan=P1^1;
sbit heater=P1^2;
sbit pump=P1^0;
sbit m_1=P1^3;
sbit m_2=P1^4;
bit ser=0;
unsigned char a[5],i;
void serial() interrupt 4
{
if(RI)
{
for(i=0;i<5;i++)
a[i]=ser_rcv();
ser=1;
}
else
;;
}
void main()
{
pump=fan=0;
IE=0x90;
lcdinit();
ser_init();
lcddis("OK");
ser_str("OK");
while(1)
{
tempr();
ser_dat(val_1);
ser_dat(val_2);
24

lcdcmd(0xc0);
lcddis("TEMP ::");
lcddat(val_1);
lcddat(val_2);
delayy(65000);delayy(65000);delayy(65000);
if(ser)
{
if(a[0]=='0')
{fan=0;}
if(a[0]=='1')
{fan=1;}
if(a[1]=='0')
{heater=0;}
if(a[1]=='1')
{heater=1;}
if(a[2]=='0')
{pump=0;}
if(a[2]=='1')
{pump=1;}
if(a[3]=='0')
{m_1=m_2=1;}
if(a[3]=='1')
{
if(a[4]=='0'){m_1=1;m_2=0;}
if(a[4]=='1'){m_1=0;m_2=1;}
}
else
;;
}
}
}

25

COMPILING
Compiling the code into machine language.
The compilation of the C program converts it into machine language file
(.hex). This is the only language the microcontroller will understand, because
it contains the original program code converted into a hexadecimal format.
During this step there were some warnings about eventual errors in the
program.
BURNING
Burning the machine language (hex) file into the microcontrollers program
memory is achieved with a dedicated programmer, which attaches to a PCs
peripheral. PCs serial port has been used for the purpose. In the present
work the PonyProg programmer has been used to burn the machine
language file into the microcontrollers program memory.
PonyProg is serial device programmer software with a user-friendly GUI
framework available for Windows95/98/ME/NT/2000/XP and Intel Linux. Its
purpose is reading and writing every serial device. It supports IC Bus,
Microwire, SPI eeprom, and the Atmel AVR and Microchip PIC microcontroller.
The microcontrollers were programmed in approximately two seconds with a
high speed-programming mode. The program memory, which is of Flash
type, has, just like the EEPROM, a limited lifespan. On the AVR
microcontroller family it may be reprogrammed up to a thousand times
without any risk of data corruption.
EVALUATION
If the system performs all the required tasks and behaves as expected the
software development phase is over. If not, the whole procedure will have to
be repeated again.
One of the difficulties of programming microcontrollers is the limited amount
of resources the programmer has to deal with. In PCs resources such as RAM
and processing speed are basically limitless when compared to
microcontrollers. In contrast to a PC, the code on microcontrollers should be
as low on resources as possible.

26

FRONT END DESIGN USING LABVIEW


LabVIEW's icon-based graphical programming language lets users design an
interface that includes instrument control, data collection, data analysis and
display functions. The language is platform-independent; applications written
using LabVIEW can be compiled to run on Macs, Windows machines and Sun
SPARCstations. LabVIEW also includes instrument libraries, which contain
controls for more than 130 common laboratory instruments.
Using LabVIEW environment a trial has been made to create a set of
programmable virtual instruments, which resemble the traditional PLC
programmable functions and networks. The target of this work is to improve
the programmability of PC-based control systems. Bringing the PLC to the
industrial type computer it becomes possible to make use of the advantages
of computer based DCSs. It will be possible to have unlimited number of
programmable objects, and to run more than one program at the same time.
By utilizing LabVIEW front panel it is an easy job to realize MMI as required,
and by creating sub VIs the program becomes more compact and easier to
debug.

27

CONNECTION DIAGRAM

28

WORKING:

29

The working of the circuit is quite simple and easily understandable by jus
observing the circuit. The working can be mainly discussed as three parts
which are the supply part, micro-controller part and the isolation part
respectively. All these parts together describe the working of the design of
wireless SCADA system.
The supply part/section mainly deals with the supply given to the circuit.
Actually it can be done in two ways i.e., either by giving 230V AC or by using
a battery (12V) as source of supply. Now in this design we are using a 230V
battery as source of supply. This 12v is regulated to 5V using a voltage
regulator as only 5V is required to drive the microcontroller.
This arrangement is done in two parts.
1. REMOTE SITE UNIT
2. CONTROL UNIT
The Remote site unit three application process is connected with the
microcontroller which is to be controlled with the help of the control unit.
1. OVER TEMPERATURE DETECTION AND CONTROLLING
2. DC MOTOR
3. WATER FLOW PUMP
In the control unit the above process is control with the help of the PC. In the
pc we have the front end software developed by using the LAB VIEW
software that enables the man machine interface. Here we can give the set
points for the upper and lower limit of the temperature to restrain the vessel
from overheating. If the lower limit of the temperature is reached then the
cooling fan is activated and if the upper limit crosses then the alarm is
activated i.e. the over temperature is detected and the heater is turned off.
We have another application of the dc motor. Here the dc motor can be
switched on or off with the help of the control unit. And also we can rotate it
in clockwise and anticlockwise according to the requirement. Last application
we have a water flow pump that can be controlled using the control unit. And
the every activities of the process is recorded in a particular file in the PC for
future references.
The control of these process at the remote site unit is controlled by the
control unit is done wirelessly using a wireless module i. e. XBee. This
wireless unit is connected with the the both of the unit.

30

COMPONENT DESCRIPTION
RESISTORS: A resistor is a two-terminal electronic component designed to oppose an
electric current by producing a voltage drop between its terminals in
proportion to the current, that is, in accordance with Ohm's law:
V = IR
Resistors are used as part of electrical networks and electronic circuits. They
are extremely commonplace in most electronic equipment. Practical resistors
can be made of various compounds and films, as well as resistance wire
(wire made of a high-resistivity alloy, such as nickel/chrome).

The primary characteristics of resistors are their resistance and the


power they can dissipate. Other characteristics include temperature
coefficient, noise, and inductance. Less well-known is critical resistance, the
value below which power dissipation limits the maximum permitted current
flow, and above which the limit is applied voltage. Critical resistance
depends upon the materials constituting the resistor as well as its physical
dimensions; it's determined by design.

Resistors can be integrated into hybrid and printed circuits, as well as


integrated circuits. Size, and position of leads (or terminals) are relevant to
31

equipment designers; resistors must be physically large enough not to


overheat when dissipating their power.

A Resistor is a heat-dissipating element and in the electronic circuits it


is mostly used for either controlling the current in the circuit or developing a
voltage drop across it, which could be utilized for many applications. There
are various types of resistors, which can be classified according to a number
of factors depending upon:
(I)
Material used for fabrication
(II) Wattage and physical size
(III) Intended application
(IV) Ambient temperature rating
(V)Cost
Basically the resistor can be split in to the following four parts from
construction viewpoint.

the

(1) Base
(2) Resistance element
(3) Terminals
(4) Protective means.
The following characteristics are inherent in all resistors and may be
controlled by design considerations and choice of material i.e. Temperature
coefficient of resistance, Voltage coefficient of resistance, high frequency
characteristics, power rating, tolerance & voltage rating of resistors.
Resistors may be classified as
(1)Fixed
(2)Semi variable
(3)Variable resistor.
In our project carbon resistors are being used.

32

CAPACITORS

A capacitor or condenser is a passive electronic component consisting of a


pair of conductors separated by a dielectric. When a voltage potential
difference exists between the conductors, an electric field is present in the
dielectric. This field stores energy and produces a mechanical force between
the plates. The effect is greatest between wide, flat, parallel, narrowly
separated conductors.
An ideal capacitor is characterized by a single constant value,
capacitance, which is measured in farads. This is the ratio of the electric
charge on each conductor to the potential difference between them. In
practice, the dielectric between the plates passes a small amount of leakage
current. The conductors and leads introduce an equivalent series resistance
and the dielectric has an electric field strength limit resulting in a breakdown
voltage.

The properties of capacitors in a circuit may determine the resonant


frequency and quality factor of a resonant circuit, power dissipation and
33

operating frequency in a digital logic circuit, energy capacity in a high-power


system, and many other important aspects.

The fundamental relation for the capacitance between two flat plates
separated by a dielectric material is given by:C=0.08854KA/D
Where: -

C= capacitance in pf.
K= dielectric constant
A=Area per plate in square cm.
D=Distance between two plates in cm

Design of capacitor depends on the proper dielectric material with


particular type of application. The dielectric material used for capacitors may
be grouped in various classes like Mica, Glass, air, ceramic, paper,
Aluminum, electrolyte etc. The value of capacitance never remains constant.
It changes with temperature, frequency and aging. The capacitance value
marked on the capacitor strictly applies only at specified temperature and at
low frequencies.

ELECTROLYTIC CAPACITOR
An electrolytic capacitor is a type of capacitor that uses an electrolyte (an
ionic conducting liquid) as one of its plates to achieve a larger capacitance
per unit volume than other types, but with performance disadvantages. All
capacitors conduct alternating current (AC) and block direct current (DC) and
can be used, amongst other applications, to couple circuit blocks allowing AC
signals to be transferred while blocking DC power, to store energy, and to
filter signals according to their frequency. The large capacitance of
electrolytic capacitors makes them particularly suitable for passing or
34

bypassing low-frequency signals and storing large amounts of energy. They


are widely used in power supplies and for decoupling unwanted AC
components from DC power connections

CERAMIC CAPACITOR
A ceramic capacitor is a fixed capacitor with the ceramic material acting as
the dielectric. It is constructed of two or more alternating layers of ceramic
and a metal layer acting as the electrodes. The composition of the ceramic
material defines the electrical behavior and therefore the application of the
capacitors which are divided into two stability classes:

Class 1 ceramic capacitors with high stability and low losses for
resonant circuit application

Class 2 ceramic capacitors with high volumetric efficiency for buffer,


by-pass and coupling applications.

Ceramic capacitors, especially the multilayer version (MLCC), are the most
produced and used capacitors in electronic equipment with a produced
quantity of approximately 1000 billion pieces per year.

LED (LIGHT EMITTING DIODES)

As its name implies it is a diode, which emits light when forward


biased. Charge carrier recombination takes place when electrons from the Nside cross the junction and recombine with the holes on the P side. Electrons
are in the higher conduction band on the N side whereas holes are in the
lower valence band on the P side. During recombination, some of the energy
is given up in the form of heat and light. In the case of semiconductor
materials like Gallium arsenide (GaAs), Gallium phoshide (Gap) and Gallium
arsenide phoshide (GaAsP) a greater percentage of energy is released during

35

recombination and is given out in the form of light. LED emits no light when
junction is reverse biased.

TRANSISTOR: A transistor consists of two junctions formed by sandwiching either ptype or n-type semiconductor between a pair of opposite types. Accordingly,
there are two types of transistors namely: (1) n-p-n transistor

(NPN)

(2) p-n-p transistor

(PNP)

An n-p-n transistor is composed of two n-type semiconductors separated by


a thin section of p type. However a p-n-p transistor is formed by two p
sections separated by a thin section of n-type. In each type of transistor the
following points may be noted.

1.

There are two p-n junctions, therefore a transistor may be regarded as


combination of two diodes connected back to back.
2.
There are three terminals taken from each type of semiconductor.
3.
The middle section is a very thin layer, which is the most important
factor in the functioning of a transistor.
4.
Transistor can be used as an Amplifier also.
A transistor raises the strength of a weak signal and thus acts as an
amplifier. The weak signal is applied between emitter base junction and
output is taken across the load Rc connected in the collector circuit (in
36

common emitter configuration). In order to achieve faithful amplification, the


input circuit should always remain forward biased. To do so, a dc voltage is
applied in the input in addition to the signal. This dc Voltage is known as
biasing voltage and its magnitude and polarity should be such that it always
keeps the input circuit forward biased regardless of the polarity to the signal
to be amplified.
As the input circuit has low resistance a small change in signal voltage
causes an appreciable change in emitter current. This causes change in
collector current (by a factor called current gain of transistor) due to
transistor action. The collector current flowing through a high load resistance
Rc produces a large voltage across it. Thus a weak signal applied to the input
circuit appears in the amplified form in the collector circuit. This is how a
transistor acts as an amplifier.
Transistor may be used in different configuration like CB (common base) &
CC (common collector) according to requirements of amplifier (impedance
matching, buffer amplifier etc.).
BC 547
The BC547 transistor is an NPN Epitaxial Silicon Transistor. The BC547
transistor is a general-purpose transistor in small plastic packages. It is used
in general-purpose switching and amplification BC847/BC547 series 45 V,
100 mA NPN general-purpose transistors.

FIG 3.8(a): BC 547 TRANSISTOR PINOUT


The BC547 transistor is an NPN bipolar transistor, in which the letters "N"
and "P" refer to the majority charge carriers inside the different regions of
the transistor. Most bipolar transistors used today are NPN, because electron
mobility is higher than whole mobility in semiconductors, allowing greater
currents and faster operation. NPN transistors consist of a layer of P-doped
semiconductor (the "base") between two N-doped layers. A small current
entering the base in common-emitter mode is amplified in the collector
37

output. In other terms, an NPN transistor is "on" when its base is pulled high
relative to the emitter. The arrow in the NPN transistor symbol is on the
emitter leg and points in the direction of the conventional current flow when
the device is in forward active mode. One mnemonic device for identifying
the symbol for the NPN transistor is "not pointing in." An NPN transistor can
be considered as two diodes with a shared anode region. In typical operation,
the emitter base junction is forward biased and the base collector junction is
reverse biased. In an NPN transistor, for example, when a positive voltage is
applied to the base emitter junction, the equilibrium between thermally
generated carriers and the repelling electric field of the depletion region
becomes unbalanced, allowing thermally excited electrons to inject into the
base region. These electrons wander (or "diffuse") through the base from the
region of high concentration near the emitter towards the region of low
concentration near the collector. The electrons in the base are called
minority carriers because the base is doped p-type which would make holes
the majority carrier in the base.

TRANSFORMER
Definition: The transformer is a static electro-magnetic device that transforms one
alternating voltage (current) into another voltage (current). However, power
remains the some during the transformation. Transformers play a major role
in the transmission and distribution of ac power.

Principle: -

Transformer works on the principle of mutual induction. A transformer


consists of laminated magnetic core forming the magnetic frame. Primary
and secondary coils are wound upon the two cores of the magnetic frame,
linked by the common magnetic flux. When an alternating voltage is applied
across the primary coil, a current flows in the primary coil producing
magnetic flux in the transformer core. This flux induces voltage in secondary
coil.
Transformers are classified as: (a)

Based on position of the windings with respect to core i.e.


(1)
Core type transformer
38

(2)
Shell type transformer
Transformation ratio:
(1)
Step up transformer
(2)
Step down transformer
Core & shell types: Transformer is simplest electrical machine, which
consists of windings on the laminated magnetic core. There are two
possibilities of putting up the windings on the core.

(b)

(a)

(1)
(2)
(b)

Winding encircle the core in the case of core type transformer


Cores encircle the windings on shell type transformer.
Step up and Step down: In these Voltage transformation takes place
according to whether the
Primary is high voltage coil or a low voltage coil.

(1)
(2)

Lower to higher-> Step up


Higher to lower-> Step down

DIODE
-

It is a two terminal device consisting of a P-N junction formed either of Ge or


Si crystal. The P and N type regions are referred to as anode and cathode
respectively. Commercially available diodes usually have some means to
indicate which lead is P and which lead is N.
IN4007 RECTIFIER DIODE
Diodes are used to convert AC into DC these are used as half wave rectifier
or full wave rectifier. Three points must he kept in mind while using any type
of diode.
1. Maximum forward current capacity
2. Maximum reverse voltage capacity
3. Maximum forward voltage capacity

39

The number and voltage capacity of some of the important diodes available
in the market are as follows:

Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006


and IN4007 have maximum reverse bias voltage capacity of 50V and
maximum forward current capacity of 1 Amp.

Diode of same capacities can be used in place of one another. Besides


this diode of more capacity can be used in place of diode of low
capacity but diode of low capacity can not be used in place of diode of
high capacity. For example, in place of IN4002; IN4001 or IN4007 can
be used but IN4001 or IN4002 cannot be used in place of IN4007.The
diode BY125made by company BEL is equivalent of diode from IN4001
to IN4003. BY 126 is equivalent to diodes IN4004 to 4006 and BY 127 is
equivalent to diode IN4007.

RELAY
A relay is an electrical switch that opens and closes under the control of
another electrical circuit. In the original form, the switch is operated by an
electromagnet to open or close one or many sets of contact. Since 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.

Fig 3.5(a): RELAY

40

Basic design and operation

A simple electromagnetic relay, such as the one taken from a car in the
above figure , 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; that is two in the relay for above figure . 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 is closed, and the other set is open. Other relays may
have more or fewer sets of contacts depending on their function. The relay
also has a wire connecting the armature to the yoke. This ensures continuity
of the circuit between the moving contacts on the armature, and the circuit
track on the Printed Circuit Board (PCB) via the yoke, which is soldered to the
PCB.

Fig 3.5(b):INTERNAL CIRCUIT OF RELAY

When an electric current is passed through the coil, the resulting


magnetic field attracts the armature and the consequent movement
of the movable contact or contacts either makes or breaks a
connection with a fixed contact. If the set of contacts was closed
when the relay was de-energised, then the movement opens the
contacts and breaks the connection, and vice versa if the contacts
were open. When the current to the coil is switched off, the armature
is returned by a force, approximately half as strong as the magnetic
force, to its relaxed position. Usually this force is provided by a
spring, but gravity is also used commonly in industrial motor starters.
Most relays are manufactured to operate quickly. In a low voltage
application, this is to reduce noise. In a high voltage or high current
application, this is to reduce arcing.

If the coil is energized with DC, a diode is frequently installed across


the coil, to dissipate the energy from the collapsing magnetic field at
deactivation, which would otherwise generate a voltage spike
41

dangerous to circuit components. Some automotive relays already


include that diode inside the relay case. Alternatively a contact
protection network, consisting of a capacitor and resistor in series,
may absorb the surge. If the coil is designed to be energized with AC,
a small copper ring can be crimped to the end of the solenoid. This
"shading ring" creates a small out-of-phase current, which increases
the minimum pull on the armature during the AC cycle.

By analogy with the functions of the original electromagnetic device,


a solid-state relay is made with a thyristor or other solid-state
switching device. To achieve electrical isolation an optocoupler can be
used which is a light-emitting diode (LED) coupled with photo diode.

Applications
Relays are used to and for:

Control a high-voltage circuit with a low-voltage signal, as in some


types of modems or audio amplifiers,

Control a high-current circuit with a low-current signal, as in the


starter solenoid of an automobile,

Detect and isolate faults on transmission and distribution lines by


opening and closing circuit breakers.

Time delay functions. Relays can be modified to delay opening or


delay closing a set of contacts. A very short (a fraction of a second)
delay would use a copper disk between the armature and moving
blade assembly. Current flowing in the disk maintains magnetic field
for a short time, lengthening release time. For a slightly longer (up to
a minute) delay, a dashpot is used. A dashpot is a piston filled with
fluid that is allowed to escape slowly. The time period can be varied
by increasing or decreasing the flow rate. For longer time periods, a
mechanical clockwork timer is installed.
42

In this circuit a 12V magnetic relay is used. In magnetic relay,


insulated copper wire coil is used to magnetize and attract the plunger .The
plunger is normally connected to N/C terminal. A spring is connected to
attract the plunger upper side. When output is received by relay, the plunger
is attracted and the bulb glows.

MOTOR DRIVER (L293D)


Push-Pull Four Channel Driver
DESCRIPTION
The L293 and L293D are quad push-pull drivers capable of delivering output
currents to 1A or 600mA per channel respectively. Each channel is controlled
43

by a TTL-compatible logic input and each pair of drivers (a full bridge) is


equipped with an inhibit input which turns off all four transistors.
A separate supply input is provided for the logic so that it may be run off a
lower voltage to reduce dissipation. Additionally the L293D includes the output
clamping diodes within the IC for complete interfacing with inductive loads.
Both devices are available in 16-pin Batwing DIP packages. They are also
available in Power S0IC and Hermetic DIL packages.

ABSOLUTE MAXIMUM RATINGS


Collector Supply Voltage, VC. . . . . . . . . . . . . . . . . . . . . . . . . . . . 36V
Logic Supply Voltage, VSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36V
Input Voltage, VI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7V
Inhibit Voltage, VINH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7V
Peak Output Current (Non-Repetitive), lOUT (L293) . . . . . . .. . 2A
lOUT (L293D) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2A
Total Power Dissipation at Tground-pins = 80C, N Batwing pkg,
(Note) . . . . . . . . . . . . . . . 5W
Storage and Junction Temperature, Tstg, TJ . . . . . . . -40 to +150C
Note: Consult packaging section of Data book for thermal limitations and
Considerations of packages.
FEATURES:
Output Current 1A Per Channel (600mA for L293D)
Peak Output Current 2A Per Channel (1.2A for L293D)
Inhibit Facility
High Noise Immunity
Separate Logic Supply
44

Over-Temperature Protection
PIN DIAGRAM

CONNECTION DIAGRAM

LCD DISPLAY
Liquid crystal display (LCD) has material which combines the properties of
both liquid and crystals. They have a temperature range within which the
molecules are almost as mobile as they would be in a liquid, but are grouped
together in an order form similar to a crystal.

45

Fig. LCD DISPLAY


More microcontroller devices are using 'smart LCD' displays to output visual
information. The following discussion covers the connection of a Hitachi LCD
display to a PIC microcontroller. LCD displays designed around Hitachi's LCD
HD44780 module, are inexpensive, easy to use, and it is even possible to
produce a readout using the 8 x 80 pixels of the display. Hitachi LCD displays
have a standard ASCII set of characters plus Japanese, Greek and
mathematical symbols.

For an 8-bit data bus, the display requires a +5V supply plus 11 I/O
lines. For a 4-bit data bus it only requires the supply lines plus seven extra
lines. When the LCD display is not enabled, data lines are tri-state which
means they are in a state of high impedance (as though they are
disconnected) and this means they do not interfere with the operation of the
microcontroller when the display is not being addressed.

The LCD also requires 3 "control" lines from the microcontroller


Enable (E)

This line allows access to the display through R/W and RS


lines. When this line is low, the LCD is disabled and ignores
signals from R/W and RS. When (E) line is high, the LCD checks
the state of the two control lines and responds accordingly.

Read/Write
(R/W)

This line determines the direction of data between the LCD


and microcontroller. When it is low, data is written to the LCD.
When it is high, data is read from the LCD.

Register
select (RS)

With the help of this line, the LCD interprets the type of data
on data lines. When it is low, an instruction is being written to
the LCD. When it is high, a character is being written to the
LCD.

Read data from data lines (if it is reading)


46

Reading data from the LCD is done in the same way, but control line R/W has
to be high. When we send a high to the LCD, it will reset and wait for
instructions. Typical instructions sent to LCD display after a reset are: turning
on a display, turning on a cursor and writing characters from left to
right. When the LCD is initialized, it is ready to continue receiving data or
instructions. If it receives a character, it will write it on the display and move
the cursor one space to the right.
The Cursor marks the next location where a character will be written. When
we want to write a string of characters, first we need to set up the starting
address, and then send one character at a time. Characters that can be
shown on the display are stored in data display (DD) RAM. The size of DDRAM
is 80 bytes.
The LCD display also possesses 64 bytes of Character-Generator (CG) RAM.
This memory is used for characters defined by the user. Data in CG RAM is
represented as an 8-bit character bit-map. Each character takes up 8 bytes
of CG RAM, so the total number of characters, which the user can define, is
eight. In order to read in the character bit-map to the LCD display, we must
first set the CG RAM address to starting point (usually 0), and then write data
to the display. The definition of a 'special' character is given in the picture.

Fig:Display
Before we access DD RAM after defining a special character, the
program must set the DD RAM address. Writing and reading data from any
LCD memory is done from the last address which was set up using setaddress instruction. Once the address of DD RAM is set, a new written
47

character will be displayed at the appropriate place on the screen. Until now
we discussed the operation of writing and reading to an LCD as if it were an
ordinary memory. But this is not so. The LCD controller needs 40 to 120
microseconds (us) for writing and reading. Other operations can take up to 5
mS. during that time, the microcontroller cannot access the LCD, and so a
program needs to know when the LCD is busy. We can solve this in two ways.

One way is to check the BUSY bit found on data line D7. This is not
the best method because LCD's can get stuck, and program will then stay
forever in a loop checking the BUSY bit. The other way is to introduce a delay
in the program. The delay has to be long enough for the LCD to finish the
operation in process.
Instructions for writing to and reading from an LCD memory shown in the
previous table. At the beginning we mentioned that we needed 11 I/O lines to
communicate with an LCD. However, we can communicate with an LCD
through a 8-bit data bus. The wiring for connection via a 8-bit data bus is
shown in the diagram below. In this example we use an LCD display with
2x16 characters, labeled LM16X212 by Japanese maker SHARP.

MAX 232
48

FIG : MAX232

FIG: CONNECTIONS

The MAX232 is an integrated circuit that converts signals from an


RS-232 serial port to signals suitable for use in TTL compatible digital logic
circuits. The MAX232 is a dual driver/receiver and typically converts the RX,
TX, CTS and RTS signals.

The drivers provide RS-232 voltage level outputs (approx. 7.5 V) from a
single + 5 V supply via on-chip charge pumps and external capacitors. This
makes it useful for implementing RS-232 in devices that otherwise do not
need any voltages outside the 0 V to + 5 V range, as power supply design
does not need to be made more complicated just for driving the RS-232 in
this case.

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


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

The later MAX232A is backwards compatible with the original MAX232 but
may operate at higher baud rates and can use smaller external capacitors
0.1 mF in place of the 1.0 mF capacitors used with the original device

49

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


voltage range, from 3 to 5.5V.
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 +15V, and changes TTL Logic 1 to between -3 to -15V, and vice versa for
converting from RS232 to TTL. It is to be realized that the RS232 Data
Transmission voltages at a certain logic state are opposite from the RS232
Control Line voltages at the same logic state.

WIRELESS MODULE (ZIGBEE)

ZigBee is a low-cost, low-power, wireless mesh network standard. The low


cost allows the technology to be widely deployed in wireless control and
monitoring applications. Low power-usage allows longer life with smaller
batteries. Mesh networking provides high reliability and more extensive
range. ZigBee chip vendors typically sell integrated radios and
microcontrollers with between 60 KB and 256 KB flash memory.
ZigBee operates in the industrial, scientific and medical (ISM) radio bands;
868 MHz in Europe, 915 MHz in the USA and Australia, and 2.4 GHz in most
jurisdictions worldwide. Data transmission rates vary from 20 to 900
kilobits/second. The ZigBee network layer natively supports both star and
tree typical networks, and generic mesh networks.

Chip-vendor independence
Rapid innovation
Extremely Low cost
Open standards enable markets
Easy to deploy
Excellent performance in environments with low signal-to-noise ratio
Appropriate range of operation (30 - 100 meters), can be expanded up
to 1-2 KM using external antenna.
Appropriate and reliable data transfer, bit rate : 250kbps at 2.4 GHz
Very low power consumption

50

Secure data transfer


Zigbee protocol needs less than 64 kb of ROM and 2-32 kb of RAM
Zigbee can bee implemented with any type of microcontroller

Application profiles-------The current list of application profiles either published, or in the works are:
Released specifications

ZigBee
ZigBee
ZigBee
ZigBee
ZigBee

Home Automation
Smart Energy 1.0
Telecommunication Services
Health Care
RF4CE - Remote Control

Specifications under development

ZigBee
ZigBee
ZigBee
ZigBee

Smart Energy 2.0


Building Automation
Retail Services
Light Lin

ZigBee protocols are intended for embedded applications requiring low data
rates and low power consumption. The resulting network will use very small
amounts of power individual devices must have a battery life of at least
two years to pass ZigBee certification.

Typical application areas include- Home Entertainment and Control Home automation, smart lighting,
advanced temperature control, safety and security, movies and music
Wireless Sensor Networks' starts with individual sensors like
Telosb/Tmote and Iris from Memsic.
Industrial control,
Embedded sensing,
Medical data collection,
Smoke and intruder warning,
Building automation.
51

There are three different types of ZigBee devices:


ZigBee coordinator (ZC): The most capable device, the coordinator
forms the root of the
network tree and might bridge to other
networks. There is exactly one ZigBee coordinator in each network
since it is the device that started the network originally. It is able to
store information about the network, including acting as the Trust
Center & repository for security keys.
ZigBee Router (ZR): As well as running an application function, a
router can act as an intermediate router, passing on data from other
devices.
ZigBee End Device (ZED): Contains just enough functionality to talk to
the parent node (either the coordinator or a router); it cannot relay
data from other devices. This relationship allows the node to be
asleep a significant amount of the time thereby giving long battery
life. A ZED requires the least amount of memory, and therefore can
be less expensive to manufacture than a ZR or ZC.

52

TEMPERARURE SENSOR (DS1621)


DESCRIPTION
The DS1621 Digital Thermometer and Thermostat provides 9bit
temperature readings which indicate the temperature of the device. The
thermal alarm output, TOUT, is active when the temperature of the device
exceeds a userdefined temperature TH. The output remains active until the
temperature drops below user defined temperature TL, allowing for any
hysteresis necessary. User-defined temperature settings are stored in
nonvolatile memory so parts may be programmed prior to insertion in a
system. Temperature settings and temperature readings are all
communicated to/from the DS1621 over a simple twowire serial interface.

OPERATION
Measuring Temperature

A block diagram of the DS1621 is shown in Figure 1. The DS1621 measures


temperatures through the use of an onboard proprietary temperature
measurement technique. A block diagram of the temperature measurement
circuitry is shown in Figure. The DS1621 measures temperature by counting
the number of clock cycles that an oscillator with a low temperature
coefficient goes through during a gate period determined by a high
temperature coefficient oscillator. The counter is preset with a base count
that corresponds to 55C. If the counter reaches 0 before the gate period is
over the temperature register, which is also preset to the 55C value, is
incremented indicating that the temperature is higher than 55C. At the
same time, the counter is preset with a value determined by the slope
accumulator circuitry. This circuitry is needed to compensate for the
parabolic behavior of the oscillators over temperature. The counter is then
clocked again until it reaches 0. If the gate period is still not finished, then
this process repeats.
53

The slope accumulator is used to compensate for the nonlinear behavior of


the oscillators overtemperature, yielding a high resolution temperature
measurement. This is done by changing the number of counts necessary for
the counter to go through for each incremental degree in temperature. To
obtain the desired resolution, both the value of the counter and the number
of counts per C (the value of the slope accumulator) at a given temperature
must be known.
This calculation is done inside the DS1621 to provide 0.5C resolution. The
temperature reading is provided in a 9bit, twos complement reading by
issuing the READ TEMPERATURE command. Table 2 describes the exact
relationship of output data to measured temperature. The data is transmitted
through the 2wire serial interface, MSB first. The DS1621 can measure
temperature over the range of 55C to +125C in 0.5C increments. For
Fahrenheit usage a lookup table or conversion factor must be used.

PIN ASSIGNMENT

FEATURES
Temperature measurements require no external components
Measures temperatures from 55C to +125C in 0.5C increments.
Fahrenheit equivalent is 67F to 257F in 0.9F increments
Temperature is read as a 9bit value (2- byte transfer)
Wide power supply range (2.7V to 5.5V)
Converts temperature to digital word in 1 second
Thermostatic settings are user definable and nonvolatile
Data is read from/written via a twowire serial interface (open drain I/O
lines)
54

Applications include thermostatic controls, industrial


consumer
products, thermometers, or any thermal sensitive system

systems,

DC MOTOR
In any electric motor, operation is based on simple electromagnetism. A
current-carrying conductor generates a magnetic field; when this is then
placed in an external magnetic field, it will experience a force proportional to
the current in the conductor, and to the strength of the external magnetic
field. As you are well aware of from playing with magnets as a kid, opposite
(North and South) polarities attract, while like polarities (North and North,
South and South) repel. The internal configuration of a DC motor is designed
to harness the magnetic interaction between a current-carrying conductor
and an external magnetic field to generate rotational motion.

Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator,
commutator, field magnet(s), and brushes. In most common DC motors, the
external magnetic field is produced by high-strength permanent magnets 1.
The stator is the stationary part of the motor -- this includes the motor
casing, as well as two or more permanent magnet pole pieces. The rotor
rotates with respect to the stator. The rotor consists of windings (generally
55

on a core), the windings being electrically connected to the commutator. The


above diagram shows a common motor layout -- with the rotor inside the
stator (field) magnets.

MICROCONTROLLER
What is Micro Controller?
A micro controller is an electronic device that generally consists of a
microprocessor, a memory unit in the form of random access memory (RAM)
and Read Only Memory (ROM), various timers and input/output serial and
parallel ports all integrated on a single chip. In some advanced micro
controller systems, on chip ADCs, DACs etc are also included. A few
examples of microcontrollers available in the market today are: - Intel 8051,
Motorolas 6811, Zilogs Z8 etc.

How does the microcontroller operate?


Even though there is a large number of different types of microcontrollers
and even more programs created for their use only, all of them have many
things in common. Thus, if you learn to handle one of them you will be able
to handle them all. A typical scenario on the basis of which it all functions is
as follows:
1. Power supply is turned off and everything is stillthe program is
loaded into the microcontroller, nothing indicates what is about to
come
2. Power supply is turned on and everything starts to happen at high
speed! The control logic unit keeps everything under control. It
disables all other circuits except quartz crystal to operate. While the
preparations are in progress, the first milliseconds go by.

56

3. Power supply voltage reaches its maximum and oscillator frequency


becomes stable. SFRs are being filled with bits reflecting the state of all
circuits within the microcontroller. All pins are configured as inputs. The
overall electronis starts operation in rhythm with pulse sequence. From
now on the time is measured in micro and nanoseconds.
4. Program Counter is set to zero. Instruction from that address is sent to
instruction decoder which recognizes it, after which it is executed with
immediate effect.
5. The value of the Program Counter is incremented by 1 and the whole
process is repeated...several million times per second.

Description
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer
with 8K bytes of Flash programmable and erasable read only memory
(PEROM). The device is manufactured using Atmels high-density nonvolatile
memory technology and is compatible with the industry-standard 80C51 and
80C52 instruction set and pinout. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with Flash on a
monolithic chip, the Atmel AT89C52 is a powerful microcomputer which
provides a highly-flexible and cost-effective solution to many embedded
control applications.
The AT89C52 provides the following standard features: 8K bytes of Flash, 256
bytes of RAM, 32 I/O lines, three 16-bittimer/counters, a six-vector two-level
interrupt architecture, a full-duplex serial port, on-chip oscillator, and clock
circuitry. In addition, the AT89C52 is designed with static logic for operation
down to zero frequency and supports two software selectable power saving
modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters,
serial port, and interrupt system to continue functioning. The Power-down
mode saves the RAM contents but freezes the oscillator, disabling all other
chip functions until the next hardware reset.

57

Features

Compatible with MCS-51 Products


8K Bytes of In-System Reprogrammable Flash Memory
Endurance: 1,000 Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes

PIN DSCRIPTION

58

Pin configuration ATMEL89C52

BLOCK DIAGRAM

59

60

Pin Description
VCC
Supply voltage.
GND
Ground.
Port 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin
can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be
used as high impedance
inputs.
Port 0 can also be configured to be the multiplexed low order address/data
bus during accesses to external program and data memory. In this mode, P0
has internal
pullups.
Port 0 also receives the code bytes during Flash programming and outputs
the code bytes during program verification. External pullups are required
during program verification.
Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pullups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins,
they are pulled high by the internal pullups and can be used as inputs. As
inputs, Port 1 pins that are externally being pulled low will source current (IIL)
because of the internal pullups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2
external count input (P1.0/T2) and the timer/counter 2 trigger input
(P1.1/T2EX), respectively, as shown in the following table.

Port 1 also receives the low-order address bytes during Flash programming
and verification.
Port Pin
Alternate Functions
P1.0
T2 (external count input to Timer/Counter
2),clock-out
P1.1
T2EX (Timer/Counter 2 capture/reload trigger
61

and direction control)


P1.5
P1.6
P1.7

MOSI (used for In-System Programming)


MISO (used for In-System Programming)
SCK (used for In-System Programming)

Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pullups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins,
they are pulled high by the internal pullups and can be used as inputs. As
inputs, Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external
program memory and during accesses to external data memory that use 16bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal
pull-ups when emitting 1s. During accesses to external data memories that
use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special
Function Register. Port 2 also receives the high-order address bits and some
control signals during Flash programming and verification.

Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins,
they are pulled high by the internal pullups and can be used as inputs. As
inputs,
Port 3 pins that are externally being pulled low will source current (IIL)
because of the pullups. Port 3 also serves the functions of various special
features of the AT89S52, as shown in the following table. Port 3 also receives
some control signals for Flash programming and verification.

Port
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5

Pin Alternate Functions


RXD (serial input port)
TXD (serial output port)
INT0 (external interrupt 0)
INT1 (external interrupt 1)
T0 (timer 0 external input)
T1 (timer 1 external input)
62

P3.6
P3.7

WR (external data memory write strobe)


RD (external data memory read strobe)

RST
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device. This pin drives High for 96 oscillator periods after
the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be
used to disable this feature. In the default state of bit DISRTO, the RESET
HIGH out feature is enabled.
ALE/PROG
Address Latch Enable (ALE) is an output pulse for latchingthe low byte of the
address during accesses to external memory. This pin is also the program
pulse input (PROG) during Flash programming. In normal operation, ALE is
emitted at a constant rate of 1/6 the oscillator frequency and may be used
for external timing or clocking purposes. Note, however, that one
ALE pulse is skipped during each access to external data memory. If desired,
ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the
bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the
pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.
PSEN
Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN
is activated twice each machine cycle, except that two PSEN activations are
skipped during each access to external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at
0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will beinternally latched
on reset. EA should be strapped to VCC for internal program executions. This
pin also receives the 12-volt programming enable voltage (VPP) during Flash
programming.

63

XTAL1
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2
Output from the inverting oscillator amplifier.

Special Function Registers


A map of the on-chip memory area called the Special Function Register (SFR)
space is shown in Table 1. Note that not all of the addresses are occupied,
and unoccupied addresses may not be implemented on the chip. Read
accesses to these addresses will in general return random data, and write
accesses will have an indeterminate effect. User software should not write 1s
to these unlisted locations, since they may be used in future products to
invoke new features. In that case, the reset or inactive values ofthe new bits
will always be 0.
Timer 2 Registers: Control and status bits are contained in registers
T2CON (shown in Table 2) and T2MOD (shown in Table 3) for Timer 2. The
register pair (RCAP2H, RCAP2L) are the Capture/Reload registers for Timer 2
in 16-bit capture mode or 16-bit auto-reload mode.
Interrupt Registers: The individual interrupt enable bits are in the IE
register. Two priorities can be set for each of the six interrupt sources in the
IP register.

64

Data Memory
The AT89C52 implements 256 bytes of on-chip RAM. The upper 128 bytes
occupy a parallel address space to the Special Function Registers. That
means the upper 128 bytes have the same addresses as the SFR space but
are physically separate from SFR space.
When an instruction accesses an internal location above address 7FH, the
address mode used in the instruction specifies whether the CPU accesses the
upper 128 bytes of RAM or the SFR space. Instructions that use direct
addressing access SFR space. For example, the following direct addressing
instruction accesses the SFR at location 0A0H (which is P2).
MOV0A0H,#data

65

Instructions that use indirect addressing access the upper 128 bytes of RAM. For
example, the following indirect addressing instruction, where R0 contains 0A0H,
accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).
MOV @R0, #data
Note that stack operations are examples of indirect addressing, so the upper 128
bytes of data RAM are available as stack space.
Timer 0 and 1
Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer 1
in the AT89C51.
Timer 2
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event
counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown in
Table 2). Timer 2 has three operating modes: capture, auto-reload (up or down
counting), and baud rate generator. The modes are selected by bits in T2CON, as
shown in Table 3. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer
function, the TL2 register is incremented every machine cycle. Since a machine
cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator
frequency.

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


transition at its corresponding external input pin, T2. In this function, the external
input is sampled during S5P2 of every machine cycle. When the samples show a
high in one cycle and a low in the next cycle, the count is incremented. The new
count value appears in the register during S3P1 of the cycle following the one in
which the transition was detected. Since two machine cycles (24 oscillator periods)
are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the
oscillator frequency. To ensure that a given level is sampled at least once before it
changes, the level should be held for at least one full machine cycle.
Capture Mode
66

In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0,
Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON. This
bit can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the
same operation, but a 1- to-0 transition at external input T2EX also causes the
current value in TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively.
In addition, the transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit,
like TF2, can generate an interrupt. The capture mode is illustrated in Figure 1.
Auto-reload (Up or Down Counter)
Timer 2 can be programmed to count up or down when configured in its 16-bit autoreload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located
in the SFR T2MOD (see Table 4). Upon reset, the DCEN bit is set to 0 so that timer 2
will default to count up. When DCEN is set, Timer 2 can count up or down,
depending on the value of the T2EX pin.
Baud Rate Generator
Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in
T2CON (Table 2). Note that the baud rates for transmit and receive can be different
if Timer 2 is used for the receiver or transmitter and Timer 1 is used for the other
function. Setting RCLK and/or TCLK puts Timer 2 into its baud rate generator mode,
as shown in Figure 4. The baud rate generator mode is similar to the auto-reload
mode, in that a rollover in TH2 causes the Timer 2 registers to be reloaded with the
16-bit value in registers RCAP2H and RCAP2L, which are preset by software.
The baud rates in Modes 1 and 3 are determined by Timer 2s overflow rate
according to the following equation.

Modes 1 and 3 Baud Rates=

Timer 2 Overflow Rate


16

The Timer can be configured for either timer or counter operation. In most
applications, it is configured for timer operation (CP/T2 = 0). The timer operation is
different for Timer 2 when it is used as a baud rate generator. Normally, as a timer,
it increments every machine cycle (at 1/12 the oscillator frequency). As a baud rate
generator, however, it increments every state time (at 1/2 the oscillator frequency).
The baud rate formula is given below.

Modes 13
Oscillator Frequency
=
Baud Rate 32[ 65536 ( RCAP 2 H , RCAP 2 L ) ]

67

where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit
unsigned
integer.
Timer 2 as a baud rate generator is shown in Figure 4. This figure is valid only if
RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and will not
generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX will
set EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus
when Timer 2 is in use as a baud rate generator, T2EX can be used as an extra
external interrupt. Note that when Timer 2 is running (TR2 = 1) as a timer in the
baud rate generator mode, TH2 or TL2 should not be read from or written to. Under
these conditions, the Timer is incremented every state time, and the results of a
read or write may not be accurate. The RCAP2 registers may be read but should not
be written to, because a write might overlap a reload and cause write and/or reload
errors. The timer should be turned off (clear TR2) before accessing the Timer 2 or
RCAP2 registers.

OSCILLATOR CHARACTERISTICS
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown
in Figure 1. Either a quartz crystal or ceramic resonator may be used. To
drive the device from an external clock source, XTAL2 should be left
unconnected while XTAL1 is driven as shown in Figure 2.There are no
requirements on the duty cycle of the external clock signal, since the input to
the internal clocking circuitry is through a divide-by-two flip-flop, but
minimum and maximum voltage high and low time specifications must be
observed.

68

Idle Mode
In idle mode, the CPU puts itself to sleep while all the onchip peripherals
remain active. The mode is invoked by software. The content of the on-chip
RAM and all the special functions registers remain unchanged during this
mode. The idle mode can be terminated by any enabled interrupt or by a
hardware reset. It should be noted that when idle is terminated by a hard
ware reset, the device normally resumes program execution, from where it
left off, up to two machine cycles before the internal reset algorithm takes
control. On-chip hardware inhibits access to internal RAM in this event, but
access to the port pins is not inhibited. To eliminate the possibility of an
unexpected write to a port pin when Idle is terminated by reset, the
instruction following the one that invokes Idle should not be one that writes
to a port pin or to external memory.
69

Power-down Mode
In the power-down mode, the oscillator is stopped, and the instruction that
invokes power-down is the last instruction executed. The on-chip RAM and
Special Function Registers retain their values until the power-down mode is
terminated. The only exit from power-down is a hardware reset. Reset
redefines the SFRs but does not change the on-chip RAM. The reset should
not be activated before VCC is restored to its normal operating level and
must be held active long enough to allow the oscillator to restart and
stabilize.

SOFTWARE REQUIREMENT
INTRODUCTION TO KEIL MICRO VISION (IDE)
Keil an ARM Company makes C compilers, macro assemblers, real-time kernels,
debuggers, simulators, integrated environments, evaluation boards, and emulators
for ARM7/ARM9/Cortex-M3, XC16x/C16x/ST10, 251, and 8051 MCU families.
Keil development tools for the 8051 Microcontroller Architecture support
every level of software developer from the professional applications engineer to the
student just learning about embedded software development. When starting a new
70

project, simply select the microcontroller you use from the Device Database and the
Vision IDE sets all compiler, assembler, linker, and memory options for you.
Keil is a cross compiler. So first we have to understand the concept of
compilers and cross compilers. After then we shall learn how to work with keil.

CONCEPT OF COMPILER
Compilers are programs used to convert a High Level Language to object code.
Desktop compilers produce an output object code for the underlying
microprocessor, but not for other microprocessors. I.E the programs written in one
of the HLL like C will compile the code to run on the system for a particular
processor like x86 (underlying microprocessor in the computer). For example
compilers for Dos platform is different from the Compilers for Unix platform So if
one wants to define a compiler then compiler is a program that translates source
code into object code.
The compiler derives its name from the way it works, looking at the entire piece of
source code and collecting and reorganizing the instruction. See there is a bit little
difference between compiler and an interpreter. Interpreter just interprets whole
program at a time while compiler analyses and execute each line of source code in
succession, without looking at the entire program.
The advantage of interpreters is that they can execute a program immediately.
Secondly programs produced by compilers run much faster than the same programs
executed by an interpreter. However compilers require some time before an
executable program emerges. Now as compilers translate source code into object
code, which is unique for each type of computer, many compilers are available for
the same language.

CONCEPT OF CROSS COMPILER


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

KEIL C CROSS COMPILER


Keil is a German based Software development company. It provides several
development tools like

IDE (Integrated Development environment)


71

Project Manager
Simulator
Debugger
C Cross Compiler, Cross Assembler, Locator/Linker

The Keil ARM tool kit includes three main tools, assembler, compiler and linker. An
assembler is used to assemble the ARM assembly program. A compiler is used to
compile the C source code into an object file. A linker is used to create an absolute
object module suitable for our in-circuit emulator.

Building an Application in Vision2


To build (compile, assemble, and link) an application in Vision2, you must:
1 Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2).
2 Select Project - Rebuild all target files or Build target.Vision2 compiles,
assembles, and links the files in your project.

Creating Your Own Application in Vision2


To
1
2
3
4
5
6

create a new project in Vision2, you must:


Select Project - New Project.
Select a directory and enter the name of the project file.
Select Project - Select Device and select an 8051, 251, or C16x/ST10 device
from the Device Database.
Create source files to add to the project.
Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and
add the source files to the project.
Select Project - Options and set the tool options. Note when you select the
target device from the Device Database all special options are set
automatically. You typically only need to configure the memory map of your
target hardware. Default memory model settings are optimal for most
applications.
Select Project - Rebuild all target files or Build target.

Debugging an Application in Vision2


To debug an application created using Vision2, you must:
1 Select Debug - Start/Stop Debug Session.
2 Use the Step toolbar buttons to single-step through your program. You may
enter G, main in the Output Window to execute to the main C function.
3 Open the Serial Window using the Serial #1 button on the toolbar.
Debug your program using standard options like Step, Go, Break, and so on.
72

Starting Vision2 and Creating a Project


Vision2 is a standard Windows application and started by clicking on the program
icon. To create a new project file select from the Vision2 menu Project New
Project. This opens a standard Windows dialog that asks you for the new project
file name. We suggest that you use a separate folder for each project. You can
simply use the icon Create New Folder in this dialog to get a new empty folder. Then
select this folder and enter the file name for the new project, i.e. Project1. Vision2
creates a new project file with the name PROJECT1.UV2 which contains a default
target and file group name. You can see these names in the Project.

Window Files.
Now use from the menu Project Select Device for Target and select a CPU for your
project. The Select Device dialog box shows the Vision2 device data base. Just
select the microcontroller you use. We are using for our examples the Philips
80C51RD+ CPU. This selection sets necessary tool Options for the 80C51RD+
device and simplifies in this way the tool Configuration.

Building Projects and Creating a HEX Files


Typical, the tool settings under Options Target are all you need to start a new
application. You may translate all source files and line the application with a click on
the Build Target toolbar icon. When you build an application with syntax errors,
Vision2 will display errors and warning messages in the Output Window Build
page. A double click on a message line opens the source file on the correct location
in a Vision2 editor window. Once you have successfully generated your application
you can start debugging.
After you have tested your application, it is required to create an Intel HEX file to
download the software into an EPROM programmer or simulator. Vision2 creates
HEX files with each build process when Create HEX files under Options for Target
Output is enabled. You may start your PROM programming utility after the make
process when you specify the program under the option Run User Program #1.

CPU Simulation
Vision2 simulates up to 16 Mbytes of memory from which areas can be mapped for
read, write, or code execution access. The Vision2 simulator traps
and reports illegal memory accesses. In addition to memory mapping, the simulator
also provides support for the integrated peripherals of the various 8051 derivatives.

73

The on-chip peripherals of the CPU you have selected are configured from the
Device.

Database selection
You have made when you create your project target. Refer to page 58 for
more Information about selecting a device. You may select and display the on-chip
peripheral components using the Debug menu. You can also change the aspects of
each peripheral using the controls in the dialog boxes.

Start Debugging
You start the debug mode of Vision2 with the Debug Start/Stop Debug
Session Command. Depending on the Options for Target Debug Configuration,
Vision2 will load the application program and run the startup code Vision2 saves
the editor screen layout and restores the screen layout of the last debug session. If
the program execution stops, Vision2 opens an editor window with the source text
or shows CPU instructions in the disassembly window. The next executable
statement is marked with a yellow arrow. During debugging, most editor features
are still available.
For example, you can use the find command or correct program errors. Program
source text of your application is shown in the same windows. The Vision2 debug
mode differs from the edit mode in the following aspects:
_ The Debug Menu and Debug Commands described on page 28 are available.
The additional debug windows are discussed in the following.
_ The project structure or tool parameters cannot be modified. All build commands
are disabled.

Disassembly Window
The Disassembly window shows your target program as mixed source and assembly
program or just assembly code. A trace history of previously executed instructions
may be displayed with Debug View Trace Records. To enable the trace history, set
Debug Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step
commands work on CPU instruction level rather than program source lines. You can
select a text line and set or modify code breakpoints using toolbar buttons or the
context menu commands.
You may use the dialog Debug Inline Assembly to modify the CPU instructions.
That allows you to correct mistakes or to make temporary changes to the target
program you are debugging. Numerous example programs are included to help you
get started with the most popular embedded 8051 devices.

74

The Keil Vision Debugger accurately simulates on-chip peripherals (IC, CAN, UART,
SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your
8051 device. Simulation helps you understand hardware configurations and avoids
time wasted on setup problems. Additionally, with simulation, you can write and test
applications before target hardware is available.

EMBEDDED C
Use of embedded processors in passenger cars, mobile phones, medical
equipment, aerospace systems and defense systems is widespread, and even
everyday domestic appliances such as dish washers, televisions, washing machines
and video recorders now include at least one such device.
Because most embedded projects have severe cost constraints, they tend
to use low-cost processors like the 8051 family of devices considered in this book.
These popular chips have very limited resources available most such devices have
around 256 bytes (not megabytes!) of RAM, and the available processor power is
around 1000 times less than that of a desktop processor. As a result, developing
embedded software presents significant new challenges, even for experienced
desktop programmers. If you have some programming experience - in C, C++ or
Java - then this book and its accompanying CD will help make your move to the
embedded world as quick and painless as possible.

LABVIEW
Using LabVIEW environment a trial has been made to create a set of
programmable virtual instruments, which resemble the traditional PLC
programmable functions and networks. The target of this work is to improve
the programmability of PC-based control systems. Bringing the PLC to the
industrial type computer it becomes possible to make use of the advantages
of computer based DCSs. It will be possible to have unlimited number of
programmable objects, and to run more than one program at the same time.
By utilizing LabVIEW front panel it is an easy job to realize MMI as required,
and by creating sub VIs the program becomes more compact and easier to
debug.

75

CONCLUSION
Wireless technology has spread widely within business and industrial sites.
Wireless SCADA is required in those applications when wireline
communications to the remote site is prohibitively expensive or it is too time
consuming to construct wireline communications. In particular types of
industry like Oil & Gas or Water & Wastewater, wireless SCADA is often the
only solution due to the remoteness of the sites. Wireless SCADA replaces or
extends the fieldbus to the site. It can reduce the cost of installing the
system. It is also easy to expand. In this paper we described an Architecture
of SCADA in wireless mode. Wireless SCADA provides

Wide area connectivity and pervasive


Redundancy and Hot Standby
Large addressing range
Integration of IT to Automation and Monitoring Networks
Standardization

76

BIBLIOGRAPHY
TEXT BOOKS REFERED:
1. The 8051 Microcontroller and Embedded systems by Muhammad Ali Mazidi and
Janice Gillispie Mazidi , Pearson Education.
2. ATMEL 89S52 Data Sheets.

WEBSITES
www.atmel.com
www.beyondlogic.org
www.wikipedia.org
www.howstuffworks.com
www.alldatasheets.com

77