Friday, April 27, 2012

PIC Based Air Quality Monitor

Idealy if you have a combustion heater in your home, there should be some means of monitoring the air quality. This is where the Air Quality Monitor comes in, it measures both carbon dioxide and carbon monoxide levels, and displays the results on LED bargraphs. If the concentration of either of these gases rises above a preset level, a loud alarm will sound, which means that you should turn off the heater and open the room up to fresh air.

Each bargraph comprises eight LEDs that light invidually to show eight distinct levels. In between values are displaed by lighting two adjacent LEDs. This gives a total of 15 levels that can be displayed. The four lower LEDs are green, followed by two orange and then two red LEDs. An automatic dimming circuit ensures that the LED displays are not too bright at night.

In addition, the alarm sounds if any of the top three LEDs light in either display. There are three alarm levels:
  1. Main alarm sounds if the top LED lights. This consists of a 64ms-long 4kHz tone that repeats every 0.5s. 
  2. Less urgent alarm sounds if the second top LED is lit (top LED off). This alarm gives a 32ms-long 4kHz ‘chip’ every four seconds (4s). 
  3.   Warning alarm sounds if the third top LED is alight. This alarm mode gives a brief 16ms 4kHz ‘chirp’ every 16 seconds (16s). 
An internal fan at one end draws air through the box so that the internally mounted CO and CO2 sensors are presented with a continuous sample of the air that’s being monitored. Power for the unit comes from a 12V DC 500mA plugpack.

Circuit details
Take a look now at the Air Quality Monitor circuit of Fig.1. It’s based on two gas sensors and a PIC microcontroller (IC1). The microcontroller monitors the sensor signals and drives two multiplexed LED bargraph displays. 
PIC Based Air Quality Monitor
We’ll start by looking at the CO2 sensor. This consists of a heater coil and a solid electrolyte cell comprising a lithium (Li) cathode and a potassium (Ka) anode. When these electrodes react with carbon dioxide, a potential difference is produced between them that varies with the CO2 concentration.

The sensor is built into a metal housing and is exposed to air (and to CO2) via a stainless steel mesh. Its output in normal air (ie, with a normal CO2 concentration) is typically 325mV. This voltage falls with increased CO2 concentrations beyond 400ppm (parts per million) or 0.04%. 

The CO2 concentration in normal air is 0.0314%, but this can increase to 5% in air that’s directly exhaled from the lungs. At this latter level, the sensor’s output will be well below 250mV (compared to 325mV in standard air). 

The CO2 sensor’s output appears across its ‘A’ and ‘B’ terminals, and has a very high impedance, so any loading will drastically reduce this output. As a result, the manufacturer recommends monitoring the voltage using a circuit that has a 100Gohm to 10Tohm input impedance and an input current not exceeding 1pA. To comply with these requirements we have used an LMC6482 CMOS op amp (IC2a) to buffer the sensor signal. Its input impedance is 10Tohm  while the input current is typically just 0.02pA. 
CO2 threshold
IC2a is wired as a non-inverting stage with a gain of about 11, as set by the 10k and 1k feedback resistors. As a result, a 315mV output from the sensor (ie, in normal air) should result in a 3.47V output from the op amp. 

In practice, we found that the output from the particular CO2 sensor we used was greater than 315mV in normal air, causing IC2a’s output to go above 5V. Consequently, trimpot VR2 has been added so that IC2a’s output can be level shifted, to correctly set the output to 3.47V in normal air. In practice, VR2 is adjusted so that the lowest LED in the CO2 bargraph is just off in normal air.

Note that the output from the sensor is valid only after it has been heated sufficiently. This is achieved by connecting a 6V supply across the  internal heater element.
CO sensor
The output from the CO sensor is mounted at the AN3 input of IC1. However this sensor operates differently from CO2 sensor, in that it varies its resistance with CO concentration.
co sensor cycle
The specifications state that this sensor must initially be heated using a 5v supply connected acress its heater element for 60s. the heater current is then reduced by placing just 1.4v across the element for 90s period. The CO concentration is then measered. In practice, this means that measurements are repeated at 150s intervals. 

Q5 is controlled by IC1’s RB1 output (pin 7) and turns on when its gate is pulled high. In operation, RB1 switches Q5 on for 60s to provide the heating current. RB1 then goes low for 90s, which switches Q5 off, so that the measurement can be made. During this 90s period (ie, with Q5 off), the CO sensor’s heater is effectively in series with the 2.2ohm and 100ohm resistors connected across Q5. As a result, the current through the sensor drops to 42.34mA, which means that the voltage across the heater is now 1.397V (ie, 33 x 0.4234). That is close enough for practical purposes to the 1.4v value specified.

During set-up, VR5 is set so that AN3 is at 0.5V when the sensor is in normal air. However, this signal voltage can rise to around 3V when the CO concentration is over 300ppm. 

The maximum bargraph level for CO is adjusted using trimpot VR4. It effectively forms a voltage divider across the 5V supply, and its output is applied to the AN4 (pin 3) input of IC1. This voltage, along with the sensor voltage on AN3, is then used by IC1 to calculate the bargraph display level.
Display dimming
Automatic display dimming is achieved using a light-dependent resistor (LDR). As shown, the LDR is connected in series with trimpot VR6 across the 5V supply to form a voltage divider. The output of this voltage divider is connected to the AN1 input (pin 18) of IC1.
In bright light, the LDR’s resistance is 50kohm or less, and so the voltage applied to IC1’s AN1 input is pulled close to the 5V supply. This signals IC1 to drive the LEDs at full brightness. 

Conversely, at lower ambient light levels, the LDR’s resistance increases and the voltage at AN1 decreases. As a result, IC1 now drives the LEDs with a reduced duty cycle. This is achieved by using a longer dead time, ie, the time between when one transistor switches off and the next one switches on. This effectively reduces the length of time that the LEDs are lit and hence reduces their brightness.
Piezo alarm
The alarm feature is provided by using the pin 6 PWM (pulse-width modulation) output of IC1 to drive a piezo transducer. Its frequency of  peration is set to 4kHz (50% duty cycle) and there are three alarm modes, as described earlier. 

Note that the alarm is only activated when one of the top three LEDs in either bargraph is lit.
Initial adjustments
Before using the unit, it’s necessary to adjust the full-scale sensitivity and threshold level of each ‘bargraph’ display. The initial procedure is as follows:
1) Adjust trimpot VR3 (CO2 level) to give 3V at test point TP3. This sets the CO2 full-scale sensitivity to about 10,000ppm or 1%.
2) Adjust trimpot VR4 (CO level) to give 3V at TP4. This sets the full-scale CO sensitivity to about 300ppm.
3) Adjust VR2 so that the bottom LED of the CO2 bargraph just extinguishes (ie, no LEDs lit). This should be with test point TP2 at just under 3V.
4) Wait 60s after applying power, then blow on the CO2 sensor to expose it to extra CO2 gas. Check that the CO2 bargraph now shows a fullscale reading (ie, top LED lit). If the piezo transducer is connected, check that the alarm sounds with any of the top three LEDs lit.

CO sensor adjustments
Making the adjustments for the CO sensor is a slow process, since it requires a ‘burn-in’ period of 48 hours. The unit must, therefore, be left on for 48 hours before making the final adjustment. Additionally, as stated in the circuit description, the sensor is heated for 60s and then allowed to respond to the gas over a 90s period before each measurement is made. This means that it will take 2.5 minutes to get the result after each adjustment.

Initially, however, you can bypass the 48-hour burn-in period and make the initial adjustments straight away.the final ‘touch up’ adjustment can then be made after the burn-in period.

The first step is to adjust trimpot VR5 so that TP5 is at 0.5V right towards the end of the 90s measurement period, ie, when the sensor is in fresh air. However, this requires some means of monitoring the heating and measurement cycles.

In practice, you can either use a second multimeter to monitor the drain (D) of Q5, or use a diagnostic tool that’s built into the Air Quality Monitor that shows the heating/measurement cycles. The procedure for each method is as follows:
METHOD 1: if you have a second multimeter, connect it between Q5’s tab (ie, its drain) and GND. Q5’s tab will be close to 0V during the heating cycle and at 4.3V during the measurement cycle. Adjust VR5 to set TP5 to 0.5V near the end of the 90s measurement cycle. 
METHOD 2: if using the inbuilt diagnostic tool, start by adjusting VR4 fully clockwise, so that TP4 is at 0V. This will now cause the CO bargraph display to show the heating and measurement cycle.

During the 60s heating cycle, the top two red LEDs will be lit. Then, during the 90s measurement cycle, the red LEDs switch off and the four green and two orange LEDs initially light. These LEDs then extinguish one at a time, starting with the topmost orange LED and continuing at 15s intervals until the bottom green LED goes out at the end of the 90s period.

The unit then reverts to the heating mode again, with the top two LEDs lit. Note that if VR4 is not set all the way down to 0V, only the top LED will light. Additionally, the alarm will sound if VR4 is set below 2V, so the piezo transducer should be unplugged during this procedure.

Assuming VR4 is set for 0V at TP4, it’s just a matter of adjusting VR5 so that TP5 is at 0.5V when the lowest one or two green LEDs are alight. Once that’s done, be sure to readjust VR4 so that TP4 is at 3V.
The Air Quality Monitor should be mounted near to the combustion heater and preferably on a wall, so that the display can be easily seen.

The box has mounting holes that are accessed with the lid off, so it’s easy to fix in aposition.
Note that it’s normal for CO2 levels to rise while the heater is on. However, the ventilation should be increased if the indicated level rises past the low region on the bargraph.

The carbon monoxide (CO) level in the room should be kept to an absolute minimum and this can be achieved by ensuring that the heater is operating correctly. With wood heaters, this means allowing the temperature to rise sufficiently after the fire has been started, to ensure clean combustion, before reducing the air intake to slow the combustion process.

Finally, never use treated or manufactured timber such as treated pine,MDF,chip board, hardboard or similar in wood fires. These product can produce nonxious fumes during combustion. 

Download:code files

No comments:

Post a Comment