Help needed with mV input BS2 project
willembad
Posts: 47
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
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
Comments
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,
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.
Maybe 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.
Would this be good for the amp? http://search.digikey.com/us/en/products/MCP607-I%2FP/MCP607-I%2FP-ND/319465
This for the ADC? http://search.digikey.com/us/en/products/MCP3202-CI%2FP/MCP3202-CI%2FP-ND/305924
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,
What are the specs of the O2 cell? ...if the output is differential then I would definitely use an instrumentation amplifier.
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.
@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.
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.
You will find many helpful people here.
I'm curious, what it the automated gas mixer for?
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.
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.
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.
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
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.
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.
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?
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.
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.
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.
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!
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.
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