EOS |
Instruments |
Humidity Sensor |
Programming Exercise in PicAxe |
The output of the Philip Harris Humidity Sensor is directly proportional to the relative humidity of the surrounding air. The capacitive sensor is at the end of the external probe which is connected to the Blue Box. The output voltage of the Blue Box ranges from 0 to +1.0 V, corresponding to a relative humidity of 0 to 100%. |
Note on relative humidity
The humidity of a parcel of air refers to the mass of water vapor contained within the mass of a certain volume of air at a given temperature. The measure of humidity would be in, say, grams of water per kilogram of air. This so-called absolute humidity would have units g/kg.
Relative humidity is the absolute humidity of the air at the given temperature divided by the absolute humidity of the air if it were completely saturated with water vapor. This ratio is expressed as a percentage. A parcel of air with a relative humidity of one hundred is completely saturated with water vapor. |
The Assignment
Write a program to read the analog input of the PicAxe microprocessor 08M2 at the pin C.1, convert that to relative humidity, continuously update and display the result on the OLED. The OLED display must include the word “Humidity” centered on the first line and the second line must display – centered – the current value of relative humidity and the percent sign. |
Basic commands which might be useful for the solution First, define some variables such as these: symbol variablename = pinC.2 ‘ no space between “pin” and “C.2” symbol Vinput = w0 symbol Pressure = w1 ‘w0 and w1 are word variables, i.e., 16 bit variables.
Commands related to reading the analog input: fvrsetup FVR2048 adcconfig %011 readadc10 C.2
Commands related to displaying the output: bintoascii serout C.1, N2400_4,(254, 128,” “) serout C.1, N2400_4,(254, 192, “ “,b9,b10,b11,” “) Note that whatever is within the parenthesis is displayed on the OLED. Make sure that there are exactly 16 characters or spaces within parenthesis. 128 is the leftmost position on line 1 of the OLED 192 is the leftmost position of line 2 of the OLED bintoascii converts a binary number to a display character.
Commands related to logic and math: if variablename = 0 then . . . endif goto (linename) VariableA = VariableB * 2 + 800 / 7 ‘math protocol strictly left to right; integers only |
Power Supply on PicAxe Circuit Board Power Input: +7.0 V to +35.0V; connector is center positive; nominally +9.0V dc power adaptor is used (+9.0 V battery for portable use, but avoid if possible since current drain is high - battery won’t last long). Power Output: +5.0 V, regulated 200mA maximum current Red LED “on” indicator. This power supply is hardwired to both the PicAxe and the OLED display; red lead positive/black lead ground, 0V. |
Philip Harris Barometer Sensor Blue Box Use only the red and black banana jack connectors on the Blue Box. Never use the blue banana jack. Power requirements: +6.0 V; separate external battery pack Battery pack red lead positive/Black lead ground, 0V Output (red/black banana jacks): Output ranges from 0 Volts to +1 Volt, and is linear in relative humidity, from 0 to 100%, sensed by the probe’ Red jack, voltage out; Black jack, ground, 0V. Switch in “BATT” position: The Blue Box output will be +1.0 V if the battery voltage is +6.0 V. Replace batteries if this output is below +0.75 V (corresponding to a battery voltage of +4.5 V). NOTE: Do not use blue banana jack – negative voltage on the PicaAxe input may damage the microprocessor.
|
Blue Box Manual |
The simplest solution is to write a Flowchart in Logicator, convert the Flowchart into Basic language and modify the program as needed, for example, by naming the variables appropriately. The Flowchart might look something like this: |
|
Solution |