8
S ENSORS produce variations in different parameters depending on the type of sensor: resistance, voltage, current, capacitance, inductance, frequency, etc. In the Lab Work for Part 2 last month we made use of the current from a photodiode in a light meter application. In Part 3 we now encounter capacitive sensors for humidity monitoring. First though, we examine more aspects of op.amps in rela- tion to their use in “conditioning” sensor outputs to interface their signals to the outside world. MORE THAN VOLTAGE We need different circuits for each type of sensor, but in many cases we end up (if necessary) converting the signal to a volt- age or a frequency (or pulse time), both of which can be readily used as the input to a subsequent processing system, such as a computer or microcontroller, for instance. As we discussed last month, the raw voltage or frequency obtained from the sen- sor or conversion circuit may need to be scaled or shifted. We need an analogue-to-digital convert- er (ADC) (more on these later in the series) to read a voltage into a microcontroller. The ADC may be “on-chip” or an external device. Frequency can be measured by a micro- controller directly by converting the signal to a square wave at the logic levels of the microcontroller and feeding it to a digital input pin. The software counts the number of pulses occurring in a given period and is therefore able to calculate the frequency. If the frequency is very high, and there- fore too fast for the software, we can scale it down using a frequency divider such as a ripple counter or series of D-type flip-flops. Scaling down a frequency, though, means that the measurement will take longer. For low frequencies it is easier to measure cycle time directly, rather than counting pulses. Frequency can be shifted and scaled up, but this requires sophisticated circuits such as phase-locked loops and will not be discussed here. Resistance based sensors are commonly used as part of a potential divider, as we did with the thermistor in Lab Work 1. Capacitance based sensors can be made one of the timing components in an oscilla- tor or pulse generator, as we will see later when we look at humidity sensors. Current can be converted to a voltage using an op.amp circuit, as we did in Lab Work 2. We will now look at this circuit in more detail. CURRENT INPUT As we saw in last month’s Lab Work, an op.amp can be used to convert a current signal from a sensor into a voltage signal, as shown in Fig.3.1. The circuit in Fig.3.1. is straightforward to understand if you recall our op.amp dis- cussion in Part 2. The inputs are both at 0V due to the virtual earth and all the current from the sensor flows in resistor R due to the high op.amp input impedance. Thus the voltage at the output is given by V out = –R × I in Here we have to be careful about the validity of one of our assumptions, namely the input impedance/current of the op.amp being negligible. If the current from the sensor is very small it may be comparable to the bias current required by the op.amp. For example, if the op.amp takes 200nA and the sensor current is 1mA we would get a 20% error. For the circuit to work as intended (for our assumption to hold) we must choose an op.amp with very high input impedance and very low bias current – a FET input device is appropriate. OFFSETS AND OP.AMPS In last month’s Lab Work we had a look at measuring the offset voltage of the 741 and OP177 op.amps which we are using in this series. Offsets cause systematic errors in measurements and, to make matters worse, vary over time and with temperature. They are a particular problem when mea- suring slowly changing quantities, such as room temperature and humidity. In applica- tions in which only a.c. signals are of inter- est (e.g. audio signals from a microphone), offsets are less likely to be a problem as they simply cause a shift in operating point and can be blocked using capacitive coupling. When you work with sensors you are bound to end up having to deal with offsets to get the most from practical circuits. To identify (and ideally avoid) offset prob- lems, it helps to know about the device specifications and basic theory associated with offsets. For op.amps we have to con- sider both the inherent offset voltage and the offsets due to currents flowing into the op.amp. Let’s look at these in turn. Ideally, with a differential input of zero, the op.amp’s output should also be zero, but in real op.amps there will typically be a non-zero output. The Input Offset Voltage V IO is defined as the d.c. voltage which must be supplied between the inputs to force the quiescent (zero input signal) open-loop (no feedback resistors) output voltage to zero. This is illustrated in Fig.3.2 as an “equiv- alent circuit” – a combination of an ideal op.amp and a voltage source to represent 56 Everyday Practical Electronics, January 2002 EPE Tutorial Series TEACH-IN 2002 Part Three – More on op.amps in sensor circuits, plus humidity sensors Making Sense of the Real World: Electronics to Measure the Environment IAN BELL AND DAVE CHESMORE Fig.3.1. Current-to-voltage converter. Fig.3.2. Equivalent circuit used to define offset voltage.

Opamps in Sensor Circuits Plus Humidity Sensors

Embed Size (px)

DESCRIPTION

Learn about Opamps in Sensor Circuits Plus Humidity Sensors

Citation preview

  • SENSORS produce variations in differentparameters depending on the type ofsensor: resistance, voltage, current,capacitance, inductance, frequency, etc.

    In the Lab Work for Part 2 last month wemade use of the current from a photodiodein a light meter application. In Part 3 wenow encounter capacitive sensors forhumidity monitoring. First though, weexamine more aspects of op.amps in rela-tion to their use in conditioning sensoroutputs to interface their signals to theoutside world.

    We need different circuits for each type

    of sensor, but in many cases we end up (ifnecessary) converting the signal to a volt-age or a frequency (or pulse time), both ofwhich can be readily used as the input to asubsequent processing system, such as acomputer or microcontroller, for instance.

    As we discussed last month, the rawvoltage or frequency obtained from the sen-sor or conversion circuit may need to bescaled or shifted.

    We need an analogue-to-digital convert-er (ADC) (more on these later in the series)to read a voltage into a microcontroller. TheADC may be on-chip or an externaldevice.

    Frequency can be measured by a micro-controller directly by converting the signalto a square wave at the logic levels of themicrocontroller and feeding it to a digitalinput pin. The software counts the numberof pulses occurring in a given period and istherefore able to calculate the frequency.

    If the frequency is very high, and there-fore too fast for the software, we can scaleit down using a frequency divider such as aripple counter or series of D-type flip-flops.Scaling down a frequency, though, meansthat the measurement will take longer. Forlow frequencies it is easier to measurecycle time directly, rather than countingpulses. Frequency can be shifted and scaledup, but this requires sophisticated circuitssuch as phase-locked loops and will not bediscussed here.

    Resistance based sensors are commonlyused as part of a potential divider, as we didwith the thermistor in Lab Work 1.

    Capacitance based sensors can be madeone of the timing components in an oscilla-tor or pulse generator, as we will see laterwhen we look at humidity sensors. Currentcan be converted to a voltage using anop.amp circuit, as we did in Lab Work 2.We will now look at this circuit in moredetail.

    As we saw in last months Lab Work, an

    op.amp can be used to convert a currentsignal from a sensor into a voltage signal,as shown in Fig.3.1.

    The circuit in Fig.3.1. is straightforwardto understand if you recall our op.amp dis-cussion in Part 2. The inputs are both at 0Vdue to the virtual earth and all the currentfrom the sensor flows in resistor R due tothe high op.amp input impedance. Thus thevoltage at the output is given by

    Vout = R Iin

    Here we have to be careful about thevalidity of one of our assumptions, namelythe input impedance/current of the op.ampbeing negligible. If the current from thesensor is very small it may be comparableto the bias current required by the op.amp.For example, if the op.amp takes 200nAand the sensor current is 1A we would geta 20% error.

    For the circuit to work as intended (forour assumption to hold) we must choose anop.amp with very high input impedanceand very low bias current a FET inputdevice is appropriate.

    In last months Lab Work we had a look at

    measuring the offset voltage of the 741 andOP177 op.amps which we are using in thisseries. Offsets cause systematic errors inmeasurements and, to make matters worse,vary over time and with temperature.

    They are a particular problem when mea-suring slowly changing quantities, such asroom temperature and humidity. In applica-tions in which only a.c. signals are of inter-est (e.g. audio signals from a microphone),offsets are less likely to be a problem as theysimply cause a shift in operating point andcan be blocked using capacitive coupling.

    When you work with sensors you arebound to end up having to deal with offsetsto get the most from practical circuits. Toidentify (and ideally avoid) offset prob-lems, it helps to know about the devicespecifications and basic theory associatedwith offsets. For op.amps we have to con-sider both the inherent offset voltage andthe offsets due to currents flowing into theop.amp. Lets look at these in turn.

    Ideally, with a differential input of zero,the op.amps output should also be zero,but in real op.amps there will typically be anon-zero output. The Input Offset VoltageVIO is defined as the d.c. voltage whichmust be supplied between the inputs toforce the quiescent (zero input signal)open-loop (no feedback resistors) outputvoltage to zero.

    This is illustrated in Fig.3.2 as an equiv-alent circuit a combination of an idealop.amp and a voltage source to represent

    56 Everyday Practical Electronics, January 2002

    EPE Tutorial Series

    TEACH-IN 2002Part Three More on op.amps in sensorcircuits, plus humidity sensors

    Making Sense of the Real World: Electronics to Measure the Environment

    IAN BELL AND DAVE CHESMORE

    Fig.3.1. Current-to-voltage converter.

    Fig.3.2. Equivalent circuit used todefine offset voltage.

  • the error due to the offset. We do not buildthis circuit, even to measure offset, it sim-ply serves to clarify the definition.

    The input offset voltage is defined withrespect to the input. The error in the outputvoltage due to VIO is equal to the circuitgain times VIO (note circuit gain, notop.amp gain). So if the datasheet quotedVIO as 2mV maximum and your circuit hada gain of 100 you could get a 02V error onthe output.

    Some op.amps have offset adjustmentcircuits (see Fig.3.3.) that allow an externaltrimmer potentiometer, connected to theappropriate pins, to be used to set the out-put voltage to zero. It is not the only offsetadjustment configuration that can be used,so you need to check the datasheet for theop.amp in question.

    The problem with manual offset trim-ming is that offsets can drift with time andare quite temperature sensitive. Thetemperature coefficient of input offsetvoltage specifies how VIO changes withtemperature. The datasheet for an op.ampmay also have a graph showing offsetvariation with temperature. Low offsetop.amps must be used in circuits where d.c.accuracy is required.

    Bipolar op.amps require bias (base) cur-

    rents for the transistors connected to theirinputs, and op.amps with FET inputs haveleakage currents at the inputs. The termInput Bias Current IIB is defined as theaverage current into the op.amps twoinputs with the output at zero volts. Thiscan vary greatly for different types ofop.amp, from femtoamps (10-15A) to tensof microamps, with bipolar op.amps havinglarger input bias currents than FET inputop.amps.

    Bias currents flow in the external com-ponents connected to the op.amp (e.g. theresistors used to set the gain) and in doingso cause voltage drops. If these voltagedrops are not equal at the op.amps twoinputs they will be amplified by the op.ampand appear as d.c. errors at the output.

    To find the unwanted output voltage,find the difference in resistance at the twoinputs and multiply this by the bias currentand the circuit gain. This effect can be min-imized by adding a resistor to one of theinputs to balance the resistance throughwhich the bias current flows (see Fig.3.4).

    In Fig.3.4 the bias current to the invert-ing input flows through resistors R1 or R2(in parallel), so making R3 equal to the

    parallel combination of R1 and R2 willresult in the same voltage at the two inputsdue to the bias currents (assuming the biascurrents are equal).

    Resistor R1 in the calibration circuit(Fig.1.5) in Lab Work 1 is used for bias off-set reduction and has a value close to theparallel combination of R4 and R5. Thesame principle can be applied to the cur-rent-to-voltage converter discussed earlier(see Fig.3.5).

    In practice, the bias currents are notequal so we have Input Offset Current

    (IIO) the difference between the cur-rents into the two inputs with the outputat zero volts, i.e. IB1 IB2, where IB1 andIB2 are the input currents for the twoinputs.

    Ideally these currents will be equal, butin practice they are not. The inputcurrents have to flow through the externalcircuitry and will cause offsets even if theimpedances connected to the two inputsare equal (we still want to keep theresistances equal as this is our best shotat keeping the current offsets low).

    Everyday Practical Electronics, January 2002 57

    Fig.3.3. Offset Adjustment. The exactarrangement may vary for differentop.amps, as will be shown in theirdatasheets.

    PANEL 3.1. Negative FeedbackIn Part 2 we used the term feedback

    and showed examples of circuits inwhich it is being used. It is worth consid-ering in a little more detail:

    For any op.amp configuration, sub-tracting a fraction of the output fromthe input (termed negative feedback)gives:

    Vout = Av x (Vin Vout)where:Av is the open loop voltage gainVout is the output voltageVin is the input voltage

    To find the gain of the circuit with neg-ative feedback applied, that is Vout / Vin,known as the closed loop gain, ACL, weneed to rearrange this equation. Thisgives:

    ACL = Vout / Vin = Av / (1 + Av ).For high Av (more specifically Av

    >>1, i.e. A much greater than 1) thegain of the circuit may usually beapproximated to ACL = 1 / , which isindependent of the gain of the op.amp aslong as the high Av assumption holds.

    For ACL to be independent of Av weneed ACL to be much smaller than Av.This is usually not a problem. For exam-ple, if an op.amp has a gain of 500,000and we require a circuit gain of 20 (ignor-ing the phase inversion sign) then weneed = 005, so Av = 25,000 which isobviously much larger than 1 (our crite-ria for accepting the simplified formulaACL = 1 / ).

    The actual gain of the op.amp if we usethe full expression ACL = Av / (1 + Av )will be 199992 instead of 20, a differenceof 0004% compare this with typicalresistor accuracy, for example five per cent.

    What is for an actual circuit? Theeasiest configuration to look at is the

    non-inverting amplifier (see Fig.2.3,centre circuit, in Part 2) as the inputand feedback signals are clearly sepa-rate. In this circuit R1 and R2 form apotential divider, which provides a por-tion of the output voltage at theop.amps negative input. The voltage atthe inverting input (V2) is given by thepotential divider formula:

    V2 = R1 Vout / (R1 + R2).The voltage at the non-inverting input

    (V1) is simply Vin, so for this circuit theop.amps output, which is given by:

    Vo = Av(V2 V1) can be written as:Vo = Av(Vin R1 Vout / (R1 + R2))

    which on comparison with our feedbackformula (ACL = etc) indicates that = R1/ (R1 + R2).

    This expression for should not besurprising, as it is simply the proportionof the output provided by the potentialdivider. If our high op.amp gainassumption holds we can write the circuitgain as 1/, which is (R1 + R2) / R1 or1 + R2 / R1.

    This is an important result because thegain of the circuit is determined by R1and R2, and is independent of theop.amps gain so long as the op.ampsgain is high, making circuit design of theamplifier very straightforward.

    It is important to make a distinctionbetween op.amp and circuit input andoutput voltages and gains. The op.ampinput voltages in last months Fig.2.3 areV1 (non-inverting input) and V2 (invert-ing input), its output voltage is Vo and itsgain is Av.

    The circuit has a single input voltageVin, an output voltage Vout and a gain ofACL. For this circuit it happens that Vin =V1 and Vout = Vo, but this may not alwaysbe the case. For the op.amp Vo = Av (V2 V1) and for the circuit Vout = (1 + R2 /R1) Vin as long as Av is very large.

    Fig.3.4. Bias Currents.Fig.3.5. Current-to-voltage converterwith offset current compensation.

  • The only cure for errors due to offsetcurrents, apart from using a better op.amp,is to reduce all the resistance values, butthis option is limited by loading and powerconsumption considerations. Of course,bias current and offset vary with tempera-ture so we have the temperature coeffi-cient of input offset current parameter,which specifies how IIO changes with tem-perature, and graphs on the datasheet toshow these changes.

    Armed with some more vital informationabout op.amps and their important d.c.characteristics, lets move on now to look-ing at another type of sensor.

    How moist is the air? We can be very

    sensitive to high levels of moisture, espe-cially if the air temperature is also high.You will know this if you have visited trop-ical countries where high humidity can bevery uncomfortable.

    What is humidity? It is a measure of themoisture content of air and is most com-monly expressed as the percentage of watervapour in the air relative to the saturationvapour pressure at the same temperatureand pressure. In other words, it is the pro-portion of water vapour compared to themaximum amount the air can hold; this isthe relative humidity (RH).

    Another measure is the absolute humidi-ty, which is the mass of water vapour perunit volume of air. The amount of watervapour the air can hold is dependent on airpressure and air temperature, so measuringrelative humidity is not particularly easy.

    One old and reliable method is to use asingle strand of human hair fixed at one endand wrapped around a spindle at the other.The spindle has a pointer attached, changesin humidity cause the hair to change lengthand move the pointer. The sensors we willbe working with are a little more sophisti-cated and not so fragile!

    There are two main forms of humiditysensor resistive and capacitive. We shalldeal with each type separately. Mosthumidity sensors have a restricted operat-ing range and will only give accurateresults between 25% and 90% humidity.

    Some operate between 0% and 100% butthey tend to be more expensive. Also, theaccuracy is not particularly good, most sen-sors only being accurate to 5% or 10% atlow or high humidity.

    Calibration is not easy and will be exam-ined later. One other problem with allhumidity sensors is that they have a verylong time constant, i.e. they take a longtime to change value from, say 10% RH to90% RH. Typical time constants rangefrom two to four minutes.

    Resistive sensors consist of a layer ofmaterial deposited on a substrate. Thislayer absorbs water vapour and changes itsresistance. A number of resistive sensorsare available and are relatively low cost.The characteristics of several readily avail-able types are given in Table 3.1.

    When designing circuits for humiditysensing, there are a number of points thatshould be considered:

    1. Resistance is related to relative humidityin a logarithmic fashion as shown in the

    graph of Fig.3.8. For example, the HS15sensor has a resistance of 10M at 30%RH and about 90k at 90% RH,measured at 5C. We therefore need tolinearise the resistance.

    2. Resistance changes as a function of tem-perature, hence the different curves inthe graph. At 90% RH, the HS15 resis-tance changes from 90k at 5C to500 at 45C. We therefore need to pro-vide temperature compensation.

    3. Resistive sensors are damaged by d.c.voltages because the active materialbecomes polarized and stops working.All circuits must therefore use a.c. sig-nals, hence the inclusion of measuringfrequency as a parameter in Table 3.1.If this all seems too complex, dont

    worry as humidity sensor modules areavailable which include linearisation andtemperature compensation. Whilst they aremore expensive, they are very easy to use,requiring only a +5V supply.

    58 Everyday Practical Electronics, January 2002

    PANEL 3.2. Linear and Non Linear ResponsesMathematically, the term linear has a

    precise meaning, usually defined withrespect to particular situations, perhapsthe most basic being linear functions, soit helps to know what a function is todefine linear.

    A function is simply a relationshipbetween the values of two or more vari-ables. For example, y = 2x means that thevalue of y is twice that of x. So, for exam-ple, if x is 4, y will be 8. Just as x standsfor any value when we can write f(x) tomean any function of x. In our example,f(x) is 2x.

    Functions, in the present context,relate to circuits and sensors. For exam-ple, if x represents the input to a circuit(e.g. in volts) and y represents the outputvoltage, then if the circuit function y =f(x) is y = 10x, the output voltage is tentimes the input voltage, so this could be avoltage amplifier with a gain of 10.

    Similarly, we can write mathematicalfunctions which describe how a sensorresponds to the parameter it is being usedto measure. We saw examples of func-tions that relate thermistor resistance totemperature in Part 1.

    A linear function of x is one of theform f(x) = ax + b, in which a and b areconstants. For example, the function f(x)= 60x + 100 is linear.

    The exponential function, f(x) = exp(x)(e to the power of x, or ex) is an exampleof a non-linear function, and quite oftenfound in sensor responses.

    The use of the term linear should makesense if you plot graphs of functions fora linear function you get a straight line,this is illustrated in Fig.3.6 which showsa graph of the two functions justmentioned.

    If our sensor response is linear, it iseasy to extract the value we want fromthe sensor output. For instance, if a tem-perature sensors output is in the form y =01t + 2, where t is temperature and y isthe current or voltage obtained, we cansimply subtract 2 then multiply by 10 toget t an example of the shift and scale

    operation performed by the calibrationcircuit in Lab Work 1.

    The subtract 2, divide by 10 tech-nique is an example of what is known asan inverse function. If we apply a func-tion to a value and then apply the inversefunction to the result we get the originalvalue back.

    If our sensor response is non-linear, wecan apply the result to a circuit that has aresponse equivalent to the inverse func-tion of the sensor response function. Foran exponential sensor response thiswould be a logarithmic circuit function.

    Designing an inverse function circuitmay not always be easy and a number ofother options exist. We can use a circuitfunction which approximates the inversefunction, or we can read the sensor valuedirectly into a microcontroller or PC anddo the maths in software. More simply(and less accurately) we can use a smallrange of a non-linear function over whichit can be regarded as approximately linear.

    Referring to Fig.3.6, if you take asmall part of the exponential curve itlooks quite straight, even though thewhole thing is obviously very curved.

    Fig.3.6. Two functions of x, one linear,the other non-linear.

    Fig.3.7. Connecting the HU10 Module.

  • The diagram in Fig.3.7 shows how to con-nect an HU10 sensor module. The character-istics of this module are given in Table 3.2.The humidity range is 25% to 100% at 5%accuracy. The module has three pins 0V,

    +5V (which must notbe exceeded) and theoutput. You will havenoticed that the outputvoltage ranges from15V at 25% to 31V at100%; this may bechanged only byadding a scaling andlevel shifting circuit.

    Capacitive sensorsare effectively capaci-tors that change theircapacitance as a func-tion of relative humidi-ty. Fig.3.9 shows thecross-section of acapacitive sensorwhich consists of a thinlayer of non-conduct-ing dielectric materialcoated with gold oneach side. The goldlayer is so thin that itallows water moleculesto pass through andchange the dielectricconstant of the non-conducting layer.

    Other sensors useplatinum instead ofgold and often havespecial coatings that

    allow water vapour to pass but makethe sensor immune to liquid water(waterproof).

    Changes in the dielectric constant alterthe capacitance. Table 3.3 gives thecharacteristics for some capacitive sensors.

    These sensors are also readily available.One useful thing to note is that some canoperate down to 0%RH.

    In order to use a capacitive humidity sen-sor, we must change the capacitance valueto a simpler parameter that can be mea-sured. This can be achieved in severalways. Perhaps the most straightforward isto use the capacitor in an oscillator circuitsuch as that shown in Fig.3.10.

    This circuit consists of a CMOS SchmittNAND gate connected as an inverter with aresistor (R1) feedback. The capacitive sen-sor (C1) is connected from the combinedinputs to ground.

    The circuit oscillates at a rate given bythe value of R1 and C1 and the supply volt-age. If the capacitors value changes due tohumidity changes, the frequency of oscilla-tion will also change. The circuit thusbehaves as a humidity-to-frequency con-verter and its oscillation frequency can bemeasured by a frequency counter.

    Unfortunately, depending on the sensorused, the variation in capacitance may notbe a perfectly linear function of relativehumidity. Consequently, we cannot directlyrelate frequency to relative humidity.

    Everyday Practical Electronics, January 2002 59

    Fig.3.8. Humidity sensing performance of the HS15 sensor.

    Table 3.1. Characteristics of some Resistive Humidity SensorsParameter HS15 C3-M3Humidity Range 20%-100% RH 20%-90% RHOperating Temperature 0C-50C 0C 60CAccuracy 5% RH 5% RHImpedance at 25C 60k 30k @ 50% RH 31k 30k @ 60% RHMeasuring Frequency 50Hz-1kHz 500Hz-2kHzTemperature dependence 05% RH/C 0.5% RH/CDrive Voltage 1V AC (rms) 1V AC (rms)Manufacturer Steatite Group

    Table 3.2 Characteristics of the HU10 Resistive Humidity ModuleSupply Voltage 5V 02VSupply Current 2mAOperating Temperature 0-50COperating Humidity Range 20% 100% RHMeasurement Humidity Range 25% 100% RHOutput Voltage 15V @ 25% RH to 31V @ 100% RHAccuracy 5% RHSensor HS15

    Resistive humidity sensor.

    Table 3.3 Characteristics of some Capacitive Humidity SensorsParameter H1 SMTHS10 SMTRH05

    Humidity Range 10% to 90% RH 0% to 100% RH 0% to 100% RHOperating Temperature 40C to 120C 0C to 85C -40C to 120CCapacitance Range (0 to 100% RH) 70pF approx 40pF 40pF12%Accuracy 5% RH (10% to 90%) 2% RH 5% RHCapacitance at 25C 122pF 15% @ 43% RH 240pF 20% 300pF @ 0% RHMeasuring Frequency 1kHz to 1MHz 10kHz to 1MHz 80kHz to 900kHzTemperature dependence negligible 01% RH/C 015% RH/CMaximum Voltage 15V 5V (a.c. only) 5V (a.c. only)Manufacturer Philips Smartec Smartec

    Fig.3.9. Cross-section of a typicalcapacitive sensor.

    Capacitive humidity sensor.

  • It is also possible to add a frequencydivider to the output of the oscillator toreduce the frequency to the audio range andto drive a piezo-buzzer directly so that wecan hear the changes in frequency.

    An example circuit diagram is shown inFig.3.10, in which a type 4520 dual binarycounter is used. The first counter is clockedby the oscillators output (connected to theinput at pin 1). The frequency is divided by2, 4, 8 or 16 depending on which output ischosen, in this instance pin 1Q3.

    Since the oscillator operates at about64kHz (depending on the capacitance of thesensor chosen), the output at 1Q3 will be64,000/16 = 4kHz, a frequency that is audi-ble. If you wish to reduce the frequency

    further, connect the 1Q3 output to the clockinput of the second counter (pin 9), as shownin the 4520 to give divisions of 32, 64, 128 or256, at outputs 2Q0 to 2Q3, respectively.

    The second method is to vary the widthof a pulse, using an RC (resistor-capacitor)integrator, which will produce a d.c. volt-age proportional to the pulse width.Fig.3.11 shows such a circuit.

    The conversion is achieved by using afixed frequency square wave which drives amonostable (see Fig.3.12). The time periodof the type 4098 monostable is determinedby the RC (resistor RS and capacitive sen-sor CS) time constant, which varies as afunction of humidity. The time constant isdetermined by the equation 05RSCS.

    The monostable is continually retrig-gered by the square wave and its output isa fixed-frequency variable width pulsetrain.

    The monostables output is connected toan integrator formed by the long time con-stant RC network (RF and CF) to give a d.c.output. Narrow pulse widths result in a lowvoltage output, and wide pulse widths pro-duce a higher output voltage.

    The oscillator frequency is approximate-ly 18kHz and the pulse width about 10msfor a capacitance of 200pF. The output volt-age at point C will vary as a function ofpulse width and hence humidity, but not bymuch because the capacitance onlychanges by a small amount. It may have to

    60 Everyday Practical Electronics, January 2002

    PANEL 3.1. A brief history of the op.amp

    The name operational amplifierreflects the original use of these circuits performing mathematical operations inanalogue computers. The first op.ampswere build using vacuum tube technolo-gy. They date from the late 1940s andwere based on development work per-formed for the United States NationalDefense Research Council.

    G. A. Philbrick of George A. PhilbrickResearches Inc (GAP/R) and C.A.Lovell of Bell Labs are both creditedwith designing the first op.amps around1948. Although analogue computers pre-dated them, op.amps facilitated thedesign and construction of bettercomputers.

    Op.amps can be configured in circuitsthat perform mathematical operationssuch as addition, scaling, integration anddifferentiation. By wiring these opera-tional units together, it is possible to cre-ate circuits which represent themathematics of a complex problem, suchas might be encountered in the design ofan aircraft.

    The early analogue computers thatused vacuum tube op.amps, were usedmainly for military design work. Theywere enormous (over 20 cubic metres)and consumed vast amounts of power(30,000 watts).

    Vacuum tube op.amps became avail-able as low cost plug-in devices suchas the K2-W general purpose computingop.amp, which was first introduced in1952. It was designed by GAP/R andJulie Research Labs Inc, and producedand marketed by GAP/R. Another com-puter tube from GAP/R, the K2-XA,which is a higher output power versionof the K2-W, is shown top right.

    The development of the transistorbrought discrete component semicon-ductor op.amps in the 1960s from com-panies such as Burr-Brown and AnalogDevices. These in turn were replaced bysingle chip devices.

    The first widely used monolithicsemiconductor op.amp (i.e. integratedcircuit op.amp) was the A709. Thiswas designed by Bob Widlar and intro-duced by Fairchild Semiconductors in1965. It was followed by the very pop-ular A741 in the late 60s. This was alot easier to use than the 709 as it fea-tured output short circuit protection and

    internal frequency compensa-tion. It quickly became theworlds most popular op.amp.

    The 741 has since been sur-passed in performance by manyother devices and there is now avast range of op.amps to choosefrom, offering higher speed,lower noise, higher stability,lower offsets, etc. Recent devel-opments have also pushed thepower supply voltages and powerconsumption levels of op.ampsprogressively lower.

    Op.amps are not only foundas discrete i.c. packages, but arealso found within the circuitryof other i.c.s, including the mas-sively complex system on achip integrated circuits foundin modern high-tech electronicproducts. However, the 741 isstill available and its very lowcost ensures continued use inapplications that do not demandhigh performance.

    We managed to find adatasheet for the K2-XA so wecan present a table of comparisonfor this device with the 741 andOP177 used in the Lab Works,Table 3.4.

    Over the years, the primary useof op.amps has changed fromanalogue computing to signalprocessing. As you will know,most computing is now done dig-itally, but one can occasionallycome across digitally-controlledanalogue-computer-like circuitslurking inside modern i.c.s.

    Signal processing is the manip-ulation of signals from sensorsand other sources in order to getthem into a form suitable for the

    user or other parts of the system.Signal processing includes things suchas amplification, level shifting, mixingand filtering and will be discussed as weprogress through this series.

    Table 3.4.K2-XA 741 OP177

    Max supply voltage 300V and 63V 15V 22Va.c. for heaterfilaments

    Typical voltage gain 30,000 (90dB) 50,000 (94dB) 12,000,000 (142dB)Max power dissipation 14W 85mW 500mWInput resistance 100M 2M 200GInput current 100nA 60nA 2nAInput offset voltage drift 8mV/day

  • Everyday Practical Electronics, January 2002 61

    TEACH-IN 2002 Lab Work 3ALAN WINSTANLEY

    Humidity Sensors and Test Equipment Limitations

    FOLLOWING on from this monthsTutorial section, in Lab Work 3 wenow perform some practical experi-ments with humidity sensors and expose afew facts about test equipment and itslimitations.

    Lab 3.1: Know the limits!This Lab demonstrates some of the prac-

    tical limitations that exist with most formsof test equipment, including the PC-basedPicoscope ADC-40 used in Teach-In 2002.

    The humidity sensor circuit in Fig.3.10(see Tutorial section) is a simple CMOSoscillator using one Schmitt NAND gaterunning at roughly 64kHz. This generates

    a square wave which is coupled to onehalf of a 4520 dual binary up-counter, sothe counters output frequency is dividedby sixteen, which can be observed atpin 6.

    The resultant frequency can be dividedfurther by a factor of 2, 4, 8 or 16, by cas-cading and clocking the 4520s secondcounter, whose input is at pin 9. Using bothcounters this way means that the originalsignal can be divided by a factor of 32, 64,128 or even 256. You would thereforeexpect to measure these frequencies at thecounters outputs 2Q0 to 2Q3.

    The pinouts of both i.c.s are given inFig.3.13 and you should now construct

    Fig.3.10 on a solderless breadboard. Youcan use either a 4093 or a 74HC132 forIC1, but note that they have differentpinouts. Note also that unused CMOSinput pins should be grounded to 0V asusual, and that the +5V supply of theTeach-In Power Supply is required.

    An ordinary fixed capacitor can beused in place of the capacitive humiditysensor for the time being. We used a100pF ceramic capacitor with a 100kresistor for R1 in the RC oscillator. Thismeans that whilst we will not necessari-ly expect a 64kHz signal we shouldstill see something of that order ofmagnitude.

    be scaled. If you want to use this circuit,you may have to change the value of RSdepending on the capacitance range ofyour sensor.

    As you can see, the conversion of capaci-tance to a voltage is not easy and requires anumber of steps. Unfortunately, few sensorsare simple to use, as you will see as theseries progresses, but our aim in this series isto help you get the best out of them. In Lab3, we construct both the foregoing circuits

    Calibration of humidity sensors isquite difficult because we need to gener-ate accurate and known levels of humidi-ty. The scientific way of doing this is toplace the sensor above a particular chem-ical solution at a known temperature in asealed container. The air above the solu-tion will contain a known amount ofwater vapour.

    To give you an idea, a saturated solutionof calcium chloride (CaCl2) at 10C has arelative humidity of 38%. A saturatedsolution of potassium bromide (KBr) has a

    relative humidity of 84% at 20C. A satu-rated solution is a solution that cannot dis-solve any more solid chemical.

    A 0% relative humidity can be obtainedmore simply by using the silica gel whichis found in little bags in boxed electricaland photographic equipment. Silica gelabsorbs moisture and will have moisture init before you use it.

    The moisture is driven out by warming itat slightly over 100C in an oven for awhile. Some gel changes colour from pink(or colourless) to blue when it is dry. Youcan place the dried silica gel into a con-tainer with the sensor and seal it. The rela-

    tive humidity content should reach zero ina short while.

    Once you have a humidity sensor, whatcan it be used for? The obvious applicationis for monitoring the weather. High humid-ity indicates possible rain and we all knowhow high humidity can get in thunderyweather!

    Other applications could include humid-ifiers and dehumidifiers, or to detect whenthe clothes in a tumble dryer have dried.For this application you will need to placethe sensor in the air outlet and use a circuitsimilar to that in the Lab Work light sens-ing circuit Fig.2.10 in Part 2.

    A relay could be used to switch off thedryer when a preset threshold has beenreached. A similar application might be toopen and close vents in a greenhouse tocontrol humidity levels.

    Alan now takes up the story anddescribes some practical experiments youcan perform using an inexpensive humidi-ty sensor.

    Fig.3.10. Frequency divider to reduce oscillator output toaudio frequencies.

    Fig.3.11. Monostable-based capacitance-to-voltage converter.

    Fig.3.12. Timing diagram for Fig.3.11.

  • The Picoscope screenshot we obtained at

    the 4520 2Q2 output is shown in Fig.3.14.By measuring the time period of the

    square wave (using on-screen rulers) if wewish, we can predict what the input frequen-cy should be (use frequency in Hz = 1 / peri-od). For example, the fo/128 output (pin 13)shows a period of 14ms, implying an inputfrequency of approximately 91kHz.

    Lab 3.2: Aliasing EffectsNow check the clock input (pin 1) of the

    4520. Using the Picoscope ADC-40 toexamine the clock signal results in somevery strange and interesting waveforms,which illustrate a principle known as alias-ing. Even after setting the Picoscope to itsfastest setting (go File/Setup/Scope andenter say 20,000 samples per scope trace),instead of a nice square wave, you will geta noisy, small signal that bears no resem-blance to the one we predicted!

    Additionally, if you connect a frequencydivider and look at each output in turn, youwill not get accurate results until the signalhas been divided by at least 8 (i.e. an outputof 8kHz).

    We will be covering the full explanation ofthis effect later but here is a brief summary:

    The Picoscopes maximum samplingrate is 20,000 samples per second andaccording to the Nyquist SamplingCriterion the maximum input frequency

    that can be seen correctly is half of thesampling frequency, 10kHz in this case. Ifany signals with frequencies greater than10kHz are input, then the result will be alower frequency than 10kHz.

    In the extreme case of the input beingexactly equal to the sampling frequencythen the output result will appear to be d.c.!Of course we could use other Picoscopemodels with higher sampling rates but theywould be more expensive.

    Lab 3.3: Relative Humidity toFrequency Converter

    Now replace the timing capacitor with acapacitive-type humidity sensor. Our ownmodel was a 122pF at 25C/43% relativehumidity (RH) device. Our timing resistorwas 100k which produced a clock frequency

    of about 75kHz as measured on a digitaloscilloscope.

    For a 240pF device, use a 56k resistorinstead. A note of caution: insert thehumidity sensor into the breadboard sym-pathetically so as to avoid bending its pins,or consider soldering a pair of leads to thesensor instead.

    The output frequencies of the 4520depend on the humidity detected by thesensor and these can be measured directlyusing the Picoscope as before. You can alsotry hooking a piezo disc to the outputs andby breathing on the humidity sensor, the

    62 Everyday Practical Electronics, January 2002

    N.B. Some componentsare repeated between LabWorks

    Lab 3.1Resistor

    R1 56k for 240p sensor, or 100k for 122p sensor

    All resistors 0.25W 5% carbon film orbetter

    CapacitorC1 100p ceramic

    SemiconductorsIC1 4093 or 74HC132 quad

    Schmitt NAND gateIC2 4520 dual binary up

    counter

    (No extra parts for Lab 3.2)

    Lab 3.3Capacitive humidity sensor 122p or 240p(see text)Piezo disc sounder element (optional)

    Lab 3.4Resistors

    R1 56kRs 100kRf 560k

    CapacitorsC1 1500p ceramicCs 122p or 240p humidity

    sensorCf 100n polyester

    SemiconductorsIC1 4093 or 74HC132 quad

    Schmitt NAND gateIC2 4098 dual monostable

    Approx. CostGuidance Only 1144

    SeeSSHHOOPPTTAALLKKppaaggee

    11

    1

    22

    2

    33

    3

    44

    4

    55

    5

    66

    6

    77

    7

    1414

    141313

    131212

    121111

    111010

    1099

    988 8

    VCCVDD

    VDD

    GNDVSS VSS

    15

    16

    ENABLE A

    CLOCK A

    RESET A ENABLE B

    CLOCK B

    RESET B

    Q1A

    Q2A

    Q3A

    Q4A Q1B

    Q2B

    Q3B

    Q4B

    45204093 74HC132A) B) C)

    Fig.3.13. Pinouts for the 4093, 74HC132 and 4520 devices.

    Fig.3.14. Picoscope screen display ofthe pin 13 output from the 4520 devicein Lab 3.1.

    Fig.3.15. Picoscope display showingthe effect of aliasing when samplinghigh frequencies at too slow a rate.

    Breadboard layout for Lab 3.2.

  • audio tone from the disc will rise slightly.The resulting square wave can be connect-ed to further processing systems to enablesome detection and monitoring of humiditylevels to be made.

    Lab 3.4: RH to Voltage ConverterLab 3.4 is an optional experiment. The

    circuit in Fig.3.11 (see Tutorial section)shows a technique for producing a voltagewhich is dependent on relative humidity. Afixed frequency oscillator is formed of dis-crete components using a NAND Schmittgate, and a capacitive humidity sensor isused as the timing capacitor in a 4098 dualmonostable multivibrator. Thus the oscilla-

    tor triggers one of the monostable timers,the period of which is controlled by ahumidity sensor.

    The period of waveform at point B isdetermined roughly by 05 RS.CS, thereforetime is proportional to the percentage ofrelative humidity. A low-pass filter, Rf andCf, produces a d.c. voltage which is propor-tional both to the time period and the %RHas well. Note that the change in voltage willbe small as the change in capacitance is initself small.

    In practice, it is only really possible todemonstrate the changing square wave witha high quality oscilloscope due to the high-er frequencies involved. Nevertheless,

    some meaningful waveforms can be mea-sured with the Picoscope. The circuit wasconstructed on solderless breadboard andwe measured a voltage of about 745mV onthe filter output (point C). By breathing onthe humidity sensor the voltage rose to790mV.

    Next month: We offer some novel ideasrelated to the use of strain gauges and wetake a look at some possible ways in whichvibration can be detected.

    We regret that in Part 2 incorrect draw-

    ings were published for Figs.2.5 and 2.7.The correct ones are printed below.

    Everyday Practical Electronics, January 2002 63

    Fig.2.5. Two input adder circuit.

    Fig.2.7. Circuit with variable gain from1 to +1.

    Breadboard layout for Lab 3.4.

    EEPPEE TTEEAACCHH--IINN 22000000Now on CD-ROMThe whole of the 12-part Teach-In 2000 series by JohnBecker (published in EPE Nov 99 to Oct 2000) is nowavailable on CD-ROM. Plus the Teach-In 2000 softwarecovering all aspects of the series and Alan WinstanleysBasic Soldering Guide (including illustrations andDesoldering).

    Teach-in 2000 covers all the basic principles ofelectronics from Ohms Law to Displays, including Op.Amps,Logic Gates etc. Each part has its own section on the inter-active PC software where you can also change componentvalues in the various on-screen demonstration circuits.

    The series gives a hands-on approach to electronics withnumerous breadboarded circuits to try out, plus a simplecomputer interface which allows a PC to be used as a basicoscilloscope.

    ONLY 1122..4455 including VAT and p&pWe accept Visa, Mastercard, Amex, Diners Club and Switch cards.

    NOTE: This mini CD-ROM is suitable for use on any PC with aCD-ROM drive. It requires Adobe Acrobat Reader (available free

    from the Internet www.adobe.com/acrobat)

    TEACH-IN 2000 CD-ROM ORDER FORMPlease send me .......................... (quantity) TEACH-IN 2000 CD-ROMPrice 12.45 (approx $20) each includes postage to anywhere in the world.

    Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Post Code . . . . . . . . . . . . . . . . . . . . . . . .Tel. . . . . . . . . . . . . . . . . . . . . . .

    I enclose cheque/P.O./bank draft to the value of . . . . . . . . . . . . . . . . . .

    Please charge my card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Card No. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Expiry Date . . . . . . . . . . . . . . . . . . . . . . Switch Issue No. . . . . . . . . . . . . .Note: Minimum order for cards 5.

    SEND TO: Everyday Practical Electronics, Wimborne Publishing Ltd.,408 Wimborne Road East, Ferndown, Dorset BH22 9ND.

    Tel: 01202 873872. Fax: 01202 874562.E-mail: [email protected]

    Online store: www.epemag.wimborne.co.uk/shopdoor.htmPayments must be by card or in Sterling cheque or bank draft drawn on a UK bank.

    Normally supplied within seven days of receipt of order.