Shop OBEX P1 Docs P2 Docs Learn Events
Oxygen sensor monitoring and valve control? — Parallax Forums

Oxygen sensor monitoring and valve control?

Andy_FreediverAndy_Freediver Posts: 16
edited 2007-07-22 23:12 in BASIC Stamp
Is a basic stamp a good way to monitor a oxygen sensor and then based on a target oxygen percentage open and close a valve until the desired percentage is reached? The oxygen sensor works by producing a voltage between 0 and 11 millivolts (0 to 100% of o2) I will be working for targets between 4% and 8% ie v small millivoltage changes!

Thanks in advance as my knowledge in this area is very limited........but that is probably obvious smile.gif

·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-05 13:30
    A Stamp is capable of this sort of control. Your main task will be taking the low voltage signal and amplifying it to a range (like 0-5V) that can be measured by an analog to digital converter. There are commercial instrumentation amplifiers that do this sort of thing. I would advise against building your own unless you have experience in doing so because of the ease of introducing errors and noise into the result. Do a web search for "instrumentation amplifier" for details. Download the Parallax tutorial called "Basic Analog and Digital" for information on and examples of the use of an analog to digital converter with a Stamp.
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-05 13:40
    Hi Mike,

    Thanks for the reply and I will download the tutorial and do some research on the amp side of things as you suggest. I thought I read on one of the posts that one of the Stamps included a analog to digital convertor already on the PCB. Is that right and can you recommend which stamp I should perhaps use?

    thanks

    Andy
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-05 13:55
    Andy,
    All of the Stamps are capable of doing simple, relatively slow analog to digital conversion using a few external components (see www.emesystems.com for a discussion of this for battery voltage monitoring). I wouldn't recommend using this for the kind of project you're working on. You need a reasonably good external ADC like the ones discussed in the tutorial.

    Any of the BS2 Stamps could do what you need. I would recommend using the BS2p since it has some additional statements and memory (compared to the BS2) that may be useful.
  • Geek_GirlGeek_Girl Posts: 7
    edited 2007-07-11 01:12
    Hi Andy,

    ··· I've been somewhat of a lurker here for a while, but your post is right up my alley, so to speak, so I thought I'd register·and reply.

    ··· I built a Closed Circuit Rebreather conversion, (can be run ECCR or MCCR)·which of course needs to monitor multiple O2 cells, drive a Heads Up Display, and control the O2 Addition solenoid valve.

    ··· A BS2 worked fine, though I could have made it more sophisticated with·one of the·2p series.

    ··· I'm curious what O2 sensor you're using with those low output levels.

    ··· Normally for O2 analysers and RBs, one of the R22 or K1D types is employed.· Each has an output range of 8 to 11mv in air, which translates to about 55mv in a 100% O2 environment.

    ··· That output level works well with low voltage, (nominally 5V) single sided, rail to rail, precision op amps as a gain stage.

    ··· If you use a 12 bit ADC with a 4.096V reference, you can read out O2 percentage or PPO2 (if that's what you need) directly, if you use a trim pot in the feedback loop of the gain stage to calibrate the output to 1000 in a 100% O2 environment.

    If you give me a more detailed idea of what you want to accomplish and some specifics, I may be able to be more helpful.





    Darlene

    ···
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-13 05:50
    Hi Darlene,

    Thanks heaps for coming out of the shadows smile.gif· as it sounds like you have already solved what I'm trying to do. I'm a freediver(ex tech diver) and use hypoxic/altitude training as part of my pre comp routine. Knowing that Hypoxic training units are essentially a rebreather I built my own and here is a link for it - http://forums.deeperblue.net/freediving-equipment/58742-diy-hypoxicator-mk2.html?highlight=hypoxic

    Simple closed circuit unit with scrubber, bladder sensor and analyser that I breathe down to 8%-10% and then maintain at that level by a simple manual valve that allows air to mix in a replenish the consumed O2.

    If you can help me with a control system for the the sensor/analyser and valve based on a preset target gas mix then that would be awesome. I have bought the BS2 and the education kit and was going to start mucking around with it this weekend. I'm using the same analyser R17(R22 with 3.5mm connector jack) but because of the low O2·targets I'm on the low end of the mV readings compared to normal rebreather usage.

    Any help would be really great



    regards



    Andy
  • Geek_GirlGeek_Girl Posts: 7
    edited 2007-07-13 09:06
    Andy,

    I'm off to work at the moment, but I'll give you a more detailed reply when I get home.· (today's going to be too hectic to get online time at work, mad.gif





    Darlene
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-13 22:01
    awesome and thanks
  • Geek_GirlGeek_Girl Posts: 7
    edited 2007-07-14 00:24
    Andy_Freediver said...
    Is a basic stamp a good way to monitor a oxygen sensor and then based on a target oxygen percentage open and close a valve until the desired percentage is reached? The oxygen sensor works by producing a voltage between 0 and 11 millivolts (0 to 100% of o2) I will be working for targets between 4% and 8% ie v small millivoltage changes!

    Thanks in advance as my knowledge in this area is very limited........but that is probably obvious smile.gif

    ·· Whew, longggggggg day· redface.gif


    I've been giving thought to your project, and since it's for training on land, (as opposed to underwater use) some aspects are less critical, but since to some extent, your life is still in it's hands, "close" may not be "good enough" so to speak. You'll need to get it right.

    The first thing I'd recommend would be changing to ·"high output"· sensors.·· The R-22DHO would be my choice.

    The reasoning is that the HO cells have a nominal output of 25 millivolts in air. That translates to about 5mv to 10 mv in the O2 concentrations you're working with, as opposed to 2mv to 4mv for the R-17 or R-22 types.

    This gets to be quite an issue as you're going to need to amplify the cell's output to feed it to the ADC, (analog to digital converter) and amplifying very low level signals without adding extraneous noise and level shifts from poor connection methods and·input offset issues with the op-amp, gets exponentially harder as the signal levels get lower. When you're down to a few millivolts of signal, every one counts.

    The real "gotcha" here is that when the signal level is lowest, you're at the most hypoxic end of your scale, where reliable data is most critical.


    I'd suggest using and monitoring at least 2 sensors, not just 1.· Most all rebreather systems use at least·3, and often a 4th .....· Sometimes things still go horribly wrong. ... You need to have at least 2 and watch to see that they track together.

    The good part is, It's about as easy to plan a 2 sensor monitor and display as a single one.

    Use a dual op-amp IC for the gain stage,·and a dual channel ADC.··A good·choice for a decent dual·op-amp would be the OPA2340, and for the ADC, the LTC1298. .... buy several 2340s (maybe 5 or 6) and hand pick the one with the lowest input offset. ... I usually use 4340s for 4 channel, and·2340 for duals.· Stay away from the cheapie, jelly bean op amps. 324s, 1458s, or even 358s, they·aren't going to cut it for such low input levels.

    Be sure to use a MCP1541 precision voltage reference (4.096V)·to supply the Vcc for the 1298.
    Everything else of course, runs off a 5v regulator, which can also provide Vin for the 1541.

    In air, and with a gain of 84, (using a 25mv cell)·your op-amp stage will feed 2.1V to the adc, which will output to the basic stamp as 2100. There are several ways you could output that value to a small LCD so you'd see it as 21.00%
    The simple Parallax 2X16 serial LCD would be fine.

    (in practice, you'd want to divide the output by 10 and display no more than 1 decimal place, (21.0%) as the cell's real accuracy is about 1% anyway)

    If you're not familiar with op-amp circuits, you'll want to do some reading up. You'll be building a non-inverting amp, and select a feedback resistor group·of 220K and 2.2K with a 2K ten turn trimpot in series to ground. You'll have an adjustable·gain range of ~50 to ~100, which you'll use to get a reading of 2100 in air·for calibration.

    The one thing I don't know right off hand, is whether the HO cells need the same 10K terminating·resistor to ground where they come into the amp as all the other cells do, or if it's a different value.·I'd have to check.




    Anyway, I hope I helped more than confused.


    Darlene


    If you'd like, I can post a couple pics of my·O2 monitor/controller.

    Post Edited (Geek_Girl) : 7/14/2007 12:45:38 AM GMT
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-14 01:03
    Hi Darlene,

    Heaps of great info, thanks and I will need to go and do some homework on availability of parts in Aus etc. My mV numbers in the first post were way wrong but you figured that out before me once I'd given the part number. Any pics, diagrams, code samples from your project would be great if you are ok with sharing them. I have loaded up the software tested the education board and stamp and everything seems to be working, so the fun and games can begin for me. I just got back from our local electonics shop to explore op-amps but they were not much help, your info gives me a lot more to go on and I might head back there today.

    Interesting comments on the HO sensor and I will drop by my old tech diving shop today and raid the fridge to see what they have in stock....this end of the world means internet shopping more than it should.

    Thanks for the help and hopefully there is more to come.

    Andy
  • Geek_GirlGeek_Girl Posts: 7
    edited 2007-07-14 02:47
    When you look at op-amps,·some of the terms you'll hear, will be·"rail to rail", "single supply",·"precision", "low/micro power".

    Single supply means it's designed to work with a positive supply voltage and ground.· Many op-amps are designed to work with both a positive and negative supply with respect to ground. You want one that works with +5V and ground.

    Rail to Rail means it's designed to accept input and then output from the ground rail level to the full supply rail level.· Some op-amps don't function right with very low or very high (with respect to supply voltage) inputs or can't output closer than a volt or so of the supply on output.· With your low input signal, you need good performance very close to the negative (ground) rail.

    Here's·some old pics of my project when it was just coming off the breadboard stage and migrating onto the pcb I made for it.

    The original project was to build a "heads up display" (the clear tube with the leds in it) to be able to know·what my PO2 was, without having to reach for and look at the PO2 monitor display module. The project sort of took on a life of it's own from the original plan.

    I hadn't yet added the lcd display, which it really needed to do it's calibration. The latter pics shows it.

    The 2 dual op-amp gain stages are there on the left, with the 4 trim pots to fine tune the gain for calibration.

    The chip in the middle is the MCP3204 4 channel adc, and the one on the right is the 2803 driver for the leds in the HUD·display.

    What is yet to be added, is the driver board for the realtime triple digital readouts, and the solenoid control board for the O2 addition valve.

    I'll post some of those pics in another post.


    Darlene
    800 x 600 - 163K
    800 x 600 - 427K
    800 x 600 - 157K
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-14 08:48
    Great pics and thanks for posting. That op amp is hard to find here and it looks like an internet purchase. I got the stamp working and had the servo doing all the things i wanted it to do, so now have the sub routines for controlling the valve opening amounts and times etc. I discovered that you can ask a servo to rotate past it's stop points and strip the gears....$29 lesson for me.confused.gif Next is the signal input side and then the control code and i'm straight to camp 4·Everest·on the couch at home in front of Discovery channel.
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-14 10:42
    I just had another thought....havent I already got the op-amp, trim pot, ADC and display driver in my existing analyser? If so, don't i just have to work out where I can pick the signal up from? Its a standard 'oxygen hackers' homebuilt analyser. Here is a pic of the unit(silver one) and the link to the design.

    ....please please please let the answer be "yes"

    http://www.cisatlantic.com/trimix/analyzer/analyzer.

    BTW - from the numbers you can see at this seesion on the unit im breathing 9% o2 and the impact is a blood o2 saturation of 71% with a slightly elevated HR of 85bpm. The next challenge is obviously hooking up and monitoring the pulseoximeter as well.
    1022 x 767 - 28K
  • Geek_GirlGeek_Girl Posts: 7
    edited 2007-07-14 13:16
    Andy_Freediver said...

    I just had another thought....havent I already got the op-amp, trim pot, ADC and display driver in my existing analyser? If so, don't i just have to work out where I can pick the signal up from? Its a standard 'oxygen hackers' homebuilt analyser. Here is a pic of the unit(silver one) and the link to the design.

    ....please please please let the answer be "yes"

    http://www.cisatlantic.com/trimix/analyzer/analyzer.

    BTW - from the numbers you can see at this seesion on the unit im breathing 9% o2 and the impact is a blood o2 saturation of 71% with a slightly elevated HR of 85bpm. The next challenge is obviously hooking up and monitoring the pulseoximeter as well.





    Ummmmmm, Nope····nono.gif··· ...... unfortunately

    The Oxyhacker analyser and countless others of it's general type, were built on the DP128 panel meter. The DP128 is a cheap (about $10 USD) panel mounting digital voltmeter module.·The parts are not discrete, but all in one big blob of black epoxy looking stuff on the board.·It's designed to read from 0 TO 1999 with a 0 to 199mV input at the meter. To measure greater voltages, you had to make an appropriate divider and set the decimal point position with a jumper.··The way it works·(if memory is·correct)·is by counting while a charged capacitor is dischaging, ....· when the cap is discharged, the count is displayed. The longer discharge took, the higher the counter counted. Obviously, the discharging resistor value (and the counting speed) was set so that the count would be·equal to the voltage being measured.

    The PO2 meter variants changed the value of one of the voltage divider resistors, such that the counter would count·to 1000 (to crresponde to a display of 100.0% or 1.000ata) with an applied input voltage equal to the output voltage of a cell in 100% oxygen, typically, about 55mV instead of the original 100mV.



    For most of us with the electronics bug, internet shopping is a way of life.

    I live on a small island in the Caribbean, and the 1·Radio Shack store is the only source of parts on the island.



    Darlene



    Here's another pic of my project as it was coming together. The module visible at the right in the canister is the driver for the triple digital readout module. Yet to be added at that time was the O2 control module.

    Post Edited (Geek_Girl) : 7/14/2007 1:38:40 PM GMT
    800 x 600 - 402K
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-14 13:59
    I had just worked some of that out also by going back through the design docs. Ashamedly, I did spend a little time trying to see if I could get at the LCD pins and just get the segment state data or get at the ICL716 pins that drive the thing. I have a rusty but once reasonable 4yrs of VB coding experience so was looking for an ugly H/W solution that I could resolve with way too much code....but then thought I should learn something and have been swatting up on ADC and op-amps and am back on the right side of the line.smile.gif Some of your earlier posts are making more sense to me now and I can't wait to get some more kit and get on with it.

    A little annoyed that I stripped the servo gears but my impatience and curiosity sometimes get the better of me (...... "I wonder what happens if I ask it to move past it's 60 degree spec sheet position") - doh

    An island·in the Caribbean! - you need to be a freediver and leave all that gear at home. Have you heard of the new tech dive computer on the market - X1? I have the freediving version the F1 which was the earlier version without the deco software. With it's open system and development kit I can imagine you linking it with your current project.

    regards

    Andy
  • Andy_FreediverAndy_Freediver Posts: 16
    edited 2007-07-22 08:10
    Hi Crew,

    Thanks Darlene and Mike for all the advice and I just wanted to let you guys know that i'm up and running as a happy little Stamper, with a working prototype. At this point I'm only using the original sensor, but it seems OK and the values are stable through the two channels of the ADC. The code is pretty simple at this stage as it simply monitors the two channels and opens the valve if I'm below target and closes it if I'm above.

    ....any thoughts on how the code·could manage it more intelligently would be appreciated. I imagine that something along·the lines of more aggressive servo action on large gaps of target to actual readings and less so on small gaps would make sense. Or would some sort of rate of change calculations be better?

    Here is a blurry pic of it on the breadboard.

    LCD is next and then time for the production version

    regards

    Andy
    2272 x 1704 - 1M
  • bottomgunbottomgun Posts: 26
    edited 2007-07-22 23:12
    Have been following this thread with interest as I have a mixed-gas Russian IDA-72 rebreather (superior to NITROX IDA-71) that is in need of electronics to make it workable. Would be interested in reviewing circuits and coding that the group has been working on. Already have electronic parts on hand including a solenoid-operated O2 valve, mostly interested in the logic behind the coding. Is it necessary to implement PID to get the correct O2 additions based upon varying demand?
    Thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,

    Jay K. Jeffries
Sign In or Register to comment.