Loading...
 
O2 sensor module.

O2 sensor

O2 sensor module.

Feb 2010,

This project is an arudino oxygen module sensor for my two wire buss.

Arduino pro mini based.


I've had pro-minis fail in the past but I'm giving them another try. These are a new batch and hopefully will be flawless. The problems appeared to be the SM resonators and I have resonators on hand should I need to replace them. This project doesn't need accurate timing so internal R/C would be good enough.

Image Power,ground and two TWI connections are all that is needed to connect to the buss. I use my "eddie standard" 8pin DIN layout. Power is connected via a 250mA polyfuse. A piece if cardboard was added before encapsulation to prevent the power lead touching the PCB.


I'm wary of completely encapsulating the pro-mini in case I need to repair it. With the back covered I can still replace the resonator. Even with the pro-mini encapsulated I can still change fuse settings by plugging the programmer into the shield socket. I may encapsulate the shield but not combo. In other words the two poly blobs will still unplug from each other.

Image As usual polymorph holds and protect the wiring. Here it is still hot and transparent.


Sensor.


The sensor I've used is of the fuel-cell variety. These are basically a metal-air battery where the current output is used to measure O2 partial pressure. These sensors do not measure O2 concentration. With a constant percentage of O2 in the gas - changing the gas pressure will change the reading. The material in the cell is consumed over time so the have a very limited life span.

Image The R-22D sensor is one of the more common types and is used in many scuba rebreathers.


Often a load resistor is used to convert the cell current into a voltage. The is how the R-22D is intended to be used. I used an alternative method which is to use an op-amp to cancel out the cell current. This gives a more linear response and probably and extend measurement range. The down side is the temperature compensation circuit built into the sensor is rendered useless and compensation (if needed) must be done externally.

I've seen MOSFET circuits added to short out the sensor terminal when the circuit is off/unpowered (to avoid O2 build up inside the cell.) I think this is totally unnecessary because you can fit a permanent discharge/shunt resistor. Seeing the cell has no voltage across it in operation the resistor passes no current an has no effect when the circuit is on. The R-22D seems to have internal discharged and does not seems to work fine even after being disconnected for long periods - it was shipped without the terminals shorted.

Electronics.

The circuit is so simple it doesn't really need a diagram.

Basically the positive sensor terminal is grounded as is the amp +ve input. The sensor -ve connected to the amp -ve and tries to make the voltage go negative. This make the amp output go high and this is connected to in -ve via a resistor. The current fed back cancels out the sensor current such that the input voltage is held at zero volts. The resistor value sets the current to voltage ratio.

My circuit is powered by the 5 volt arduino regulator. I need the output to be under 1.1V so I can read it using the AVR ADC. I have this configured to use the 1.1V internal reference.

The opamp used must be able to run off a single 5V supply. It must also have inputs and outputs capable of working down to ground. It also need to have low input offset or be trim-able. The TEXAS INSTRUMENTS TLC271ACD was the first op-amp I found that was suitable and that is what I used. I meant to order a DIP package version but ended up with SM. SM is a pain to solder but the smaller package ended up being a good thing.

The TLC271 can be setup for different bias currents and I selected "high current" for better performance.

Image The electronics lives on a mini-shield made from a piece of prototyping PCB (sparkfun). This board has pins which insert into sockets on the minipro.


The yellow trim pot and resistors on the LHS of the photo are for offset trimming. The blue trimmer is the feedback from the amp output to the summing point at the -ve input. The 3 pins on the right are for the cable to the sensor (the middle one isn't connected).

Image A side view of the two PCB stack. It is asking for a layer of polymorph but not until it is complete and tested.


Software.

The micro was programmed with my own bootstrap as explained on other pages. It allows the main application to be uploaded via the TWI network.
The main code is very similar to the code on the pressure and air quality sensors. Initially I used the existing sensor code unmodified but later modified it to add temperature compensation. The code is written using WINAVR.

First run.

I adjusted the gain till the ADC read 420 - this is 20 units for every percent of O2 (Air is about %21 O2).

Image A plot of the first test run - very promising.


The plot above has a grid line every 20 seconds. The big dip is where I displaced all the O2 by filling a plastic bag with refrigerant/propellent from a spray freeze aerosol tin. The output fell to zero and recovered nicely when the sensor was back in air. The second dip is exhaled air after hold my breath a little while.
The module worked perfectly except for temperature drift.

Temperature compensation.

You can compensate for the sensor's temperature coefficient using something like a thermistor in the op-amp circuit.
Apart from being yukky analogue stuff which would be a pain to calibrate - it also gets messy because you want the temperature sensor at the O2 sensor.
My approach is the use a temperature sensor on or in the O2 sensor and calibrate in software.
I could use a digital device such as the DS18B20. This should work but they're not that easy to use and they are slow. These are solvable problems but an suitable analogue sensor is easier.

I've tried using a diode as a sensor and the works but the precision is not great. The diode was placed inside the cavity at the back of the O2 sensor (near the 3 pin connector). The O2 sensor drifts almost exactly four times the rate of the diode sensor.

A diode is good enough for what I'm doing but it would be nice to have something just a little better - a LM35 or LM34 should do the trick nicely - stay tuned.

Image
 
	ADMUX=0xc0;		
	O=getadc();
	ADMUX=0xc1;		
	T=getadc();	
	if (tune!=0) 
		correction=(float)(gain+(T-Tref)/(float)tune);
	else correction=gain;
	temp=(int)O*correction;
	if (temp>1023) temp=1023;

eddie
http://www.btinternet.com/~madmole/DiverMole/DMCells.htm


Created by eddie. Last Modification: Thursday 18 of February, 2010 15:53:18 AEDT by eddie.

Main Index

Switch Theme

Shoutbox

eddie, 13:04 AEST, Thu 10 of Aug, 2023: Offline tiki 26 upgrade went badly. Waiting for 26.1. Will limp on.
System Administrator, 18:45 AEST, Wed 26 of Jul, 2023: Recovered from lockout but unable to upgrade to V24
eddie, 23:20 AEST, Sun 29 of Aug, 2021: moving to new server
System Administrator, 17:23 AEST, Thu 12 of Aug, 2021: Image thumbnails not working for gallery images. Problems with the GD extension.
System Administrator, 19:44 AEST, Mon 09 of Aug, 2021: uploaded wiki and database to main server. It didn't work but the old wiki and repaired database seem to mostly work.

Last-Visited Pages

Online Users

8 online users