circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

January 2005, Issue 174

Microcontroller-Based Nitrox Analyer


by David Smith


ANALYZER HARDWARE

The AT90S4433 microcontroller that serves as the computing core for this project is extremely powerful and loaded with a full complement of peripherals (see Figure 1 and Photo 2).  It’s equipped with 4 KB of in-system programmable code flash memory, 128 bytes of data SRAM, and 256 bytes of data EEPROM. Furthermore, the microcontroller’s native instruction size is 16 bits, which means that its code flash memory can hold at most 2,048 assembly instructions.

(Click in to enlarge)

Figure 1—The main components of the design are the microcontroller, LCD interface, analog amplifier, and the power control and conditioning.

 

(Click here to enlarge)

Photo 2—Take a look at the Nitrox Analyzer’s main electronic components, subsystems, and PCB. Note the homemade protoboard section in the upper right corner.

The AT90S4433 contains 32 general-purpose 8-bit registers, a 10-bit ADC, a UART, an SPI port, an 8-bit counter, a 16-bit counter, an analog comparator, and a watchdog timer. It can run at up to 8 MHz, with the majority of its instructions executing in a single cycle. Atmel has issued an “end-of-life” notification for the microcontroller, but a pin-compatible upgrade path exists via the ATmega8. 

The Teledyne R-17D oxygen sensor is the key to sensing the percentage of oxygen. It produces a linear output voltage that’s proportional to the partial pressure of oxygen to which it’s exposed. The percentage of oxygen is determined with this information by dividing the measured partial pressure of oxygen by the ambient atmospheric pressure. The sensor is temperature compensated and rated to operate over a range of 0 to 1 atmosphere of pressure. Its accuracy is within ±1% of full scale at constant temperature and pressure. A zero-input offset error of up to 0.5% also may exist.

The datasheet indicates that the sensor produces a 10-mV, ±3-mV output when exposed to approximately 21% oxygen, which is present in air at sea level. Because there is the potential for such a relatively large variation in the normal output characteristic from sensor to sensor, calibration is required in order to compensate.

The millivolt-level signal from the oxygen sensor is scaled by an instrumentation op-amp before being passed to the microcontroller’s ADC input. Certification agencies require recreational Nitrox mixes to be between 21% and 40% oxygen, so I chose an amplifier gain of 184 to scale 41.6% oxygen to an unclipped, full-scale signal under worst-case conditions. This ensured that the smallest maximum of slightly more than 40% oxygen could be measured for the worst in-spec sensors (see Figure 2). In this case, full-scale is 4.8 V, which is used as the theoretical maximum because the op-amp’s output is limited to 70 mV less than the positive supply rail of 5 V.

Figure 2—This equation illustrates the calculation of the worst-case maximum percentage O2 that the analyzer can measure.

The user interface consists of one push button for input and a 2 × 8 LCD module for output. The push button turns the unit on and off and allows you to select modes and options. In addition, the unit saves battery power by automatically powering down after various specified timeouts have elapsed. Furthermore, a spare ADC channel measures battery voltage to provide a low-battery warning.

The Nitrox analyzer is housed in a PacTec HP-9VB project case that includes a built-in compartment for the unit’s 9-V battery. I’d like to thank Gordon Fry and David Manley for their assistance in modifying the housing to accept a bezel for the LCD. 

In order to measure the percentage of oxygen in the Nitrox in a scuba tank, I built a sensor mount from a small, T-shaped PVC tube. The sensor is in the top opening. A second opening is held against the tank valve. The third opening is covered with a cap with a small hole in it. The tank valve is opened slightly—just enough to allow the Nitrox to begin flowing through the tube. It’s important to keep the pressure of the Nitrox flowing from the tank to a minimum, because pressure will affect the accuracy of the measurement.