Ozone (O3) sensors for grow chambers and tanks, Interfacing with embedded CPUs, ADC conversions ppb

Ozone (O3) sensors for grow chambers and tanksOzone is part of the Methane/Ozone/Sulpher cycle.  When UV light is radiated on O2, it has enough energy to force a single O2 molecule apart and put it together into O3.  Water in the air mixed with ozone creates hydroxides.  When the hydroxide is mixed with CH4 or with H2S, it creates different compounds ranging from VOCs to H2SO4 (acid rain).  In CELSS it is used for controlling the methane and pH of the water.  Ozone is very short lived.  It breaks apart quickly.  A typical room holds about 23 ppb (parts per billion) of Ozone.  The sensor is very sensitive, but your noise is often more sensitive.

When CH4 (methane) is created from microbes decomposing organic material and releasing CH4, CO2 and H2O into the air.  Methane rises into the air and mixes with hydroxides created from Ozone mixing with water vapor.  Methane is monitored in CELSS along with CO2 for monitoring decomposition.  Below is a link for CELSS description.

 Description of CELSS

Ozone can be used in the home for an odor neutralizer.  Great for bathrooms and bathroom odors.  Most offensive odors are some form of sulpher.  Ozone mixes with water in the air and then changes H2S into SO2 or some other form.   Methane has no odor.  All of the other smells associated with a fart come from other anaerobic gases being released from decomposition.    

Methane Sensor

 Ozone Sensor Circuit

The sensor works like an old style vacuum tube.  There is a heater that uses about 1 watt of power.  Heat from the heater acts like a bridge between two electrodes.  The variation in methane content in the air varies the current through the sensor.  The current is log rhythmically proportional to the ppb of O3 in the air. 

The sensor is stacked on the top of a 100K resistor with a 6 volt regulated power supply.  It takes roughly 24 hours for the sensor to stabilize.  Usable readings can be measured in 2 or 3 minutes.  The sensitivity of this sensor needs to be great.  The signal input is put through a op-amp to make a positive gain of 2:1.  This means the total swing for input range is 2 times.  When making the calculation for ADC to ppb, the number has to be divided by two.  This is done before the lookup table(s). 

Connections to PIC18F4550

There is no much filter done on the signal input.  The resistive bridge between the 100K resistor and methane sensor directly enters into the ADC.  The reference voltage for the ADC is default to +5 volts.  That means 5 volts is divided into 1024 measurement levels.    

 

Ozone Sensor ADC to ppb Conversion

All data is collected using a 10 bit ADC (Analog to Digital Converter)   This gives 1024 levels of voltage measurement.  All samples are averaged using 40 readings.  The input gain is doubled by the external op-amp.  See software routines at the bottom of this posting.

To use the charts we need to calculate the ratio of Rs/Ro.  Or in other words, we need to solve for Rs.  Find the ratio of Rs/Ro and look it up on the provided sensor graph.  Rs is the resistance value of the sensor at any given time.  This is calculated by taking the measured voltage across the sensor and dividing it by the current.  See the equations below…

 

For automating the calculation using the provided graph, we need to find the slope of the curve and make it into an equation (y = mx +b).  In this case the sensor works log rhythmically.  This means the slope changes every decade by a factor of 10.  Hence we use log base 10.  The y = mx + b can be converted into a log rhythmic version of the linear version.  See the conversion equation at the bottom of the set of equations above.  The ppb of Ozone is a sum of two exponential calculations.

 

Ozone Software and Routines

The last step to make an automated methane sensor is constructing routines that can be called in an RTOS.  Below are callable routines in C.  The routines call each other.  You need to call one routine to read the methane value and the CPU goes out an gets the measurements, averages  and converts the ADC value into ppm.  See routines below.

//************************************************************
// Created Nov. 30, 2012
//This routines converts the raw data from the ADC into data for O3.  The units is returned in ppm.
//There are a lot of log funtions to slow the RTOS.
//************************************************************
int16 ScaleToOzone(int16 AveragedADCReading)
 {
 float VRecycled1,VRecycled2;

// Find the Vin across the bottom 100K resistor
 AveragedADCReading = AveragedADCReading / 2;   //Divide the ADC by two because it is gained by two.
 VRecycled1 = (AveragedADCReading * 6.0)/1024.0;

 VRecycled2 = 6.0 * ( 1.0 – (AveragedADCReading/1024.0));   // Voltage over the sensor

 VRecycled1 = (6.0 * AveragedADCReading/1024.0)/100000.0;  //  Current through sensor

 VRecycled1 = VRecycled2/VRecycled1;   // E/I = R

// Ratio the resistance with Ro/Rs
 VRecycled1 = VRecycled1/150000.0;   // Rs is the optimal resistance at normal temperature.

//  Next is the mapping to the O3 plot graph

 VRecycled1 = pow(10.0,1.3953) * pow(VRecycled1,-1.1565);  //  This converts the ADV average for the resistance over the ssnesor into ppm of CH4 or Methane.

 return((int16)(VRecycled1));   //Return the value
 }
//*************************************************************
// Created Nov. 6, 2012
//  This routine reads an ADC and averages 16 samples into one and returns the number.
// There is no scaling or any signal condition excepct for a low pass averaging filter.
//  The input selection is for ADC 1, 2 and 3.  The numbers 0, 1 and 2 are used for selecting the ADC.
//*************************************************************

int16 GetADCValue(int selection)
 {
 int16 ReturnedADC, Summer; 
 int f;
     set_adc_channel(selection);
     Summer=0;
     for (f=0; f < 40; f++)
      {
     delay_us(10);
     Summer = Summer + read_adc(); // Read adc channel 0
      }
     ReturnedADC = Summer/40;
 if (selection == 1)
  {
  return(ScaleToMethane(ReturnedADC));  // Convert into Methane ppm from raw data.
  }
 if (selection == 2)
  {
  return(ScaleToOzone(ReturnedADC));  // Convert into Methane ppm from raw data.
  } 
}

 

//********************************************************************
// Created Nov 6, 2012
// This inits all of the ADC convereters for input.
//  There is no output from this funtion.
//********************************************************************
void SetupADC(void)
 {
 setup_adc_ports(AN0_TO_AN2);  //Set up AD0, AD1 and AD2 for ADC inputs.
    setup_adc(ADC_CLOCK_INTERNAL);
 }

Leave a Reply