Hey gang,
Can I get some math guidance?
I have these results from a MAX31865
MSB value read 45 LSB value read BC Channel 0 ADCcode = 45BC Temperature Deg C 22.00
MSB value read 45 LSB value read CA Channel 1 ADCcode = 45CA Temperature Deg C 23.00
MSB value read 45 LSB value read CE Channel 2 ADCcode = 45CE Temperature Deg C 23.00
MSB value read 45 LSB value read C8 Channel 3 ADCcode = 45C8 Temperature Deg C 23.00
MSB value read 45 LSB value read D2 Channel 4 ADCcode = 45D2 Temperature Deg C 23.00
MSB value read 45 LSB value read DC Channel 5 ADCcode = 45DC Temperature Deg C 23.00
MSB value read 45 LSB value read B0 Channel 6 ADCcode = 45B0 Temperature Deg C 22.00
MSB value read 45 LSB value read F0 Channel 7 ADCcode = 45F0 Temperature Deg C 23.00
MSB value read 45 LSB value read D6 Channel 8 ADCcode = 45D6 Temperature Deg C 23.00
MSB value read 45 LSB value read D4 Channel 9 ADCcode = 45D4 Temperature Deg C 23.00
MSB value read 45 LSB value read BC Channel 10 ADCcode = 45BC Temperature Deg C 22.00
MSB value read 45 LSB value read AA Channel 11 ADCcode = 45AA Temperature Deg C 22.00
MSB value read 45 LSB value read D2 Channel 12 ADCcode = 45D2 Temperature Deg C 23.00
MSB value read 45 LSB value read BA Channel 13 ADCcode = 45BA Temperature Deg C 22.00
MSB value read 45 LSB value read AC Channel 14 ADCcode = 45AC Temperature Deg C 22.00
and the formula making these is:
// From MAX31865 data sheet:
// The ratiometric ADC conversion results found in the RTD Data Registers can be converted
// to temperature with a few calculations.
// First, the Resistance of the RTD needs to be determined with the following equation:
// R(RTD)= (ADC Code x R(REF))/2^15
// ADC Code = 15-bit ADC results from RTD Data registers (01h–02h)
// R(REF) = Resistance of the reference resistor (4K)
// Once the resistance of the RTD is known, the well defined resistive properties of the selected RTD can be
// used to determine temperature by either calculations or lookup tables.
// For a temperature range of -100NC to +100NC, a good approximation of temperature can be made by simply
// using the RTD data as shown below:
// Temperature (NC) ?(ADC code/32) – 256 >>> See Page 10
// send read address, read the data
digitalWrite (SSarray[channelCount], LOW);
digitalWrite (SSarray[channelCount], LOW);
SPI.transfer(RTD_MSB_read); // send out register #
delayMicroseconds(10);
incomingByte1 = SPI.transfer(0); // read register contents back
digitalWrite(SSarray[channelCount], HIGH);
Serial.print ("MSB value read ");
Serial.print (incomingByte1, HEX);
digitalWrite (SSarray[channelCount], LOW);
digitalWrite (SSarray[channelCount], LOW);
SPI.transfer(RTD_LSB_read); // send out register #
delayMicroseconds(10);
incomingByte2 = SPI.transfer(0); // read register contents back
digitalWrite(SSarray[channelCount], HIGH);
Serial.print (" LSB value read ");
Serial.print (incomingByte2, HEX);
Serial.print (" Channel ");
Serial.print (channelCount);
Serial.print (" ADCcode = ");
// Temperature (NC) =(ADC code/32)/ 256
ADCcode = (incomingByte1<<8) + incomingByte2;
Serial.print (ADCcode, HEX);
ADCcode = ADCcode >>1; // drop LSB, is set to 1 if there is a fault flag >>> see Page 14
temperature = ( (ADCcode/32) - 256);
Serial.print (" Temperature Deg C ");
Serial.println (temperature, 2);
When I do the math by hand, I get results with something besides .00 for decimal points:
45BC >>1 = 22DE = 8926 dec
8926/32 = 278.9375
- 256 = 22.9375
yet my print comes out as 22.00 and 23.00
What am I missing?
Thanks