Shop OBEX P1 Docs P2 Docs Learn Events
Help needed with mV input BS2 project — Parallax Forums

Help needed with mV input BS2 project

willembadwillembad Posts: 47
edited 2012-06-06 10:36 in BASIC Stamp
Hi all,

I am new here as well as to the world of BASIC Stamp. I bought the Basic Stamp discovery kit for my son and we have been working through the chapters. I got an idea to incorporate the stamp into a project for a automated gas mixer I am thinking about. The basic premise is to add oxygen to the stream of air that enters a compressor. I would like to monitor the concentration of the oxygen and adjust it accordingly based on a preset value.

The sensor I am currently using in a manually adjusted system is an O2 cell that generates voltage in the presence of oxygen. In normal air the output is around 10 mV and it is basically linear. I am interested in the range of ~10 mV to ~20 mV. I would like to measure this voltage and adjust a needle valve with a servo to maintain a specific setting. So far it seems from me reading up a bit that the best way to do this would be to use an op-amp and ADC for the input. Would the LM358 op-amp sold by Parallax http://www.parallax.com/Store/Components/IntegratedCircuits/VoltageRegulator/tabid/615/CategoryID/80/List/0/SortField/0/Level/a/ProductID/231/Default.aspx
work in this case and if not could you point me to one that has the right specs? As for the ADC, they sell an 8-bit ADC0831 http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/ADC/List/0/SortField/4/ProductID/245/Default.aspx. I'm not 100% sure what resolution that would give me but I think it is good enough for this project. Any thoughts or comments on these components?

Thanks in advance,

Willem
«1

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2012-05-01 11:53
    Welcome to the forums.

    You're on the right track as far as using an opamp and a a/d converter. Nearly any general purpose amp that will operate with a gain of about 250 (to give an output of 5 volts) will do.

    An lm324 has 4 amps in the package and will operate from a single supply .I'd recommend an ltc1298 a/d which gives you two channels to play with and 12-bit resolution.

    Cheers,
  • davejamesdavejames Posts: 4,047
    edited 2012-05-01 11:54
    Hello Willem - welcome to the Forum!

    The books at the following link may hold some useful information for you. The physical books are available for purchase, or you can download the PDFs for free:

    http://www.parallax.com/Store/Books/AllBooks/tabid/763/CategoryID/41/List/0/SortField/0/Level/a/ProductID/141/Default.aspx
    http://www.parallax.com/Store/Books/AllBooks/tabid/763/CategoryID/41/List/0/SortField/0/Level/a/ProductID/395/Default.aspx

    Regards,


    ***followup - when choosing an opamp for low signal levels such as you're facing, make sure the Vos (voltage offset) spec is at least a factor of 10 better. Meaning, if the signal is in the 1mV range, look for an opamp that has a Vos of 100uV. With mV signals, the inherent offset voltage of many opamps will "skew" the ouput resulting in an unaccurate measurement/reading.
  • willembadwillembad Posts: 47
    edited 2012-05-01 17:29
    Thanks guys. How about this op-amp? http://search.digikey.com/us/en/products/MCP607-I%2FP/MCP607-I%2FP-ND/319465
    M
    aybe this for ADC? http://search.digikey.com/us/en/products/MCP3202-CI%2FP/MCP3202-CI%2FP-ND/305924

    I
    'm reading through those texts right now. I actually worked through the first half of the first one before but without the parts it's just theoretical.
  • stamptrolstamptrol Posts: 1,731
    edited 2012-05-02 09:31
    Willem,

    The parts I recommended are ones I'm familiar with.

    The op-amp you've referenced looks like should work with a supply of 5 volts.
    The a/d can probably be made to work. I suggested the ltc1298 because the code to access it is readily availalble.

    Cheers,
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2012-05-02 09:43
    Because of the low voltage levels I would lean towards using an instrumentation amplifier.

    What are the specs of the O2 cell? ...if the output is differential then I would definitely use an instrumentation amplifier.
  • willembadwillembad Posts: 47
    edited 2012-05-02 11:46
    I just realized that I can source the LTC1296 from Parallax. I would like to get all that I need from them just to make one order, and I need to order some other goodies as well. I did not see an amp on the Parallax site that looked promising.

    As far as the O2 cell. It is a Teledyne R-17 oxygen sensor http://www.teledyne-ai.com/oem/diving.asp It basically functions as a tiny fuel cell and generates voltage in the presence of oxygen. In normal air (20.9% O2) it is spec'd to generate between 7 and 11 mV. My current unit reads 9.2 mV in air. As you increase the partial pressure of O2 on the sensor (persentage O2) it generates a higher voltage. My current unit reads 14.7 mV at 32.5% O2. I'm interrested in the range of 20.5% (air adjusted for humidity/temperature and 40% which should be from ~9 mV to max ~18 mV. The voltage never reverses and is independant of everything other than the presence of oxygen.
  • davejamesdavejames Posts: 4,047
    edited 2012-05-02 12:01
    ...surfed the Teledyne site looking for R-17 specs and wasn't able to find.

    @Willembad - a comment concerning the R-17 says that the interface is a mini-phone plug. Can you relate if it's a mono plug or stereo plug? If a stereo type, I'd echo Mr. Schwabe's suggestion that the output of the sensor may be differential. And if that's the case, the op-amp circuit would take a little different turn.
  • willembadwillembad Posts: 47
    edited 2012-05-02 12:06
    The plug is a mono 1/8" jack. I am currently reading it with a modified DVM. The DVM reads out in percentage O2 instead of volts by re-calibrating the circuit. I couldn't find a spec sheet either, but I'm sure the output is not differential. As far as I understand these things it is linear positive voltage on the center pin of the mono jack. Output is steady and continious. It does not fluctuate as long as the mix on the sensor face stays constant. The only variation is over time from the fuel cell being spent - around 3 years of usefull life so very slowly.
  • davejamesdavejames Posts: 4,047
    edited 2012-05-02 12:18
    ...ok - that simplifies the buffer circuit.
  • willembadwillembad Posts: 47
    edited 2012-05-02 12:33
    I do appreciate the input. I'm working my way through the texts that you provided links to. Usefull stuff. I think the point of using the LTC1296 is valid (availability of working code) although I'm much more confident in my coding for this project than the electronics. I did find this for an instrumentation amp that seems to have what I need http://search.digikey.com/us/en/products/AD622ANZ/AD622ANZ-ND/750972
  • willembadwillembad Posts: 47
    edited 2012-05-13 16:33
    Update:

    I have about half of my components here and the rest should arrive tmrw. I had no trouble making the ADC work so the only hurdle left is the inamp. I ordered the one in the post above and the datasheet shows the pin-out as follows:

    pin 1 Rg
    pin 2 - in
    pin 3 + in
    pin 4 - Vs
    pin 5 ref
    pin 6 output
    pin 7 + Vs
    pin 8 Rg

    My plans for the circuit are: 205 Ohm between pin 1 and 8 to set gain to 250. My expected max input will be 20 mV so I was shooting for .02x250=5V. Pin 4 and pin 5 to Vss. Pin 6 to the input of the ADC. Pin 7 to Vdd. Since my sensor is basically a small battery that delivers dc mV's I'm not sure if I should connect the - cell out to pin 2 and the + to pin 3 or should the - out go to ground and pin 2 to Vss or No Connect? Any thoughts on this? I guess I'm asking if the sensor should share ground with the rest of the circuit or not.

    Please feel free to comment on any part of this if you think there's an issue. I really don't know what I'm doing here.
  • PliersPliers Posts: 280
    edited 2012-05-13 16:59
    Welcome to the forum willembad.
    You will find many helpful people here.
    I'm curious, what it the automated gas mixer for?
  • willembadwillembad Posts: 47
    edited 2012-05-13 17:05
    Thanks,

    It is to baby-sit a manually controlled system I have now to mix breathing gas for scuba diving. Not really fully automated, just so that less attention required for normal operation. Also to shut down O2 supply if mix > 40% going into compressor or compressor stops for any reason.
  • tobdectobdec Posts: 267
    edited 2012-05-14 06:18
    Im kinda junior compared to some of these guys willembad...but i'm curious, would the pressures related to diving in any way be able to affect the operation of this sensor? From my understanding this sensor is designed for surface use in an engine environment...correct me if im wrong im a little pressed for time work in 20 mins. GL and welcome!

    edit:My bad....I was looking at the wrong link you can disreguard my post I see your sensor was designed for this typ of environment.
  • davejamesdavejames Posts: 4,047
    edited 2012-05-14 08:45
    ...I'd go with putting the sensor directly across the +/- inputs of the instrument amp. That way you'd be doing a differential measurement...which is kinda the point of using an IA.

    Suggestion - do a "null" reading first; meaning, with the transducer connected, make a reading with the ADC and record it. That reading (if everything is working correctly) will contain any error in the measurement circuitry (offsets, mainly). If the null reading is consistant over multiple measures, then you can subtract that amount from the reading while the circuit is in operation. The end result is a "mo-beddo" measurement.
  • willembadwillembad Posts: 47
    edited 2012-05-14 13:04
    tobdec - the sensor is on a system used to fill the tanks, it doesn't go diving at all ;)

    davejames - Tried that and failing miserably so far. I can not get anything usefull out of the amp. As far as the adc reading, I already have a calibration routine in the code. I'll post all that when I get it working, but it seems as if it's going to be a while. I do not know how to build the amp circuit to get usefull output at all :(
  • davejamesdavejames Posts: 4,047
    edited 2012-05-15 08:24
    willembad wrote: »
    Tried that and failing miserably so far. I can not get anything usefull out of the amp.

    What does "failing miserably" and "can not get anything useful" mean?

    Is the output of the IA flat at ground?
    Has the output of the IA railed to +V?
    Is the output of the IA oscillating? If so, what frequency?
    Is the IA powered correctly? (sorry, had to ask)
    Are the IA power supply lines decoupled correctly?
    Is the "not anything useful" the output of the IA or your code?
    Have you fed a known voltage level into the IA to verify correct operation (with a scope/meter)?

    What circuit are you using as an example?

    Just a few things to check. :smile:
  • willembadwillembad Posts: 47
    edited 2012-05-15 11:56
    I believe my problem is partly the fact that I'm not powering the amp correctly. I had Vdd on V+ and Vss on V-. With gain set to 1 and 0-5V input I get between 649mV and 4.14V out. I think all the good stuff for my sensor happens below that 649mV I get when the amp goes to - rail (It doesn't get to 0 obviously). I think I need -5V on V- to start. Is there an easy way to source this on a board of education? I'll say again that I have never messed with any of these components and I'm learning as I go. No question or suggestion is below my level. I have not even hooked anything to the adc yet, just trying to get analog voltage out of the amp.
  • willembadwillembad Posts: 47
    edited 2012-05-15 12:07
    davejames wrote: »
    What does "failing miserably" and "can not get anything useful" mean?

    Is the output of the IA flat at ground?
    Has the output of the IA railed to +V?
    Is the output of the IA oscillating? If so, what frequency?
    Is the IA powered correctly? (sorry, had to ask)
    Are the IA power supply lines decoupled correctly?
    Is the "not anything useful" the output of the IA or your code?
    Have you fed a known voltage level into the IA to verify correct operation (with a scope/meter)?

    What circuit are you using as an example?

    Just a few things to check. :smile:

    Hi Dave,

    Sorry for that reply, I'll be more specific.

    1. Is the output of the IA flat at ground? - I have no idea what that means, sorry.
    2. Has the output of the IA railed to +V? - No, I can get varied output between .6V and 4.1V (0-5V in, gain at 1)
    3. Is the output of the IA oscillating? If so, what frequency? - No, steady output.
    4. Is the IA powered correctly? (sorry, had to ask) - I don't think so. Vdd at V+ and Vss at V-.
    5. Are the IA power supply lines decoupled correctly? - Since I don't know what this means, I doubt it.
    6. Is the "not anything useful" the output of the IA or your code? - Just analog output. Have not connected to adc or run any code.
    7. Have you fed a known voltage level into the IA to verify correct operation (with a scope/meter)? - Yes. See above for 0-5V in. I also got output from independent 1.5V cell and could even get a little gain - maybe 1.5x

    I have no example to follw for the circuit. I basically tried to cobble it together from bits of datasheet and parallax examples for other amps.
  • davejamesdavejames Posts: 4,047
    edited 2012-05-15 13:05
    Hi Willem...a few sources for information that might help, but there's some reading involved:

    http://www.ti.com/lit/an/snla140a/snla140a.pdf ...page 15. Does your circuit look like the one at the top of the page?

    http://www.electronics-tutorials.ws/opamp/opamp_1.html ...the whole section is good for starters, and:

    http://www.electronics-tutorials.ws/opamp/opamp_5.html ...for a discussion about the differential amp, which is the heart of an Instrumentation Amplifier.


    BTW - if safe to say, what's your locale?
  • davejamesdavejames Posts: 4,047
    edited 2012-05-15 13:15
    willembad wrote: »
    1. Is the output of the IA flat at ground? - I have no idea what that means, sorry.
    2. Has the output of the IA railed to +V? - No, I can get varied output between .6V and 4.1V (0-5V in, gain at 1)
    3. Is the output of the IA oscillating? If so, what frequency? - No, steady output.
    4. Is the IA powered correctly? (sorry, had to ask) - I don't think so. Vdd at V+ and Vss at V-.
    5. Are the IA power supply lines decoupled correctly? - Since I don't know what this means, I doubt it.
    6. Is the "not anything useful" the output of the IA or your code? - Just analog output. Have not connected to adc or run any code.
    7. Have you fed a known voltage level into the IA to verify correct operation (with a scope/meter)? - Yes. See above for 0-5V in. I also got output from independent 1.5V cell and could even get a little gain - maybe 1.5x

    1 - apologies...I wasn't very clear with that. Is the output of the Instrument Amp (IA) holding steady at zero volts?
    2 - ok, understood.
    3 - by what means did you determine the output was steady? Do you have an oscillocsope, or did you attempt to use a volt meter?
    4 - what voltages are you using for V+ and V-?
    5 - "decoupling" is tech-speak (again, apologies) concerning the use of capacitors on the power pins. The IA spec sheet should mention something about power supply filtering and suggest a value of capacitance.
    6 - ok, understood.
    7 - ok, understood.

    Errr...lemme think more about this.

    Other Forum members - if you have ideas, chime in. I don't mean to hog this.
  • willembadwillembad Posts: 47
    edited 2012-05-15 13:21
    Dave,

    Thanks for the time you're spending on this. I don't have a scope so all measurements and conclusions of mine are based on what I can see on my dvm. I'm supplying +5V on V+ and 0V (ground bus) on V-.

    I'll start reading, thanks again.
  • davejamesdavejames Posts: 4,047
    edited 2012-05-15 13:28
    ...more than welcome - happy to help!

    FYI - DVMs have an extremely slow reaction time and most are unable (and are specifically designed such) to respond to high frequency changes; a scope would be required to detect them.

    One of the reasons I queried your locale. I've the equipment if you're in the south San Francisco bay area.
  • willembadwillembad Posts: 47
    edited 2012-05-15 13:49
    Thanks for the offer but I'm in Florida. Any ideas on a easy way to get -5V to supply the amp?
  • davejamesdavejames Posts: 4,047
    edited 2012-05-15 15:05
    willembad wrote: »
    Thanks for the offer but I'm in Florida. Any ideas on a easy way to get -5V to supply the amp?

    What other voltages do you have at hand?

    If you've +5V only, there are available DC/DC converters that can output negative voltages. Or as some would suggest, roll your own converter.

    CUI Inc. offers some, although I'm sure there are other makers:

    http://search.digikey.com/scripts/dksearch/dksus.dll

    I'll be using a +/-15V version of these in an upcoming project. Looking forward to see how well they operate!
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-05-15 15:43
    A negative rail is needed to amplify an AC signal, if the sensor output is DC, you don't need a dual polarity power supply.
  • willembadwillembad Posts: 47
    edited 2012-05-15 16:18
    Sensor output is dc only. I can not get the amp output below .6V with 0V at v- though. This would not be an issue if I could get it to amplify at the gain I set per datasheet. It calls for 205 Ohm between pin 1 and 8 (Rg of in-amp) for a gain of 250 but I'm not getting anything near that. Could someone explain to me the difference between power ground and signal ground in this application? The datasheet for the amp calls for resistors to signal ground from the input but it's not clear if these are needed for dc input or not. It also calls for the ref pin (5) to go to signal ground. Will this be my ground for the output signal?

    fig 17. here: http://www.analog.com/static/imported-files/data_sheets/AD622.pdf

    My circuit is nothing like the figure you referenced Dave. The AD622 has three op amps in the package to accomplish the goal with one component.
  • davejamesdavejames Posts: 4,047
    edited 2012-05-15 16:36
    ...just finished surfin' the Analog Devices website and found the following (more reading for you!):

    http://www.analog.com/static/imported-files/design_handbooks/5812756674312778737Complete_In_Amp.pdf

    This is 130 pages of just about any/every thing you might want to know about Instrumentation Amplifiers.

    http://www.analog.com/static/imported-files/application_notes/AN-244.pdf

    This appears to be a more trimmed-down version of the handbook.

    Later,

    DJ
  • willembadwillembad Posts: 47
    edited 2012-05-15 17:26
    Great links Dave! I think I learned that I need some coupling issues sorted and that I should be using an AD623 instead of the 622. More studying for me although most of it is way over my head.
Sign In or Register to comment.