当前位置:首页 > 技术学院 > 技术前线
[导读]max31865模块RTD测温注意事项

max31865模块RTD测温注意事项

注意事项1 参考电阻

注意事项2 接线

注意事项3 电气连接

注意事项4 max31865模块重要细节

注意事项5 SPI时序间隔

注意事项6 max31865读取不到寄存器数据的原因

参考代码

注意事项1 参考电阻

The PT100 version of the breakout uses 430Ω

The PT1000 version uses 4300Ω

一般PT100选400欧姆参考电阻,但是板子上给的是4300,也就是430Ω。程序里需要设置参考电阻为430,PT1000选择4300Ω。

#define REF_RES 430


max31865问题

注意事项2 接线

板子上有三个位置用于设置线的。


max31865问题


max31865问题

注意事项3 电气连接

Power Pins:

Vin - this is the power pin. Since the chip uses 3 VDC, we have included a voltage regulator on board that will take 3-5VDC and safely convert it down. To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V micro like Arduino, use 5V

3Vo - this is the 3.3V output from the voltage regulator, you can grab up to 100mA from this if you like

GND - common ground for power and logic

SPI Logic pins:

All pins going into the breakout have level shifting circuitry to make them 3-5V logic level safe. Use whatever logic level is on Vin!

SCK - This is the SPI Clock pin, its an input to the chip

SDO - this is the Serial Data Out / Microcontroller In Sensor Out pin, for data sent from the MAX31865 to your processor

SDI - this is the Serial Data In / Microcontroller Out Sensor In pin, for data sent from your processor to the MAX31865

CS - this is the Chip Select pin, drop it low to start an SPI transaction. Its an input to the chip

If you want to connect multiple MAX31865’s to one microcontroller, have them share the SDI, SDO and SCK pins. Then assign each one a unique CS pin.

RDY (Ready) - is a data-ready indicator pin, you can use this pin to speed up your reads if you are writing your own driver. Our Arduino driver doesn’t use it to save a pin.

注意事项4 max31865模块重要细节

SPI对其寄存器进行读写,寄存器如下图。

配置寄存器,想读就读0x00,想写就写0x80。

转化后的RTD数值存放于0x01和0x02这2个8位寄存器。

可以设置错误报警门限上限和下限,通俗来说,比如一个PT100能测温范围是-200℃到420℃,用户想设置下限报警值为-180℃,上限报警值为400℃,那么当max31865转换RTD后,会将0x01和0x02寄存器结果与上限值和下限值比较,如果不在设置的范围,就会产生错误标志。

错误标志存在0x07寄存器中。

读取温度过程:

(1)读取0x07寄存器,看是不是等于0x00,即是说无错误标志。有错误标志时,0x07寄存器里面某个值就是1。

错误标志可以手动清除,但如果没实际解决问题,下次检测这个标志还是会被模块拉起。

(2)如果能过错误检测,就开始下面的过程。向0x80写入配置,这里写入的是说进行一次转换(One_Shot_Conversion ),然后等待DRDY 引脚变成低电平(意味转换结束)。然后读取0x01和0x02这2个8位寄存器,0x02的最低位装的是错没错的标志,没错的话就可以利用0x01和0x02这2个8位寄存器合成电阻数值。

4)PT100电阻变成温度

这个就各显神通了,有各种各样的转换公式。

注意事项5 SPI时序间隔


max31865问题

注意事项6 max31865读取不到寄存器数据的原因


max31865问题


max31865问题

从机发数据也是需要主机提供时钟信号的

参考代码

//使用RT1052 LPSPI3

//LPSPI3:读写一个字节

//TxData:要写入的字节

//返回值:读取到的字节

uint8_t LPSPI3_ReadWriteByte(uint8_t TxData)

{

uint8_t spirxdata=0;

uint8_t spitxdata=TxData;

lpspi_transfer_t spi_tranxfer;

lpspi_master_handle_t master_handle;

spi_tranxfer.configFlags=kLPSPI_MasterPcs1|kLPSPI_MasterPcsContinuous; //PCS1

spi_tranxfer.txData=&spitxdata; //要发送的数据

spi_tranxfer.rxData=&spirxdata; //要接收到的数据

spi_tranxfer.dataSize=1; //数据长度

LPSPI_MasterTransferBlocking(LPSPI3,&spi_tranxfer); //SPI阻塞发送

// LPSPI_MasterTransferNonBlocking(LPSPI3, &master_handle, &spi_tranxfer);

return spirxdata;

}

uint8_t max31685_ReadRegister8(uint8_t addr)

{

uint8_t ret;

GPIO_PinWrite(BOARD_USER_SPI_CS0, BOARD_USER_SPI_CS0_PIN, 1U);

SysTick_DelayTicks(1U);

GPIO_PinWrite(BOARD_USER_SPI_CS0, BOARD_USER_SPI_CS0_PIN, 0U);

SysTick_DelayTicks(1U);

ret = LPSPI3_ReadWriteByte(addr);

SysTick_DelayTicks(1U);

ret = LPSPI3_ReadWriteByte(0xff);

SysTick_DelayTicks(1U);

GPIO_PinWrite(BOARD_USER_SPI_CS0, BOARD_USER_SPI_CS0_PIN, 1U);

return ret;

}

uint8_t max31685_WriteRegister8(uint8_t addr, uint8_t data)

{

uint8_t ret;

GPIO_PinWrite(BOARD_USER_SPI_CS0, BOARD_USER_SPI_CS0_PIN, 1U);

SysTick_DelayTicks(1U);

GPIO_PinWrite(BOARD_USER_SPI_CS0, BOARD_USER_SPI_CS0_PIN, 0U);

SysTick_DelayTicks(1U);

ret = LPSPI3_ReadWriteByte(addr | 0x80);

SysTick_DelayTicks(1U);

ret = LPSPI3_ReadWriteByte(data);

SysTick_DelayTicks(1U);

GPIO_PinWrite(BOARD_USER_SPI_CS0, BOARD_USER_SPI_CS0_PIN, 1U);

return ret;

}

void max31865_Init(void)

{

uint8_t ret; //for test

GPIO_PinWrite(BOARD_USER_SPI_CS0, BOARD_USER_SPI_CS0_PIN, 1U);

SysTick_DelayTicks(10U);

//BIAS ON,自动,三线,50Hz

max31685_WriteRegister8(MAX31856_CONFIG_REG, MAX31856_CONFIG_BIAS | MAX31856_CONFIG_MODEAUTO | MAX31856_CONFIG_3WIRE | MAX31856_CONFIG_FILT50HZ);

ret = max31685_ReadRegister8(MAX31856_CONFIG_REG);

}

uint8_t max31865_ReadFault(void)

{

}

void max31865_ClearFault(void)

{

}

void max31865_Config(uint8_t reg, uint8_t cfgValue)

{

}

uint16_t max31865_ReadRTD(void)

{

uint16_t rtd = 0;

rtd = max31685_ReadRegister8(MAX31856_RTDMSB_REG) << 8;

rtd |= max31685_ReadRegister8(MAX31856_RTDLSB_REG);

rtd = rtd >> 1;

return rtd;

}


max31865问题


本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭