Monday 26 August 2013

How to calculate a logarithmic sensor reading in java?

How to calculate a logarithmic sensor reading in java?

I have a sensor that's output is a logarithmic representation. For example
every 56mV (millivolts) represents a decade of value. So I get a mV
reading for 100 and it's -30mV and a mv reading that is +26mv that
represents a value of 1000 and going further a mV reading of +82mV
represents a value of 10,000 (56mV between each decade). These numbers are
just an example I'll have two calibration mV values so I'll know what 100
and 1000 mV readings are. My question is, is there an easy way to
calculate the value given a mV reading? I can think of a few ways to go
about it programically but it seems there must be a function to do this.
I'm guessing that function is log(x) but I'm not certain how to go about
it. Especially since the mV value can be negative. As you can probably
guess math is not my strong suit.
Any insight will be greatly appreciated.

No comments:

Post a Comment