You are on page 1of 36

PREFACE

Many metals, semiconductors, and ceramics change their electrical resistance with
temperature in a known reproducible manner. This change in resistance results in a
change of current or voltage, so it can be measured and then displayed in an analog to
digital fashion. This is the basis for digital thermometer. Digital thermometers are a
quick, simple and effective way of obtaining temperature information.
Digital thermometers are quickly replacing traditional mercury thermometers mercury
thermometers were used in the same way as by heating the liquid mercury in the tip
would cause it to expand into the tube of the thermometer, thus fluctuating according
to temperature and stopping at a point on the scale. For clinical use to prevent
contamination between patients in 1990s digital thermometers began replacing
traditional thermometers in medicine due to safety concerns.

ACKNOWLEDGEMENT

We would like to acknowledge and extend our heartfelt gratitude to the persons who
have made possible the completion of our project. Without their timely help, the
project could not have been a success, our supervisor Madam Uzma Raheem, for her
vital encouragement and support. Madam Shafia Tabbassum our cosupervisor, for
her understanding and assistance. Prof.Dr.M.A.Haleem, Chairman, Department of
Biomedical Department for the help and inspiration he extended. Sir Zeeshan project
incharge for the constant reminders and much needed motivation. All Biomedical
department faculty members and Staff Sir Asif Memon, for assisting in the collection
of the topics for the chapters.
Most especially we gratefully acknowledge to our family for their encouragement and
financial support, and above all to God, who made all things possible.

ABSTRACT
A digital thermometer is designed and built utilizing a temperature sensor LM35 and
distributed control system circuit. Temperature was recorded in the range 97F
to100F, 37C with an accuracy of 0.01. Numeric and graphical data were displayed
on a PC using a program written in Visual Basic. The project is based on Human
Machine Interface (HMI) equipment which provides a control and visualisation
interface between a human and a process; machine, application or appliance. HMIs
allow us to control, monitor, diagnose and manage our application.

The report

comprises of three chapters; CHAPTER#1 consists of theory section, CHAPTER#2


consists of project details, CHAPTER #3 consists of appendices.

Sir Syed University of Engineering & Technology


University Road, Karachi -75300, Pakistan.
Tel: - 4988000-5, 4980059, 4980072
Website: www.ssuet.edu.pk

CERTIFICATE
This is to certify that:

SYED WAHAB ALI ZAIDI


MUHAMMAD AZAM
AFSHEEN HUSSAIN
SYEDA SABIKA ZAIDI

2005-BM-132
2005-BM-113
2005-BM-123
2005-BM-130

Are student of Biomedical Engineering Department batch 2005 and have completed
their final year project assign to them.

Prof.Dr.M.A.Haleem
Chairman
Biomedical Engineering Department

Sir Syed University of Engineering & Technology


University Road, Karachi -75300, Pakistan.
Tel: - 4988000-5, 4980059, 4980072
Website: www.ssuet.edu.pk

CERTIFICATE
This is to certify that:

SYED WAHAB ALI ZAIDI


MUHAMMAD AZAM
AFSHEEN HUSSAIN
SYEDA SABIKA ZAIDI

2005-BM-132
2005-BM-113
2005-BM-123
2005-BM-130

Are student of Biomedical Engineering Department batch 2005 and have completed
their final year project assign to them.

Engr.Uzma Raheem
Project Advisor
Lecturer
Dept. of Biomedical Engineering

Engr.Shafia Tabbasum
Project Advisor
Lecturer
Dept. of Biomedical Engineering

Table of Contents
Chapter # 1

Theory

1.1

Introduction

1.2

General Description

1.2.1

Thermometer

1.2.2

Sensor

1.2.3

Analog-To-Digital Converter

1.2.4

Microcontroller

1.2.5

Liquid Crystal Display (LCD)

1.3

Serial Interfacing

1.3.1

Popular Computer Interface Specifies the Typical Maximum

1.3.2

System Components

1.3.3

Computer

1.3.4

Physical Link

1.3.5

Programming

10

1.3.6

Languages

10

1.4

HMI (Human Machine Interface)

10

1.5

Distributed Control System

11

1.5.1

Elements

11

1.5.2

Application of DCS in Our Project

11

Chapter # 2

Technical Data

12

2.1

Block Diagram

12

2.2

Components List

13

2.2.1

LM35

13

2.2.2

ADC0804

13

2.2.3

Microcontroller 89C51

13

2.2.4

MAX232 & RS232

14

2.3

Circuit Description

14

2.3.1

Power Supply

14

2.3.2

Main Control Unit

14

2.3.3

Analog Unit

15

2.3.4

Display Unit

15

2.5

Programmme

15

2.6

Key Specification Of The Project

24

2.6.1

24

Vital Statistics

Chapter # 3
References

Project Management

25

Chapter # 1

Theory

1.

Theory

1.1

Introduction

Digital Thermometer with computer Interface provides temperature readings which


indicate the temperature of the three different persons at a time. No additional
components are required; the device is truly a temperature-to-digital converter.
Temperature readings are communicated from the 8 bit a-d- converter or a standard 3wire serial interface. The choice of interface standard is selectable by the user. Having
connectivity with PC is great we can always see current temperatures or we can
collect a long term statistics or for future enhancement even publish on the web.

1.2

General Description
1.2.1

Thermometer

Thermometer is a device that measures temperature or temperature gradient


using a variety of different principles; it comes from the Greek roots thermo,
heat, and meter, to measure. A thermometer has two important elements: the
temperature sensor (e.g. the bulb on a mercury thermometer) in which some
physical change occurs with temperature, plus some means of converting this
physical change into a value (e.g. the scale on a mercury thermometer).
Industrial thermometers commonly use electronic means to provide a digital
display or input to a computer.
Types of Thermometers
Thermometers have been built which utilise a range of physical effects to
measure temperature. Most thermometers are originally calibrated to a
constant-volume gas thermometer. Temperature sensors are used in a wide
variety of scientific and engineering applications, especially measurement
systems. Temperature systems are primarily either electrical or mechanical,
occasionally inseparable from the system which they control (as in the case of
a mercury thermometer).

Sir Syed University of Engineering & Technology

Chapter # 1

Theory

Alcohol thermometer

Beckmann differential thermometer

Bi-metal mechanical thermometer

Coulomb blockade thermometer

Galileo thermometer

Infrared thermometer

Liquid crystal thermometer

Medical thermometer (e.g. oral thermometer, rectal thermometer, basal


thermometer)

Mercury-in-glass thermometer

Pill thermometer

Resistance thermometer

Reversing thermometer

Silicon bandgap temperature sensor

Six's thermometer- also known as a Maximum minimum thermometer

Thermistor

Thermocouple

1.2.2

Sensor

A sensor is a device that measures a physical quantity and converts it into a


signal which can be read by an observer or by an instrument. For example, a
mercury thermometer converts the measured temperature into expansion and
contraction of a liquid which can be read on a calibrated glass tube. A
thermocouple converts temperature to an output voltage which can be read by
a voltmeter. For accuracy, all sensors need to be calibrated against known
standards.
A sensor's sensitivity indicates how much the sensor's output changes when
the measured quantity changes. For instance, if the mercury in a thermometer
moves 1 cm when the temperature changes by 1 C, the sensitivity is 1 cm/C.
Sensors that measure very small changes must have very high sensitivities.

Sir Syed University of Engineering & Technology

Chapter # 1

Theory

Classification of Measurement Errors


A good sensor obeys the following rules:
1. the sensor should be sensitive to the measured property
2. the sensor should be insensitive to any other property
3. the sensor should not influence the measured
Types of Sensors

Electromagnetic

Chemical

Mechanical

Optical Radiations

Ionising Radiations

Acoustics

Temperature Sensor
Big differences exist between different temperature sensor or temperature
measurement device types. Using one perspective, they can be simply
classified into two groups, contact and non-contact. The two links below take
you to descriptive pages on each type with a breakdown by more specific,
detailed types under that simple, first breakout.
There are also vendors of each sensor type, some vendors sell more than one
type and some sell nearly all types, but not always all brands. There are
differences between brands and the differences are most evident among those
device types for which there are few if any recognized standards. Start your
search either for a specific temperature measurement device type or go to the
vendor page index and you can access the vendors of specific types from
there.
Both contact and non-contact sensors require some assumptions and
inferences in use to measure temperature. Many, many well-known uses of
Sir Syed University of Engineering & Technology

Chapter # 1

Theory

these sensors are very straightforward and few, if any, assumptions are
required. Other uses require some careful analysis to determine the controlling
aspects of influencing factors that can make the apparent temperature quite
different from the indicated temperature
1.2.3

Analog-To-Digital Converter

An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device


which converts continuous signals to discrete digital numbers. The reverse
operation is performed by a digital-to-analog converter (DAC).
Resolution
The resolution of the converter indicates the number of discrete values it can
produce over the range of analog values. The values are usually stored
electronically in binary form, so the resolution is usually expressed in bits. In
consequence, the number of discrete values available, or "levels", is usually a
power of two. For example, an ADC with a resolution of 8 bits can encode an
analog input to one in 256 different levels, since 28 = 256. The values can
represent the ranges from 0 to 255 (i.e. unsigned integer) or from -128 to 127
(i.e. signed integer), depending on the application.
Linear ADCS
Most ADCs are of a type known as linear, although analog-to-digital
conversion is an inherently non-linear process (since the mapping of a
continuous space to a discrete space is a piecewise-constant and therefore nonlinear operation). The term linear as used here means that the range of the
input values that map to each output value has a linear relationship with the
output value
Non-Linear ADCS
If the probability density function of a signal being digitized is uniform, then
the signal-to-noise ratio relative to the quantization noise is the best possible.
Because of this, it's usual to pass the signal through its cumulative distribution
function (CDF) before the quantization. This is good because the regions that

Sir Syed University of Engineering & Technology

Chapter # 1

Theory

are more important get quantized with a better resolution. In the


dequantization process, the inverse CDF is needed.
Accuracy
An ADC has several sources of errors. Quantization error and (assuming the
ADC is intended to be linear) non-linearity is intrinsic to any analog-to-digital
conversion. There is also a so-called aperture error which is due to a clock
jitter and is revealed when digitizing a time-variant signal (not a constant
value).
These errors are measured in a unit called the LSB, which is an abbreviation
for least significant bit. In the above example of an eight-bit ADC, an error of
one LSB is 1/256 of the full signal range, or about 0.4%.
Quantization Error
Quantization error is due to the finite resolution of the ADC, and is an
unavoidable imperfection in all types of ADC. The magnitude of the
quantization error at the sampling instant is between zero and half of one LSB.
Sampling Rate
The analog signal is continuous in time and it is necessary to convert this to a
flow of digital values. It is therefore required to define the rate at which new
digital values are sampled from the analog signal. The rate of new values is
called the sampling rate or sampling frequency of the converter.
Aliasing
All ADCs work by sampling their input at discrete intervals of time. Their
output is therefore an incomplete picture of the behaviour of the input. There
is no way of knowing, by looking at the output, what the input was doing
between one sampling instant and the next. If the input is known to be
changing slowly compared to the sampling rate, then it can be assumed that
the value of the signal between two sample instants was somewhere between
the two sampled values. If, however, the input signal is changing fast
compared to the sample rate, then this assumption is not valid.

Sir Syed University of Engineering & Technology

Chapter # 1

Theory

Applications
AD converters are used virtually everywhere where an analog signal has to be
processed, stored, or transported in digital form. Fast video ADCs are used, for
example, in TV tuner cards. Slow on-chip 8, 10, 12, or 16 bit ADCs are
common in microcontrollers. Very fast ADCs are needed in digital
oscilloscopes, and are crucial for new applications like software defined radio.
1.2.4

Microcontroller

A microcontroller (also MCU or C) is a functional computer system-on-achip. It contains a processor core, memory, and programmable input/output
peripherals. Microcontrollers include an integrated CPU, memory (a small
amount of RAM, program memory, or both) and peripherals capable of input
and output. Microcontrollers are used in automatically controlled products and
devices, such as automobile engine control systems, remote controls, office
machines, appliances, power tools, and toys. By reducing the size, cost, and
power consumption compared to a design using a separate microprocessor,
memory, and input/output devices, microcontrollers make it economical to
electronically control many more processes.
Programs
Microcontroller programs must fit in the available on-chip program memory,
since it would be costly to provide a system with external, expandable,
memory. Compilers and assembly language are used to turn high-level
language programs into a compact machine code for storage in the
microcontroller's memory. Depending on the device, the program memory
may be permanent, read-only memory that can only be programmed at the
factory, or program memory may be field-alterable flash or erasable read-only
memory.
Other Microcontroller Features
Since embedded processors are usually used to control devices, they
sometimes need to accept input from the device they are controlling. This is
the purpose of the analog to digital converter. Since processors are built to
interpret and process digital data, i.e. 1s and 0s, they won't be able to do
Sir Syed University of Engineering & Technology

Chapter # 1

Theory

anything with the analog signals that may be being sent to it by a device. So
the analog to digital converter is used to convert the incoming data into a form
that the processor can recognize. There is also a digital to analog converter
that allows the processor to send data to the device it is controlling.
In addition to the converters, many embedded microprocessors include a
variety of timers as well. One of the most common types of timers is the
Programmable Interval Timer, or PIT for short. A PIT just counts down from
some value to zero. Once it reaches zero, it sends an interrupt to the processor
indicating that it has finished counting. This is useful for devices such as
thermostats, which periodically test the temperature around them to see if they
need to turn the air conditioner on, the heater on, etc.
Types of Microcontrollers

ARM

MIPS (32-bit PIC32)

AVR

PIC (8-bit PIC16, PIC18, 16-bit dsPIC33 / PIC24)

V850

PowerPC ISE

AT-MEGA 16

1.2.5

Liquid Crystal Display (LCD)

Liquid crystal display (LCD) is an electro-optical amplitude modulator


realized as a thin, flat display device made up of any number of color or
monochrome pixels arrayed in front of a light source or reflector. It is often
utilized in battery-powered electronic devices because it uses very small
amounts of electric power.
Specifications
Important factors to consider when evaluating an LCD monitor:

Sir Syed University of Engineering & Technology

Chapter # 1

Theory

Resolution: The horizontal and vertical size expressed in pixels (e.g.,


1024x768). Unlike monochrome CRT monitors, LCD monitors have a
native-supported resolution for best display effect.

Dot pitch: The distance between the centers of two adjacent pixels. The
smaller the dot pitch size, the less granularity is present, resulting in a
sharper image. Dot pitch may be the same both vertically and horizontally,
or different (less common).

Viewable size: The size of an LCD panel measured on the diagonal (more
specifically known as active display area).

Response time: The minimum time necessary to change a pixel's color or


brightness. Response time is also divided into rise and fall time. For LCD
Monitors, this is measured in btb (black to black) or gtg (gray to gray).
These different types of measurements make comparison difficult.

Matrix type: Active TFT or Passive.

Color support: How many types of colors are supported (coll., more
specifically known as color gamut).

Brightness: The amount of light emitted from the display (coll., more
specifically known as luminance).

Contrast ratio: The ratio of the intensity of the brightest bright to the
darkest dark.

Input ports (e.g., DVI, VGA, LVDS, DisplayPort, or even S-Video and
HDMI).

1.3

Serial Interfacing

A serial port is a computer interface that transmits data one bit at a time. In common
use, the term serial port refers to ports that use a particular asynchronous protocol.
These ports include the RS-232 ports on PCs and many serial ports in embedded
systems. Most serial ports are bidirectional: they can both send and receive data.
Transmitting one bit at a time might seem inefficient but has advantages, including the
ability to use inexpensive cables and small connectors.

Sir Syed University of Engineering & Technology

Chapter # 1

Theory

Serial ports are ideal for many communications between embedded systems or
between embedded systems and PCs. Serial ports can also be a good choice when you
need very long cables or a basic network among PCs, embedded systems or a
combination. Some systems include a serial port that is hidden from users but
available to technicians for debugging and diagnostics.
1.3.1

Popular Computer Interface Specifies the Typical Maximum

1.3.2

System Components

Communicating via serial ports requires three things: computers with serial
ports, a cable or wireless interface that provides a physical link between the
ports, and programming to manage the communications.
1.3.3

Computer

Just about any computer can use serial-port communications, including


inexpensive microcontrollers and PCs that dont have built-in serial ports.

1.3.4

Physical Link

The physical link between computers consists of the wires or other medium
that carries information from one computer to another and the connectors and
other components that interface the medium to the computers.
RS-232 links can use just about any cable type and require one line per signal
plus a common ground line. RS-485 networks typically use twisted-pair cables
with a pair for each differential signal. Other options for serial
communications include fiber-optic cable, which encodes data as the presence
or absence of light, and wireless technologies, which enable sending data as
electromagnetic (radio) or infrared signals through the air. Computers

Sir Syed University of Engineering & Technology

Chapter # 1

Theory

connected by wires must have a common ground reference, typically provided


by a ground wire in the cable.
1.3.5

Programming

A computer must perform the following tasks in serial communications:

Detect and process received data.

Provide and send data as needed.

Carry out any other tasks the computer is responsible for.

If the connection is to a serial network, each computer must ignore


communications intended for other computers in the network and comply with
network protocols for addressing transmitted data to the appropriate
computer(s). Program code carries out these tasks, often with help from
hardware.
1.3.6

Languages

The programming for a serial interface can use any language, and the language
doesnt have to be the same on every computer. The only requirement is that
all of the computers must agree on a format. Microcontroller programs might
access UART registers directly or use library functions or other higher-level
methods to set communications parameters and exchange data. PC
applications typically use higher-level functions to access ports.

1.4

HMI (Human Machine Interface)

The user interface of a mechanical system, a vehicle or an industrial installation is


sometimes referred to as the Human-Machine Interface (HMI). HMI equipment from
Telemecanique spans from simple text displays, graphical operator panels,
touchscreens, industrialised PCs (iPC), Supervisory Control and Data Acquisition
(SCADA) and web-based HMI Solutions.
HMI provides a competitive advantage and significant business benefits.

Optimisation of process control through full access to process data in realtime

Sir Syed University of Engineering & Technology

10

Chapter # 1

Theory

Flexible and scalable easily adaptable solutions to different user needs

A HMI represents the front end of a machine, the visible window into
the

process.

Good HMI aesthetics and ergonomy are often key selling features for machines.

Rapid machine set-up and changeover, via easily re-configurable hardware


and software products

Improved efficiency and minimised downtime - with pin-point


maintenance information, intelligent troubleshooting and on-line help

1.5

Distributed Control System

A distributed control system (DCS) refers to a control system usually of a


manufacturing system, process or any kind of dynamic system, in which the controller
elements are not central in location (like the brain) but are distributed throughout the
system with each component sub-system controlled by one or more controllers. The
entire system of controllers are connected by networks for communication and
monitoring.
1.5.1

Elements

A DCS typically uses custom designed processors as controllers and uses both
proprietary interconnections and protocols for communication. Input & output
modules form component parts of the DCS. The processor receives
information from input modules and sends information to output modules. The
input modules receive information from input instruments in the process and
transmit instructions to the output. Computer buses or electrical buses connect
the processor and modules through multiplexers/demultiplexers. Buses also
connect the distributed controllers with the central controller and finally to the
Human-Machine Interface (HMI) or control consoles
1.5.2

Application of DCS in Our Project

We investigate, design and implement distributed control systems, ranging


from networked and embedded control systems to automation and control
systems. Our research interests include:

Time sensitive networked control systems

Sir Syed University of Engineering & Technology

11

Chapter # 1

Real-time control systems

Control methods for recource-constrained control systems

Adaptive resource allocation

Schedulability analysis

Sir Syed University of Engineering & Technology

Theory

12

Chapter # 2

Technical Data

2.

Technical Data

2.1

Block Diagram

SENSOR
LM35

A/D
UNIT

MCU
ATMEL
80C51

SENSOR
LM35

LCD

A/D
UNIT

MCU
ATMEL
80C51

LCD

SENSOR
LM35

A/D
UNIT

MCU
ATMEL
80C51

LCD

COMPUTER INTERFACING UNIT

COMPUTER
PC

Sir Syed University of Engineering & Technology

12

Chapter # 2

2.2

Technical Data

Components List
2.2.1

LM35

Precision Centigrade Temperature Sensors


The LM35 series are precision integrated-circuit temperature sensors, 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 can be used with single
power supplies, or with plus and minus supplies. As it draws only 60 A from
its supply, it has very low self-heating, less than 0.1C in still air. The LM35 is
rated to operate over a 55 to +150C temperature range.
2.2.2

ADC0804

8-Bit P Compatible A/D Converters


The ADC0804 are CMOS 8-bit successive approximation A/D converters that
use a differential potentiometric ladder. This converter is designed to allow
operation with the NSC800 and INS8080A derivative control bus with TRISTATE output latches directly driving the data bus. This A/D appear like
memory locations or I/O ports to the microprocessor and no interfacing logic
is needed.
2.2.3

Microcontroller 89C51

8-Bit with 4k Bytes


The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer
with 4K 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 MCS-51
instruction set and pinout. By combining a versatile 8-bit CPU with Flash on a
monolithic chip, the Atmel AT89C51 is a powerful microcomputer which
provides a highly-flexible and cost-effective solution to many embedded
control applications.

Sir Syed University of Engineering & Technology

13

Chapter # 2

Technical Data

2.2.4

MAX232 & RS232

RS-232 is an interface that is suitable for many basic communication tasks


between two computers. RS-232 is designed to handle communications
between two devices with a distance limit of around 80 to 130 ft, depending
on the bit rate and cable type.RS-232 uses unbalanced, or single-ended, lines.
The MAX232 includes two drivers that convert TTL or CMOS inputs to RS232 outputs and two receivers that convert RS-232 inputs to TTL/CMOScompatible outputs. The drivers and receivers also invert the signals.

2.3

Circuit Description

Our digital thermometer consists of four units, Power Supply, Main Control Unit,
Analog Unit and Digital or Display Unit.
2.3.1

Power Supply

We have separately developed a power supply for our digital thermometer.


This power supply is providing 5 volts regulated power to all three units at the
same time.
2.3.2

Main Control Unit

In main control unit we use 89c51 microcontroller with a crystal frequency is


11.095 to achieve baud rate of 9600.it has a reset circuit and we only use
internal memory and deactivate EA pin.

5 V

31
19
100 R
1

L C D D is p l a y

5K6

5 V

10 uF
2

30 pF x 2

1 1 .0 9 5 M H z

18
9

8K2

12
13
14
15
1
2
3
4
5
6
7
8

U 2
E A /V P
X1
X2
R ESET
IN T 0
IN T 1
T0
T1
P
P
P
P
P
P
P
P

1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7

P
P
P
P
P
P
P
P

0 .0
0 .1
0 .2
0 .3
0 .4
0 .5
0 .6
0 .7

P
P
P
P
P
P
P
P

2 .0
2 .1
2 .2
2 .3
2 .4
2 .5
2 .6
2 .7

R D
W R
PSEN
A L E /P
TXD
R XD

39
38
37
36
35
34
33
32
21
22
23
24
25
26
27
28
17
16
29
30
11
10

8051
5 V

10 uF

13
8
11
10
1
3
4
5
2
6

U 4
R 1 IN
R 2 IN
T 1 IN
T 2 IN
C
C
C
C
V
V

+
12+
2+
-

R 1O U T
R 2O U T
T1O U T
T2O U T

12
9
14
7

5
9
4
8
3
7
2
6
1

P1

C O N N EC TO R D B9

M A X232

Sir Syed University of Engineering & Technology

14

Chapter # 2
2.3.3

Technical Data
Analog Unit

An 8 bit ADC is used which convert the data receive from temperature sensor
connected to pin 6 of ADC, a 10 k resistor and 150 pf capacitor is used to
generate clock pulse and a 10 k variable resister is required to set the
reference.
The sequence of conversion of data is as follows:
1. CS ( pin 1) is applied to activate the ic
2. WR (pin 3) is applied to get the analog value
3. INT (pin 5) gives the indication that the indication is complete.
4. RD ( pin 2) signal is applied to get the digital converted value

5 V
U 3

10 K
1

9
4

10 K

19
7

150 pF

AG N D
VR EF
C LK
C LKR
V IV I+

IN T R
W R
R D
C S
D
D
D
D
D
D
D
D

B
B
B
B
B
B
B
B

7
6
5
4
3
2
1
0

5
3
2
1
11
12
13
14
15
16
17
18

AD C 0804

T e m p e r a tu r e
S encer

2.3.4

Display Unit

The last section consists of LCD Module and output to PC. Signals are sent to
the LCD for the display of temperature in degree centigrade and degree
ferenheit.This can also be seen through PC by implementation of the signals to
MAX232, which is connected to Serial Connector RS232.This RS232 is then
connected to the printer port of the computer, so that parameter like
temperature could be seen on the PC.

2.5

Programmme

#include <reg51.h>
#include <math.h>
#define ADDRESS 'B'

Sir Syed University of Engineering & Technology

15

Chapter # 2

Technical Data

sfr

ldata

= 0x80;

sfr

adc

= 0x90;

sbit

adccs =P3^0;

sbit

adcrd =P3^1;

sbit

adcwr =P3^2;

sbit

adcint =P3^3;

sbit

relay

sbit

rs

= P2^7;

sbit

rw

= P2^6;

sbit

en

= P2^5;

sbit

check = P1^0;

=P3^7;

unsigned char ADC;


void MSDelay(unsigned char itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void lcdcmd(unsigned char value)
{
ldata = value;
rs = 0;
rw = 0;
en = 1;
MSDelay(1);
en = 0;
MSDelay(10);
return;
}
void lcddata(unsigned char value)
{
ldata = value;
Sir Syed University of Engineering & Technology

16

Chapter # 2

Technical Data
rs = 1;
rw = 0;
en = 1;
MSDelay(1);
en = 0;
MSDelay(10);
return;

}
void ClearScreen(void)
{

lcdcmd(0x01); }

void Intilize(void)
{

lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x06);
ClearScreen();

}
void Location(unsigned char Row,unsigned char Col)
{
unsigned char DispLoc = 0x80;
if(Row == 2)
DispLoc = 0xc0;

DispLoc = DispLoc+Col;
lcdcmd(DispLoc);
}
LCDString(char str[])
{
int x = 0;
while(str[x] != '$' )
{
lcddata(str[x]);
x++;
Sir Syed University of Engineering & Technology

17

Chapter # 2

Technical Data
}

}
int

RoundOff(float

x)

{
float

r;

float

d;

r = ceil (x);
d = x-(r-1);
if (d>0.5)
return((int)r);
r--;
return((int)r);
}
void PrintChar (unsigned char PChar)
{
float

r,r2;

float

PCharL = PChar;

unsigned char ValString[4] = {' ',' ',' ', '$'};


//

ValString[3] = '$';
r = PCharL/10;

//getting the unit

r2 = ceil(r);
if (r2 != r)
r2--;
r = (r-r2)*10;
r = RoundOff(r);
ValString[2] = ((char)r)+48;
if (r2>9)
{
r = r2/10;
r2 = ceil(r);
if(r2 != r)
Sir Syed University of Engineering & Technology

18

Chapter # 2

Technical Data
r2--;
r = (r-r2)*10;
r = RoundOff(r);
ValString[0] = ((char)r2)+48;
r2 = r;
}
ValString[1] = ((char)r2)+48;

LCDString(ValString);
}

void PrintInteger(float PInt)


{
unsigned char ValString[6] = {' ', ' ',' ', '.', ' ', '$'};
float

ValPint = PInt;

float

RoundPint;

float

DecPint;

float

r;

RoundPint = ceil(ValPint);
if (RoundPint > ValPint)
RoundPint--;
DecPint = (ValPint-RoundPint)*10;
DecPint = RoundOff(DecPint);
ValString[4] = ((char)DecPint)+48;
ValPint = RoundPint;
DecPint = RoundPint/10;
RoundPint = ceil(DecPint);
if(RoundPint > DecPint)
RoundPint--;
DecPint = (DecPint-RoundPint)*10;
DecPint = RoundOff(DecPint);
ValString[2]= ((char)DecPint)+48;
Sir Syed University of Engineering & Technology

19

Chapter # 2

Technical Data

ValPint = (ValPint-DecPint)/10;
if (ValPint > 9)
{
RoundPint = ValPint / 10;
DecPint = ceil(RoundPint);
if (DecPint > RoundPint)
DecPint--;
RoundPint = (RoundPint-DecPint)*10;
ValPint = RoundPint;
ValString[0]= ((char)DecPint)+48;
}
ValString[1]= ((char)RoundPint)+48;
LCDString(ValString);
}
unsigned char GetADC()
{
unsigned char AdcData;
adc = 0x0ff;
adccs = 0;
MSDelay(10);
adcwr = 0;
MSDelay(10);
adcwr = 1;
MSDelay(5);
adcrd = 0;
MSDelay(10);
AdcData = adc;
adcrd = 1;
adccs = 1;
return(AdcData);
}
unsigned int C2F(unsigned char DC)
Sir Syed University of Engineering & Technology

20

Chapter # 2

Technical Data

{
return (135.8);
}
void

IntilizeTimer(void)
{
TMOD
TH1

= 0x20;
= -3;

SCON = 0x50;
TR1

= 1;

}
void

Transmit(unsigned char Trans)


{
SBUF = Trans;
while (TI == 0);
TI

= 0;

}
unsigned char Receive(void)
{
unsigned char Rec = '%';
while (RI == 1)
{
Rec = SBUF;
RI = 0;
}
return (Rec);
}
void

TransmitAscii(unsigned char AsciiData)


{
float

Unit,Ten;

float

Hund = 0;

float

x=

float

x2;

AsciiData;

Sir Syed University of Engineering & Technology

21

Chapter # 2

Technical Data

x = x / 10;
x2 = ceil(x);
if (x2 > x)
x2--;
x = ((x- x2)*10);
Unit = ceil(x);
if(Unit > x)
Unit--;
Unit = Unit;
x=

AsciiData;

x2 = (x - Unit)/10;
if (x2 > 9)
{
Ten = x2;

//Temp

x = x2 / 10;
x2 = ceil(x);
if(x2 > x)
x2--;
Hund = x2;
x2 = (x -x2)*10;
}
Ten = x2;
Transmit(((char)Hund)+48);
MSDelay(10);
Transmit(((char)Ten)+48);
MSDelay(10);
Transmit(((char)Unit)+48);
MSDelay(10);
Transmit('$');
MSDelay(10);
}
void main(void)
{
Sir Syed University of Engineering & Technology

22

Chapter # 2
char

Technical Data
loop = 0;

unsigned char deg_c = 0;


float

deg_f = 0;

unsigned char Instruction;

//

TransmitAscii(155);
Intilize();
IntilizeTimer();
relay = 0;
Location(1,2);
LCDString("Deg C$");
Location(2,2);
LCDString("Deg F$");
while(loop == 0)
{
Location(1,8);
deg_c = GetADC();
Instruction = Receive();
if (Instruction != '%')
{
switch (Instruction)
{
case 'Q':
relay = 0;
break;
case 'q':
relay = 0;
break;
case ADDRESS:

Sir Syed University of Engineering & Technology

23

Chapter # 2

Technical Data
relay = 1;
Transmit('$');
break;
case 'd':
TransmitAscii(deg_c);
break;
}
}
PrintChar(deg_c);

//

Location(2,2);

//

PrintInteger(deg_f);

//

deg_c++;

//

deg_f = deg_f + 0.1;

//

deg_c = GetADC();

//

deg_f = C2F(deg_c);
}
}

2.6

Key Specification Of The Project


2.6.1

Vital Statistics

Temperature Range: 37o C, (97-100o F)


Accuracy: 0.5 C.
Sensor: Uses LM 35 in two units B & C, potentiometer used in unit A to show
variation in temperature for dummy reading.
Data Connection: RS-232 PC serial computer interface9600 baud rate.
COM1 connector to computer.
Size Of Main Unit: 3.5" x 2.25" x 1".
Power Supply: 5V battery
Weight: 280 grams (9.9 ounces) including battery
Display: Large, easy to read VGA monochrome LCD.

Sir Syed University of Engineering & Technology

24

Chapter # 3

3.

Project Management

Project Management

April
As soon as project was selected, an extensive research was being done covering all
the aspects of the project. Internet was the primary source to gather information about
working principle and components used in digital thermometer.
May & June
It is also necessary to study and collect data about distributed control system (DCS)
on which basically our project works, study and selection of suitable microcontroller
was the next task to be done.
July & August
Purchasing of components was the next step, which is a long and tedious job with
multiple visits to Electronic market during the period of our semester break. Finally
we selected MCS 89C51 as our controller, several small practical were performed on
it to check its performance.
September
Interfacing of MCS51 with ADC and LCD was the next task to be performed by us,
which is not the easy job because firstly experiment with ADC had to be done then the
interfacing and then test codes for ADC was performed. Same procedure was applied
for LCD, after experiment with LCD module interfacing was done and then test codes
for LCD module.
October
To complete the analog part Designing and fabrication of PCBs was done by taking
help with our supervisors Madam Uzma and Madam Shafia. Fabrication of PCBs
required much time in the mean while we acquire knowledge about RS 232 port and
Max232 port for serial communication.

Sir Syed University of Engineering & Technology

25

Chapter # 3

Project Management

November
Assembling of components was done on PCBs so that analog part should be
completed before final semester exams. Programming of C language for
microcontroller was the major step done in this month.
December
Digital part was the next step so test codes for serial communication via
HyperTerminal for LCD and also for PC interfacing for that we require VB
programming. We have faced many problems in interfacing with PC because when
we interface 3 of our modules with computer and on giving 0 1 logic we are getting
noise instead of any result, this actually happens because we do not know the
tristate. After studying the tristate we came to know that the basic logic behind it is
that PC first calls all the modules then it interfaces with one module at a time and the
other two stay at rest , but this is happening so quickly that we are getting all the three
results at the same time.
After the successful testing of project by achieving temperature in Centigrade and in
Fahrenheit on both LCD and on PC, we work on the last step of our project which is
finalizing of our project report and preparing for poster presentation.

Sir Syed University of Engineering & Technology

26

References

Websites
1.

www.linuxfocus.org/English/February2005/article365.shtml -

2.

www.beyondlogic.org/serial/serial.htm -

3.

www.arcelect.com/rs232.html -

4.

www.datasheetcatalog.com/datasheets_pdf/L/M/3/5/LM35.shtml -

5.

dcs.upc.edu/

6.

www.schneider-electric.co.uk/electricity.nsf/automation-control/hmi-humanmachine-interfaces-

Books
1.

Lakeview.Research.Serial.Port.Complete.2nd.Edition.Dec.2007

You might also like