You are on page 1of 83

REAL TIME FULLY PROGRAMMABLE

INDUSTRIAL THERMAL PROCESS CONROL

WI T H

PC INTERFACE

PROJECT REPORT
SUBMITTED TO THE UNIVERSITY OF PUNE
FOR PARTIAL FULFILMENT
OF THE DEGREE OF
B.E. ELECTRONICS

BY

ABY KURUVILLA
MARK SAMUEL

PROJECT GUIDES
Prof. (Mrs.) S.S. VEER (Internal)
Mr. PRASAD PRABHUGHATE (Company)

ELECTRONICS ENGINEERING DEPARTMENT


POONA DISTRICT EDUCATION ASSOCIATION’S
COLLEGE OF ENGINEERING
MANJRI ROAD
HADAPSAR, PUNE-26

* 2005-2006 *
POONA DISTRICT EDUCATION ASSOCIATION’S
COLLEGE OF ENGINEERING
MANJRI ROAD, HADAPSAR PUNE-26

This is to certify that the project work entitled


“REAL TIME FULLY PROGRAMMABLE INDUSTRIAL THERMAL
PROCESS CONTROL WITH PC INTERFACE”
Submitted by

ABY KURUVILLA - Roll No. B2263401


MARK SAMUEL - Roll No.

is a bonafide work carried out by them under my supervision and guidance, in


partial fulfillment of the requirements for the award of the Degree of Bachelor of
Engineering (Electronics Engineering) of University of Pune, during the
academic year 2005-2006.

Date :
Place :

PROF. C.G. PATIL PROF. S.S. VEER PRINCIPAL


(H.O.D Electronics) (Project Guide)
*2005-2006*

Certificate

The project work entitled

“REAL TIME FULLY PROGRAMMABLE


INDUSTRIAL THERMAL PROCESS CONROL WITH
PC INTERFACE”

Submitted By:

Aby Kuruvilla
Mark Samuel

is approved for the Degree of Bachelor of Engineering – Electronics Engineering, of

University of Pune, Pune.

Examiner ______________________

Date:

Place
Without hard work, determination and a systematic planning, we cannot
achieve anything in life. However, we do come across a lot of hurdles on the road to
achieving our goal. Here is when we need help, guidance, encouragement, co-
operation, etc from our elders, teachers, etc to overcome such hurdles. Here are a few
words to express our gratitude to a few such special people, without whose timely
help, guidance and blessings, we could not have completed our Project successfully
on time.
First and foremost, we would like to express our profound gratitude to
our Internal Guide, Prof. (Mrs.) S.S. Veer, who has been helping us right from the
conceptualization till the completion of this Project. We have been very fortunate to
get a lot of inspiration, suggestion and guidance from her. We also thank her for all
the help and support during the entire course of the project without which our project
would not have been a success.
We are very thankful to Mr. Prasad Prabhughate, Manager – PWA,
Integrated Supply Chain of Honeywell Automation India Limited, Pune for
suggesting us this project and providing us with constant support and guidance. In
spite of his very trying work schedule, he has always given us a patient listening and
shared his ideas with us at every stage of the Project. We also thank entire team of
Honeywell Automation India for giving us an opportunity to have this wonderful
experience and for providing us with a great working environment.
We are very grateful to Prof. C.G. PATIL (Head of the Department,
Electronics) for allowing us to do this project, and for his kind co-operation and
encouragement.
We would also like to thank all the staff members and the laboratory in
charges for their timely help.
Last but not the least, we take this opportunity to thank our parents for
their relentless support, encouragement, blessings and prayers throughout the project.

Aby Kuruvilla
Mark Samuel
TABLE OF CONTENTS

CHAPTER PAGE NO

1. LITERATURE SURVEY ………………………………..1


2. INTRODUCTION ………………………………………2
ENVIRONMENTAL TESTING ………………………………….2
ENVIRONMENTAL TEST CHAMBER …………………………3
PROJECT OBJECTIVES …………………………………………4
PROJECT SPECIFICATIONS ……………………………………4
BLOCK DIAGRAM ………………………………………………5
BLOCK DIAGRAM DESCRIPTION …………………………….6
CIRCUIT SCHEMATIC
3. HARDWARE ... ……………………………………………8

COMPONENT SELECTION CRITERIA …………. ……………..8


MICROCONTROLLER AT89C52 ……………………………….12
SENSOR –LM35 (PRECISION CENTIGRADE
TEMPERATURE SENSOR)………………………………………19

8-BIT A/D AND D/A CONVERTER (PCF8591 – PHILIPS) …….21


I2C BUS …………………………………………………...25
REAL TIME CLOCK (DS12C887) ………………………………..30
SERIAL INTERFACE WITH PC ………………………………….35
RS-232 STANDARDS ……………………………………..39
MAX232 ……………………………………………………43
. RELAY DRIVER - ULN2003A – SEVEN DARLINGTON
ARRAYS …………………………………………………………45

RELAYS ………………………………………………………….47

. LCD DISPLAY – ALPHANUMERIC DOT MATRIX


MODULE…………………………………………………………49

4. POWER SUPPLY DESIGN ……………………………...51

5. PCB DESIGN ……………………………………………..55

6. SOFTWARE
FLOW CHART – MAIN PROGRAM ……………………………58
RTC TIME SET MODULE ……………………………………….59
USER INPUT PROGRAM MODULE ……………………………60
4.4. RUN PROGRAM MODULE ……………………………………..61
7. TESTING …………………………………………………..62
8. LIST OF COMPONENTS ………………………………..64
9. FUTURE SCOPE …………………………………............65
10. BIBLIOGRAPHY ………………………………………..66
11. DATA SHEETS
1. LITERATURE SURVEY
1

1. LITERATURE SURVEY

As the application of this system is thermal process control of


environmental chambers in real time, we started our literature survey by collecting
some literature on environmental testing and environmental test chambers. Some of
this information was sourced from the net and some from Honeywell.

This study gave us an insight into the system requirements and helped
us to understand the proposed specifications better. Then we shifted our focus
towards component selection. We zeroed in on certain prime criteria for the selection
of components like easy availability, upgradeability, competitive pricing without
compromising on quality, compatibility and availability of study and reference
material. For this, we went through many data sheets and did a market survey and
then finalized the components.

We zeroed in on AT89C52 microcontroller from Atmel based on the


MCS-51 family of Intel. “The 8051 Microcontroller and Embedded Systems” by
Mazidi and Mazidi and “Programming & Customizing the 8051 Microcontroller” by
Myke Predko helped us in understanding the various hardware and software concepts
related to 8051 family of microcontrollers. The “Microcontroller Design & Projects
Handbook” by Chandra Sekhar Roy enlightened us on the practical utility of
microcontrollers and interfacing with other peripherals through real life projects.

Important topics like the serial port and I2C bus were understood
through “Serial Port Complete” by Jan Axelson and “Philips Application Data”
available on-line respectively. Data Sheets and other reference materials were
sourced through the net which helped us complete the project successfully.
2. INTRODUCTION

ENVIRONMENTAL TESTING
ENVIRONMENTAL TEST CHAMBER
PROJECT OBJECTIVES
PRODUCT SPECIFICATIONS
BLOCK DIAGRAM
BLOCK DIAGRAM DESCRIPTION
CIRCUIT SCHEMATIC
2

2. INTRODUCTION

GOD’s greatest creation – MAN – is always on the look out for


making life around him easier and comfortable. As they say, “Necessity is the Mother
of Invention”; this very necessity of man has made him an inventor with only his
imagination and ideas as his driving force - be it the invention of the wheel, the steam
engine, the bulb, or all the comforts we are enjoying today. The various machines,
robots, control systems etc available today have led to speedy industrial production
and improved productivity at reduced costs.
But many a time, the nature and surroundings of man act as the biggest
road block in the functioning of these devices. While these devices work fine at the
development stage in the laboratories, adverse climatic conditions at the real work site
render them useless. This has necessitated the need for environmental testing of
devices, especially electronic devices, in an environmental test chamber which
involves simulating the environment condition which the equipment must withstand
in service. Here the systems are stressed to accelerate premature failures, in order to
remove them before delivery, thereby improving reliability of the product.
Through our Project, we intend to make a controller for such an
environmental test chamber to help duplicate adverse environmental conditions
during testing of PCBs.

2.1. Environmental Testing:

Environmental testing is done to determine the suitability of components,


equipments or other articles for use and storage under conditions of high and
low temperatures and relative humidity.
The test is primarily intended to permit the observation of the effects of high
and low temperatures and humidity over a prescribed period.
The significance of environmental testing lies in testing the reliability of the
product, especially under arduous environmental conditions.
3

Although some information is available about failure rates at elevated


temperatures, damp environments and in environments subject to vibration, it
is most unlikely that a particular combination of these different conditions can
be withstood by the equipment.
Thus when reliability is the most important concern, it requires that the
equipment be put on life test in a test chamber which as far as possible
duplicates the environmental condition which the equipment must withstand
in service. This is called environmental testing wherein systems are stressed
to accelerate premature failures in order to detect and remove them before
delivery, so as to improve the reliability and life of the end product.

2.2. Environmental Test Chamber:

Environmental testing calls for a complicated and expensive test facility with the
following provisions and precautions.
The temperature and humidity of the chamber are monitored by sensing
devices located in the work space.
The temperature and relative humidity in the work space can be maintained.
Provision for condensed water to be continuously drained out from the
chamber and not used until it has been re-purified.
Conditions prevailing throughout the work space must be kept uniform and as
similar as possible to those prevailing in the immediate vicinity of the
monitoring devices.
No condensed water from the walls or roof of the test chamber must fall on
the specimens.
The properties or loading of the specimen under test must not influence
conditions within the chamber.
4

2.3. Project Objectives

To devise an intelligent industrial thermal process control system for an


environmental test chamber that is fully programmable which controls and
maintains the temperature of the test chamber in real time.
To provide temperature control in the range 0-800C .
To provide a good user-friendly and ergonomically designed user interface.
To provide PC interface
To provide data logging of time and corresponding temperature.

2.4. Project Specifications

Temperature range  0°°C to 100°°C.


Set point difference  0.8°°C.
PC interface  Yes
Data logging  Yes
Display  16x2 LCD Display with Backlight.
Indicators  Alarm, Heater ON, Cooler ON LED.
Keypad  Tactile.
Power supply  In-built 5V.
Program Cycles  5 Fully User Programmable Cycles.
Real time control  Using DS12C887.
Output  On LCD display & on PC through RS232.
5

2.5. Block Diagram

Environmental
Chamber

Heater
Cooler

LCD Real Time


Clock
2*16 DS12C887

Temperature
Sensor
LM35

Relays
Microcontroller
89C51
Relay Driver
ADC
PCF8591 TxD ULN2003
RxD

MAX232

Keyboard To pc
Power
Supply
6

2.6. Block Diagram Description

The heart of the system is the AT89C52 Microcontroller from Atmel


which is hooked up to an A/D Converter (PCF8591) from Philips and Dallas
DS12C887 Real Time Clock (RTC).

The temperature measurement portion of this system uses a solid-state


temperature sensor IC interfaced directly to the Philips PCF8591 A/D converter
device. Here we have used National Semiconductor’s LM35 temperature IC. The
LM35 temperature sensor senses the temperature of the environmental chamber being
controlled. By using an external A/D converter, this circuit has been made, to some
extent, universal in the sense that practically any physical quantity (temperature,
humidity, etc) can be handled with this, i.e. the system can be upgraded to sense and
control more parameters according to future needs. The A/D converter PCF8591
converts the analog output from the temperature sensor (LM35) into digital format
and gives it to the microcontroller.

Through the key pad, the user can input the process starting time,
process ending time, the end temperature to be achieved and also to set the Real Time
Clock.

The Real Time Clock from Dallas DS12C887 is used as a system clock
and to control the process time.

The 16x2 LCD Display displays the welcome messages, user


programmed values and during the process, it displays the temperature of the
environmental chamber and the corresponding time.
7

The microcontroller sends the sensed temperature and corresponding


time of the environmental chamber to the PC through a MAX232 IC. MAX232
device is a dual driver/receiver that includes a capacitive voltage generator to supply
EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232
inputs to 5-V TTL/CMOS levels.

The system is programmed to take the end temperature and end time to
be achieved in the environmental chamber as inputs from the user. Accordingly, the
system senses the temperature inside the environmental chamber and depending on
the magnitude of the temperature being sensed, the microcontroller drives the relays
through a relay driver (ULN2003). The relays, in turn, control the heater and cooler
till the end temperature is achieved. The periodically sensed environmental chamber
temperature and corresponding time are flashed on to the LCD display and the PC
through the serial interface.
3. HARDWARE

COMPONENT SELECTION CRITERIA

MICROCONTROLLER AT89C52

SENSOR – LM35 (PRECISION CENTIGRADE


TEMPERATURE SENSOR)

8-BIT A/D & D/A CONVERTER – PCF8591


(PHILIPS)

REAL TIME CLOCK – DS12C887

SERIAL INTERFACE WITH PC (RS-232 STANDARDS & MAX232)

RELAY DRIVER – ULN2003A – SEVEN DARLINGTON ARRAYS

RELAYS

LCD DISPLAY – ALPHANUMERIC DOT MATRIX MODULES


8

3. HARDWARE

3.1. Component Selection Criteria

Why use external devices which are expensive and increase the size of the
product? E.g.DS12C887. Why not replace DS12C887 by software implemented
time keeping?
Inherent time-accuracy of DS12C887 RTC chip cannot be achieved with
software-time keeping approach.
DS12C887 is Y2K compatible.
Incorporation of calendar facility is rather difficult without a dedicated RTC
hardware.
DS12C887 has on-chip battery backup facility.
Availability of 114 bytes of non-volatile RAM which will prove useful for
some added features.
Also chip is widely available at a reasonable price (around Rs.150/-)

Why use LM35 as temperature sensor?

The temperature sensor portion of the system uses a solid state temperature
sensor IC from National Semiconductor interfaced directly to ADC PCF8591.
Instead of using LM35 and PCF8591 combination, other superior alternatives
include very advanced devices LM 74, LM 75, DS 1820 etc. These devices
have temperature sensor, A/D converter and associated hardware to provide
direct digital output (in serial data format).
Example, LM 74 has a temperature range of -55oC-150 oC and communicates
with the microcontroller via SPI bus. It provides 13 bit signed binary value.
The IC has a temperature sensor and a SIGMA-DELTA A/D converter and
comes in 8 pin SMT package. It works on 3.3 to 5.5 V power supply.
9
2
LM 75 is quite similar to LM 74, except for the use of I C bus. It generates 9
bit serial output and has a comparator to indicate overflow out of the
temperature boundary value.
Disadvantage with these high end sensors is that they are neither widely
available nor inexpensive.
LM 35 is a cheaper alternative.
Another reason for using LM 35 and external A/D converter (PCF 8591) is
that it makes the circuit universal in the sense that practically any physical
quantity can be handled with this.

Criteria for Choosing a Microcontroller

Chip manufacturers make 8-bit, 16-bit, 32-bit and 64-bit microcontrollers.


Some of the major 8-bit microcontrollers are Motorola’s 6811, Intel’s 8051, Zilog’s
Z8, PIC 16X from Microchip Technology. With all these microcontrollers available,
three criteria can be considered to select a microcontroller for design purpose.

The microcontroller must meet the task at hand efficiently and cost
effectively. While analysing the needs of a microcontroller based project, the
designer must first see whether an 8-bit, 16-bit, 32-bit or 64-bit microcontroller
can best handle the computing needs of the task most effectively. Some of the
considerations in this category are:
Speed : The highest speed that the microcontroller supports
The type of packaging: eg. 40 pin DIP (Dual Inline Package) or QFP (Quad
Flat Package). This is important in terms of space, assembling and
prototyping of end product.
Power consumption
Amount of on-chip ROM and RAM
Number of I/O pins and timers on chip
Easy upgradability to higher performance or lower power consumption
versions.
Cost per unit
10

The second criterion in choosing a microcontroller is how easy it is to develop


products around it. Key considerations include availability of assembler, debugger,
a code efficient C language compiler, emulator, technical support and both in-house
and outside expertise.
Ready availability of microcontroller in required quantities both now and in
the future.

Criteria for Choosing a Relay

Features to be considered when choosing a relay are:

Physical size and pin arrangement: While choosing a relay for an existing
PCB, one needs to ensure that its dimensions and pin arrangement are suitable.
This information can be found in the supplier's catalogue.
Coil voltage: The relay's coil voltage rating and resistance must suit the circuit
powering the relay coil. Many relays have a coil rated for a 12V supply but 5V
and 24V relays are also readily available. Some relays operate perfectly well
with a supply voltage which is a little lower than their rated value.
Coil resistance: The circuit must be able to supply the current required by the
relay coil. Ohm’s law can be used to calculate the current:

supply voltage
Relay coil current =
coil resistance

For example: A 12V supply relay with a coil resistance of 400 passes a
current of 30mA. This is OK for a 555 timer IC (maximum output current
200mA), but it is too much for most ICs and they will require a transistor to
amplify the current.
Switch ratings (voltage and current): The relay's switch contacts must be
suitable for the circuit they are to control. The voltage and current ratings need
to be checked. Note that the voltage rating is usually higher for AC, for
example: "5A at 24V DC or 125V AC".
11

Switch contact arrangement (SPDT, DPDT etc): Most relays are SPDT
(Single Pole, Double Throw - This switch can be on in both positions,
switching on a separate device in each case. It is often called a changeover
switch) or DPDT (Double Pole, Double Throw - A pair of on-on switches
which operate together) which are often described as "Single Pole
Changeover" (SPCO) or "Double Pole Changeover" (DPCO).

Relays and transistors compared

Like relays, transistors can be used as an electrically operated switch. For


switching small DC currents (< 1A) at low voltage they are usually a better choice
than a relay. However transistors cannot switch AC or high voltages (such as
mains electricity) and they are not usually a good choice for switching large
currents (> 5A). In these cases a relay will be needed, but note that a low power
transistor may still be needed to switch the current for the relay's coil! The main
advantages and disadvantages of relays are listed below:

Advantages of relays:

Relays can switch AC and DC, transistors can only switch DC.
Relays can switch high voltages, transistors cannot.
Relays are a better choice for switching large currents (> 5A).
Relays can switch many contacts at once.

Disadvantages of relays:

Relays are bulkier than transistors for switching small currents.


Relays cannot switch rapidly (except reed relays), transistors can switch
many times per second.
Relays use more power due to the current flowing through their coil.
Relays require more current than many chips can provide, so a low power
transistor may be needed to switch the current for the relay's coil.
12

Purpose of using LCD modules:

Very low current required (in mA) for driving LCD. Maximum 15mA
required.
Numeric values and alphabets can be easily displayed, and also some graphics
can be displayed.
Interfacing to microcontroller is easy.
LED displays require more current.

3.2. Microcontroller AT89C52

Features:

 Compatible with MCS-51TM Products


 8K Bytes of In-System Reprogrammable Flash Memory.
Endurance: 1000 Write/Erase cycles
 Fully Static Operation: 0 Hz to 24MHz
 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.
13

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 Atmel’s high density
nonvolatile memory technology and is compatible with the industry standard 80C51
and 80C52 instruction set and pin out. The on-chip flash allows the program memory
to be reprogrammed in-system or by a conventional nonvolatile memory programmer.
By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel
AT89C52 is a powerful microcomputer which provides a highly flexible and cost
effective solution to many embedded control applications.
Pin Configuration:

PDIP
14

PIN DESCRIPTION :

VCC : Supply voltage. (Pin 40)

GND : Ground. (Pin 20)

Port 0 : Port 0 is an 8-bit open-drain bi-directional I/O port. Port 0 occupies a total of
8 pins (pins 32 – 39). It can be used for input or output. To use the pins of Port 0 (P 0)
as both input and output ports, each pin must be connected externally to a 10K ohm
pull-up resistor. This is due to the fact that P0 is an open drain, unlike P1, P2, P3.
Open drain is a term used for MOS chips in the same way that open collector is used
for TTL chips.

Port 0 may 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 pull-ups.

Port 0 also receives the code bytes during Flash programming, and
outputs the code bytes during program verification. External pull-ups are required
during program verification.

Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups and occupies
pins 1 through 8. 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 pull-ups and can be used as
inputs. Upon reset Port 1 is configured as output port. Port 1 also receives the low-
order address bytes during Flash programming and verification.

In addition, P 1.0 and P 1.1 can be configured to be the timer/counter 2


external count input (P 1.0/T2) and the timer/counter 2 trigger input (P 1.1/T2EX).
15

Port 2: Port 2 is an 8 bit bidirectional I/O port with internal pull-ups and occupies
pins 21 through 28. 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 pull-ups and can be used
as inputs. Upon reset Port 2 is configured as output port. Port 2 emits the high-order
address byte during fetches from external program memory and during accesses to
external data memory that use 16 bit addresses. In this application it uses strong
internal pull-ups when emitting 1s. During accesses to external data memory that use
8 bit addresses, 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 pull-ups and occupies
pins 10 through 17. 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 pull-ups and can be used
as inputs. Although Port 3 is configured as an output port upon reset, this is not the
way it is most commonly used. Port 3 has the additional function of providing some
extremely important signals of the AT89C51 as listed below.

P3.0 RXD Serial Input Port


P3.1 TXD Serial Output Port
P3.2 INTO External Interrupt 0
P3.3 INT1 External Interrupt 1
P3.4 T0 Timer 0 External Input
P3.5 T1 Timer 1 External Input
P3.6 WR External Data Memory Write Strobe
P3.7 RD External Data Memory Read Strobe
16

RST: RST pin 9 is the reset pin. It is an input and is active high (normally low). Upon
applying a high pulse to this pin, the microcontroller will reset and terminate all
activities. This is often referred to as a power-on reset. Activating a power-on reset
will cause all values in the registers to be lost. In order for the reset input to be
effective, it must have a minimum duration of two machine cycles. In other words the
high pulse must be high for a minimum of two machine cycles before it is allowed to
go low. A machine cycle is defined as 12 oscillator periods.

ALE/PROG: The ALE or the Address Latch Enable (Pin 30) is an output pulse and is
active high. It is used for latching the address during accesses to external memory.
This pin is also the program pulse input (PROG) during flash programming. The
ALE pin is used for demultiplexing the address and data bus.

In normal operation, ALE is emitted at a constant rate of 1/6th the


oscillator frequency, and may be used for external timing or clocking purpose.
However, 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 disabled bit has no effect if the
microcontroller is in external execution mode.

PSEN: The PSEN or Program Store Enable (Pin 29) is an output pin. It is the read
strobe to external program memory. When the AT89C52 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: The EA or External Access Enable (Pin 31) must be strapped to GND in
order to enable the device to fetch code from external program memory locations
starting at 0000H to FFFFH. If lock bit 1 is programmed, EA will be internally
latched on reset.
17

EA must be strapped to VCC for internal program executions. This


pin also receives 12V programming enable voltage (VPP) during Flash programming.

XTAL1: XTAL1 (Pin 19) acts as input to inverting oscillator amplifier and internal
clock operating circuit.

XTAL2: XTAL2 (Pin 18) acts as output from the inverting oscillator amplifier.

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 below.
Most often a quartz crystal or ceramic resonator may be used. The quartz crystal is
connected to inputs XTAL1 (Pin 19) and XTAL2 (Pin 18). The quartz crystal
oscillator connected to XTAL1 and XTAL2 also needs two capacitors of 30pF value.
If ceramic resonators are connected between XTAL1 and XTAL2, two 40pF
capacitors are used. One side of each capacitor is connected to the ground.
Figure

To drive the device from an external clock source, XTAL2 should be


left unconnected while XTAL1 is driven as shown in Figure below. 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.
18
Figure:

Idle Mode
In idle mode, the CPU puts itself to sleep while all on-chip peripherals remain active.
The mode is invoked by software. The content of on-chip RAM and all special
function registers remain unchanged during this mode. The idle mode can be
terminated by enabling an interrupt or by a hardware reset.

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.

Program Memory Lock Bits


On the chip are three lock bits which can be left unprogrammed (U) or can be
programmed (P) to obtain the additional features listed in the Table below.
19
Lock Bit Protection Modes:
Program Lock Bits
LB1 LB2 LB3 Protection Type
1 U U U No program lock features
MOVC instructions executed from external
program memory are disabled from fetching code
2 P U U
bytes from internal memory. EA is sampled and
latched on reset and further programming of the
Flash is disabled.
3 P P U Same as mode 2, also verify is disabled.
4 P P P Same as mode 3, also external execution is
disabled.

3.3. Sensor - LM35 (Precision Centigrade Temperature Sensor):

Features:
Calibrated directly in Celsius (Centigrade)
Linear + 10.0mV/°C scale factor
0.5°C accuracy guaranteeable (+25 °C)
Rated for full -55 °C to +150 °C range
Suitable for remote applications
Low cost due to wafer level trimming
Operates from 4 to 30 volts
Less than 60µA current drain
Low self-heating, 0.08°C in still air
Non-linearity only ±¼°C typical
Low impedance output, 0.1 Ω or 1 mA load
20

Vout

Vcc GND

LM 35 (National Semiconductor) Bottom View

Description:
The LM35 series are precision integrated-circuit temperature sensors,
manufactured by National Semiconductor, whose output voltage is linearly
proportional to the Celsius (Centigrade) temperature. The LM35 thus has an
advantage over linear temperature sensors calibrated in ° Kelvin as the user is not
required to subtract a large constant voltage from its output to obtain convenient
centigrade scaling.

It is fabricated as three-terminal transistor package and is designed to


provide 1mV output for each °C above 0. For LM35 sensor, the variation of output
voltage with temperature is very linear (unlike thermistors or diodes). This means for,
say, 25°C the output voltage will be 250 mV and 50°C it will be 500 mV and so on, in
linear step for the entire range. This IC is available in two varieties LM35CZ and
LM35DZ. The LM35CZ has a temperature range of -40°C to 110°C and the LM35DZ
has a working temperature range of 0°C to 100°C.
21

3.4. 8-Bit A/D and D/A Converter - PCF8591 (Philips)

Features:

Single power supply.

Operating supply voltage 2.5volt to 6 volt.

Low stand by current.

Serial input/ output via I2C bus.

Addresses by three hardware address pins.

Sampling rate given by I2C bus speed.

Four analog inputs programmable as single-ended or differential


inputs.

Auto-incremented channel selection.

Analog voltage range from VSS to VDD.

On-chip track and hold circuit.

8-bit successive approximation A/D conversion.

Multiplying DAC with one analog output.

General Description:

The PCF8591 is a single-chip, single-supply low power 8 bit CMOS data


acquisition device with four analog inputs, one analog output and a serial I2C-bus
interface. Three address pins A0, A1, A2 are used for programming the hardware
address, allowing the use of up to eight devices connected to the I2C bus without
additional hardware. Address, control and data to and from the device are transferred
serially via the two-line bi-directional I2C bus. The function of device includes analog
input multiplexing, 8-bit analog-to-digital conversion and 8-bit digital-to-analog
conversion. The maximum conversion rate is given the maximum speed of the I2C
bus.
22

Pin Description

SYMBOL PIN DESCRIPTION


AINO 1
AIN1 2 Analog inputs
AIN2 3 (A/D converter)
AIN3 4
A0 5
A1 6 Hardware address
A2 7
VSS 8 Negative supply voltage
SDA 9 I2C-bus data input/output
SCL 10 I2C-bus clock input
OSC 11 Oscillator input/output
EXT 12 External/internal switch for oscillator input
AGND 13 Analog ground
VREF 14 Voltage reference input
AOUT 15 Analog output (D/A converter)
VDD 16 Positive supply voltage
23

Functional Description:

MSB LSB

1 0 0 1 A2 A1 A0 R/W

fixed part programmable part

Fig. Address Byte

Addressing:

Each PCF-8591 device in an I2C bus system is activated by sending a valid address to
the device. The address consist of a fixed part and a programmable part. The address
always has to be sent as the first byte after the start condition in the I2C bus protocol.
The last bit of the address byte is the read/write-bit which sets the direction of the
following data transfer.

Control Byte:

The second byte sent to a PCF 8591 device will be stored in its control register and is
required to control the device function.

MSB LSB

0 x x x 0 x x x

7 6 5 4 3 2 1 0

A/D CHANNEL NUMBER

AUTOINCREMENT FLAG

ANALOG INPUT PROGRAMMING

ANALOG OUTPUT ENABLE FLAG


24

A/D Channel No.

00  Channel 0
01  Channel 1
10  Channel 2
11  Channel 3

Autoincrement Flag: Switched on if 1

Analog Input Programming:

00  For single ended inputs


01  Three differential inputs
10  Single ended and differential mixed
11  Two differential inputs

Analog Output Enable Flag: Analog output active if 1

D/A Conversion:

The third byte sent to the PCF 8591 is stored in the DAC data register
and is converted to the corresponding analog voltage using the on-chip D/A converter
which consists of a resistor divider chain connected to an external reference voltage
with 256 taps and selection switches. The analog output voltage is buffered by an
auto-zeroed unity gain amplifier.

The on-chip D/A converter is also used for successive approximation


A/D conversion. A track and hold circuit in the unity gain amplifier holds the output
voltage during A/D conversion.

A/D Conversion:
The A/D converter makes use of successive approximation technique. The on-chip
D/A converter and a high gain comparator are used temporarily during an A/D
conversion cycle. An A/D conversion cycle is started after sending a valid read mode
address to a PCF 8591 device. A/D conversion cycle is triggered at the trailing edge
of the acknowledged clock pulse. The conversion result is stored in the ADC data
register and awaits transmission.
25

Reference Voltage:
For the D/A and A/D conversion, either a stable external voltage
reference or the supply voltage has to be applied to the register divider chain (pins
VREF and AGND). The AGND pin has to be connected to the system analog ground.
The D/A converter can be used as one quadrant multiplier by applying a low
frequency to VREF and AGND. The A/D converter may be used as a one or two
quadrant analog divider by dividing the analog input voltage by the reference voltage.

Oscillator:
An on-chip oscillator generates the clock signal required for the A/D
conversion cycle and for refreshing the auto-zeroed buffer amplifier. When using the
oscillator, EXT pin must be connected to VSS. At the OSC pin, the oscillator
frequency is available. To feed an external clock signal to OSC, the EXT pin must be
connected to VDD.

3.4.1. I2C Bus:

The I2C bus was developed in the early 1980’s by Philips


Semiconductors. Its original purpose was to provide an easy way to connect a CPU to
peripheral chips in a TV set. Peripheral devices in embedded systems are often
connected to the MCU as memory mapped I/O devices using the microcontrollers,
parallel address and data bus. This resulted in a lot of wiring on the PCB to route the
address and data lines to connect everything. This was not acceptable in mass
production items because lots of control lines implied that the system was more
susceptible to disturbances by Electromagnetic Interference (EMI) and Electrostatic
Discharge (ESD). Also increased components meant reduced profitability and
costlier products for the end customer. To overcome these problems and to maximize
hardware efficiency and simplify circuit design, Philips developed a simple bi-
directional two-wire communication bus for inter-IC control called I2C bus. This is
the acronym for Inter-IC bus.
26

Features of I2C bus:


Only two bus lines are required; a Serial Data Line(SDA), and a Serial Clock
Line(SCL).
Each device connected to the bus is software addressable by a unique address
and simple master/slave relationship exits at all times; masters can operate as
master transmitters or as master receivers.
It’s a true multi-master bus including collision detection and arbitration to
prevent data corruption if two or more masters simultaneously initiate data
transfer.
Serial 8-bit oriented, bi-directional data transfers can be made up to 100
Kbits/s in a standard mode up to 400 Kbits/s in fast mode up to 3.4Mbits/s in
high speed mode.
On-chip filtering rejects spikes on the data bus line to preserve data integrity.
The number of ICs that can be connected to the same bus is limited only by a
maximum bus capacitance of 400 pF.

Designer Benefits:
I2C bus compatible ICs allow system design to rapidly progress from a
functional block diagram to a prototype. Since they clip directly onto the I2C bus
without any additional external interfacing, they allow easy upgradation and
modification of the prototype.

Here are some of the features of I2C bus compatible ICs particularly useful for
designers.
Functional blocks on the block diagram correspond with actual ICs; designs
proceed rapidly from block diagram to final schematic.
No need to design bus interfaces because the I2C bus interface is already
integrated on-chip.
Integrated addressing and data transfer protocol allow systems to be
completely software defined.
27

The same IC type can be used in many different applications.


Design time reduces as designers quickly become familiar with the frequently
used fundamental blocks represented by I2C bus compatible ICs.
ICs can be added to or removed from a system without affecting any other
circuits on the bus.
Fault diagnosis and debugging are simple; malfunctions can be immediately
traced.
Software development time can be reduced by assembling a library of reusable
software modules.
In addition to these, CMOS ICs in the I2C bus compatible range offer designers
special features which are particularly attractive for portable equipment and battery
backed systems.
They all have:
Extremely low current consumption
High noise immunity
Wide supply voltage range
Wide operating temperature range

Manufacturer Benefits:
I2C bus compatible ICs provide a wide range of benefits to manufacturers also. They
are:
The simple 2-wire serial I2C bus minimizes inter-connections, so ICs have
fewer pins thus reducing the number of PCB tracks resulting in smaller and
less expensive PCBs.
The completely integrated I2C bus protocol eliminates the need for address
decoders and other ‘glue logic’.
The multi-master capability of the I2C bus allows rapid testing and alignment
of end-user equipment via external connections to the assembly line.
The availability of I2C bus compatible ICs in SO (Small Outline), VSO (Very
Small Outline) as well as DIL packages reduces space requirement even more.
28

In addition to this, I2C bus compatible ICs increase system design flexibility
by allowing simple construction of equipment variants and easy
upgradeability.

I2C bus Concept:


The I2C bus supports any IC fabrication process (NMOS, CMOS,
Bipolar). Two wires, serial data (SDA) and serial clock (SCL), carry information
between the devices connected to the bus. Each device is recognized by a unique
address (whether it is a microcontroller, LCD driver, memory or key board interface)
and can operate as either a transmitter or receiver, depending on the function of the
device. Obliviously an LCD driver is only a receiver, whereas a memory can both
receive and transmit data. In addition to transmitters and receivers, devices can also
be considered as masters or slaves when performing data transfers.

Definition of I2C bus terminology:

TERM DESCRIPTION

TRANSMITTER The device which sends the data to the bus

RECEIVER The device which receives data from the bus

MASTER The device which initiates a transfer, generates clock signals


and terminates a transfer

SLAVE The device addressed by a master

MULTI MASTER More than one master can attempt to control the bus at the
same time without corrupting the message.

ARRBITRATION Procedure to ensure that if more than one master


simultaneously tries to control the bus. Only one is allowed
to do so and the winning message is not corrupted

SYNCRONIZATION Procedure to synchronize the clock signals of two or more


devices
29

I2C Data Transfer Formats:

Master transmits to slave receiver. The transfer direction is not changed

S SLAVE R/W A DATA A DATA A/A P


ADDRESS

‘0’(WRITE) DATA TRANSFERRED

A MASTER TRANSMITTER ADDRESSING A SLAVE RECEIVER WITH A 7-BIT ADDRRESS

Master reads slave immediately after first byte. At the moment of the first
acknowledge, the master-transmitter becomes master-receiver and slave-
receiver becomes a slave-transmitter. This first acknowledge is still generated
by the slave. The stop condition is generated by the master, which has
previously sent a not-acknowledge.

S SLAVE R/W A DATA A DATA A P


ADDRESS

‘1’(READ) DATA TRANSFERRED

A MASTER READS A SLAVE IMMEDIATELY AFTER FIRST BYTE

NOTE

FROM MASTER TO SLAVE

FROM SLAVE TO MASTER

A = ACKNOWLEDGE (SDA LOW)

A = NOT ACKNOWLEDGE (SDA HIGH)


S = START CONDITION
P = STOP CONDITION
30

3.5. Real Time Clock – DS12C887

Features:

Drop-in replacement for IBM AT computer clock/calendar.


Pin-compatible with MC146818B and DS 1287
Totally nonvolatile with over 10 years of operation in the absence of power.
Self-contained subsystem includes lithium, quartz and support circuitry.
Counts seconds, minutes, hours, days, day of the week, date, month and year
with leap year compensation valid up to 2100.
Binary or BCD representation of time, calendar and alarm.
12-hour or 24-hour clock with AM and PM in 12-hour mode.
Daylight Savings Time option.
Selectable between Motorola and Intel bus timing.
Multiplex bus for pin efficiency
Interfaced with software as 128 RAM locations
- 15 bytes of clock ad control registers
- 113 bytes of general-purpose RAM
Programmable square-wave output signal
Bus-compatible interrupt signals (IRQ)
Three interrupts are separately software-maskable and testable
- Time-of-day alarm once/second to once/day
- Periodic rates from 122ms to 500 ms
- End-of-clock update cycle
Century register

Description:

The DS12C887 Real Time Clock plus RAM is designed as a direct


upgrade replacement for the DS12887 in existing IBM compatible personal computers
to add hardware year 2000 compliance. A century byte was added to memory
location 50, 32H as called out by PC AT specification. A lithium energy source,
quartz crystal and write protection circuitry are contained within a 24-pin dual in-line
31

package. As such, the DS12C887 is a complete sub-system replacing 16 components


in a typical application. The functions include a non-volatile time-of-day clock, an
alarm, a one-hundred-year calendar, programmable interrupt, square wave generator,
and 113 bytes of nonvolatile static RAM. The real time clock is distinctive in that
time-of-day and memory are maintained even in the absence of power.

Pin Description:
32

Operation:

The block diagram below shows the pin connection and major internal functions of
DS12C887. The following paragraphs describe the functions of each pin.

Power-down/Power-up considerations: The Real Time Clock function will continue


to operate and all of the RAM, time, calendar, and alarm memory locations remain
non-volatile regardless of the level of Vcc input. When Vcc is applied to the
DS12C887 and reaches a level of greater than 4.25V, the device becomes accessible
after 200 ms, provided that oscillator is running and the oscillator countdown chain is
not in reset. This time period allows the system to stabilize after power is applied.
33

When Vcc falls below 4.25V, the chip select input is internally forced to an inactive
level regardless of the value of CS at the input pin. The DS12C887 is therefore write-
protected. When the DS12C887 is in write-protected state, all the inputs are ignored
and all outputs are in high impedance state. When Vcc falls below 3V, the external
Vcc supply is switched off and an internal lithium energy source supplies power to the
Real Time Clock and the RAM memory.

Signal Descriptions:

GND, Vcc  DC power is provided to the device on these pins. Vcc is the
+5V input. When 5V is applied within normal limits, the device is fully
accessible and data can be written and read. When Vcc is below 4.25V, reads
and writes are inhibited. However, the time keeping function continues
unaffected by the low input voltage. When Vcc falls below 3V, the RAM and
time keeper are switched over to the internal lithium energy source. The time
keeping function has an accuracy of ±1 minute per month at 250C regardless
of the input voltage on Vcc pin.
MOT (Mode Select)  The MOT pin offers the flexibility to choose
between two bus types. When connected to Vcc, Motorola bus timing is
selected. When connected to ground or left disconnected, Intel bus timing is
selected. The pin has internal pull-down resistance of approximately 20KΩ.
SQW (Square Wave Output)  The SQW pin can output a signal from one
of the 13 taps provided by the 15 internal divider stages of the Real Time
Clock. Frequency of the SQW pin can be changed by programming Register
A. The SQW signal can be turned on and off using SQWE bit in Register B.
The SQW signal is not available when Vcc is less than 4.25V.
AD0-AD7 (Multiplexed Bidirectional Address/Data Bus)  Multiplexed
buses save pins because address information and data information time share
the same signal paths. Address/data multiplexing does not slow access time
of the DS12C887 since the bus change from address to data occurs during the
internal RAM access time.
34

AS (Address Strobe Input)  A positive going address strobe pulse serves


to demultiplex the bus. The falling edge of AS/ALE causes the address to be
latched within the DS12C887. The next rising edge that occurs on the AS bus
will clear the address regardless of whether CS is asserted.

DS (Data Strobe or Read Input)  The DS/RD pin has two modes of
operation depending on the level of the MOT pin. When MOT is connected
to Vcc (i.e. Motorola bus timing selected), DS is a positive pulse during the
latter portion of the bus cycle and is called data strobe. During read cycles,
DS signifies the time that the DS12C887 is to drive the bidirectional bus. In
write cycles, the trailing edge of DS causes the DS12C887 to latch the written
data. When MOT pin is connected to GND (i.e. Intel bus timing selected), DS
pin is called Read (RD). RD identifies the time period when the DS12C887
drives the bus with red data.

R/W (Read/Write Input)  The R/W pin has two modes of operation.
When MOT pin is connected to Vcc (Motorola timing), R/W indicates
whether the current cycle is a read or write. A read cycle is indicated by a
high level on R/W while DS is high. Write cycle is indicated when R/W is
low during DS. When the MOT pin is connected to GND (Intel timing), the
R/W signal is an active low signal called WR, i.e. a write enable signal.

CS (Chip Select Input)  The chip select signal must be asserted low for a
bus cycle in DS12C887 to be accessed. CS must be kept in active state during
DS and AS for Motorola timing and during RD and WR for Intel timing. Bus
cycles which take place without asserting CS will latch addresses but no
access will occur. When Vcc falls below 4.25V, the DS12C887 internally
inhibits access cycles by internally disabling the CS input to protect the Real
Time Clock data and RAM data during power outages.
35

IRQ (Interrupt Request Output)  The IRQ pin is an active low output of
the DS12C887 that can be used as an interrupt input to a processor. The IRQ
output remains low as long as the status bit causing the interrupt is present and
the corresponding interrupt enable bit is set. To clear the IRQ pin, the
processor program normally clears the C Register. Multiple interrupting
devices can be connected to an IRQ bus. The IRQ bus is an open drain output
and requires an external pull-up resistor.
RESET (Reset Input)  The reset pin has no effect on the clock, calendar
or RAM. On power-up, the reset pin can be held low for a time, to allow the
power supply to stabilize depending on the application. If reset is used on
power-up, the time for which reset is low should not exceed 200 ms. When
reset is low and Vcc is above 4.25V, the Periodic Interrupt Enable (PEI),
Alarm Interrupt Enable (AIE), Update Ended Interrupt Flag (UF), Interrupt
Request Status Flag (IRQF), Periodic Interrupt Flag (PF), Alarm Interrupt
Flag (AF), Square Wave Output Enable (SQWE), Update Ended Interrupt
Enable (UIE) bits are cleared to zero. IRQ pin is in high impedance state.
The device is not accessible until reset is returned high. In a typical
application, reset can be connected to Vcc allowing the DS12C887 to go in
and out of power fail without affecting any of the control registers.

3.6. Serial Interface with PC

Introduction: Computers transfer data in two ways: parallel and serial. In parallel
data transfers, often 8 or more lines (wire conductors) are used to transfer data to a
device that is only a few feet away, example printers, hard disks, etc. Although in
such cases a lot of data can be transferred in a short amount of time by using many
wires in parallel, the distance cannot be great. To transfer to a device located many
meters away, the serial method is used. In serial communication, the data is sent one
bit at a time in contrast to parallel communication, in which the data is sent a byte or
more at a time. As the AT89C52 has built-in serial communication capability, it is
possible for fast data transfer using only a few wires.
36

Serial Transfer Parallel Transfer

D0

Sender Receiver
Sender Receiver

D7

Serial Communication Basics:

An 8-bit data path is expensive. For this reason, serial communication


is used for transferring data between two systems located at far away distances. In
serial communication a single data line is used instead of the 8-bit data line of parallel
communication which makes it much cheaper. For serial data communication to
work, the byte of data must be converted to serial bits using a parallel-in-serial-out
shift register; then it can be transmitted over a single data line. At the receiving end,
there must be a serial-in-parallel-out shift register to receive the serial data and pack
them into a byte.

Serial data communication uses two methods - asynchronous and


synchronous. The synchronous method transfers a block of data (characters) at a time
while the asynchronous transfers a single byte at a time. Several special IC chips
have been made by many manufacturers for serial data communications which are
commonly referred to as UART (Universal Asynchronous Receiver-Transmitter) and
USART (Universal Synchronous-Asynchronous Receiver-Transmitter). Example, the
8051 has a built-in UART.
37

In data transmission, if the data can be transmitted and received, it is


called as duplex transmission. This is in contrast with simplex transmissions where
only the transmitter can transmit. If data is transmitted one way at a time, it is
referred to as half duplex. If can data can go both ways at the same time, it is full
duplex (requires two wire conductors, one for transmission and one for reception, in
addition to signal ground).

Synchronous Data Transfer Format: In synchronous transmission, all devices use a


common clock generated by one of the devices or an external source. The clock may
have a fixed frequency or it may toggle at irregular intervals. All transmitted bits are
synchronized to the clock, i.e. each transmitted bit valid at a defined time after a clock
transition (rising or falling edge). The receiver uses the clock transitions to decide
when to read each incoming bit. Synchronous formats use a variety of ways to signal
the start and end of transmission, including start and stop bits and dedicated chips
select signals. Synchronous interfaces are useful for short links with cables of 15 feet
or less or even between components on a single circuit board. For longer links,
synchronous links are less practical because of the need to transmit the clock signal,
which requires an extra line and is subject to noise.
38

Asynchronous Data Transfer Format: In asynchronous transmissions, the link does


not include a clock line, because each end of the link provides its own clock. Each
end must agree on the clock’s frequency, and all the clocks must match within a few
percent. Each transmitted byte includes a start bit to synchronize the clocks and one
or more stop bits to signal the end of the transmitted word. The RS-232 ports on PCs
use asynchronous formats to communicate with modems and other devices. Although
an RS-232 interface can also transfer synchronous data, asynchronous links are much
more common.

Data Transfer Rate: The rate of data transfer in serial data communication is stated
in bps (bits per second). Another widely used terminology for bps is baud rate.
However, baud and bps rates need not be equal because baud rate is defined as the
number of signal changes per second and there might be occasions when a single
change of signal transfers several bits of data, e.g. modems. As far as conductor wires
are concerned, baud rate and bps are the same. In asynchronous serial data
communication, the baud rate is generally limited to 100,000 bps.

Data Communication Classification: Current terminology classifies


communication equipment as DTE (Data Terminal Equipment) or DCE (Data
Communication Equipment). DTE refers to terminals and computers that send a
receive data while DCE refers to communication equipment, such as modems, that are
responsible for transferring the data.

Note: The simplest connection between a PC and microcontroller requires a


minimum of 3 pins, TxD, RxD and ground.
39

3.6.1. RS-232 Standards:

To allow compatibility among data communication equipment, made


by various manufacturers, an interfacing standard called RS-232 was set up by the
Electronic Industries Association (EIA) in 1960. In 1963 it was modified and called
RS-232A. RS-232B and RS-232C were issued in 1965 and 1969 respectively.
Hereafter, in this report we will refer it as RS-232 only. RS-232 is today the most
widely used serial I/O interfacing standard used in PCs and numerous types of
equipments. However, since the standard was set long before, the advent of TTL
logic family, its input and output voltage levels are not TTL compatible. In RS-232, a
1 is represented by -3 to -25V, while a 0 bit is +3 to +25V, making -3 to +3
undefined. For this reason, to connect any RS-232 to a microcontroller system, we
must use voltage converters such as MAX232 to convert the TTL logic levels to the
RS-232 voltage level, and vice versa. MAX232 IC chips are commonly referred to as
line drivers.

RS-232 Pins:

The table below provides the pins and labels for the RS-232 cable,
commonly referred to as the DB-25 connector. In labelling, DB-25P refers to the plug
connector (male) and DB-25S is for the socket connector (female).
40

RS232 on DB25 (RS-232C)

Pin Name Notes/Description Pin Name Notes/Description


No. No.
Protective/shielded Secondary Transmit
1 - 14 STD
ground Data
Transmit Data Transmit Clock (a.k.a.
2 TD 15 DB
(a.k.a. TxD, Tx) TCLK, TxCLK)
Receive Data Secondary Receive
3 RD 16 SRD
(a.k.a. RxD, Rx) Data
Receive Clock (a.k.a.
4 RTS Request To Send 17 DD
RCLK)
5 CTS Clear To Send 18 LL Local Loopback
Secondary Request to
6 DSR Data Set Ready 19 SRTS
Send
7 SGND Signal Ground 20 DTR Data Terminal Ready
Signal Quality
Carrier Detect
8 CD 21 RL/SQ Detector/Remote
(a.k.a. DCD)
loopback
Ring Indicator (DCE
raises when incoming
Reserved for data
9 - 22 RI call detected used for
set testing
auto answer
applications)
Reserved for data
10 - 23 CH/CI Signal Rate selector
set testing
Auxiliary Clock (a.k.a.
11 - Unassigned 24 DA
ACLK)
Secondary Carrier
12 SDCD 25 - Unassigned
Detect
Secondary Clear to
13 SCTS - - -
send

NOTE: Leave all pins not specified above unconnected.


41

View - looking into male connector

Since not all the pins are used in PC cables, IBM introduced the DB-9 version of the
serial I/O standard, which uses 9 pins only as shown in table below. The DB-9 pins
are as shown in figure below.

RS232 on DB9 (EIA/TIA 574)

Pin Name Notes/Description


No.
1 DCD Data Carrier Detect
2 RD Receive Data (a.k.a RxD, Rx)
3 TD Transmit Data (a.k.a TxD, Tx)
4 DTR Data Terminal Ready
5 SGND Ground
6 DSR Data Set Ready
7 RTS Request To Send
8 CTS Clear To Send
9 RI Ring Indicator
42

View - looking into male connector

RS-232 Handshaking signals:

To ensure fast and reliable data transmission between two devices, the
data transfer must be coordinated. Many of the pins of RS-232 connector are used
for handshaking signals. Their description is provided below.
Note: These are not supported by the 8051 UART chip.

DTR (Data Terminal Ready): When the terminal (or PC COM port) is
turned on, after going through a self-test, it sends out signal DTR to indicate
that it is ready for communication. This is an active-low signal. This signal
will not be activated if there is something wrong with the COM port.
DSR (Data Set Ready): When the DCE is turned on and has gone through
the self-test, it asserts DSR to indicate that it is ready to communicate. Thus it
can be an output from the modem (DCE) and input to the PC (DTE). This is
an active-low signal. If the modem cannot make a connection to the
telephone, this signal remains inactive.
RTS (Request To Send): When the DTE device has a byte to transmit, it
asserts RTS to signal the modem that it has a byte of data to transmit. RTS is
an active-low output from the DTE and input to the DCE.
CTS (Clear To Send): In response to the RTS, the DCE has room for storing
the data it is to receive, it sends out signal CTS to the DTE to indicate that it
can receive the data now so that the DTE can start transmission.
43

DCD (Data Carrier Detect): The modem asserts signal DCD to inform the
DTE that a valid carrier has been detected and that contact between it and the
modem is established. DCD is an output from the modem and an input to the
PC.
RI (Ring Indicator): An output from the modem (DCE) and an input to a PC
(DTE) indicate that the telephone is ringing. It goes on and off in
synchronization with the ringing sound. It is least used handshaking signal as
modems take care of answering the phone. It is used if the PC is in charge of
an answering the phone in a given system.

3.6.2. MAX 232

Introduction:

Since the RS-232 is not compatible with today’s microprocessors and


microcontrollers, we need a line driver (voltage converter) to convert the RS-232’s
signals to TTL voltage levels that will be acceptable to the 8051’s TxD and RxD
pins. The MAX232 converts from RS-232 voltage levels to TTL voltage levels and
vice versa. One advantage of the MAX232 chip is that it uses a +5V power supply
which is the same as the source voltage for the 8051.

Description:

The MAX232 device is a dual driver/receiver that includes a capacitive


voltage generator to supply EIA-232 voltage levels from a single 5-V supply. Each
receiver converts EIA-232 inputs to 5-V TTL/CMOS levels. These receivers have a
typical threshold of 1.3V and a typical hysteresis of 0.5V, and can accept ± 30V
inputs. Each driver converts TTL/CMOS input levels into EIA-232 levels. The
driver, receiver and voltage-generator functions are available as cells in Texas
Instruments LinASICTM Library.
44

The MAX232 is characterized for operation from 00C -700C. The


MAX232I is characterized for operation from -400C to 850C.

Features:

Operates with single 5-V power supply.


LinBiCMOSTM Process Technology
Two drivers and two receivers
± 30V input levels
Low supply current …. 8 mA typical
Meets or exceeds TIA/EIA-232-F and ITU Recommendation V.28
Designed to be interchangeable with Maxim MAX232.
Applications :
TIA/EIA-232-F
Battery-Powered Systems
Terminals
Modems
Computers
45

PIN Configuration:

3.7. Relay Driver - ULN2003A – Seven Darlington Arrays

Features:

Seven darlingtons per package


Output current 500 mA per driver (600 mA peak)
Output voltage – 50V
Integrated suppression diodes for inductive loads
Outputs can be parallel for higher current
TTL/CMOS/PMOS/DTL compatible inputs
Inputs pinned opposite outputs to simplify layout.
46

PIN Connection:

Description:

The ULN2003A is a high-voltage, high-current darlington array, each


containing seven open collector darlington pair with common emitters. Each channel
is rated at 500 mA and can withstand peak currents of 600 mA. Suppression diodes
are included for inductive load driving and the inputs are pinned opposite the outputs
to simplify board layout. It interfaces to all common logic families.

ULN2003A 5V TTL, CMOS

This versatile device is useful for driving a wide range of loads


including solenoids, relays, DC motors, LED displays, filament lamps, thermal print
heads and high power buffers.

Because of darlington pair, input impedance is very high, so for


driving the gate, very low current is required and so it does not load the
microcontroller.
47

ULN2003A is supplied in 16 pin plastic DIP packages with a copper


lead frame to reduce thermal resistance. It is also available in small outline package
as ULN2003D.

3.8. Relays

Relays

A relay is an electrically operated switch. Current flowing through the coil of the
relay creates a magnetic field which attracts a lever and changes the switch contacts.
The coil current can be on or off so relays have two switch positions and they are
double throw (changeover) switches.

Relays allow one circuit to switch a second circuit which can be completely separate
from the first. For example a low voltage battery circuit can use a relay to switch a
230V AC mains circuit. There is no electrical connection inside the relay between the
two circuits, the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for
a 12V relay, but it can be as much as 100mA for relays designed to operate from
lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually
used to amplify the small IC current to the larger value required for the relay coil. The
maximum output current for the popular 555 timer IC is 200mA so these devices can
supply relay coils directly without amplification.
48

Most relays are designed for PCB mounting but you can solder wires directly to the
pins, provided you take care to avoid melting the plastic case of the relay.

The supplier's catalogue should show you the relay's connections. The coil will be
obvious and it may be connected either way round. Relay coils produce brief high
voltage 'spikes' when they are switched off and this can destroy transistors and ICs in
the circuit. To prevent damage a protection diode needs to be connected across the
relay coil.

The relay's switch connections are usually labelled COM, NC and NO:

Circuit symbol for a relay

COM = Common, always connect to this, it is the moving part of the switch.
NC = Normally Closed, COM is connected to this when the relay coil is off.
NO = Normally Open, COM is connected to this when the relay coil is on.
Connect to COM and NO for the switched circuit to be on when the relay coil
is on.
Connect to COM and NC for the switched circuit to be on when the relay coil
is off.

Relay showing coil and switch contacts


49

LCD Display - Alphanumeric Dot Matrix Modules

Description:

It is a 5x7 dot matrix display. The LCD character matrix is 35 points


(5 across and 7 high). LCD has 2 lines and 16 characters. The LCD is driven by its
own on-board microcontroller. One has to simply insert ASCII characters into it.

Definition of Terminals:

PIN NO. SYMBOL FUNCTION


1 Vss Ground terminal of module
2 Vdd Supply terminal of module, +5 V
3 Vo Power supply for liquid crystal drive
Register select
4 RS RS=0  Instruction Register
RS=1  Data Register
Read/Write
5 R/W R/W=1  Read
R/W=0  Write
6 E Enable
Bi-directional data bus.
Data transfer is performed once, through DB0-
7-14 DB0-DB7 DB7, if the interface data length is 8 bits; and
twice through DB4-DB7, if the interface data
length is 4 bits. Upper 4 bits first, then lower 4
bits.
15 LAMP- LED or EL Lamp power supply terminals
16 LAMP+
50

Before sending commands or data to the LCD module, the module must be
initialized. This is done using the following series of operations for 8-bit mode:

Wait more than 15 msec after power is applied


Write 0x030 to LCD and wait 5 msec for the instruction to complete
Write 0x030 to the LCD and wait 160 µsec for the instruction to complete.
Write 0x030 again to the LCD and wait 160 µsec or poll the busy flag
Set the operating characteristics of the LCD

a) Write “Set Interface Length”


b) Write 0x010 to turn off the display
c) Write 0x001 to clear the display
d) Write “Set Cursor Move Direction” setting cursor behaviour bits
e) Write “Enable Display/Cursor” and enable the display and optional
cursor.
4. POWER SUPPLY DESIGN
51

4. POWER SUPPLY DESIGN

A power supply is a vital part of all electronic systems. Most digital ICs including
microprocessors, microcontrollers and memory ICs operate on ± 5V supply. The
power supply consists of Step-Down Transformer, Bridge Rectifier, Filter and IC
Regulator. The figure below shows the block diagram of a typical power supply.

Block diagram of a Power Supply:

230V Step Down Bridge Regulator


50Hz Transformer Rectifier Filter Regulator Output

Concept:
The schematic above shows the design of a power supply that provides
an output voltage of +5V at 0.5A. The +5V supply voltages are obtained from the
12V step down transformer. The secondary output of the transformer is applied to the
bridge rectifier circuit made using diodes IN4007 which convert the sinusoidal inputs
into full wave rectified outputs. The filter capacitor (electrolytic) at the output of the
bridge rectifier is charged to the peak value of the rectified output voltage whenever
52
the diodes are forward biased. Since the diodes are not forward biased during the
entire positive and negative half cycle of the input wave form, the voltage across the
filter capacitor is a pulsating DC that is a combination of DC and a ripple voltage.
From the pulsating DC voltage, a regulated DC voltage is extracted by a regulator IC
(7805).

Design Process:

Let us first consider how the +5V supply voltages are obtained in the
circuit. The 7805 is a ±5V regulator and it can deliver output current in an excess of
1A. Hence, it will perform satisfactorily in the circuit providing ±5V at 0.5A.
However, since the drop out voltage (Vin – Vo) is 2V, the input voltage of 7805
must be at least +7V, which it turn implies that the secondary voltage must be larger
than 14V peak or 10Vrms. The voltage across the transformer secondary is 12Vrms,
thus satisfying the minimum voltage requirement of 10Vrms. Also the peak voltage
at the secondary is 6(√2) = 8.5V peak which is less than the maximum peak voltage
of 7805.

During the positive half cycle, the diodes D1 and D3 conduct and
capacitor C4 charges towards the positive peak value ≈8.5V. During the negative half
cycle of the input wave form, diode D2 and D4 conduct and charge capacitor C4
towards the peak voltage of 8.5V. Note that the diode that conducts during either the
positive or negative half cycle does not do so for the entire half cycle. The diode
conducts only during the time the anodes are positive w.r.t the cathodes, i.e., when the
diodes are forward biased, the capacitors are charged by current pulses. The
maximum average rectified current Iomax that IN4007 can safely handle is 1 A.
In addition, when the power supply is first turned on, the initial charging of the
capacitor causes a large transient current called the surge current IFS to pass through
the diodes for a short period. It is larger than Iomax. For IN4007, the surge current
IFSM is 30A.

53
Finally, the size of the filter capacitor depends on the secondary
current rate of transformer. As a rule of thumb, a 1500µF capacitor should be used
for each ampere of current. The working voltage rating of the capacitor must be at
least 20% higher than the peak value of the voltage it is expected to charge to.
Capacitor C4 satisfies this requirement. The capacitor C5 at the output of 7805
regulator helps to improve the transient response and should be in the range of
1µF. The power dissipated by the 5V regulator is given by:

Power dissipated = (dropout voltage) (current)


= (8.5 – 5) (0.5)
= 1.75W
4. PCB DESIGN
54

5. PCB DESIGN

A printed circuit board (PCB), sometimes referred to as printed wiring


board (PWB), is the foundation of circuit construction. Components are soldered onto
the PCB, and the PCB provides the electrical connection pathways between
components to form the physical circuit. Connections are made using copper tracks
etched onto the various layers of the PCB. A PCB document is displayed as a set of
superimposed layers, with each layer corresponding to an individual "phototool" used
to fabricate the board.

In general, a PCB is derived from a schematic representation of the


circuit. When a schematic is loaded into a PCB document, schematic part symbols are
translated to corresponding board component footprints and the connectivity of the
schematic is preserved and displayed as connection lines in the PCB document.

Types of Boards:
Two most popular types of PCBs are:

Single sided boards: Single sided PCBs are used mostly in entertainment
electronics, industries where manufacturing costs have to be kept to the
minimum or during prototype testing. To jump over conductor tracks, jumper
wires are used. Jumper wire should be minimum, otherwise use of double
sided PCBs should be considered.
Double sided boards: Double sided PCBs can be made with or without
plated through holes. Boards with plated through holes are fairly expensive
and are chosen only where the circuit complexity and density do not leave any
other choice.
55

PCB Construction:
PCB consists of two layers.

Laminate: Laminate consists of filler material with resin. The common filler
materials are paper, rags, craft paper. Common resins used are phenolic,
epoxy, polytetra fluoro ethylene (PTFE).
Copper foil: The copper cladding is having a thickness of 35 µ or 70 µ.
Copper foil is pressed against the laminate at a temperature of 150-1700C and
a pressure of 20-80 cm2.

Types of PCBs Depending on the Laminate:

Paper Phenolic: It is one of the cheapest types of PCBs available with lower
mechanical strength. It is used in entertainment electronics and prototype
testing.
Glass Epoxy: This type of PCBs contain glass cloth as filler material. It has
high mechanical strength and is highly resistant to insulation. It is costlier
than paper phenolic PCBs.
PTFE PCB: It is a double sided PCB. It has very good insulation and good
mechanical strength and is costlier than glass epoxy. It is used for high
switching circuits.
Multi-layered PCB: It is manufactured by computer controlled machines.
The pins go through the layers without making any contact with other layers in
the PCB. It is useful when there are various signal levels and supply voltage
in the electronic circuits. It is difficult to repair such PCBs and needs to be
thrown away.
56

Completing the PCB layout is the first part of the process that culminates in the
fabrication and assembly of the PCB. The link between the design and finished board
are the print, Gerber and NC drill fabrication files, as well as the Bill of Materials,
testpoint report, and pick and place assembly files.

Gerber files: A PCB is fabricated as a series of layers that the manufacturer


assembles into a board through a variety of chemical and mechanical processes. To
fabricate each physical layer in the PCB the manufacturer uses an image of that layer
-- this image is referred to as a phototool. A phototool is a piece of clear film, with
black lines, circles and other shapes.

Once the PCB design process is complete and the design has passed all
the design rule checks, the Gerber files are generated, one for each layer needed in the
fabrication process. The Gerber language is the standard language format used to
transfer PCB layout data from the PCB design software to the phototool creation
process. These Gerber files are then sent to the manufacturer, who loads them into a
photoplotting machine and creates the phototools.

Each phototool is created by exposing the film to build up the image


required for that layer. The information needed to form the image includes the shape
and size of the objects on that layer, and the coordinates of these objects. The shapes
are specified in the Gerber file as apertures.
57
6. SOFTWARE

58
6. SOFTWARE
Flowchart:
Start

Initialize Stack Pointer

Disable Interrupt and ‘Power On’


Delay

Initialize LCD

Display ‘Welcome’
Messages

Wait for ‘Command’ Key


Press

Any Command
No Key Pressed?
Yes

Select one of the modules below


depending on key press

(RTC Time Set Module)


A

(User Input Program


Module) B

(Run Program Module) C

6.1. Main Program

59
A

Start

Enter Present
Hour Value <24

Is ‘Set Key’
Pressed?
No
Yes

Stores Hour Value in


RTC

Enter Present
Minute Value <60

Is ‘Set Key’
Pressed?
No
Yes

Stores Minute Value in


RTC

Go to ‘Main Program’ and


wait for next ‘Command
Key’ press

6.2. RTC Time Set Module


6.3. User Input Program Module 60

Enter Process Start


Time (Hr: Min)

Is ‘Set Key’
Pressed?
No
Yes
Stores Process Start
Time in RTC

Enter Process End


Time (Hr: Min)

Is ‘Set Key’
* Program 1 *
Pressed?
No
Yes
Stores Process End
Time in RTC

Enter End
Temperature to be
Achieved <100

Is ‘Set Key’
Pressed?
No
Yes
Stores End
Temperature in RTC

* Program 5 *

Go to ‘Main Program’ and


wait for next ‘Command
Key’ press
61

Repeat Get Present Time from RTC


Comparison
from Prog2-5 &
repeat process Compare Present Time with
Process Start Time for
Program 1

No
Is Present Time=
Start Time?

Yes
Read Present Temp from CH1 of ADC

No No
Is Present Is Present Heater Off, Cooler
Temp=End Temp<End On & Alarm On
Temp Temp

Yes Yes
Heater & Cooler Off Heater On & Cooler Off

Compare Present Time


with End Time

No
Is Present
Time =End
Time?

Yes
End Process

6.4. Run Program Module


7. TESTING
62

7. TESTING

“If you don’t test and engineer right, if the people and engineers are not right,
you know the consequences, right?” …. National Technical Systems Corp.

The above statement emphasizes the importance of product testing.


Functionality testing is the process of verifying whether a product meets its design
and functional specifications. In the process, functionality testing can identify
potential product bugs, and once those bugs are eliminated, functionality testing can
verify that the fixes were successful and within the applicable standards.

Keeping the specifications and end product in mind, the testing was
done in a step-by-step procedure.
Once the schematic and the PCB design were finalized, we split the rest of the
project into different modules and kept upgrading the software and testing each
module using SIM31 simulator.

PCB Testing: The PCB was tested by tracing the tracks from the netlist and
the artwork of the PCB. The errors in the artwork were eliminated while
testing and after that it was given for PCB manufacture. The PCB was tested
using DMM to check continuity of tracks.
LCD Module Testing: Once we had the PCB in hand, our motto was to check
the PCB design. For this, we mounted just enough components (power
supply, LCD through connector, microcontroller with crystal and reset switch)
and developed a basic LCD initialization program to check whether
microcontroller, crystal, reset circuit and LCD display were working.
RTC Time Set Module Testing: Once the LCD program was found working,
we shifted our focus to displaying the present time. For this, we mounted the
RTC (DS12C887) and developed an RTC initialization program to both
display and edit the time on LCD.
63

Temperature Display Module Testing: To display the present temperature,


the ADC (PCF8591) and temperature sensor (LM35) were mounted and
temperature display module was developed and tested. The temperature was
displayed both on the LCD and on PC through serial port successfully.
User Input Program Testing: A timer program which takes process start
time, end time and end temperature as user inputs was developed. On
successful testing of this program module, it was replicated for four more
instances, taking the programmable memory into consideration.
Timer Program: The purpose of the timer program was to see whether the
present time matched any user programmed on-time, switch on the heater or
cooler relay, depending on the end temperature to be achieved and switch off
the process on reaching end time. This program module was also tested
successfully and replicated four more times.
The final product was also tested in the Company premises successfully.
8. LIST OF COMPONENTS
64

8. LIST OF COMPONENTS

Approx. cost
S.No. Name of parts Manufacturer Nos.
(Rs.)
1 AT89C52 Atmel 75 1
2 PCF8591 Philips 200 1
3 MAX-232 Maxim 50 1
4 LCD (2 x 16) 250 1
5 DS12C887 Dallas 250-300 1
6 Relay 15 2
7 ULN-2003 ST 10 1
National
8 LM 35 75 1
Semiconductor
9 7805 ST 15 2
10 Power Supply - 300-350 -
11 PCB (Artwork) - 10/sq.cm. -
IC sockets
40 pm 5
12 -
8 pm 2
16 pm 3
DS 12887
13 - 4 1
socket
LCD
14 - 25 1
Connector
Presto
15 Cabinet 1
Enclosures
16 Buzzer - 20 1
Connectors
17 - 10
(RS-232)
18 Crystal - 10 1
19 Switches - 8/switch 1
4x4 Key Pad
20 - 190 1
(Tactile)
9. FUTURE SCOPE
65

9. FUTURE SCOPE
When we set forth to make this project, the basic aim in mind was to
make a competitively priced environmental chamber controller which can simulate
the harsh weather conditions faced by electronic equipments in real environments.
The controller needed to be user-friendly, ergonomic, and fully user-programmable in
real time with computer interface and data logging.
Although, in the short time available to us we have managed to achieve
our target, we would like to see our project being transformed into a valued product
being used by industries with many more added features. A few added features which
we can think of now are listed below.
Ability to remotely load the system and interact with it through software.
Self-diagnosis and ability to detect errors with better control system.
We have used RS232 serial communication and given a provision to upgrade
to RS485 in future which we would like to see as a standard feature in our
product in future. RS485 would help to increase the distance of data
transmission helping it to operate remotely.
At the moment we are controlling only the temperature and time. We would
like more parameters like humidity, pressure, vibration, etc being controlled.
The PCF8591 A/D converter which we have used allows upgradeability to
control three more parameters.
Hopefully in the future with better sensors flooding the market at affordable
rates, we could get better and properly calibrated sensors to control more
parameters and over a greater range.
At present the data logged is only the present temperature and the
corresponding time (hours and minutes) which is flashed on the PC through
Hyper Terminal. We would like to improve data logging in future by using an
exclusive VB software with a good and easy user interface.
Although the user-programmed data is safe even in case of a power failure in
the real time clock, the controller would go off in case of a power failure. We
can avoid this by using a battery back-up.
Also the product would do well with better looks by using a custom made key
pad and enclosure.
10. BIBLIOGRAPHY
66

10. BIBLIOGRAPHY
Books:
1. The 8051 Microcontroller and Embedded Systems
- Muhammad Ali Mazidi and
Janice Gillispie Mazidi
2. Programming & Customizing the 8051 Microcontroller
- Myke Predko
3. Microcontroller Design & Projects Handbook
- Chandra Sekhar Roy
4. Serial Port Complete
- Jan Axelson
5. Op-Amps and Linear Integrated Circuits
- Ramakant A. Gayakwad
6. Printed Circuit Boards
- Bosshart
7. National Semiconductor Analog Products Data Book
8. Microprocessor and Microcontroller
- Techmax Publication
On-Line Resources:
1. www.atmel.com
2. www.maxim-ic.com
3. www.semiconductors.philips.com
4. www.national.com
5. www.st.com
6. www.iguanalabs.com
7. www.zytrax.com
8. http://eserver.bell.ac.uk/mirrors/dc100www/dc_014.htm
9. www.keylabs.com
10. www.ntscorp.com

Protel 99SE Help Files


11. DATA SHEETS

You might also like