Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Math Trick anyone? Exponential Notation, Floating Point Limitations... — Parallax Forums

BS2 Math Trick anyone? Exponential Notation, Floating Point Limitations...

xanatosxanatos Posts: 1,120
edited 2015-02-27 14:29 in BASIC Stamp
Hi,

I'm reading the output from a 12 bit ADC that monitors the output from a vacuum sensor. The ADC output is 7.20 volts when the ADC count is 2996, and 6.42 volts when the ADC count is 2675. There is a rough relationship between voltage out and ADC count of 416 (ex. 2675 ADC out / 416 = 6.430V)

So my first threshold is trying to figure out how to do this without an available floating point processor...

Add to this the following: to convert the voltage to a pressure reading, the formula is:

Pressure = 10 ^ ((1.5 * V) - 12.125)

So I have two hurdles to overcome here...

I can multiply the ADC output by 10 and get the volts and tenths... but I still want to get the hundredths. My ADC Output variable is a WORD, so I'm limited to 32,768 as a max count before it flips over.

Is this even possible on a BS2px?

Ultimately, I want to read pressure in a format of x.y e-z Torr, as in 8.5 e-3 Torr. So I need to have the voltage converted to a pressure with the exponent being available as a separate integer.

Am I completely nuts for even trying this??? :)

Thanks,

Dave

PS., S I guess the full formula I am trying to get my stamp to operate on is:

Pressure = 10^((1.5 * (ADC/416)) - 12.125)

Could a Propeller even do that?

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2015-02-27 00:03
    With respect to the first step, you can get the answer in millivolts by using the ** operator,

    mV = ADCount * 10 ** 15754 ' e.g. 2675counts --> 6430mV
    or
    mV = (ADCount ** 26466) + (ADcount * 2) ' ditto

    For the exponential part, what is the range of pressures or voltages you expect? Also, what accuracy is required? There are fair approximations and approaches. It is tricky on the Stamp and depends on the range to cover.

    The Propeller could do it. One way is to load the floating point object, in which case it is simply a matter of turning the crank. The Prop has a table of the exponential function over one octave burned into its rom, and that can help if you want to attempt it without floating point.
  • xanatosxanatos Posts: 1,120
    edited 2015-02-27 11:54
    Thanks Tracy - that's a great start. I always seem to forget about the ** operators... I think I'll make it a point to become proficient on those lesser-used (by me) operators.

    I'll probably play with the propeller on this since I have so many other things going on on the same project... relay controls, sensors & sensor controls, counters (using those 515 counters for my neutron counters!) - even an EMIC2 (who doesn't need their fusion reactor to talk to them? :) )

    Basically, the vacuum gauge manufacturer (Edwards WRG) just provides the calculation to convert volts to pressure in mbar or torr, and a graph that does the same. Around 8 volts and up is atmospheric pressure basically, with an ADC output of around 3400 - which, when multiplied by ten wraps around, so I just limit the max count because I really don't care about the pressure until it gets down around 1e-2 torr and below - which is around 6.5 volts and an ADC output of ~2708. Not overly concerned about exactly accurate pressure readings - as long as I can resolve to around .1 torr I'm happy. I should be so far down Paschen's curves that there's almost no chance of arcing unless I get to the megavolt range, so I just need to know if I'm in the proper ballpark to be sure it's the right time to introduce Deuterium.

    I've attached the graph if you're interested.

    Thanks again for the hints - you're always a fantastic resource for my weird projects! :)

    Dave
    1024 x 724 - 100K
  • davejamesdavejames Posts: 4,047
    edited 2015-02-27 13:17
    "...introduce Deuterium."

    Dave - how's your stock of lead shielding? :smile:
  • xanatosxanatos Posts: 1,120
    edited 2015-02-27 14:29
    Lol... what's a few (hundred thousand per second) neutrons between friends? :)

    Actually I do now have a roll of lead shielding, appx. 36" x 48" x 1/16" thick. I will be running this only for about 5 minutes at a time once I introduce Deuterium, and since I don't plan on having any more kids, I should be good :)

    Like your avatar icon... "Excessively Dangerous Thing" lol! I'm actually FAR more concerned about the 35kv at 50mA than the neutrons ;)

    Dave
Sign In or Register to comment.