Beeb Bodybuilding Course Exercise No. 44 The Humid Condition Our brand new Editor bounced across the room and said, "What's it to be this month then?" "A computerised Hygrometer," I replied. He looked a little puzzled and asked why. "Because," I said, "I am a humid being." "Oh!" he said mysteriously, "so what the previous Editor told me about you is true." and he turned away wondering if he had made the right decision in accepting the job. For those none the wiser for the anecdote, let me say that a hygrometer is used to measure humidity, i.e. the amount of water in the air. It is not very useful to measure the absolute amount of water vapour as this changes with temperature and pressure so we normally deal with relative humidity. This is a measure of the amount of water vapour in the air relative to how much vapour it can take. As the total amount of water vapour depends upon temperature a sudden drop in temperature can force the relitive humidity to 100% and beyond. When this happens moisture is condensed out of the air as dew or fog. Why should anyone want to monitor the RH? Well those of you who have an interest in weather measurements might like to add this to the Body Build anemometer pressure gauge and wind vane covered in past issues. But interest in this device is not restricted to that as it can be used to control and monitor air conditioning systems, humidifiers and greenhouse climate controllers. It can even be used to monitor tumble dryers to detect when the load is dry. Now traditionally electronic humidity sensors have been very expensive but now Mullard have come up with a sensor that is reasonably priced. It is designed to work over a range of RH between 10% to 90%. Whilst it is not a precision transducer it will perform to an accuracy of 5% under worst case conditions and as worst case conditions do not prevail most of the time it will be more accurate than this. Mullard are naturally cagey about exactly how the sensor works but basically it is a capacitive sensor. If you remember basic theory you will know that a capacitor is simply a pair of conducting plates separated by some insulating material known as a dielectric. It stores charge and the amount of charge it can store is known as its capacitance, this depends upon three things. The first is the area of the plates, the more area the more charge. Secondly the closer the plates are together the more charge can be stored and finally the type of dielectric also affects the amount of charge. The measure of how a material effects capacitance is known as the material's dielectric constant. What Mullard have done is to produce a membrane whose dielectric constant changes with the RH. As a warning is given in the data sheets that some solvents such as acetone will attack the membrane, it is a fair guess that it is some sort of plastic. To make the humidity transducer both sides of the membrane are covered with gold to form a capacitor and the whole unit is mounted in a perforated plastic case. Thus the transducer is easy to handle and to build into a humidity sensor. So basically the sensor will change capacitance as the RH changes. The capacitance and the change however are quite small, it has a value of 112pF with 10% RH and rises to 144pF at 90% RH. So our problem is to convert this capacitance into something we can measure with our computer. The way we will do this is to incorprate the the transducer into an oscillator. However, with such a small capacitance the oscillator will be running much too fast for accurate measurements and temperature changes would also affect the accuracy, so to overcome this we have two synchronised oscillators, one with the transducer and the other with variable capacitor trimmer. If we adjust the trimmer to be the same as the standing capacitance of the transducer and then compare the two output pulses the difference in the two will be proportional to the RH. This is shown in Figure I. We can simply convert this pulse into a measurable voltage by smoothing it with a resistor and capacitor and then we can measure it with the analogue input port of the computer or more accurately with the Body Build digital voltmeter (April 85). So we need to consider what oscillator to use. An oscillator is a circuit that strives to be in one condition but only achieves that condition when it achieves a state of "wanting to be in its original condition". A perfect example of this was given to me by my youngest son Graham. You see he is particularly fond of dummies (or dodies). One day whilst sucking his blue dummy he spotted his yellow one. This proved such an attraction that he removed the one he was sucking and replaced it with the yellow one. However now he could see his blue one and that looked nice too so he removed the yellow one and replaced it with the blue one. This cycle continued for some time until he was distracted by my laughter. Figure II shows the basic form of oscillator we will use. It consists of two inverter gates so called because the output is the inverse of the input. Suppose point B is high then point C will be low and point A will also be low. But as time passes the high voltage at point B charges up the capacitor through the resistor until point A goes high. This will cause point B to go low as they are connected through an inverter and point C will go high. As time passes the capacitor will discharge through the resistor until point A is low driving point B high. This cycle repeats and we have an oscillator. The time taken for the oscillator to change states is determined by the capacitor and the resistor. Figure III shows the full circuit of the humidity monitor. You will see that there are two oscillators made from gates on the same integrated circuit. This ensures that any changes in frequency due to temperature variations will occur equally to both oscillators. The oscillator with the humidity transducer is gated by the other oscillator to ensure that the two oscillators are synchronised. The output from the two oscillators is fed into a second integrated circuit where the exclusive OR gate produces an output only when the two oscillator outputs differ. As there are four of these gates in one package we drive them all in parallel. This uses up all the gates as CMOS should never have unconnected inputs. It also makes a nice low impedence source to drive the next stage. This is simply a smoothing circuit to average the pulse and give a steady voltage that can be measured by the computer's analogue input port. All the parts for the humidity sensor circuit are available as Body Build pack No.37. Note that the sensor alone can be purchased. You will find the order form on page XXX. The only snag with the Humidity transducer is that it has a non-linear response. This means that there is no simple relationship between relative humidity and capacitance. To compensate for this it is traditional to use a linearising circuit but these are difficult to set up and are not very accurate. Insted the linearisation takes place in software and can be tailor made to your sensor and so will result in quite an accurate measurement. The data sheet for the sensor gives a curve of relative humidity against capacitance, these are summarised in table 1. Using this I subistituted several accurately measured fixed capacitors for the humidity sensor and noted the readings from the analogue input port of the computer. I could then draw a curve of capacitance against computer reading and finally produce a list of reading and humidity to use in the linearising software. Alternatively the list may be produced by noting the reading with the humidity sensor fitted and then measuring the humidity by some conventional means. The most common of which is wet and dry bulb thermometers. A mixture of these two techniques may be used if you like. Now to make it easy for you to calibrate your system, if you order the kit of parts, you will get a calibrating capacitor individually measured with a note of what relative humidity it represents. Then all you have to do is substitute this capacitor for the sensor and adjust the trimmer until the correct humidity is indicated. The program to read the sensor is shown in listing I. The DATA statements contain the calibration list we have just been talking about. The first number is the number of reading/humidity pairs we have in the other data statements. These pairs are read into two arrays. Then the value on the analogue input port is averaged over five readings. This number is easily changed by line 150. Having got the reading we must now see what humidity level it corresponds to. The table of readings is then searched until we find a value in excess of our reading, therefore the reading we have is between the last two array entries looked at. Line 290 works out the fractional distance our measurement is between the two table entries (e.g. maybe half way) .Then line 300 takes this fraction and applies it to the two corresponding humidity values (ie the actual humidity is half way between the two table entries). This technique is known as interpolating between table entries and gives a much more accurate reading than just relying on the table alone. The more table entries there ar the more accurate this becomes. In practice it takes the sensor about five minutes to respond fully to sudden changes in humidity but in most situations this is quite acceptable. So now, in the humid spirit, I can wish you a very merry Christmas. TABLE 1 Capacitance Relative Humidity 112pF 10% 115pF 20% 118pF 30% 121pF 40% 124pF 50% 128pF 60% 132pF 70% 137pF 80% 144pF 90%