You are on page 1of 98

N.

Senthil Kumar,
M. Saravanan &
S. Jeevananthan
Oxford University Press 2013

8051 Interface Examples
Oxford University Press 2013
Learning Outcomes
After studying this chapter, you will be able to understand
the following:
Interfacing of the programmable interface IC 8255 and
switches and LEDs with the 8051
Interfacing of analog-to-digital and digital-to-analog
converters
Interfacing of LCD interface, Matrix keyboard and motors
8051 application examples

Oxford University Press 2013
Interfacing 8255 to 8051
When the 8051 is connected to external memory, port 0 (P0) is used
for the lower-order address and data bus and port 2 (P2) is used for
the higher-order address bus.
Since the port 3 pins have an alternative function, the net result is
that only P1 is left for input and output operation.
One way to expand the number of I/O ports is to connect the 8255
programmable peripheral interface with the 8051.
The interfacing of the 8255 with the 8051 is done assuming the 8255
as a memory location, because the 8051 supports only memory-
mapped I/O.
For accessing the external memory in the 8051, the MOVX instruction
is used.
The lower-order address bus and the data bus are multiplexed and are
available in the port 0 pins.
This is de-multiplexed using a latch and the ALE signal.
Oxford University Press 2013
Interfacing 8255 with 8051
Oxford University Press 2013
Interfacing 8255 to 8051
The first step in the general interfacing method is to decide the
addresses for the port.
The 8051 uses 16-bit addresses and the most significant address
lines are used for decoding and selecting the device.
Here, the higher-order address bus from port 2 is given to a
decoder logic circuit.
From the decoder, the 8255 chip select signal is generated.
The 8255 needs four addresses for interfacing with any
processorthree for the ports A, B, and C and one for the control
register.
The lower-order address lines A0 and A1 are connected to select
one of these four registers. The read and write control signals are
available from the port 3 pins P3.7 and P3.6.
Oxford University Press 2013

Interfacing of Push button switches
and LEDs
The simplest input and output device that can be interfaced to
any microprocessor is the push button switches and Light
Emitting Diodes (LEDs).
The example here is considering 4 push button switches
interfaced to one port of 8051 and four LEDs connected to
another port.
The switches are connected in such a way that when it is open,
it connects a logic 0 i.e. 0Volts to the port and when it is
closed, it connects logic 1 i.e. 5Volts to the port pins.
Oxford University Press 2013
Interfacing of switches to port pins
Oxford University Press 2013
Interfacing of Push button switches
and LEDs
The circuit connections are shown in Figure are such that the
port is not damaged and also the port is not sourcing over
current. This ensures safe operation of the ports and switches.
An LED gives out light illuminating when it is forward biased
and has enough current flowing through it. LED indicators are
easy to interface with the microcontrollers as output device.
LEDs can be driven with a minimum current of about 10mA. A
driver IC can be used for illuminating LEDs.
Oxford University Press 2013

Interfacing LED with driver to port
pins
Oxford University Press 2013
Figure shows a method of using an inverter driver for
connecting ports to LEDs.
Description
When logic 1 is given out on the port pin, it will be inverted
by the inverter and will connect ground (logic 0) to the
cathode of LED. This will forward bias the LED and light will
be given by LED.

Oxford University Press 2013
Interfacing of 4 switches and 4 LEDs
Oxford University Press 2013
Figure shows the interfacing of 4 Switches to port 3 pins and 4 LEDs
to Port1 pins of 8051.
The inverter driver IC 74240 is used to drive the LEDs. Even though
only 4 LEDs are shown connected in Figure 12.4, we can connect 8
LEDs as 74240 has eight inverter drivers.
The program to display the contents of 4 switches on to the LEDs is
as followed.

Description
Start: MOV A, P3
MOV P1, A

When logic 1 is sensed on port 3 line, the same data is given
as output on port 1 lines. When logic 0 is sensed, the same is
given on port 1lines. The LEDs will not be illuminated now as
the LEDs are not forward biased.

Oxford University Press 2013
Interfacing of Seven Segment
Displays
Seven segment displays consist of seven LED segments. The seven
segments are arranged in the form as shown in figure and the
display of various digits is also shown in the same figure.
Seven segment displays are available in a single dual line in
package.
There are each pin for each segment and these pins are named
from a to f and another LED is available for decimal point.
In addition to these eight pins, the seven segment displays have
one more pin for power supply.
Seven segment displays come in two types either in common
anode or common cathode.
Oxford University Press 2013
Interfacing of Seven Segment
Displays
In common anode display, the anode of all segment LEDs are
tied together and taken out.
So, to illuminate a segment, the common anode is
connected to the supply and then the segment input i.e. a to
f is connected to a low level logic 0.
In common cathode display, the cathodes of all the LEDs are
connected together and taken out.
So, to illuminate a segment, the corresponding segment
input is connected to the high level voltage or logic 1 and the
common cathode is connected to the ground. This will
forward bias the LEDs and illuminate them.
Oxford University Press 2013
Seven Segment Display
Oxford University Press 2013
Interfacing Description
Interfacing of Seven segment displays to 8051
microcontroller needs a driver as shown in Figure. Here
74240 TTL inverter driver IC is used for driving the seven
segment displays.
Also the seven segment display is assumed to be common
anode type. The common anode is connected to the supply
+5V.
The interfacing diagram for displaying the BCD code
obtained from key connected to port3 and displaying the
same in seven segment display connected to port 1

Oxford University Press 2013
Interfacing Switches and seven
segment display to 8051
Oxford University Press 2013
Interfacing Description
The segments can be illuminated
if the segments pins are
connected to the low level of
supply or to ground.
This is done by connecting the
segment inputs of logic 0 through
74240. The 74240 IC will invert the
inputs applied to it. So, if we want
to illuminate a particular segment,
the corresponding output for that
segment has to be logic 1.
The data output for displaying
decimal digits 0 to 9

Oxford University Press 2013
Interfacing ADC chip
The Analog to digital converter are essential in any microprocessor
or microcontroller system for interfacing analog inputs to the
system.
The specifications of the ADC are the range of analog input
voltage, the number of digital bits at the output, resolution, the
conversion time and the number of analog input channels.
The analog input voltage can be either unipolar or bipolar.
Unipolar means the input voltage can have only one polarity like
(0 to +5V) or (0 to +10V).
Bipolar means the input voltage can range from one polarity to
the other like (-5V to +5V) or (-10V to +10V). Most of the ADC
chips come with an option of selecting one of these voltage
ranges using Vref input pins.

Oxford University Press 2013
ADC chip - Description
The ADC chips are available for different number of output
binary bits. ADCs are available with 8 bits or 10 bits or 12 bits
or 16 bits digital outputs.
The number of bits will decide the number of voltage levels
sensed. For example an eight bit ADC will have 28 possible
levels i.e., 256 levels.
The number of bits and the input voltage range will decide the
resolution. The resolution of an ADC is defined as the smallest
change in the input voltage that can be sensed or detected at
the output.
The resolution can be mathematically defined as the range of
input voltage divided by the number of levels at the output.
Oxford University Press 2013
ADC chip - Description
For example, an ADC with the input voltage range of (0
to+5V) with 8 bits at the output will have a resolution of
(5/256) i.e., approximately 19.5mV. The conversion time of
ADCs will be decided by the type of the ADC, and the clock
frequency used in the converter circuits.
Some ADC chips come with an option of having more than
one analog input. One of these analog input channels are
selected using select lines and an analog multiplexer circuit.
Oxford University Press 2013
Interfacing ADC chip - Introduction
The ADC chips also have a sample and hold circuit. The
sample and hold circuit is used to maintain the analog
input voltage constant when the conversion is in progress.
For interfacing of ADC chips with 8051, there are two
possible ways. One is to directly interface ADC chip with
the 8051 parallel ports.
In complex systems, involving many external chips
including memory, an 8255 PPI chip may be interfaced
with the 8051 and the ADC chip can be interfaced with
8051 through 8255.

Oxford University Press 2013
Interfacing ADC chip directly to 8051
Oxford University Press 2013
Interfacing ADC Description
Figure shows the interfacing of ADC 0808/0809 with 8051
directly. ADC 0808/0809 is a commonly used ADC chip with 8
analog input channels and with 8 bit digital output.
The 8 analog inputs are multiplexed and selected using the
three select lines A, B and C.
The select lines are connected to the port 0 LSB three bits.
To the ADC chip, additional inputs +Vref, -Vref, CLK and
supply inputs must be given.

Oxford University Press 2013
Interfacing ADC Description
The ALE and SC pins are tied together and connected to port
pin P0.3. The OE pin is connected to another port 0 pin P0.4
and the end of conversion signal EOC is sensed through P0.5.
The software part follows the flowchart shown in figure The
channel selection signal is first issued to the ADC chip
followed by the ALE/SC signal.
Then the conversion starts within the chip and we get EOC
signal. When EOC signal is received, the program issues OE
signal and the reads the data from the data lines connected
to Port 1.

Oxford University Press 2013
Flowchart
Oxford University Press 2013
Program
Oxford University Press 2013
Interfacing DAC chip
Digital to analog converters are used to get a proportional
analog voltage or current for the digital data given out by the
microprocessor.
The common digital to analog converter chip DAC 0800 is
considered in this interface example. This section will describe
the interfacing of DAC 0800 with the 8051 microcontroller. Any
one port is enough to interface an 8-bit DAC with 8051.
The data lines of the DAC chip is connected to the Port 1 lines
of the microcontroller 8051.
The Port 1 lines should now be made as output lines.
The output from the DAC chip is in the current variation and
this is converted in to voltage variation using a current to
voltage converter.
Oxford University Press 2013
Interfacing DAC 0800 to 8051
Oxford University Press 2013
Interfacing Matrix keypad
Matrix keypad is organised as matrix connection of switches.
Mechanical switches have a problem called Contact Bounce
because of their construction.
Pressing a mechanical switch must produce a single pulse
output.
Practically, instead of producing a single clean pulse output,
the switches generate a series of pulses because the switch
contacts do not come to rest immediately.
Oxford University Press 2013
Key debouncing
As the microprocessor is faster than manual key pressing,
the single key pressed will be registered as multiple key
presses. This is the main disadvantage of key bouncing.
The signal from keys falls and rises a few times within a
period of about 5ms as the contact bounces.
So, the signal from the key must be must be made free from
key bouncing transients. This technique is called as
Debouncing of key.
Oxford University Press 2013
Solution Key debouncing
Key board debouncing can be accomplished in hardware or
software. The bouncing of key signals occur within 5ms.
A human cannot press and release a switch in less than
20ms. A debouncing logic will check the signal after 20ms
and then recognize whether a key is pressed or not.
This logic can be implemented in hardware or software.
Oxford University Press 2013
Solution Key debouncing
The hardware techniques employ SET-RESET flip flops or
Non-inverting CMOS gates or integrating debouncer.
The software technique uses the wait and see method.
When signal from a switch is sensed, the program will wait
for 10ms and look at the same key again.
If the signal form the switch still indicates the key press,
then the program decides that the user has pressed the key.
Otherwise the signal received is rejected as noise.

Oxford University Press 2013
Matrix keyboard interfaced to 8051
Oxford University Press 2013
Description
The software for this application does a column scan with
zero level from P1.0 to P1.3 pins of PORT1 and detects which
key was stroke checking in which row (P2.0 to P2.3 of PORT
2) the zero level appear.
Scanning a row is achieved by applying 0 V to the port 1 pin
and 5 V to the other three port 1 pins, then scanning each
individual port 2 pins to see if one of them is LOW.
If it is, then the key at the junction between the row and
column being scanned is the pressed key.
Oxford University Press 2013
Description
An ASCII code corresponding to each key (0, 1, 2, 3, ... , 9, A,
B, C, D, E, F) can be assigned to each key. The SCAN
program given below uses the look up table concept to get
the ASCII value for the key pressed and returns the same in
R2 register.
The routine includes the software delay routine of 20ms in
order to solve the keyboard debouncing problems.
The procedure for finding a key pressed follows the steps
given below.

Oxford University Press 2013
Steps Key Pressed
Clear P1.0, set other 3
Scan P2.0
Scan P2.1
Scan P2.2
Scan P2.3
Clear P1.1, set other 3
Scan P2.0
Scan P2.1
Scan P2.2
Scan P2.3

Oxford University Press 2013
Steps Key Pressed
Clear P1.2, set other 3
Scan P2.0
Scan P2.1
Scan P2.2
Scan P2.3
Clear P1.3, set other 3
Scan P2.0
Scan P2.1
Scan P2.2
Scan P2.3

Oxford University Press 2013
Program
Oxford University Press 2013
Program
Oxford University Press 2013
Program
Oxford University Press 2013
Description
This software can also be modified and written using SETB
bit and CLR bit instructions.
A set of 16 flag bits, in the bit addressable internal RAM
region can be used to store the bit information of which key
was pressed, and this can be used by main software routine.


Oxford University Press 2013
Interfacing Stepper motor
Stepper motors are used for position control applications,
such as for the control of the disk drives and in robotics.
The most common stepper motors have four stator windings
that are paired with a center tapped common shown in
Figure 12.13.
While the conventional motor shaft runs freely, the stepper
motor shaft moves in a fixed repeatable increment, which
allows one to move it to a precise position.
The typical stepper motor considered here has 50 teeth on
the rotor and 8 poles on the stator for a 1.8 step angle.

Oxford University Press 2013
Switching Sequence
Oxford University Press 2013
Interfacing Stepper Motor
The interfacing of four phase stepper motor to 8051 is given
in figure 12.13. The figure shows the four terminals ABCD of
the motor connected to Port 0 pins through the transistor
drivers.
The common terminal of the motor is connected to the
supply. The excitation sequence for the stepper motor is
given in Tables 12.2 and 12.3.
The single phase excitation results in low current through
the motor windings and it is also called wave mode.
In two phase excitation, the excitation current through the
motor winding is high and so it is called as high torque
excitation.
Oxford University Press 2013
Stepper motor connections to 8051
Oxford University Press 2013




LCD Interface to 8051
Modern LCD devices are becoming popular with more and
more number of applications. The main advantage of LCD
over seven segment displays is the ability of LCD to display
numbers, characters and graphics, when LED can display
only numbers and limited characters.
The LCD comes with an internal controller and refreshing
circuit and so the CPU is relieved from the work of refreshing
the display.
The programming of LCD devices is also easier with
predefined control words and addresses. The cost of the LCD
is also declining.
Oxford University Press 2013




LCD Interface to 8051
The general LCD devices have 14 pins .Eight data lines are
used for interfacing LCD with the processor.
The three control signals are RS, R/W and E. RS is used to
select a control register or a data register.
R/W indicates the direction of data flow between the
processor and the display. E signal is used to enable the data
transfer.

Oxford University Press 2013
LCD Display PIN Configuration
Oxford University Press 2013
LCD Interfaced with 8051
The three control signals and eight data lines are interfaced
with the two ports if 8051.
In the interfacing diagram, Port 1 lines are used to transfer
the data and Port 2 lines are used to issue the control signals
from the microcontroller to LCD.

Oxford University Press 2013
LCD Command Codes
The LCD interface can take up many commands or
instructions regarding the display.
These commands have been interpreted which gives all
display commands.

Oxford University Press 2013
LCD Command words
Oxford University Press 2013
LCD Command words
Oxford University Press 2013
LCD Command words
Oxford University Press 2013
LCD Programming
The programming of LCD is done with proper initialization and
writing command words for the initialization.
Every time when a control or command word is written into
the LCD, the RS signal input must be made 0 and R/W must be
made 0 for write operation.
After setting these two signals, the Enable E signal must be
applied as a pulse for the duration of not less than 450ns.
Similarly, when data is written into the LCD device, the RS
signal must be made 1 and R/W must be made 0.
To display characters and numbers, the corresponding ASCII
code is sent to the data registers of LCD display.
Oxford University Press 2013
Interfacing DC motors / Servomotors
An interfacing method for turning on and off a DC motor via
a microcontroller is shown








Oxford University Press 2013
Interfacing DC motors/Servomotors
The above circuit will only work for a 5 V motor. When the
output on port pin is logic 1 i.e. 5V, the p-n-p transistor is off.
This means that the current through the motor is made is
zero.
So, the motor is off. If the port pin output is at logic 0, then
pnp transistor is on. So, the transistor allows the current
through the motor and the motor is on.
If the motor supply voltage is higher, then the circuit shown
is used.
This circuit uses two transistors one pnp and the other npn.
In the circuit, a 12 V DC motor is interfaced to a
microcontroller pin.

Oxford University Press 2013
Circuit diagram for interfacing 12V DC
motor
Oxford University Press 2013
Interfacing DC motors
When the port pin is set i.e. at 5 V, the p-n-p transistor is off
which means the n-p-n transistor is also off.
Therefore there is no path for current through the motor
and the motor is off.
When the port pin is cleared, the p-n-p transistor is on. This
turns on the n-p-n transistor which allows current to flow
through the motor to ground; the motor is on.
The value of R2 needs to be chosen such that it will not be
too high or too low.
Oxford University Press 2013
Interfacing DC motors
High value of R2 will make the current into the base of the n-
p-n transistor to be low so that it will not be enough to turn
on the npn transistor. Too low value of R2 will result too
much current through the motor.
Bi-directional DC Motor control: A circuit diagram for
interfacing a 12V DC motor to a microcontroller in a way that
allows the controller to not only turn on and off the motor
but also to set the direction in which the motor runs when it
is on
Oxford University Press 2013
Circuit diagram for driving 12V DC
motor bidirectional
Oxford University Press 2013
Interfacing DC motors
The circuit is made up of a four transistor H-bridge. To run
the motor in one direction, the transistors T1 and T4 are
turned on and T2 and T3 are turned off.
The left side of the motor is at 12 V and the right side is at
ground and the motor runs in one direction.
To reverse the direction, the transistors T2 and T3 are
turned on and the other two transistors in the H bridge are
off.
Oxford University Press 2013
Interfacing DC motors
If T3 and T2 are on, then the left side of the motor is at
ground and the right side is at 12 V, therefore the motor runs
in the opposite direction.
If both terminals of the motor are at the same voltage, the
motor is off. So, if T1 and T3 are on, both sides of the motor
are connected to 12 V and the motor is off.
If T2 and T4 are on, both sides of the motor are connected to
ground and the motor is off.
Oxford University Press 2013
Interfacing DC motors
The circuit is designed so that T1 and T2 cannot be on at the
same time and T3 and T4 cannot be on at the same time.
This is very important; if T1 and T2 were on at the same time
there would be a short circuit between 12 V and ground and
the transistors would burn out.
The same is true for T3 and T4. The truth table for the circuit
with its two inputs, A and B, is given below.

Oxford University Press 2013
Bidirectional motor control modes
An explanation of the four entries in the table is given below:
Mode 0:
With A at 0 (i.e. ground) T5 is on, which turns on T2; left side of
motor is at ground. A at 0 also means T6 is off. Since there is no
path for current through R3 and R4 there is no voltage drop
across them which in turn mean the base of T1 is at 12 V, hence
it is off.
The right-hand side of the circuit is a mirror image of the left,
therefore with B at 0, T4 is on and T3 is off - hence the right
side of the motor is also at ground; the motor is off.

Oxford University Press 2013
Bidirectional motor control modes
Mode 1:
A is still at 0 which means T1 is still off and T2 is still on; the left
side of the motor is at ground.
With B at 5 V (ie; logic 1 on the port pin which is being used for
B) T7 is off which means T4 is off. But T8 is on, which generates
a path for current through T8 to ground and also through R9 to
the base of T3. There is a certain amount of voltage dropped
across R9, but the base of T3 is close enough to ground for T3
to turn on; the right side of the motor is at 12 V.
The motor is therefore on and we stated above that ground on
the left of the motor and 12 V on the right would be called
reverse.

Oxford University Press 2013
Bidirectional motor control modes
Mode 2:
This is the mirror image of mode 1, resulting in T1 on, T2 off, T3
off and T4 on; hence the left side of the motor is at 12 V and
the right side is at ground - the motor runs forward.
Mode 3:
As in mode 2, with A at 5 V the left side of the motor is at 12 V.
As in mode 1, with B at 5 V the right side of the motor is at 12
V.
Therefore the motor is off.

Oxford University Press 2013
Microcontroller Application
Example - Stopwatch
Figure shows the complete circuit diagram for a stop watch.
The circuit basically consists of 4 sets of seven segment LEDs
connected through the BCD to seven segment display code
converter.
This code converter IC 7448 can also act as a driver for
display segments. The other circuit arrangements are for
power ON reset and clock signals.
Oxford University Press 2013
Circuit diagram for Timer/ Stopwatch
Oxford University Press 2013
Circuit - Description
The circuit with R and C will have zero volts when the power is
OFF. When the power is switched ON, the capacitor will start
charging and will gradually rise towards the supply voltage of
5V.
This will apply a logic high voltage of 5V and gradually
decreasing towards 0V at the RST pin.
The RST is the active high reset signal and has to be applied for
at least 24 clock periods. The RC combination and the time
constant will ensure that the active high reset signal is applied
for at least 24 clock periods.
The microcontroller chip has in built clock oscillator and it is
enough to connect the crystal to the XTAL1 and XTAL2 pins.
Oxford University Press 2013
Circuit - Description
The circuit consists of 4 seven segment displays. For
displaying numerals in the 4 displays, we have to connect the
pins of two ports to the display code converter.
Here, the port pins of P0 and P1 are used. The BCD data of
the display is given to the port pins.
For the stop watch operation, an additional switch is needed
to switch on and off counting in the stopwatch.
A separate push to on switch is connected to the LSB of
Port2.
The voltage on this pin can be sensed to control the counting
and displaying in the seven segment displays
Oxford University Press 2013
Circuit - Description
The software part of the stopwatch consists of having a
timer register incremented at regular intervals. The interval
can be programmed to be either (1/10)th of a second or
even 1 second.
With the interval of (1/10)th of a second and 4 digit display,
the hardware arrangement can be used to count up to 999
seconds with another digit for (1/10)th of second.
With the interval of 1 second, the hardware arrangements
can count up to 9999 seconds.
The timer register can be programmed to generate an
interrupt after every interval.
Oxford University Press 2013
Circuit - Description
The flowchart for the stopwatch example is given in the
figure . The programming part consists of first initialising a
timer for the required time interval.
The display is also initialized to display all zeros. Then, the
status of the switch is sensed from the port 2 LSB.
If the switch is pressed, then the program moves to the next
step of starting the timer and giving data output to the
displays.
Oxford University Press 2013
Flowchart for the stopwatch
Oxford University Press 2013
Flowchart - Description
Otherwise, the program keeps looping in the status check on
P2.0. After every timer overflow, the data for display is
incremented and the data is converted in to the BCD data.
The new data is given to the port pins by writing them to the
port registers. The increment of data in the display occurs
until the switch on the P2.0 is pressed.
The hardware, flowchart and the program can be improved
further to have more additional features like resetting the
display, separate switches for start and stop of stopwatch,
using press to on and press to off of stopwatch, etc,.

Oxford University Press 2013
Microcontroller Application -
Traffic light control
Oxford University Press 2013
Figure shows the basic traffic control signals at a four road
junction. The following assumptions are made for designing
the traffic light control.
There are free left turns in all the four directions..
Each sequence will again will have two combinations of
traffic signals - one for red and Green combination and other
for red, green and yellow combination.
Traffic light controls at four road
junction
Oxford University Press 2013
Traffic light control sequence 1
Oxford University Press 2013
Traffic light control sequence 2
Oxford University Press 2013
Traffic light control sequence 3
Oxford University Press 2013
Traffic light control sequence 4
Oxford University Press 2013
Hardware connection diagram for
Traffic lights
Oxford University Press 2013
Description
The traffic light control using microcontroller can be done
easily by using parallel ports. The port pins can be connected
to each light or LED or group of LEDs through a proper driver
circuit.
The data in the parallel port can be changed using the
program for turning ON and OFF of the proper lights.
Figure shows the connection diagram for all the lights -
assumed here as LEDs. The port pins of Port 0 and port 1 are
used. Port 0 LSB three bits are used for West direction. Port
0 pins 3, 4, 5 are used North direction.
Oxford University Press 2013
Description
Similarly, Port 1 LSB 3 bits are used for lights in East direction
and pins 3, 4, 5 are used for south direction.
The reset pins and clock inputs are connected to the
corresponding circuit.

Oxford University Press 2013
Data for Port Pins for Traffic Light
Control
Oxford University Press 2013
Microcontroller Application -
Thermometer
Temperature measurement is one of the most common tasks
in the industries.
The thermistor (temperature-sensitive resistors) is an
electrical component capable of measuring temperature
variations, relying on the change in its resistance with
changing temperature.
Once calibrated against the thermistor equation, it is
possible to electronically determine the temperature around
the thermistor, by measuring the change in voltage across it
as its resistance changes.

Oxford University Press 2013
Thermometer - Introduction
The thermistors operate in the limited temperature range
(typically -80 to 150C). The significant advantages of
thermistor as a tool for temperature measurement are
A large output signal that results in better precision
Greater stability, providing accurate performance for longer
periods of time
Higher accuracy than thermocouples in mid-range
temperatures

Oxford University Press 2013
Thermometer - Introduction
Most thermistors have a negative temperature coefficient
(NTC), meaning the resistance goes up as temperature goes
down.
Of all passive temperature measurement sensors,
thermistors have the highest sensitivity (resistance change
per degree of temperature change).
Thermistors do not have a linear temperature/resistance
curve. The nonlinear curve of resistance against temperature
is given in figure.
The figure shows the normalized resistance variation with
reference to resistance at 25C.

Oxford University Press 2013
Resistance variation of Thermistor
with Temperature
Oxford University Press 2013
Thermometer - Introduction
Oxford University Press 2013
The Steinhart-Hart equation is widely used to approximate the
temperature, T, of a thermistor as a cubic function of the
logarithm of its resistance, RT. It is written as


where a, b, and c are physical constants depending on the system.
Within the small temperature range of 30 to 100 degree Celsius, the
further linear approximation as followed can be done.

Circuit - Description
Figure shows a simple circuit that could be used to allow a
microprocessor to measure temperature using a thermistor.
A resistor (R1) pulls the thermistor up to a reference voltage.
This is typically the same as the ADC reference, so Vref
would be 5V if the ADC reference were 5V.
This thermistor circuit has a nominal resistance value of 10
k at 25C, and varies from 330 k at 40C down to 200
at 150C, a range of 1650:1. Such a huge dynamic range in
output resistance can make measurement difficult.

Oxford University Press 2013
Simple circuit to measure
temperature using thermistor
Oxford University Press 2013
Circuit - Description
It's possible to perform a "good enough" linearization by
adding some very inexpensive circuitry.
One way is to incorporate the thermistor into a Wheatstone
bridge
But this arrangement provides an essentially linear output
voltage in response to small changes in resistance.
The linearity in the desired range of temperature can be
achieved by changing the value of R in the bridge circuit.
Oxford University Press 2013

Circuit diagram for temperature
measurement using Microcontroller
Oxford University Press 2013
Description
Figure shows the complete interfacing arrangement for the
temperature measurement using the thermistor and an ADC
with 8051 microcontroller.
The ADC 0804 is used in this circuit. This is an ADC chip with
single analog input.
The commonly used pins alone are shown in the figure. The
analog input can be converted into digital equivalent by
providing a Start Conversion (SC) signal to the ADC chip.
The end of Conversion can be sensed on a separate port pin.
After the end of conversion, the data on the DB0- DB7 lines
can be read by applying a Read signal to the RD pin of ADC
chip.
The digital data received can be properly converted into the
display data and can be given to the LCD screen.

Oxford University Press 2013
Algorithm
The software part of this temperature measurement routine
will have the following steps.
Clear Display
Give start Conversion signal
Check for End of Conversion
Read data from ADC (temperature)
Convert to corresponding display data of temperature using
the look-up table concept
Display temperature

Oxford University Press 2013
Algorithm
The algorithm explained above uses the simple I/O interface.
The program can be made more efficient by using Interrupts.
The End of Conversion (EOC) signal can be connected to an
interrupt input of the processor.
At every end of conversion, the program can read and
display temperature and once again initiate the conversion
process.
The circuit arrangement shown in figure can be used for any
measurement.
Instead of thermistor and bridge arrangement, proper circuit
must be provided for the measurement of the physical
quantities.

Oxford University Press 2013

You might also like