Finding the change and direction of a signed word value (sensor output) ?
I'm being bogged down by the math involved in using a I2C pressure sensor to calculate true pressure, so I'm looking for a simpler course to just detect a positive or negative changes in it's output rather calculate than it's absolute value.
At this point I only need to know if pressure is rising, falling, or steady. The sensor outputs a signed 16bit value.
Has anybody seen or used some PBP code to compare a new Word value against a previous Word value to see if the difference is positive or negative, and by how much ?
I'm short on bright ideas right now, so anything may help me get going the right way.
Supposing you build a barometer or altimeter ... using MS5534 or Hope HP03 ...
Hi, Martin
Assuming :confused: pressure will be read as i.e 1013.3 mb ( displayed number < 65536) ...
the difference between two measures will be < 32768 ... ( or you will feel really really really bad !!! )
sooo ...
the MSB of the difference will be 0 for positive difference and 1 for neg difference... add to that PBP offers the direct print of the value and sign : " SDEC Difference "
Alain