waveshareteam / High-Pricision_AD_HAT

MIT License
24 stars 19 forks source link

Python RTD not giving correct readings #17

Open Alexander-Mundy opened 3 months ago

Alexander-Mundy commented 3 months ago

Using the example python code, installing the 0 ohm resistors, and removing the COM/AVSS jumper as instructed results in incorrect resistance readings. I thought at first that I might have done something wrong while soldering, however I tried a different board and got the same results. I metered all soldered connections on both boards. Both boards consistently give readings that are too high but not a straight multiplier or subtraction. Using resistors checked for true resistance the readings are off by: True resistance = Reported resistance by HAT 0.83565 - 60.25 I verified by inserting into the code in main.py between lines 82 and 83: RES = RES 0.83565 - 60.25 I then put a beaker of ice water on a heated magnetic stirrer from 0.5C to 98.8C (boiling at my elevation and barometric pressure) The reported adjusted temperature agreed with the RTD of the stirrer probe within 0.25C.

Alexander-Mundy commented 2 months ago

So I figured out what is wrong with the code. In ADS1263.py line 264 the Mode 1 Register is set to 0x84 which puts it in FIR filter mode, sets the Sensor Bias Magnitude to 50uA, connects Sensor bias to ADC1 mux out, and Sensor Bias Polarity to pull up mode. The 50uA Sensor Bias unbalances the 250uA IDACMAG IDAC1 & IDAC2 settings at line 504 that biases the RTD sensor and Rref resistor. Adding the following line in "def ADS1263_RTD_Test(self):" results in the correct RTD resistance and temperature: self.ADS1263_WriteReg(ADS1263_REG['REG_MODE1']. 0x80) This puts it in FIR filter mode, sets the Sensor Bias Magnitude to none instead of 50uA, connects Sensor bias to ADC1 mux out, and Sensor Bias Polarity to pull up mode. One could change line 264 to 0x80 instead of 0x84, but that would leave the MUX inputs for reading ADC values floating when doing ADC readings.

I am very surprised that no one has brought this coding error up because the RTD readings are so far off with the example code.