math issue
acadienjcc
Posts: 6
Hello all,
what would be the math function to reverse a value?
i.e. the value is high when there is less pressure, and it gets lower as pressure is increased. what math algorithm would I use to obtain the reverse? (higher pressure gives a higher number & lower pressure gives a lower number)
the sensor is a flexiforce sensor, sample code: FlexiForce_Simple.bs2
what would be the math function to reverse a value?
i.e. the value is high when there is less pressure, and it gets lower as pressure is increased. what math algorithm would I use to obtain the reverse? (higher pressure gives a higher number & lower pressure gives a lower number)
the sensor is a flexiforce sensor, sample code: FlexiForce_Simple.bs2
Comments
For example if the value goes from 10 to 100 just do "value = 110 - value" and the value have the same range.
I hope this helps,
Bean
Just Google "signal scaling equation" or "signal scaling and offset" and check out a couple of articles.
Briefly, to reverse the response of the sensor, you start with the maximum possible value and subtract the sensor output from it. Say the sensor goes from 0 - 256. For normal readout, you'd expect the number to go from 0 up to 256. For reverse readout you'd say (256-sensor)=value.
Cheers,
I'll see if I can get it to work now and post if I run into problems.
Cheers,