I’m using the Sparkfun Photoacoustic Spectroscopy CO2 Sensor SEN-22956.
At the bottom of page 19 of the data sheet it says: “Complete ‘Register-map description’ has been covered in a separate application note titled as ‘Register-map description of XENSIVTM PAS CO2’ in the product webpage.”
On pages 7, 11, 16, and 18 this document it says the data is coded as two’s complement.
Page 7 is “Measurement period configuration registers (MEAS_RATE_H and MEAS_RATE_L)” in seconds
Page 11 is “CO2 concentration result register (CO2PPM_H and CO2PPM_L)”
Page 16 is “Alarm threshold register (ALARM_TH_H and ALARM_TH_L)”
Page 18 is “Automatic baseline offset compensation reference”
Why are these two’s Complement?
How could time, ppm, threshold, or baseline possibly be negative (less than zero)?
Careful reading of the data sheet indicates that post processing of the data can be performed, such as baseline drift compensation and atmospheric pressure compensation. Baseline drift can be positive or negative.
Also, statistically speaking, these steps can be expected to produce negative results for low values of the measured quantity, and must be accurately represented in a valid data stream. It makes perfect sense to use signed data types for these quantities, and for the hardware to perform twos complement math.
Thanks for your fast and interesting reply but I still have a question about the measurement period.
On page 7 of the ‘Register-map description of XENSIVTM PAS CO2’ document , it says “Values above 0FFFH are treated as being equal to FFFH (4095 s). Values below 0005H are treated as being equal to 0005H (5 s).”
If the lowest value the sensor outputs is 5 seconds how could it ever go negative?
Also the concept of a negative time period is mind boggling. It sounds like something out of quantum physics.