MAX31865 - RDT Thermometer

Recurrent H/W and software problems
Post Reply
User avatar
Richo
Posts: 16
Joined: Mon Apr 04, 2022 3:37 pm
Location: Nakskov, Denmark
Has thanked: 36 times
Been thanked: 2 times

MAX31865 - RDT Thermometer

Post by Richo »

Spent days trying to get a MAX31865 to read an RTD value - no luck
A setup value must be written in register h80, and a ratio value of two resistors (15 bits) must be read. Should be simple, but obviously not for me.
The MAX31865 also has some "error registers", but since I know which measurement range interests me, I don't care about them.
It's obviously SPI I don't understand.
Is there anyone who knows it and can give me a hint?
Hardware, linearization, etc. I have it under control.
https://www.analog.com/media/en/technic ... X31865.pdf
Best regards
Richo
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: MAX31865 - RDT Thermometer

Post by cicciocb »

What is exactly the module that you have? Is for a PT100?

Edit:
As it seems interesting, I've just bought one module to integrate the driver directly inside Annex
User avatar
Richo
Posts: 16
Joined: Mon Apr 04, 2022 3:37 pm
Location: Nakskov, Denmark
Has thanked: 36 times
Been thanked: 2 times

Re: MAX31865 - RDT Thermometer

Post by Richo »

https://www.aliexpress.com/item/1005005 ... Redirect=y

Yes, it's for PT100
I got it with a 400 Ohm reference resistor, but I want to change it to a lower value.
Since it only has to cover 0-100 C, I can get a higher resolution - it could be 150 Ohm
/Richo
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: MAX31865 - RDT Thermometer

Post by cicciocb »

I bought the same ... I'll try to integrate the driver inside but I'll not be able to test until the reception of the module
User avatar
Richo
Posts: 16
Joined: Mon Apr 04, 2022 3:37 pm
Location: Nakskov, Denmark
Has thanked: 36 times
Been thanked: 2 times

Re: MAX31865 - RDT Thermometer

Post by Richo »

Linearization is straight forward and may be that could be part of the function?
Long-term stabilization/temp. depends on the comparison resistance. It is not the tolerance, but the temperature coefficient it depends on.
If you want a precision instrument, the whole thing must be calibrated together, and here it doesn't matter if it's a class A or AA you have, nor the absolute value of the comparison resistor.
I myself am thinking of temperature stabilizing the PCB (oven)
If you have an ice bath, and boiling water (clean), and the air pressure, you have 0c and 99.9xC, and then it is just a matter of using the Callendar–Van Dusen equation to linearize.

https://en.wikipedia.org/wiki/Callendar ... n_equation
https://www.physics.utoronto.ca/apl/fe/ ... ersion.pdf

/Richo
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: MAX31865 - RDT Thermometer

Post by cicciocb »

The linearization formula is quite easy so, just having the resistance, it can be also be implemented in basic
User avatar
cicciocb
Site Admin
Posts: 2195
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: MAX31865 - RDT Thermometer

Post by cicciocb »

Hello,
I received yesterday the module with a PT100.

I did a quick "library" using an ESP32-S3 (the one I have on the bench in this moment) and it seems to work.
I think that this code contains all you need.

Code: [Local Link Removed for Guests]

'simple library for the MAX31865
'datasheet https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31865.pdf
MAX31865_CONFIG_REG  = 0
MAX31865_RTDMSB_REG  = 1
spi.setup 100000,1,1
spi.cspin 10
r$ = ""
read8 MAX31865_CONFIG_REG, r$
wlog "MAX31865_CONFIG_REG" , r$

'datasheet Table 2
'VBIAS ON, COnversion mode Auto, no one shoot, 2 or 4 wires, fault clear, 50 Hz filter
write8 MAX31865_CONFIG_REG, &b11000011 'datasheet Table 2
pause 100
read8 MAX31865_CONFIG_REG, r$
wlog "MAX31865_CONFIG_REG" , r$

r = 0
Rref = 430 ' reference resistance on the module
for z = 1 to 1000
  read16 1, r$
  v = val("&h" + r$) >> 1
  convert v, r
  wlog "value" , r$, v, v/(2^15),  v/(2^15)*Rref, r
  pause 500
next z
end

sub read8(address, ret$)
  local a$
  a$ = str$(address,"%02X", 1)
  a$ = a$ + "00"
  ret$ = spi.hex$(a$, 2)
  ret$ = mid$(ret$, 3)
end sub


sub read16(address, ret$)
  local a$
  a$ = str$(address,"%02X", 1)
  a$ = a$ + "0000"
  ret$ = spi.hex$(a$, 3)
  ret$ = mid$(ret$, 3)
end sub

sub write8(address, value)
  a$ = str$(address + 128,"%02X", 1)
  a$ = a$ + str$(value,"%02X", 1)
  ret$ = spi.hex$(a$, 2)
end sub

sub convert(raw, temp)
  rt = v/(2^15) * Rref
  RTDnominal = 100
  RTD_A = 3.9083e-3
  RTD_B = -5.775e-7
  Z1 = -RTD_A
  Z2 = RTD_A * RTD_A - (4 * RTD_B)
  Z3 = (4 * RTD_B) / RTDnominal
  Z4 = 2 * RTD_B
  temp = Z2 + (Z3 * Rt)
  temp = (sqr(temp) + Z1) / Z4
  if temp >=0 then exit sub
 
  Rt = Rt / RTDnominal
  Rt = Rt * 100 ' normalize to 100 ohm

  temp = -242.02 + 2.2228 * Rt + 2.5859e-3 *(rt^2) -4.8260e-6 *(Rt^3) - 2.8183e-8 *(Rt^4) + 1.5243e-10 * (Rt^5)

end sub
Some pictures
1709633612706.jpg
1709633612685.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Richo
Posts: 16
Joined: Mon Apr 04, 2022 3:37 pm
Location: Nakskov, Denmark
Has thanked: 36 times
Been thanked: 2 times

Re: MAX31865 - RDT Thermometer

Post by Richo »

Just what I needed - thank you very much
Post Reply