Shop OBEX P1 Docs P2 Docs Learn Events
Scaling data from an ADC0831 — Parallax Forums

Scaling data from an ADC0831

Turnbull2112Turnbull2112 Posts: 65
edited 2011-03-20 12:39 in BASIC Stamp
I need some help here. I am trying to scale the data from three ADC0831's to some pressure readings and a gas concentration (in %) reading. I've looked over the Basic Analog Digital book but I'm getting snagged on converting .86-4.7VDC as 0-101 PSI. The ADC decimal range is 44 to 240. I am trying to play around with y = mx + b but the values arent matching up as I test it on the bench. How do I go about this? My program is attached. The first two ADC's are reading pressure sensors 0-101 PSI and the third is reading an oxygen conc 's/entration sensor 0-100%. The pressure sensors are MPX5700A's from Freescale Semi. Thanks!

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2011-03-16 13:33
    Here is how I Caculate percentage in a project that I once did

    SL VAR Word                       ' [B]Product that is in Sand Silo [/B]
    [B]SL = 50000 [/B]
    T = (SL/500) * 1                     ' T = Caculate percentage of product used
    

    You can adjust this value to get the scale that you need
    The ADC decimal range is 44 to 240.
    That is what is used to get your scale value
    cnts2mv          CON          [B] $139C[/B]
    

    $139C = 5020 DEC

    Here I what I used went I need to change HEX to DEC

    http://www.statman.info/conversions/hexadecimal.html


    I used this when I wrote the Demo for the MAX186 ADC chip
    Cnts2Mv     CON       $00F6                ' x 245 > 4.00 volts
    

    You could do the same thing in that change the CON value until you get it to read .87 to read 0 and 4.7VDC to read 101

    You have to play with the value CON to the scale that you need
    and the third is reading an oxygen conc 's/entration sensor 0-100%.

    What is the scale for this
  • Turnbull2112Turnbull2112 Posts: 65
    edited 2011-03-17 07:11
    Excellent thanks you Sam, I will try this today.The O2 sensor scale I believe is 0-255 DEC and 0-100% It hovers around 20% with atmospheric oxygen. Thanks again for the help.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-03-17 09:20
    The */ or ** operators handle fractions on the Stamp.

    Range 240 - 44 = 196 will map into a new range, 0 to 101

    On a calculator do, 256 * (101 - 0) / (240 - 44) = 132
    Note that the fraction 132 / 256 is very close to the fraction 101/196

    Now, on the Stamp write,
    pressure = (adcResult MIN 44 - 44) */ 132

    The business with MIN is to prevent the possibility of a wild reading less than zero.
  • LloydsLloyds Posts: 75
    edited 2011-03-20 12:39
    Turnbull,
    Looking at your code, in the MAIN section where you are doing the conversion, you are doing the conversion for the slope, but you aren't doing any addition or subtraction for the offset, I think. In other words, in your y = mx + b, you aren't doing the "b". Think of the C to F conversion, and the F to C conversion for temp. If you understand that, do the same for your situation.
    Definitely maybe for sure, but I hope that helps. I do a lot of sensor stuff like that and once you get the first one figured out, the rest will be easy.

    Then eventually you'll want to use instrument amps and such with offset adjustments so that you can use the full bit capability of the convertors.
    Lloyd
Sign In or Register to comment.