Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

10
Sensors and Actuators A 121 (2005) 78–87 Accuracy and resolution of direct resistive sensor-to-microcontroller interfaces Ferran Reverter , Josep Jordana, Manel Gasulla, Ramon Pall` as-Areny Instrumentation, Sensors and Interfaces Group, Technical School of Castelldefels (EPSC), Department of Electronic Engineering, Technical University of Catalonia (UPC), Avda. del Canal Ol´ ımpic s/n Edifici C4, 08860 Castelldefels (Barcelona), Spain Received 28 July 2004; received in revised form 11 January 2005; accepted 11 January 2005 Available online 16 February 2005 Abstract This paper analyses the accuracy and resolution of direct resistive sensor-to-microcontroller interfaces using theoretical and experimental methods. Three calibration techniques are evaluated: single-point, two-point and three-signal. This last method is a two-point calibration technique that needs a single calibration resistor. For each calibration formula, we analyse both the effects of the internal resistances of the microcontroller pins on the accuracy and the resolution, which is evaluated by the combined standard uncertainty of the calculated resistance. The experimental analysis was performed by measuring resistors in the range of Pt1000-type temperature sensors with two commercial microcontrollers (AVR AT90S2313 and PIC16F873). The experimental results were similar for both microcontrollers and agreed with theoretical predictions. For the AVR, the three-signal measurement method yielded a 0.01% relative systematic error and a 0.10 resolution when averaging 10 calculated resistances. © 2005 Elsevier B.V. All rights reserved. Keywords: Microcontroller; Sensor interface; Resistive sensor; Resistance measurement 1. Introduction Several applications notes from different microcon- troller manufacturers propose direct resistive sensor-to- microcontroller interfaces, which use neither a signal con- ditioning circuit nor an analogue-to-digital converter, thus resulting in a simple, compact and low-cost solution. Nev- ertheless, the design rules, accuracy and resolution of these interface circuits have not been either analysed or reported in detail. Direct resistive sensor-to-microcontroller interfaces rely on measuring either the charging [1–4] or discharging time [5–7] of an RC circuit. Current-day microcontrollers often include timers/counters that can easily perform the timing process, which stops when the exponential waveform reaches the digital threshold of an input port pin. In general, that input pin includes a Schmitt-trigger (ST) buffer with a lower (V TL ) Corresponding author. Tel.: +34 934137090; fax: +34 934137007. E-mail address: [email protected] (F. Reverter). and an upper (V TH ) threshold voltage. The noise voltage su- perimposed on V TL is smaller than that on V TH and, hence, the measurement of the discharging time has a smaller variability than that of the charging time [8]. Moreover, microcontroller data sheets show that port pins can normally sink more cur- rent than they can source. For these reasons, only interface circuits based on the measurement of the discharging time are analysed here. The value of the capacitor used to generate the exponential waveform plays an important role in those interface circuits. Short time constants provide a fast measurement, whereas long time constants yield a higher resolution. However, be- cause of the trigger noise at the stop point of the timing pro- cess, from a given time constant up, large capacitors carry no benefit in terms of resolution [9]. This suggests that there is an optimal time constant offering the best speed-resolution trade-off. Most application notes provided by manufacturers pro- pose a single-point calibration technique. A two-point cali- bration should in principle yield better results, but it is less 0924-4247/$ – see front matter © 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.sna.2005.01.010

Transcript of Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

Page 1: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

A

xperimentalm calibrationt nces of them resistance.

commercialmtw©

K

1

tmdreid

o[iptp

0d

Sensors and Actuators A 121 (2005) 78–87

Accuracy and resolution of direct resistivesensor-to-microcontroller interfaces

Ferran Reverter∗, Josep Jordana, Manel Gasulla, Ramon Pallas-ArenyInstrumentation, Sensors and Interfaces Group, Technical School of Castelldefels (EPSC), Department of Electronic Engineering,

Technical University of Catalonia (UPC), Avda. del Canal Ol´ımpic s/n Edifici C4, 08860 Castelldefels (Barcelona), Spain

Received 28 July 2004; received in revised form 11 January 2005; accepted 11 January 2005Available online 16 February 2005

bstract

This paper analyses the accuracy and resolution of direct resistive sensor-to-microcontroller interfaces using theoretical and eethods. Three calibration techniques are evaluated: single-point, two-point and three-signal. This last method is a two-point

echnique that needs a single calibration resistor. For each calibration formula, we analyse both the effects of the internal resistaicrocontroller pins on the accuracy and the resolution, which is evaluated by the combined standard uncertainty of the calculatedThe experimental analysis was performed by measuring resistors in the range of Pt1000-type temperature sensors with two

icrocontrollers (AVR AT90S2313 and PIC16F873). The experimental results were similar for both microcontrollers and agreed with

heoretical predictions. For the AVR, the three-signal measurement method yielded a 0.01% relative systematic error and a 0.10� resolutionhen averaging 10 calculated resistances.2005 Elsevier B.V. All rights reserved.

ance m

on-r-to-

con-husev-theseted in

relyeen

ing

a su-p em bilityt rd cur-r rfacec timea

entialw uits.S ereasl be-c pro-c ry no

eywords:Microcontroller; Sensor interface; Resistive sensor; Resist

. Introduction

Several applications notes from different microcroller manufacturers propose direct resistive sensoicrocontroller interfaces, which use neither a signalitioning circuit nor an analogue-to-digital converter, tesulting in a simple, compact and low-cost solution. Nrtheless, the design rules, accuracy and resolution of

nterface circuits have not been either analysed or reporetail.

Direct resistive sensor-to-microcontroller interfacesn measuring either the charging[1–4] or discharging tim

5–7] of anRC circuit. Current-day microcontrollers oftnclude timers/counters that can easily perform the tim

rocess, which stops when the exponential waveform reaches

he digital threshold of an input port pin. In general, that inputin includes a Schmitt-trigger (ST) buffer with a lower (VTL)

∗ Corresponding author. Tel.: +34 934137090; fax: +34 934137007.E-mail address:[email protected] (F. Reverter).

b isa utiont

pb

924-4247/$ – see front matter © 2005 Elsevier B.V. All rights reserved.oi:10.1016/j.sna.2005.01.010

easurement

nd an upper (VTH) threshold voltage. The noise voltageerimposed onVTL is smaller than that onVTH and, hence, theasurement of the discharging time has a smaller varia

han that of the charging time[8]. Moreover, microcontrolleata sheets show that port pins can normally sink moreent than they can source. For these reasons, only inteircuits based on the measurement of the dischargingre analysed here.

The value of the capacitor used to generate the exponaveform plays an important role in those interface circhort time constants provide a fast measurement, wh

ong time constants yield a higher resolution. However,ause of the trigger noise at the stop point of the timingess, from a given time constant up, large capacitors carenefit in terms of resolution[9]. This suggests that theren optimal time constant offering the best speed-resol

rade-off.Most application notes provided by manufacturers pro-

ose a single-point calibration technique. A two-point cali-ration should in principle yield better results, but it is less

Page 2: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

s and Actuators A 121 (2005) 78–87 79

c ce re-s esis-t menti le int electt

, thef rel-a from1i rbr oller,t iffer-e rfacec dif-f

sest r-to-m outb

2

con-s of anR ges:( t. Ont id-i g aht( ichis(b

Ft

tc ght eniW r( thefw

R

T

Ip vertst

N

wt

F. Reverter et al. / Sensor

ost-effective because of the need of two stable referenistors. To evaluate the interest of using two calibration rors instead of one, it is necessary to know the improven accuracy they achieve. This information is not availabhe technical literature, neither are the design rules to she value of the calibration resistors.

With regard to the accuracy of those interface circuitsollowing experimental results have been reported: (a) ative error smaller than 2% when measuring resistorsto 999 k� [4]; (b) an accuracy equal to 0.1◦C for circuits

ntended for Pt500 temperature sensors[5]; and (c) an erroelow 0.5� for resistances from 600 to 3550� [10]. Thoseesults are difficult to compare because the microcontrhe calibration technique and the resistance range are dnt for each case. A comparative analysis between inteircuits intended for a given application implemented byerent microcontrollers has not yet been performed.

This paper theoretically and experimentally analyhe accuracy and resolution of direct resistive sensoicrocontroller interfaces. The experiments are carriedy using two different commercial microcontrollers.

. Operating principle

The direct sensor-to-microcontroller interfaces hereidered are based on measuring the discharging timeCcircuit. This measurement involves two operation sta

a) charging and (b) discharging and time measuremenhe charging stage (Fig. 1a), pin 1 is set as an output provng a digital “1”, whereas pin P is set as an input, offerinigh-impedance (Zin). Therefore, the capacitorC is charged

owardsVDD (positive supply voltage for I/O pins) throughRpinternal resistance of the pin when it provides an “1”), wh

s small enough to obtain a fast charging time. The chargingtage is set to last more than 5RpC. During the second stageFig. 1b), pin 1 is set as a high-impedance input (with an STuffer), pin P is set as an output providing a digital “0”, and

dct

Fig. 1. Equivalent circuit of the interface during (a) the charg

ig. 2. Waveform of the voltage across the capacitor (VC) in Fig. 1 duringhe charge–discharge process.

he embedded timer starts the timing process. Then,C is dis-harged towardsVSS(ground reference for I/O pins) throuhe resistanceRplusRn (internal resistance of the pin wht provides a “0”) resulting in a time constantτ = (R+Rn)C.

hen the voltage acrossC (Vc) reachesVTL, the ST buffewhich is configured to interrupt the main program onalling edge) triggers and the timer stops.Fig. 2 shows theaveform ofVc during the charge–discharge process.The time needed to dischargeC fromVDD toVTL through

plusRn ideally is

0 = (R + Rn)C ln

(VDD − VSS

VTL − VSS

)(1)

f we assume thatVDD,VSS,VTL andCare constant, thenT0 isroportional to the resistance. The embedded timer con

hat time to a digital numberN:

= kR(R + Rn) (2)

herekR is a constant that depends onVDD,VSS,VTL,Candhe time-base of the timer.

The above models consider thatRn is constant during theischarging process and independent ofR. For a CMOS mi-rocontroller,Rn models the channel resistance of the NMOSransistor of the output buffer; hence,Rn can be assumed to be

ing stage and (b) the discharging and time measurement stage.

Page 3: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

8 s and Actuators A 121 (2005) 78–87

c gion[ nitei ed asi naly-s t in an suredt negli-g s oft

3

c yo andm ostly.M ture.C oneo etersa

3

sis-tT rdingt e-m -s P inF r ther cts asp

hicha ea linege

R

Fs

F uit inF

F t,t oR

3

llerii ensorm( e-ma state.

cessw Theca

R∗x = Nx − Nc1

N − N(Rc2 − Rc1) + Rc1 (4)

0 F. Reverter et al. / Sensor

onstant whenever the transistor works in the ohmic re11]. Furthermore, we do not consider the effects of the fimpedance and the leakage current of the pin configurnput during the discharging process. The theoretical ais in [10] shows that these non-ideal parameters resulonlinear relation between the resistance and the mea

ime. Nevertheless, their effects can be expected to beible for a CMOS microcontroller measuring resistance

he order of kiloohms or smaller.

. Calibration technique

From(1), if VDD,VSS,VTL,CandRn are known,Rcan bealculated from the discharging timeT0. However, usuallnly the nominal value of these parameters is knowneasuring each of them would be time-consuming and coreover, these parameters drift with time and temperaalibration yields measurement results that depend onr more reference components rather than on the parambove.

.1. Single-point calibration technique

Fig. 3shows a microcontroller-based interface for a reive sensorRx with a single calibration resistorRc1 [3,4,6,7].he interface circuit performs two measurements acco

o the procedure described in Section2: (a) sensor measurent (Nx) and (b) reference measurement (Nc1). For the sen

or measurement, pin 2 implements the tasks of pinig. 1, and pin 3 is switched to high-impedance state. Foeference measurement, the roles are switched: pin 3 ain P and pin 2 offers a high impedance.

Fig. 4shows the measurement calibration process, wssumes that the relation betweenRx andNx does not havny offset to compensate for. Therefore, the calibrationoes through (0, 0) and (Rc1, Nc1). For any outputNx, the

stimated valueR∗

x is calculated from

∗x = Nx

Nc1Rc1 (3)

ig. 3. Microcontroller-based interface circuit for a resistive sensor using aingle calibration resistor.

F

Ft

ig. 4. Single-point calibration technique applied to the interface circig. 3.

romFig. 4, if the relation betweenRx andNx has an offsehis offset will be compensated only forRx values close tc1.

.2. Two-point calibration technique

Fig. 5 shows a direct resistive sensor-to-microcontronterface with two calibration resistorsRc1 andRc2 [5]. Thenterface circuit performs now three measurements: (a) s

easurement (Nx), (b) first reference measurement (Nc1) andc) second reference measurement (Nc2). For each measurent, the respective pin implements the tasks of pin P (Fig. 1)nd the other two pins are placed into high-impedance

Fig. 6 shows how the measurement calibration proorks when there is offset, gain and nonlinearity errors.alibration line goes through (Rc1, Nc1) and (Rc2, Nc2). Forny outputNx, the estimated valueR∗

x is calculated from

c2 c1

romFig. 6, only nonlinearities remain uncorrected.

ig. 5. Microcontroller-based interface circuit for a resistive sensor usingwo calibration resistors.

Page 4: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

F. Reverter et al. / Sensors and A

F it inF

3

mentm entsi se oftR

R

F ee-s -s rgec dert ortu-n ctualvcm

Fo

4

facec ins.B tivet

N

N

N

w alr ller( li-b

4

R

a

e

a

R

F ea rrorsa fo of

ig. 6. Two-point calibration technique applied to the interface circuig. 5.

.3. Three-signal measurement method

We propose to apply here the three-signal measureethod, which was suggested for capacitive measurem

n [12]. This technique can be considered a particular cahe two-point calibration that uses a short-circuit asRc1 andc2 usually equalsRx,max. Eq.(4) simplifies then to

∗x = Nx − Nc1

Nc2 − Nc1Rc2 (5)

ig. 7 shows the interface circuit when applying the thrignal measurement method.Rc2 is a stable calibration reistor andR0 is an additional resistor to limit the dischaurrent to the maximal current sunk by a port pin in oro ensure a correct exponential discharge waveform. Fately, the calibration process does not involve the a

alue ofR0 and, further, its temperature stability is not criti-al. Consequently, the three-signal method seems in principleore cost-attractive than the two-point method.

ig. 7. Microcontroller-based interface circuit for a resistive sensor basedn the three-signal measurement method.

T alueo .

4

R

w�

e

a

R

ctuators A 121 (2005) 78–87 81

. Accuracy analysis

The main source of systematic error of those interircuits is the internal resistance of the microcontroller pecause of that, ifkR is the same for the three consecu

ime measurements, the digital numbers are

x = kR(R0 + Rx + Rn,2) (6a)

c1 = kR(R0 + Rc1 + Rn,3) (6b)

c2 = kR(R0 + Rc2 + Rn,4) (6c)

here Rn,2, Rn,3 and Rn,4 are the respective internesistances of pins 2, 3 and 4 of the microcontroFigs. 3, 5 and 7). For the single-point and two-point caration techniques,R0 = 0.

.1. Single-point calibration technique

Replacing(6a)and(6b) in (3) yields

∗x = Rc1

Rc1 + Rn,3Rx + Rc1Rn,2

Rc1 + Rn,3(7)

nd, hence, the relative error equals

r = |R∗x − Rx|Rx

=∣∣∣∣ −Rn,3

Rc1 + Rn,3+ 1

Rx

Rc1Rn,2

Rc1 + Rn,3

∣∣∣∣ (8)

nd it will be zero when

x = Rc1Rn,2

Rn,3(9)

rom(7), R∗x =Rx only whenRn,2=Rn,3= 0, otherwise ther

re zero (offset) and sensitivity (gain) errors. These ere of the same magnitude asRn, which is about tens ohms. IfRn,2≈Rn,3, from (9), the relative error will be zer

or Rx≈Rc1 and will increase asRx moves away fromRc1.herefore, a calibration resistor close to the midrange vr to the most probable sensor value seems appropriate

.2. Two-point calibration technique

Replacing(6) in (4) yields

∗x = Rc2 − Rc1

Rc2 − Rc1 + �R43Rx + Rc1�R42 − Rc2�R32

Rc2 − Rc1 + �R43(10)

here �R32 =Rn,3−Rn,2, �R42 =Rn,4−Rn,2 andR43 =Rn,4−Rn,3. Hence, the relative error equals

r =∣∣∣∣ −�R43

Rc2 − Rc1 + �R43+ 1

Rx

Rc1�R42 − Rc2�R32

Rc2 − Rc1 + �R43

∣∣∣∣(11)

nd it will be zero when

x = Rc1�R42 − Rc2�R32

�R43(12)

Page 5: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

8 s and Actuators A 121 (2005) 78–87

F( zeroa gle-p is oft rt eforet an as

a -a ncesa� api therR them ever-t� ento ea ritye tionr if it isq lw oft

4

nalm

5

-c seast un-ci tantl

w rdu

stp

of

ngethen

r-

r-

intlu-

2 F. Reverter et al. / Sensor

rom (10), R∗x =Rx only when �R32 =�R42 =�R43 = 0

matched internal port resistances), otherwise there arend sensitivity errors. However, by contrast with the sinoint calibration technique, the magnitude of these errors

he order of�R32, �R42 and�R43, which are much smallehan the absolute value of the internal resistances. Therhe two-point calibration technique is more accurate thingle-point calibration.

If �R32 =�R42 =�R43 = 0 and the relation betweenRxndNx is linear, any resistor pairRc1,Rc2 would be approprite to calibrate the system. However, if the internal resistare not matched, from(12), depending on the sign of�R32,R42 and�R43, the relative error will be zero for eitherositive or a negativeRx value. A negativeRx value would

mply that the relative error would never be zero insideange of interest. If theRx value is positive instead,Rc1 andc2 could be selected to obtain the minimal error close toidrange value or to the most probable sensor value. N

heless, this selection rule is not very useful because�R32,R42 and�R43 are unknown and the specific measuremf Rn,2, Rn,3 andRn,4 for each microcontroller would not bcost-effective solution. The reduction of the nonlinea

rror[10] provides another criterion to select the calibraesistors. Regardless of the actual nonlinear response,uadratic, as shown inFig. 6, the maximal error is minimahen selecting the two calibration points at 15 and 85%

he measurement range[13].

.3. Three-signal measurement method

Eqs.(10)–(12)are directly applicable to the three-sigeasurement method by consideringRc1 = 0.

. Resolution analysis

The measurement ofNx, Nc1 andNc2 has two basic unertainty sources[9]: (a) quantization and (b) trigger noiffecting the voltage comparison betweenVc andVTL at thetop point of the timing process. The analysis in[9] showshat, from a given time constant up, the relative standardertainty of the digital number remains constant tour,0. If thenterface circuit herein analysed works with a time consarger than that, then

u(Nx)

Nx

= u(Nc1)

Nc1= u(Nc2)

Nc2= ur,0 (13)

hereu(Nx), u(Nc1) andu(Nc2) are the respective standancertainties ofNx, Nc1 andNc2.

The combined standard uncertainty of the calculated re-istanceuc(R∗

x) can be obtained by appropriately combininghe standard uncertainties ofNx,Nc1 andNc2, which are inde-endent from each other. By applying the law of propagation

,

of uncertainties[14], uc(Rx) is

u2c(R∗

x) =(

∂R∗x

∂Nx

)2

u2(Nx) +(

∂R∗x

∂Nc1

)2

u2(Nc1)

+(

∂R∗x

∂Nc2

)2

u2(Nc2) (14)

In order to encompass a larger fraction of the distributionvalues that could reasonably be attributed to the sameRx, weuse the expanded uncertainty[14]

U = kuc(R∗x) (15)

wherek is the coverage factor. We selectk= 2 to define aninterval having a level of confidence of 95% wheneverR∗

x

has a normal distribution. To observe a significant chain R∗

x, Rx must change more than the noise producingvariability onR∗

x. According to that, we define the resolutioas the amplitude of the uncertainty interval, i.e. two timesU.

5.1. Single-point calibration technique

Replacing(3) in (14)and considering(13)yields

uc(R∗x)

R∗x

= ur,0√

2 (16)

Using ur,0 ≈ 50× 10−6 [9], the relative standard uncetainty of R∗

x is 71× 10−6. For Rx= 1000�, we haveuc(R∗

x) = 0.07�,U= 0.14� and the resolution equals 0.28�.

5.2. Two-point calibration technique

Replacing(4) in (14)and considering(13)yields

uc(R∗x)

R∗x

= ur,0

√√√√√√1 +

N2c1(1 − Nc2/Nx)2

+ N2c2(1 − Nc1/Nx)2

(Nc2 − Nc1)2(17)

which depends onNx and, hence, onRx. For a circuit withRc1 =Rx,min and Rc2 =Rx,max, the relative standard uncetainty of R∗

x is maximal forNx=Nc1 andNx=Nc2, and(17)simplifies to(16) in both cases. Therefore, the single-poand two-point calibration techniques yield a similar resotion.

5.3. Three-signal measurement method

BecauseRc1 = 0 here, wheneverRxRn, we have

NxNc1 andNc2Nc1, and, therefore,(17) also simpli-fies to(16). Usually,Rn is of the order of tens of ohms and,hence,(16) can be applied to a broad range of resistive sen-sors.
Page 6: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

s and Actuators A 121 (2005) 78–87 83

6

-m ro-c 873( nicd s, ex-t witha usedt link),w sed.

r andP B5f ree bothm thedt ,w

ari-s thef

1 e-

2 cro-ac-

3 volt-kes

4 tivity,gd (b)sede (asod)timer.ngd

sis-t s. Toe1F -l ue.F -ta ortaia

F asedo uffer.

1 oft ea-s 17)w t.W -cp eed-r out1 er insu-l s ina

onw Forem of( ns rror,w ”.T mea-s s-t

edb ss tor( rR theN italm fa tsw

wase am-

F. Reverter et al. / Sensor

. Materials and method

The interface circuits described in Section3 were experientally analysed using two commercial 8-bit CMOS mic

ontrollers: the AVR AT90S2313 (Atmel) and the PIC16FMicrochip), which are very common in current electroesigns. These microcontrollers have embedded timer

ernal interrupt pins configurable in both edges, inputsn embedded Schmitt-trigger buffer and an UART (here

o transmit the data to a personal computer via a serialhich make them suitable for the application herein analyThe function of pins 1, 2, 3 and 4 inFigs. 3, 5 and 7was,

espectively, implemented by pins INT0/PD2, PB7, PB6B5 for the AVR, and by RB0/INT, RB7, RB6 and R

or the PIC. Pins INT0/PD2 (AVR) and RB0/INT (PIC) axternal interrupt pins with an embedded ST buffer. Foricrocontrollers, the embedded 16-bit Timer 1 countedischarging time. To have a similar counting time-baseTs,

he AVR ran on a 4 MHz quartz oscillator clock (Ts = 250 ns)hereas the PIC ran on a 20 MHz clock (Ts = 200 ns).In order to reduce noise affecting the voltage comp

on at the stop point of the timing process, we appliedollowing design solutions:

. A decoupling capacitor (Cd = 100 nF) was connected btween the microcontroller power supply pins.

. The layout of the ground and supply tracks of the micontroller was implemented by following the manufturer’s recommendations.

. The microcontroller was supplied by an independentage regulator (LM7805), thus avoiding power rail spifrom other devices[15].

. To decrease the effects of noise due to the CPU actwo approaches were tested[16]: (a) stop the CPU usinthe sleep mode when the timing process starts anuse an external ST buffer (MC74HC14A). The AVR uthe first solution, whereas the PIC used the second onshown inFig. 8for the three-signal measurement methbecause its sleep mode stops the time-base of theFromFig. 8, pin RB0/INT cannot implement the chargiprocess as inFig. 1a and, therefore,C must be chargefrom an additional pin RB4.

The interface circuits were applied to measure reors in the range of Pt1000-type temperature sensormulate the resistance of the Pt1000 sensor from−45 to20◦C, we selected 12 resistorsRx from 825 to 1470�.or the single-point calibration technique (Fig. 3), we se

ectedRc1 = 1100�, which was close to the midrange valor the two-point calibration technique (Fig. 5), the calibra

ion resistors were approximately at the 15% (Rc1 = 909�)nd 85% (Rc2 = 1330�) of the measurement range. F

he three-signal measurement method (Fig. 7), Rc2 = 1470�nd R0 = 330�. The value ofR0 was selected by taking

nto account that the maximal current sunk by a pin usu-lly equals 20–25 mA. The resistors had 0.1% tolerance and

bpfc

ig. 8. Microcontroller-based interface circuit for a resistive sensor bn the three-signal measurement method and using an external ST b

5× 10−6 ◦C−1 temperature coefficient. The actual valuehe resistors was measured by applying the four-wire murement method with a digital multimeter (Prema 50hose accuracy was better than 0.05� in the range of interese selected a capacitorC= 2.2�F, with a metallized poly

arbonate dielectric, 5% tolerance and 100× 10−6 ◦C−1 tem-erature coefficient. That capacitor provided the best spesolution trade-off[9] when measuring resistances ab000� and permitted us to apply(13). During the tests, thesistors and the capacitor were shielded by a thermalator to reduce thermal drifts resulting from the changembient temperature in the laboratory.

The three calibration techniques described in Secti3ere experimentally analysed for both microcontrollers.ach value ofRx, the digital numbersNx, Nc1 andNc2 wereeasured 100 times. Then, we calculated 100 valuesR∗

x

by using (3)–(5)), their meanR∗x and standard deviatio

(R∗x). The accuracy was evaluated via the relative e

hich was calculated by usingR∗x as the “measured value

he resolution was evaluated from the histogram whenuringRx= 1000� (nominal value) plus the following resiances: a short-circuit, 0.10, 0.22, 0.33 and 0.47�.

The internal resistanceRn of pins 2, 3 and 4 was measury using a dc voltage divider, as shown inFig. 9. Each pin waet as an output providing a digital “0”. A voltage regula7805) supplied the dc voltage levelVdc. The external resistoext was 1000�, which was large enough to ensure thatMOS transistor worked in the ohmic region. The digultimeter (Prema 5017) measured the actual value oVdcndRext, and the resulting voltageVpin. The measuremenere performed for both microcontrollers.The sensitivity of the interface circuit to temperature

xperimentally analysed by placing it inside a climatic ch

er (Model FCH from CCI, Mataro, Spain). We tested tem-eratures from 10 to 50◦C, which is a typical operating range

or electronic systems. For temperature measurement appli-ations involving temperatures outside that range, the sensor

Page 7: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

84 F. Reverter et al. / Sensors and Actuators A 121 (2005) 78–87

F ocon-t

w tem-p tureo i-b hichw acedi cir-c h ap robew

7

m icro-c ortp

tives t inFt eR reew ini-ma ately0 imi-l as0D ay bea

ointcsr

TE

P

RRR

F AVRw

t -taI -sP uringt0a sor,n acy,a

al-c hlya e dis-c uracyo ntiza-t

The relative systematic error when applying the three-signal measurement method(5) was very similar to thatshown inFigs. 11 and 12. For the AVR, the maximal rel-

ig. 9. Experimental set-up to measure the internal resistance of micrrollers’ port pins.

ould be remote to the interface circuit. To analyse theerature effects on the interface circuit only, the temperaf Rx remained constant at 20◦C by placing it inside a calrator for temperature sensors (9102 Hart Scientific), works as a small climatic chamber. This calibrator was pl

nside the large climatic chamber containing the interfaceuit. The temperature of the circuit was monitored witortable thermometer (Delta Ohm DO 9406) whose pas close to it.

. Experimental results and discussion

Table 1summarizes the experimental values ofRn for bothicrocontrollers. The internal resistances of the PIC m

ontroller were almost 9� higher than those of the AVR. Fhe AVR, the maximal difference betweenRn for differentins was�R43 = 0.11�, whereas for the PIC,�R43 = 0.22�.

Fig. 10 shows the experimental and theoretical relaystematic error for the AVR when the interface circuiig. 3 used the single-point calibration technique(3). The

heoretical error was calculated by applying(8)and using thn values inTable 1. Experimental data quantitatively agith the theoretical predictions. The relative error was mal whenRx≈Rc1and increased asRxmoved away fromRc1,s expected. The maximal relative error was approxim.55%. For the PIC, the results were qualitatively very s

ar, but quantitatively higher (the maximal relative error w.85%). This was because the PIC had a higherRn (Table 1).epending on the intended application, these errors mcceptable or not.

The relative systematic error when applying the two-p

alibration technique(4) is shown inFigs. 11 and 12for, re-pectively, the AVR and the PIC. For the AVR, the maximalelative error (er,max) was 160× 10−6 (Fig. 11), whereas for

able 1xperimental values ofRn for the AVR and PIC microcontrollers

arameter AVR PIC

n,2 (�) 16.79 25.30

n,3 (�) 16.72 25.27

n,4 (�) 16.83 25.49Fw

ig. 10. Experimental and theoretical relative systematic error for thehen applying the single-point calibration technique.

he PIC,er,max= 210× 10−6 (Fig. 12). For both microconrollers, the relative error achieved when applying(4) wasbout 40 times smaller than that obtained when applying(3).

n the worst-case situation (Fig. 12for Rx= 1400�), the abolute error was 0.30�, which corresponds to 0.075◦C for at1000 sensor. This error is smaller than the manufact

olerance specified for Pt1000 sensors: 0.15◦C at 0◦C and.35◦C at 100◦C for Class A sensors, and 0.30◦C at 0◦Cnd 0.80◦C at 100◦C for Class B sensors. Hence, the senot the circuit itself, would limit the measurement accurs expected from a well-designed interface circuit.

Figs. 11 and 12also show the theoretical relative error culated from(11). The trend of the experimental data rouggrees with the theoretical predictions, but there are somrepancies. These can be explained from the limited accf the reference measurement system and from the qua

ion effects of the digital timer.

ig. 11. Experimental and theoretical relative systematic error for the AVRhen applying the two-point calibration technique.

Page 8: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

F. Reverter et al. / Sensors and Actuators A 121 (2005) 78–87 85

F PICw

a sf et pen-d ludet -e akagec ringr hree-s ancer

sis-tf entm ,s

stt

Fa alm

r ano -v reetw s-o llera

owni etv er-a epen-d stable.A in

F(

ig. 12. Experimental and theoretical relative systematic error for thehen applying the two-point calibration technique.

tive error was a bit smaller,er,max= 100× 10−6, whereaor the PIC it was a bit larger,er,max= 370× 10−6. Becaushe accuracy of the measurement was practically indeent of the two calibration resistors selected, we conc

hat the relation betweenRx andNx was very linear. Nonlinarity sources (such as the finite impedance and the leurrent of input ports) had negligible effects when measuesistances in the kiloohms range. Consequently, the tignal measurement method yields the best cost-performatio.

Fig. 13 shows the histogram of 100 calculated reances forRx= 1000� plus (a) a short-circuit and (b) 0.33�,or the AVR when applying the three-signal measuremethod. For the case (a),s(R∗

x) = 0.08�, whereas for (b)

(R∗

x) = 0.07�, which agree with the theoretical combinedtandard uncertainty calculated in Section5. FromFig. 13,he two populations of calculated resistances are perfectly dis-inguishable when�Rx= 0.33�, which agrees with the theo-

R

cet

ig. 14. Temperature effects on the calculated resistance, for the AVR micronominal value).

ig. 13. Histogram of 100 calculated resistances forRx = 1000� plus (a)short-circuit and (b) 0.33�, for the AVR when applying the three-signeasurement method.

etical resolution of 0.28� calculated above. Using the mef 10 calculations ofR∗

x as an estimate ofRx, the standard deiation of the population of means was approximately thimes smaller, and the circuit was able to detect�Rx= 0.10�,hich corresponds to 0.025◦C for a Pt1000 sensor. The relution results were very similar for the PIC microcontrond for the other two calibration techniques.

Temperature effects on the interface circuit are shn Fig. 14, for the AVR microcontroller when applying thhree-signal measurement method andRx= 1000� (nominalalue). AlthoughNx, Nc1 andNc2 depended on the tempture, the calibration process compensated for that dence and, hence, the measurement result was quitetemperature change of 40◦C brought about a change

∗x of 0.3�. This systematic error agrees with the resistancehange of the calibration resistor due to its temperature co-fficient. Therefore, the sensitivity of the interface circuit to

emperature when using this calibration method is much bet-

controller when applying the three-signal measurement method andRx = 1000�

Page 9: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

8 s and

t istorb ardd acec 10t

cir-c ranged From( hodh

e

F n( (e.g.f fac-t thes igh-v atures reasew ction5 ce oft rovef ex-pa

8

r-to-m al re-s rrors,w (duet heire rationt giblee e besc cali-b rcuita

rs in-s d usi ndP r forb ea-s witho ide-l larf gnalm owert tion.Osst

i 10w ther-m 10t sed(

A

Sci-e thorsa theirc rancisL

R

A/D,.s,

, Mi-

C622,

exas

or

ort,

inXVII,

inl. 15

[ onrum.

e-um,

[ for

[ ive-536–

[ cal-v. Sci.

[ ment,d and

[ r-ed in

6 F. Reverter et al. / Sensor

er than the temperature coefficient of the calibration reseing used (15× 10−6 ◦C−1). On the other hand, the standeviation ofR∗

x and, hence, the resolution of the interfircuit did not show any temperature dependence fromo 50◦C.

Finally, we discuss the performance of that interfaceuit when measuring resistive sensors with a resistanceifferent from that of the Pt1000 sensor analysed above.10), the two-point calibration and the three-signal metave an absolute error equals

≈ Rc1�R42 − Rc2�R32 − Rx�R43

Rc2 − Rc1(18)

rom(18), if Rx, Rc1 andRc2 are conveniently scaled dowe.g. for a circuit intended for a Pt100 sensor) or upor a circuit intended for a Pt10000 sensor) by the sameor, the absolute error in ohms will be independent ofcale and, hence, the relative error will improve for halue resistive sensors. Therefore, for platinum temperensors, the absolute error in Celsius degrees will decith the scale of the sensor. On the other hand, from Se, the relative resolution is independent of the resistanhe sensor and, hence, the absolute resolution will impor low-value resistive sensors. These predictions wereerimentally verified for resistors in both the 100� rangend the 10 k� range.

. Conclusions

The accuracy and resolution of direct resistive sensoicrocontroller interfaces has been analysed. The intern

istances of the microcontroller pins lead to systematic ehereas the uncertainty of the measured digital numbers

o quantization and trigger noise) limits the resolution. Tffects on the measurement result depend on the calib

echnique being used. If nonlinearity sources have negliffects, the three-signal measurement method yields thost-performance ratio, because it applies a two-pointration using a single calibration resistor and a short-cis reference inputs.

Experimental tests have been carried out on resistoide the range of Pt1000-type temperature sensors anng two commercial microcontrollers (AVR AT90S2313 aIC16F873). The experimental results were very similaoth microcontrollers; hence, the performance of the murement system herein analysed may be achievablether microcontrollers provided the design follows the gu

ines given in Section6. The systematic error was simior the two-point calibration technique and the three-sieasurement method, and it was practically 40 times l

han that obtained when applying the single-point calibra

n the other hand, the three calibration techniques achievedimilar values of resolution. Hence, the three-signal mea-urement method offers the best cost-performance ratio. Forhe AVR, the (maximal) relative systematic error when us-

[

Actuators A 121 (2005) 78–87

t

-

ng this method was 0.01% and the resolution was 0.�

hen averaging 10 calculated resistances. Further, theal behaviour of the interface circuit in the range from

o 50◦C was better than that of the calibration resistor u15× 10−6 ◦C−1).

cknowledgments

This work has been funded by the Spanish Ministry ofnce and Technology, Project DPI2002-00707. The aulso appreciate the discussions and insight provided byolleague Oscar Casas and the technical support of Fopez.

eferences

[1] D. Sherman, Measure Resistance and Capacitance without anAN449, Philips Semiconductors Microcontroller Products, 1993

[2] A. Webjorn, Simple A/D for MCUs without built-in A/D converterAN477, Motorola Semiconductor, 1993.

[3] D. Cox, Implementing Ohmmeter/Temperature Sensor, AN512crochip Technology, Inc., 1997.

[4] R. Richey, Resistance and Capacitance Meter using a PIC16AN611, Microchip Technology, Inc., 1997.

[5] L. Bierl, Precise measurements with the MSP430, Report, TInstruments, 1996.

[6] L. Bierl, Economic Measurement Techniques with comparatAmodule, SLAA071, Texas Instruments, 1999.

[7] B. Merritt, MSP430 based digital thermometer, Application repTexas Instruments, 1999.

[8] F. Reverter, J. Jordana, R. Pallas-Areny, Internal trigger errorsmicrocontroller-based measurements, in: Proceedings of theIMEKO World Congress, Dubrovnik, Croatia, 22−27 June, 2003pp. 655–658.

[9] F. Reverter, R. Pallas-Areny, Effective number of resolution bitsdirect sensor-to-microcontroller interfaces, Meas. Sci. Techno(2004) 2157–2162.

10] A. Custodio, R. Pallas-Areny, R. Bragos, Error analysis and reductifor a simple sensor-microcontroller interface, IEEE Trans. InstMeas. 50 (6) (2001) 1644–1647;A. Custodio, R. Pallas-Areny, R. Bragos, Error analysis and rduction for a simple sensor-microcontroller interface: corrigendIEEE Trans. Instrum. Meas. 52 (3) (2003) 990.

11] R.L. Geiger, P.E. Allen, N.R. Strader, VLSI Design TechniquesAnalog and Digital Circuits, McGraw-Hill, New York, 1990.

12] F.M.L. Van der Goes, G.C.M. Meijer, A novel low-cost capacitsensor interface, IEEE Trans. Instrum. Meas. 45 (2) (1996)540.

13] R. Pallas-Areny, J. Jordana, O. Casas, Optimal two-point staticibration of measurement systems with quadratic response, ReInstrum. 75 (12) (2004) 5106–5111.

14] ISO 1993. Guide to the expression of uncertainty in measureInternational Organization for Standardization, Geneva, correctereprinted 1995.

15] F. Reverter, O. Casas, J. Jordana, R. Pallas-Areny, Trigger uncetainty in period-to-code converters based on counters embeddmicrocontrollers, Sens. Actuators A 110 (2004) 439–446.

16] F. Reverter, J. Jordana, R. Pallas-Areny, Program-dependent uncer-tainty in period-to-code converters based on counters embedded inmicrocontrollers, in: Proceedings of the IEEE Instrumentation andMeasurement Technology Conference, Vail, CO, USA, 20–22 May,2003, pp. 977–980.

Page 10: Accuracy and Resolution of Direct Resistive Sensor to Microcontroller Interface

F. Reverter et al. / Sensors and Actuators A 121 (2005) 78–87 87

Biographies

Ferran Reverter received his BEng degree in industrial electronic en-gineering from the University of Girona (UdG), Girona, Spain, in 1998.In 2001, he received his MEng degree in electronic engineering fromthe University of Barcelona (UB), Barcelona, Spain. Since September2001, he has been with the Technical School of Castelldefels, Castellde-fels (Barcelona), which belongs to the Technical University of Catalonia(UPC), where he is a PhD candidate and an Assistant Professor, en-gaged in teaching analogue electronics and digital systems. His researchinterests are in the area of electronic instrumentation and direct sensor-to-microcontroller interfaces.

Josep Jordana received the Enginyer de Telecomunicacio and DoctorEnginyer de Telecomunicacio degrees from the Universitat Politecnicade Catalunya, Barcelona, Spain, in 1990 and 1999, respectively. In 1993he joined the Department of Electronic Engineering as a Lecturer andsince 2001 he is an Associate Professor at the same university. His re-search interests are electronic instrumentation and sensor–microcontrollerinterfaces.

Manel Gasulla received his MSc and PhD degrees in telecommunicationengineering from the Technical University of Catalonia (UPC), Barcelona,Spain, in 1992 and 1999, respectively. Since 1993 he has been withthe UPC, where he is an Associate Professor, engaged in teaching onanalogue electronics and electronic instrumentation. In 2001–2002, hewas a visiting post-doc at the Electronic Instrumentation Laboratory, DelftUniversity of Technology, The Netherlands. His research interests include

smart capacitive sensors systems, electrical impedance measurements andsubsurface resistivity imaging.

Ramon Pallas-Areny received the Ingeniero Industrial and Doctor In-geniero Industrial degrees from the Technical University of Catalonia(UPC), Barcelona, Spain, in 1975 and 1982, respectively. He is a Profes-sor of Electronic Engineering at the same university, and teaches coursesin medical and electronic instrumentation. In 1989 and 1990 he was avisiting Fulbright Scholar, and in 1997 and 1998 he was an Honorary Fel-low at the University of Wisconsin, Madison. In 2001 he was nominatedProfessor Honoris Causa by the Faculty of Electrical Engineering of theUniversity of Cluj-Napoca (Romania). His research includes instrumen-tation methods and sensors based on electrical impedance measurements,sensor interfaces, noninvasive physiological measurements and electro-magnetic compatibility in electronic systems. He is the author of severalbooks on instrumentation in Spanish and Catalan, the latest one beingSensors and Interfaces, Solved Problems(1999), published by EdicionsUPC, Barcelona, Spain. He is also coauthor (with John G. Webster) ofSensors and Signal Conditioning, 2nd ed. (New York: Wiley, 2001), andAnalog Signal Processing(New York: Wiley, 1999). Dr. Pallas-Areny wasa recipient, with John G. Webster, of the 1991 Andrew R. Chi Prize Pa-per Award from the Instrumentation and Measurement Society (IEEE).In 2000 he received the Award for Quality in Teaching granted by theBoard of Trustees of the UPC, and in 2002 the Narcıs Monturiol Medalfrom the Autonomous Government of Catalonia. He is a Fellow of theIEEE and a member of the International Society for Measurement andControl (ISA).