SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By atedeschi
#136071
I had taken a few PIC microcontroller classes in college but have not used it in awhile so I am def rusty. I see the arundio chip is popular here and seems like there is a lot of great support.

Here is what I am trying to do:
Read 3 seperate sensors with a starting output voltage between 9-12 mv.
I believe the signal needs to be amplified, then sent to the A/D convertor in the chip.
With the code then take the voltage reading to a decimal. The program will loop to check the sensor every second.
I want to then take each of the three converted readings and display on a backlight screen. Possible OLED but something that can easily be viewed in all lighting conditions.

Thanks in advanced for the help/suggestions.
By Mee_n_Mac
#136083
What are you asking for ? Yes, you will need to amplify the sensor outputs to get them into a reasonable range. This is probably the most difficult part of your project to get right. Depend on which MCU you choose (PIC, Arduino, ???) you'll want to amplify the signal from your O2 sensor to ~3 v or ~5 v to get the best resolution from your A/D (likely a 10 bit ADC). Probably do-able with an op-amp or two. We'd need to know what the minimum and maximum voltages are out of the sensor. I'm not sure if your 9-12 mv "starting output voltage" is a min or max or ????

You'll probably also want to low pass filter the signal as you amplify it so you minimize the amount of noise presented along with your signal. To spec out this LPF you'll need to have some idea of how quickly the O2 sensor can change it's output (aka it's bandwidth or frequency response). If there's a good amount of gain needed, your amp stage(s) should also incorporate some DC/offset nulling scheme.

You'll need 3 such circuits, one for each sensor. Each output will be routed to ADC pins on the MCU so it must have at least 3 ADC inputs. The software will then choose an input, perform the A/D conversion, scale and store the result and then do the same for the other 2 sensors. I'd set up a timer to trigger an interrupt to run this every so often, perhaps faster than your 1/sec so I could use software to further filter the readings before sending them to the display (if they're too noisy).

As for displays ... you've got a ton of options. But to make it simple you might want to look at some of the "serial enabled" displays SF sells. They're easy to "talk" to and you'd just have to use the MCU's serial port.

You might want to think about a few details too.
1) Are you running this off batteries or line power ?
2) Is the display going to be in bright sunlight or ??
3) Do the O2 sensors need any power or some biasing current ? How do they work exactly ?
4) Will you ever want to send the readings to something other than the "onboard" display ? To a PC or a logger of some sort ?
5) Do you need an on/off switch ?
6) Do you want some other user input ? Like an "hold display" button or a brightness/dimmer control ?
7) Do you want to display to show the recent readings (possibly filtered) only ? How about a running average ? Or the max or min since whenever ? Or some other statistics ? This is all software but you'll need a way for the user to request these optional displays which gets us back to #6 above.
8 ) How much resolution do you want ? I'll say 10 bits it what you're likely to get with any MCU. How many digits do you want to display ? With 10 bits you'll get 4 (0 to 1023).
9) Will this be in some enclosure of some sort ? Must it be weather proof or tamper proof or handle extremes of hot/cold ?

Odd tidbit for today : Did you know that if you want to make a numbered list 1) ... 9) that you must use "8 space )", 8 ), because w/o the space the forum SW displays this 8)
By DougCoutts
#136091
Sounds like you are working on a DIY rebreather.

I have been following the evolution of this technology for about 30 years and I do think that it is now possible to do it safely. Mee_n_Mac's comments about the analog electronics design are spot on. Another significant issue is the mechanical design needed to avoid condensation on the O2 sensors...particularly if you dive in cold water, like in the Pacific NW. Condensation can throw off the readings significantly.
By atedeschi
#136096
Mee_n_Mac wrote:What are you asking for ?
I would like some help selecting the best hardware and help setting it up. I dont need a microcontroller that is overkill and big in size.

We'd need to know what the minimum and maximum voltages are out of the sensor. I'm not sure if your 9-12 mv "starting output voltage" is a min or max or ????
Min voltage is 6.00 mv & max is 114.29 mv. it have the poential to go lower or higher but at those max and min i wanna just read as error.

how quickly the O2 sensor can change it's output (aka it's bandwidth or frequency response)
less then 5 seconds

As for displays ... you've got a ton of options
Looking for something small, enough to read three readings of four characters and space between or one under the other, about 16 font size.

You might want to think about a few details too.
1) Are you running this off batteries or line power ?
battery: thinking 9v or maybe something smaller but looking to get like 20-30hrs of usage out of it before changing. Also no special order batteries, no to expensive.

2) Is the display going to be in bright sunlight or ??
Yes in bright sunlight and in complete dark.

3) Do the O2 sensors need any power or some biasing current ? How do they work exactly ?
No Power needed they output a voltage all the time. here is a datasheet: http://www.maxtecscuba.com/replacementS ... AX-305.pdf

4) Will you ever want to send the readings to something other than the "onboard" display ? To a PC or a logger of some sort ?
No just want display the current readings of each sensor. maybe add a three color led to light depending on a reading.

5) Do you need an on/off switch ?

Yes, maybe a magnetic reed switch or leave the hardware on in a sleep mode a use a switch when pushed and held either wakes it up or puts it to sleep. Also need a switch when pushed and held down for x number of seconds will calibrate the system.


6) Do you want some other user input ? Like an "hold display" button or a brightness/dimmer control ?
Nope

8 ) How much resolution do you want ? I'll say 10 bits it what you're likely to get with any MCU. How many digits do you want to display ? With 10 bits you'll get 4 (0 to 1023).
Dislpay for each sensor look like this X.XX

9) Will this be in some enclosure of some sort ? Must it be weather proof or tamper proof or handle extremes of hot/cold ?
Yes I wanted to pot the electronics maybe at the end but have a seperate battery compartment.
By atedeschi
#136097
DougCoutts wrote:Sounds like you are working on a DIY rebreather.

I have been following the evolution of this technology for about 30 years and I do think that it is now possible to do it safely. Mee_n_Mac's comments about the analog electronics design are spot on. Another significant issue is the mechanical design needed to avoid condensation on the O2 sensors...particularly if you dive in cold water, like in the Pacific NW. Condensation can throw off the readings significantly.
Yes I want to build displays to read the oxygen pressure in my rebreather. I built an analog version like the one here: http://www.ppo2.com/PPO2/Files/3_ppo2-schem.pdf but wanna make a digitial one to be able to calibrate easier and make smaller.
By Mee_n_Mac
#136118
atedeschi wrote:
DougCoutts wrote:Sounds like you are working on a DIY rebreather.

I have been following the evolution of this technology for about 30 years and I do think that it is now possible to do it safely. Mee_n_Mac's comments about the analog electronics design are spot on. Another significant issue is the mechanical design needed to avoid condensation on the O2 sensors...particularly if you dive in cold water, like in the Pacific NW. Condensation can throw off the readings significantly.
Yes I want to build displays to read the oxygen pressure in my rebreather. I built an analog version like the one here: http://www.ppo2.com/PPO2/Files/3_ppo2-schem.pdf but wanna make a digitial one to be able to calibrate easier and make smaller.
How small is "smaller" ? I looked around Mr Munro's site and his Gen Six - 3 display is pretty small. Much smaller than that and I'd be concerned it wouldn't be readable. I can envision a time shared display, one that outputs only 1 sensor's reading at any one moment and allows the diver to choose which sensor to display. I might be concerned that such a concept could be easily misread and lead to problems though. I think you need to look around at displays and find one you think is the right size to be readable at depth through murk and a facemask. I have no idea what those conditions are like so I can't be of help in this regard. Do you have an enclosure, suitable for the depths you'll dive, in mind ? I suspect that will be the design driver for size.

I can envison a system where the 3 O2 sensors are read by a single MCU and that then drives a display. There'd be 3 op-amp circuits to amp the O2 signals up to ~ 3V. I do have a question as to what Mr Munro's calibration process is. I'll have to peruse his site some more (after Thanksgiving) to figure that out. I think some form of "auto-cal", done digitally when invoked by the diver, is possible.
By atedeschi
#136134
Yes his is not a bad size, but you wouldn't need the text to be that big. The overall display could be equal to the size of those three combined. Ill look at some screens. I want to display all three sensors at the same time.

As for calibration the analog setup uses a pot for each sensor. The sensors do not have to be calibrated everytime but when they need to be I want to do it with air. When the sensors in air they will have a reading between 9-12mv. So I suggest having another button that if held down for 10sec will record the mv reading and that value will be used to calibrate the conversion calculation. If the mv is above 12 or below 9 mv when holding the calibrate button display fail for that sensor.

I will make a custom housing to encase the electronics. I would like if possible to pot all the electronics and make a seperate battery compartment in the housing to be able to change the battery.

What do you think would be the best products to use with this project? I do not have a programer I believe the Arundio (spelling?) can be programed via mini usb. Im going to need some help with hardware and I am trying to find some sample programs with A/D conversion to brush up.

Thanks so much for your help so far and have a happy thanksgiving.
By Mee_n_Mac
#136190
Regarding calibration : What level of accuracy, what error is acceptable, for the measured O2 level over all ranges of O2 levels ? It looks to me like what "calibration" does now is correct any offset between the expected reading at normal 1 ATM pressure and O2 level and the actual reading. This then relies that, over the rest of the range of possible O2 readings, that the gain and linearity of the sensor and other electronics are perfect .. or at least good enough (hence my question). I'll guess there's nothing (practically speaking) you can do to calibrate the sensor but it's not too hard to come up with a calibration device/scheme that allows calibration of the rest of the electronics over the whole range of expected O2 sensor outputs. Given this would all (now) be "computerized" it would be a simple as pushing a button to enter a cal routine and using a cal tool (in place of the sensors) to take "readings" at different voltages. But only if the accuracy requires it be done.

I'd post a simple block diagram of what I think the pieces are but ATM it would seem the SF forum is AFU regarding the display of attachments so that will have to wait.

I do have to ask how much trouble are you willing to go to for this project ? I think you could end up with something better and perhaps smaller than the one I linked to above but it'll take some work and involve making your own PCB and, as I think you already expect, doing your own custom coding. And probably cost more than buying Mr Munro's Gen6.

BTW : An Arduino is a Atmel microcontroller (MCU) on a standardized PCB with all the other components needed to make the MCU run and then has all it's I/O pins brought out for the user to access. It also has a USB to serial converter chip on the PCB to allow communication to/from most PCs (which all have USB ports these days). It also has a bootloader program already loaded into the MCU so when powered up the Arduino/MCU looks to download additional programs from it's serial port ... which might be connected to a PCs USB port. If it finds a new program, it D/Ls it and runs it ... otherwise the bootloader reverts to whatever program was last D/L'ed. This allows the user to write and compile programs and D/L them to the Arduino w/o having to have a specialized programming tool. (Not that such tools are hard to use or expensive, <$50). This is all intended to make the Arduino an easy to use board to develop hardware and software on. After getting everything to run you may elect to keep the Arduino as the final tool or come up with your own PCB with an MCU and a cutdown set of support circuitry and I/O ports ... for less $$ and in a smaller size/footprint when compared to an Arduino. Where size seems to be a design driver for you, you may want to look at one of the "pro" mini Arduino boards ... which lack some of the support circuitry so as to minimize cost and size. For example you buy a separate USB to serial converter to "talk" to the Arduino Pro via the PCs USB port.
http://www.sparkfun.com/products/9220
Using the above would still mean you'd have another board with the 3 amp circuits as I don't think an Arduino's ADC will work well enough with ~100 mV levels. And whatever else is needed to run whatever display looks good.

PS - I agree a separate battery compartment that allows recharging or replacement of the battery w/o having to open up the watertight display enclosure is a good idea. It''s the one thing I find wrong with Mr Munro's designs.

EDIT : I also have another reason for trying to pin you down on the accuracy needed. I believe most of the MCUs you might opt to use can use another reference voltage for their A/D converter. I'm not sure if they can use something as low as 200 mV (like the Datel DPMs Mr Munro used) but ~1 V is likely. If you don't need much accuracy then using a 1V reference and a 10 bit A/D means there's about 100 bits covering the 0-100 mV range you're primarily interested in. Given a couple of bits of inherent inaccuracy in these A/D's, you're left with something like +/-2 % accuracy and no need for any op-amp circuitry.
By atedeschi
#136262
Min voltage is 6.00 mv & max is 114.29 mv. At that max and min I wanna just say error and that will notifiy person to adjust gas content.

This is how the calibration works.
1) read mv reading in air at ambient pressure
2) Scaling Factor (SF) = (mv reading) / 0.21
3) Display Output = (mv reading) / SF

How the program will work
1) has a SF stored from last calibration
2) display will show a reading from the Display output equation above
3) if the reading in air at ambient pressure is off then hold down a button to calibrate system
4) calibrate (see above)
By Mee_n_Mac
#136263
So what happens when the reading is 82.5 mV ? (in use, not during calibration) That is supposed to correspond to some O2 level. How far off from the true O2 level can that reading be ? If the true O2 level was 2% higher, would that be OK ? How about 5% lower ? 10% higher ?? This is an example of what I meant by asking how accurate must the display reading be.
By atedeschi
#136286
82.5 mv would be around 1.9248 for the display output. I would want the display to read 1.92
So I guess to answer your question I want the reading to be the true or close to exact as possible.
By Mee_n_Mac
#136324
atedeschi wrote:So I guess to answer your question I want the reading to be the true or close to exact as possible.
Well that's not very informative. :( Let me lay out 2, of perhaps many more choices, for you to consider.

1) Let's call this design approach the easy way. You route the O2 sensors directly into an MCU of some sort (perhaps some flavor of Arduino) and you use that MCU's ability to have it's A/D converter scale it's 0-1023 bits over 0 to 1 V (too bad it can't go any lower than 1V). So basically every count out of the A/D = 1 mV. Now that A/D has an error of perhaps +/- 2 bits and thus +/- 2mV. Because there's no amps in this approach, every mV of error is about a 1% error (1 mV is 1% of 100 mV, about = to your max expected O2 sensor output). And there's probably some other error sources that add to this and they can't all be calibrated out. So at best you have a reading that may be off by 2 mV and perhaps by more (? 4 mV ?). The trade off for this "high" level of error is that your display design is simple. It's really nothing more than the MCU + support circuitry. the display(s) and some switches and the battery + power conditioning (if any). It's as minimal as it can be.

2) A more complicated design approach, let's call this the kitchen sink way, would add in 1 to 3 amplifiers and perhaps some analog mux'es (switches) and perhaps some temperature sensors ... all of which allow the O2 outputs to be measured more accurately despite any changes in temp or any errors in the amp circuitry. This takes more space and means you'll have to have some form of circuit board to mount the amps, etc on. It'll be more accurate (how much I can't say at the moment but let's SWAG +/- 0.5% of error after any and all calibration.

So how much extra time, trouble, $$s and how much space do you want to devote to making the error in what's displayed go from perhaps 4% to perhaps 0.5% PLUS (in both cases) whatever error the O2 sensors have all by themselves ? If life and death depend on the reading being off by no more than 1%, then that choice is easy. If it can be off by 5%, then the choice is a little more squishy. Since I'm not a diver I am not qualified to give you any advice in this regard.
By atedeschi
#136377
Yes the error has to be low as possible. Where Is the +/- 2 bit error coming from? Is that from the single not being ampified? I believe just ampilifying the single will keep the error low. I do not need to add temperature sensors. What do you think?
By Mee_n_Mac
#136383
atedeschi wrote:Yes the error has to be low as possible. Where Is the +/- 2 bit error coming from? Is that from the single not being ampified? I believe just ampilifying the single will keep the error low. I do not need to add temperature sensors. What do you think?
The 2 bits comes from the spec for the MCU used in an Arduino. I just happened to use that because you mentioned to possibility of using an Arduino. Those 2 bits of error might be present no matter what you do with the signal. It reall just a question of how large 2 bits are compared to the signal. Let me give you the 2 cases above.

In the easy way the max signal (~100 mV) was also = 100 bits. So 2 bits is 2% of the full scale range. If you amplify the signal so that it's ~3V (about as big as you want it) and the A/D is set up so 0 to 3 V gets you 0 - 1023 bits, then 2 bits is only about 0.2% of the FSR. Amplifying the signal reduces the impact of the A/D's inherent error.

On the subject of errors ... I note the O2 sensor itself has a 2% max linearity error. That means even if all your display circuitry is perfect, the reading might be off by 2% from the true O2 level. I assume that's good enough and if not, there's nothing (practically speaking) you can do about it short of getting a better sensor.
By atedeschi
#136398
Ok I get what you are saying. It looks like I will have to amp to 3volts to reduce the error. I saw what you are saying about the cell and yes that is the best we have for the job. Hence why I would like to reduce any other errors.