This is only a preview of the April 2022 issue of Practical Electronics. You can view 0 of the 72 pages in the full issue. Articles in this series:
|
Circuit Surgery
Regular clinic by Ian Bell
The LM35 temperature sensor
I
n this month’s article we look
at the LM35 – a widely used temperature sensor integrated circuit (IC) –see
this month’s Flowcode article on p.49.
Temperature is one of the most frequently measured physical quantities and
is commonly used as an input to microcontroller unit (MCU) based systems (and
embedded systems in general). Typically,
a (contact) temperature sensor produces
an analogue signal (voltage or current)
which varies in a well-defined way with
the temperature of the sensor. This can be
converted to a digital representation by
an analogue-to-digital converter (ADC),
which may be built into the MCU, be
part of a temperature-sensing IC, which
communicates with the MCU digitally; or
it may be a separate converter chip. The
MCU reads the ADC (directly or indirectly)
to obtain a binary number related to the
temperature of the sensor. Usually, this
number must be processed in some way
to obtain the temperature value on a standard scale, such as degrees Celsius (°C).
The complexity or processing required depends on the type of sensor
used and the accuracy of measurement
needed – one advantage of the LM35
is the straightforward relationship between its output and temperature being
measured. Although processing is more
complex if code is used to compensate
for accuracy variation with temperature.
Of course, analogue-output sensors can
also be used in circuits which do not
require an MCU or any code to be written – for example, analogue temperature
switches and controllers.
In an MCU system using an analogue
sensor IC, such as the LM35, the ADC,
which may be on the MCU chip or external, must be set up correctly. This
includes setting the reference voltages
which determine the ADC’s conversion
range. The output voltage range from
a typical temperature sensor may be
smaller than the default input range of
the ADC, so if the ADC range is not adjusted then the full ADC resolution will
not be used. Correct ADC setup is also
important when using other analogue
temperature sensors.
46
Sensor choices
In general, when designing a temperature
measurement system, a decision has to
be made on what type of sensor is to be
used – there are several to choose from. A
broad category is contact and non-contact
sensors. The most common approach to
non-contact temperature sensing measures
infrared radiation and includes pyrometers and thermal imaging cameras, both
of which measure the temperature of the
surface of the object they are ‘looking at’.
Contact temperature sensors include
thermistors, thermocouples, resistance
temperature detectors (RTDs) and IC
temperature sensors. These devices are
all fundamentally based on electrical
properties of materials which vary with
temperature in predictable ways that can
be calibrated to provide a useful measurement. The devices vary in terms of
their basic physics as well as the materials and fabrication processes used to
build them. The advantage of ICs over
the other devices listed is in their enhanced functionality and/or simplicity
of use, but they cover a narrower range
of temperatures than sensors such as
thermocouples and cannot achieve the
accuracy of the best RTD circuits.
Temperature sensor ICs fall into two
main categories – those that output an
analogue signal (usually voltage) directly related to temperature and those with
The LM35
sensor
digital interfaces.
Thetemperature
latter are convenient in microcontroller systems with
relatively low accuracy requirements, but
will require the user to manage the digital interface (such as an SPI or I2C bus).
developing a sensor (like the LM35) is to
obtain a linear, and well-controlled dependence between temperature and device
output over a wide temperature range.
An ordinary diode (PN junction) can
be used as a temperature sensor, since its
forward voltage changes by approximately –2mV/°C. Improved accuracy can be
obtained by using two diodes (or transistor base-emitter junctions) – the voltage
difference between two PN junctions,
operated at different current densities,
varies linearly with absolute temperature.
This temperature sensitivity has been exploited for many temperature sensor ICs,
such as the LM34, LM35, LM50, LM60,
LM61, MCP9700, MCP9701, TMP35,
TMP36, TMP37 and TSIC301.
Other approaches are also used. For
example, the AD22100 and AD22103 use
a temperature-dependent resistor. The
LMx35 series (x is 1,2,3) are like zener
diodes with breakdown voltages directly
proportional to absolute temperature at
10mV/K. The LM135’s range is from −55°C
to 150°C. There is also the AD950, which
is a two-terminal device. This has a linear
current output of 1µA/K (again, a kelvin
scale) with a supply of 4V to 30V over a
measurement range of −55°C to +150°C.
How the LM35 Works
We can relate the emitter current (IE) of
a bipolar transistor to its base-emitter
voltage (VBE) using the basic form of the
Ebers-Moll equation:
𝐼𝐼! = 𝐼𝐼" exp &
𝑞𝑞𝑞𝑞#!
+
𝑘𝑘𝑘𝑘
Here, IS is the reverse saturation current
of the base-emitter
𝑘𝑘𝑘𝑘
𝐼𝐼! PN junction, which is
ln & +individual transistor; q
#! =
a 𝑞𝑞
property
Many IC temperature sensors, like the
𝑞𝑞 of the
𝐼𝐼"
is the electronic charge (the charge on one
LM35, are based on the temperature-deelectron, which is a physical constant); k
pendent behaviour of semiconductors,
is𝑘𝑘𝑘𝑘
Boltzmann’s
constant
specifically
theLM35
PN-junction
found
in
The
temperature
sensor
𝐼𝐼!$
𝑘𝑘𝑘𝑘
𝐼𝐼!%(another physical
𝛥𝛥𝑞𝑞#! =
ln & and
+ − T islnthe
& absolute
+
constant);
temperadiodes and bipolar transistors. Circuit de𝑞𝑞
𝐼𝐼"
𝑞𝑞
𝐼𝐼"
ture (in kelvin). The equation applies for
signers often spend a lot of effort trying
𝑞𝑞𝑞𝑞#!
relatively
large
currents (IE >> IS).
to overcome the effects of temperature on
𝐼𝐼! = 𝐼𝐼" exp
& emitter
+
𝑘𝑘𝑘𝑘
𝐼𝐼
𝐼𝐼
𝑘𝑘𝑘𝑘 be rearranged
𝐼𝐼!$
transistor circuits (see the December 2021
This!$
equation
to give
!% 𝑘𝑘𝑘𝑘 can
𝛥𝛥𝑞𝑞#! =
𝑙𝑙𝑙𝑙 & 2 + =
𝑙𝑙𝑙𝑙 & +
and January 2022 Circuitry Surgery articles
the
base-emitter
voltage:
𝑞𝑞
𝐼𝐼" 𝐼𝐼"
𝑞𝑞
𝐼𝐼!%
on logarithmic and exponential amplifi𝑘𝑘𝑘𝑘
𝐼𝐼!
ers) – temperature-dependent signals are
𝑞𝑞#! =
ln & +
𝑞𝑞𝑘𝑘𝑘𝑘 𝐼𝐼"
not hard to obtain, but the challenge when
𝛥𝛥𝑞𝑞#! =
𝑙𝑙𝑙𝑙(𝑁𝑁)
𝑞𝑞
Practical Electronics | April | 2022
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝑘𝑘𝑘𝑘
𝐼𝐼!%
𝛥𝛥𝑞𝑞#! =
ln & + −
ln & +
𝑞𝑞𝛥𝛥𝑞𝑞 =
𝐼𝐼" 𝑞𝑞 𝑞𝑞
𝐼𝐼"
#!
&'('
Principles of operation
𝑘𝑘𝑘𝑘
𝐼𝐼!$ 𝐼𝐼!%
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝛥𝛥𝑞𝑞#! =
𝛥𝛥𝑞𝑞#! =
I
I
I/2
I/2
Q1a
2E
E
Q1b
Q2
∆VBE
IE
0V
Fig.1. Concept circuit for obtaining VBE
from two transistors with scaled sizes.
In which ln() is the natural logarithm
35 temperature sensor
function, the inverse of the exponential function. If we have two transistors
𝑞𝑞𝑞𝑞#!currents (IE1 and
with different emitter
𝐼𝐼! = 𝐼𝐼" exp &
+
I
)
and
we
assume
the transistors are
𝑘𝑘𝑘𝑘
E2
M35 temperature sensor
at the same temperature (T) and closely matched in terms of their physical
𝑘𝑘𝑘𝑘
𝐼𝐼!= I = I ) then the
characteristics
(solnIS1
S2
S
𝑞𝑞#! =
&&𝑞𝑞𝑞𝑞
+#!
= 𝐼𝐼𝑞𝑞" exp
𝐼𝐼"𝑘𝑘𝑘𝑘 +base-emitter
difference𝐼𝐼!between
their
voltages ( VBE) is:
𝛥𝛥𝑞𝑞#! =
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝑘𝑘𝑘𝑘
𝐼𝐼!%
ln
&= 𝑘𝑘𝑘𝑘
+ −ln &𝐼𝐼!ln+ & +
𝑞𝑞
#!
𝑞𝑞
𝐼𝐼" 𝑞𝑞 𝑞𝑞 𝐼𝐼
𝐼𝐼"
"
We are subtracting two logarithms, which
𝑘𝑘𝑘𝑘 𝑘𝑘𝑘𝑘
𝐼𝐼!$ 𝐼𝐼𝐼𝐼!%
𝑘𝑘𝑘𝑘
!$
𝐼𝐼𝐼𝐼!%
!$+ = 𝑘𝑘𝑘𝑘 𝑙𝑙𝑙𝑙
is#!equivalent
𝛥𝛥𝑞𝑞
= #! =
𝑙𝑙𝑙𝑙 & lnto
2& dividing
𝛥𝛥𝑞𝑞
+ − 𝑞𝑞 lnby
&&𝐼𝐼 the
++ sub𝑞𝑞
𝐼𝐼
𝐼𝐼
𝑞𝑞 "inside
𝐼𝐼"" the𝑞𝑞logarithm.
𝐼𝐼!%
tracted value
So,
"
we can write:
𝑘𝑘𝑘𝑘 𝐼𝐼!%
𝑘𝑘𝑘𝑘 =𝐼𝐼!$
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝛥𝛥𝑞𝑞#! = 𝛥𝛥𝑞𝑞#!
𝑙𝑙𝑙𝑙 & 𝑞𝑞 2𝑙𝑙𝑙𝑙(𝑁𝑁)
+=
𝑙𝑙𝑙𝑙 & +
𝐼𝐼" 𝐼𝐼"
𝐼𝐼!%
𝑞𝑞
𝑞𝑞
The transistor matching can be achieved
𝛥𝛥𝑞𝑞#! = 𝑞𝑞𝑘𝑘𝑘𝑘
&'('
with correct𝛥𝛥𝑞𝑞
layout
and
fabrication of tran𝑙𝑙𝑙𝑙(𝑁𝑁)
#! =
sistors on the same𝑞𝑞IC (it is much more
difficult with discrete transistors). The
result is the difference in VBE only depends
𝛥𝛥𝑞𝑞 = 𝑞𝑞&'('
on temperature#!and the
emitter current,
not on the transistor characteristic (IS).
35 temperature sensor
This is important because although two
transistors can be matched on a single IC,
𝑞𝑞𝑞𝑞#!will have transisdifferent𝐼𝐼individual
ICs
+
! = 𝐼𝐼" exp &
𝑘𝑘𝑘𝑘
tors with different IS. Furthermore,
IS varies
significantly with temperature, resulting
in complex and variable temperature de𝑘𝑘𝑘𝑘
𝐼𝐼!
pendence𝑞𝑞#!
for=transistors
ln & +across multiple
𝑞𝑞
𝐼𝐼" possible to make
ICs. This means it is not
an accurate temperature sensor based on a
single transistor,
but using
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝑘𝑘𝑘𝑘 the
𝐼𝐼!%difference
between
IC is
𝛥𝛥𝑞𝑞#! = twolntransistors
& + − on
ln &a single
+
𝑞𝑞
𝐼𝐼"
𝑞𝑞
𝐼𝐼"
a viable approach.
PTAT𝑘𝑘𝑘𝑘
𝐼𝐼!$ 𝐼𝐼!%
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝛥𝛥𝑞𝑞
& 2 currents
+=
𝑙𝑙𝑙𝑙
If#!
the= two𝑙𝑙𝑙𝑙emitter
are& set+ to be
𝑞𝑞
𝐼𝐼" 𝐼𝐼"
𝑞𝑞
𝐼𝐼
in a fixed ratio (N), that is I E2!%= NI E1,
then we get:
𝛥𝛥𝑞𝑞#! =
𝑘𝑘𝑘𝑘
𝑙𝑙𝑙𝑙(𝑁𝑁)
𝑞𝑞
In which ln(N), k and q are constant, so
VBE is proportional
to absolute temper𝛥𝛥𝑞𝑞#! = 𝑞𝑞&'('
ature with a positive relationship ( VBE
Practical Electronics | April | 2022
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝑘𝑘𝑘𝑘
𝐼𝐼!%
ln & + −
ln & +
𝑞𝑞
𝐼𝐼"
𝑞𝑞
𝐼𝐼"
𝑘𝑘𝑘𝑘
𝐼𝐼!$ 𝐼𝐼!%
𝑘𝑘𝑘𝑘
𝐼𝐼!$
𝑙𝑙𝑙𝑙 & 2 + =
𝑙𝑙𝑙𝑙 & +
𝑞𝑞
𝐼𝐼" 𝐼𝐼"
𝑞𝑞
𝐼𝐼!%
increases with increasing temperature). This is
𝑘𝑘𝑘𝑘
referred
to
as a ‘Voltage
𝛥𝛥𝑞𝑞
𝑙𝑙𝑙𝑙(𝑁𝑁)
#! =
𝑞𝑞
Proportional
to Absolute
Temperature’, or VPTAT:
𝛥𝛥𝑞𝑞#! = 𝑞𝑞&'('
+VS
A1
+
R1
Q1
Q2
A2
–
VO UT =
10mV/°C
V
PTAT
If we have N = 10 (as
0.125R2
used in the LM35) VPTAT
10E
E
nR1
in the above equation is
8.8mV/°C
198µV/°C , which can be
R2
scaled to give 10mV/°C or
I
other convenient ‘round
number’ values (eg, for the
Fahrenheit scale).
0V
Setting up two indepenFig.2. LM35 simplified device schematic (based on Texas
dent currents of ratio N (as
Instruments data sheet).
might be implied by the
above discussion) is not the most practithe voltage across it will be n VBE. As an
cal way to create a temperature sensor. It
end of nR1 is grounded, the voltage at the
is easier to scale the effective size of the
base of Q1 will be a PTAT voltage related
two transistors and ensure exactly the
to the VBE difference. The output of the
same current passes through both of them.
LM35 is derived from the voltage at the
Scaled transistors can be implemented
current source, which is two diode voltage
on ICs using transistors with multiple
drops below Q1’s base voltage (these also
emitters, which is equivalent to multiple
contribute to the final output temperature
parallel (ideally) identical transistors.
coefficient). This voltage is scaled by the
voltage amplifier A2, whose gain is set to
provide a 10mV/°C variation with temSensor circuits
perature at the output.
An example of this principle is shown in
The circuit in Fig.2 can be calibrated
Fig.1. Q1 has two emitters and is representafter fabrication by adjusting nR1 using
ed as two identical parallel devices (Q1a
and Q1b) in Fig.1. Q2 is a single transistor
various trimming techniques, for examidentical to Q1a and Q1b. The circuit is
ple, fuse links across the resistors in a
set up so that the same current (I) flows
series string can be blown to increase
through Q1 and Q2, which means that
the resistance. The calibration sets the
the currents in Q1a and Q1b are both I/2
correct temperature coefficient of the
(the currents split equally between Q1a
output voltage.
and Q1b because they are identical). The
For a more detailed discussion of the
total current is kept constant and well
operation of these devices, including
controlled by the current source IE – the
calibration and nonlinearity compensation (not covered here) refer to LM34/
equality of currents in Q1 and Q2 is enLM35 Precision Monolithic Temperature
sured by circuitry not shown in Fig.1.
Sensors, National Semiconductor AppliThe VBE voltages of Q1a and Q1b must
cation Note 460, October 1986.
be equal due to their parallel connection
and each transistor has a current of I/2
with respect to Q2. Thus, the difference
The LM35 IC and variants
in base-emitter voltages is given by the
The LM35 is a three-terminal device which
VBE equation above, with N = 2, and
has two power pins and an output pin
producing a voltage which, as described
so has a linear dependence on temperaabove, varies linearly with temperature
ture (PTAT).
at 10mV/°C. There are a large range of
The circuit in Fig.2 is a simplified
similar devices, some with similar part
schematic of the LM35. The core of the
numbers such as those listed above. These
circuit, Q1 and Q2 and the current source,
devices vary in various ways, such as the
is configured as in Fig.1, expect that there
temperature scale, supply voltage range,
is a ten-times rather than two-times relaand presence, or otherwise, of a powertionship between the transistors (10E and
saving shutdown pin. Most devices are
E on Fig.2). The differential current-in,
aimed at the Celsius scale, but the LM34
voltage-out amplifier A1 is in a feedback
provides a 10mV/°F output.
loop controlling the difference between
Even with a given basic part number,
the base-emitter voltages ( VBE) so that
such as ‘LM35’, there are quite a few
the collector currents of Q1 and Q2 (A1’s
variants with different packaging (such
inputs) are forced to be equal.
as TO92, TO220, TO46, SOT and SOIC),
The VBE voltage is across R1, so it will
different accuracy ratings and different
cause a current of VBE/R1 to flow through
temperature ranges – not all devices proit. Assuming this is much larger than Q1’s
vide the full datasheet headline range. This
base current (which can be ignored) the
diversity means that care must be taken
same current flows in the resistor nR1, so
47
which can measure
negative temperatures on a single
VO UT
VO UT
+
LM35
LM35
LM35
supply. Examples
VO UT
include the TMP36
0V
–
0V
from Analog Devices
R1
1N914
R1
and the LM50 from
–VS
Texas Instruments.
These devices have
0V
a 10mV/°C output,
like the LM35, but
Left to right (all based on Texas Instruments datasheet):
with a +0.5V offset
Fig.3. Basic LM35 circuit; Fig.4. Full range LM35 circuit; and
(so output 0.5V at
Fig.5. LM35 range extension on a single supply.
0°C, 0.75V at 25°C
and 0.25V at –25°C) which facilitates
when ordering parts. Some variants are
output of voltages representing negasignificantly more expensive than others.
tive temperatures. An example circuit
Using the LM35 and similar devices for the TMP36 is shown in Fig.6. Note
the shutdown pin which is available on
The most basic LM35 circuit is shown in
some package options.
Fig.3. This provides a 10 mV/°C output
over the range 2°C to 150°C (20mV to 1.5V
out) – notice that the lower end of the
Long leads
LM35’s temperature range is not covered
It is not uncommon to need to locate a tembecause the output of the LM35 cannot
perature sensor away from the main circuit
go negative in this circuit. The solution
board. This may make the sensor wiring
is to use a negative supply in the system
susceptible to noise pick-up from various
and wire the LM35 as shown in Fig.4. The
sources. Fortunately, in most situations,
LM35 can only source current (current
temperatures change relatively slowly and
flows out, not in), but with the resistor
appropriate low-pass filtering can reduce
(R1) connected to a negative supply, a
noise without excessively impacting the
measurement process. As usual, shielded
sourced current can result in an output
and/or twisted pair cable should also be
voltage of either polarity with respect to
used for lengthy sensor connections to
ground. The value of R1 is specified in
reduce the amount of noise pickup.
the LM35 datasheet as VS/50µA.
Another issue with long sensor connecIf a negative supply is not available, the
tions, which should not be overlooked, is
circuit shown in Fig.5 can be used. The
the capacitance of the cable. A common
diodes raise the voltage at the ground pin
solution is to use an isolation resistor beof the LM35 above 0V (system ground)
tween the output and capacitive load. The
so the system ground is like a negative
capacitive drive capability varies signifisupply from the perspective of the LM35.
cantly for different integrated analogue
The approach used in Fig.4 can then be
temperature sensors, but in general, the
applied. It may be tempting to assume
series resistor approach is applicable (see
the diodes drop about 0.6V or 0.7V (the
Fig.7) and sensor datasheets may provide
typical assumption), but the LM35 may
advice on appropriate values (this is the
only be consuming 60µA, and at these
case for the LM35 and TMP36). Alternacurrent levels the 1N914 forward drop is
tively, an RC damper may be used (see
in the range 0.45V to 0.5V. If we assume
Fig.8). The series resistor, plus cable ca0.9V total, then the rule for R1 in Fig.4
pacitance, or a damper circuit, also forms
gives the datasheet value for R1 of 18kΩ.
a low-pass filter assisting reduction noise.
The circuit in Fig.5 differs from the one
As with many integrated circuits, it is
in Fig.4 in that the output voltage is not
often a good idea, or even essential, to
referenced to ground. Various approaches
connect one or more supply decoupling
to dealing with this are possible. Just the
capacitors as close as possible to the sensor
normal output pin of the LM35 could be
IC. A typical value is 0.1µF, but the dataused, on the assumption that the diode
sheet should be consulted for the most
drop is constant, subtracting this to get the
appropriate values. The circuits in Fig.7
temperature voltage, but this is very likely
and 8 show typical circuits for using temto be inaccurate as a diode drop value will
perature sensors on long cables. In more
change (eg, with temperature and LM35
extreme situations (very long cables, high
supply current). Better approaches are
electrical noise) converting the sensor voltto use the differential output (as shown)
age to a current for transmission down the
with a differential input amplifier, a difcable may be a better approach.
ferential input ADC, or to measure both
voltages separately (eg, using multiple
ADC channels) and subtract in software.
Layout considerations
The circuit in Fig.5 is not very conThere is more to temperature sensing than
venient, so a better approach with a
the circuit design – the physical strucsingle supply is to use a different chip,
ture is also important to ensure that the
+VS
48
+VS
0.1µF
+VS
+VS
SHUTDOWN
0V
+VS
VO UT
TMP36
GND
0V
Fig.6. TMP36 circuit with −40°C to +125°C
range (based on Analog Devices datasheet).
right temperature is being measured and
device operation is not undermined. The
leads of the device conduct heat to the
chip inside the package, so in situations
where a device is glued to the surface of
an item whose surface temperature is
being measured, the air temperature surrounding the leads may have an unwanted
influence on the reading – particularly
for plastic package devices. The LM35
datasheet advises covering the leads with
epoxy if this might be a problem (if the
surface and air temperatures may be different). Metal package devices are less
problematical in this respect and can be
soldered to metal surfaces being measured, but only if the metal to which it
is attached can be at the device negative
supply lead voltage.
If the device is used to measure liquid
temperature, then arrangements must be
made to keep it and its wiring dry and
electrically insulated from the liquid.
Moisture may also be an issue where cold
temperatures are being measured and
condensation may occur on the device
or surrounding circuitry – suitable coatings can help in these situations.
+VS
C1
Sensor
VO UT
R1
Long cable
0V
Fig.7. Analogue integrated temperature
sensor on long cable with decoupling
capacitor C1 and load capacitance
isolation resistor R1.
+VS
C1
Sensor
VO UT
R1
Long cable
C2
0V
Fig.8. Analogue integrated temperature
sensor on long cable with decoupling
capacitor C1 and RC damper (R1 and C2).
Practical Electronics | April | 2022
![]() ![]() |