LTC2986 - 具有 EEPROM 的多传感器高准确度数字温度测量系统

特点

  • 可直接对两线、三线或四线电阻式温度检测器 (RTD)、热电偶、热敏电阻和二极管进行数字化处理
  • 片内 EEPROM (LTC2986-1) 可存储通道配置数据和定制系数
  • 2.85V 至 5.25V 单电源
  • 10 个灵活的输入允许交换传感器
  • 自动热电偶冷结点补偿
  • 用于热电偶、RTD 和热敏电阻的内置标准系数和用户可编程系数
  • 可测量负的热电偶电压
  • 烧毁、短路和故障的自动检测
  • 缓冲输入可提供外部保护
  • 同时 50Hz / 60Hz 抑制
  • 包括 15ppm/°C (最大值) 基准
  • 包括特殊的保护模式

典型应用

LTC2986 Typical Application
LTC2986 Typical Application

描述

LTC®2986 可测量多种温度传感器并以数字方式输出结果 (采用 °C 或 °F 为单位),具有 0.1°C 的准确度和 0.001°C 的分辨率。LTC2986 能够测量几乎所有标准 (B、E、J、K、N、S、R、T 类) 热电偶或定制热电偶的温度,可自动补偿冷结点温度并对结果进行线性化。另外,该器件还能利用标准的两线、三线或四线式 RTD、热敏电阻和二极管来测量温度。LTC2986 包括适用于每种温度传感器的激励电流源和故障检测电路。

LTC2986 / LTC2986-1 是 20 通道 LTC2983 / LTC2984 的 10 通道软件和引脚兼容型版本。其他特点包括在通用多传感器应用中实现简易保护的特殊模式、用于普通 ADC 读数的定制表、以及从有源模拟温度传感器的直接温度读出。LTC2986-1 是 LTC2986 的 EEPROM 版本。

封装

如需了解完整与最新的封装信息及图例,请查阅我们的封装网页

器件型号 封装 Code 温度 封装图 RoHS 数据
LTC2986CLX-1#PBF 7x7 LQFP-48 LX C 05-08-1760 Yes
LTC2986CLX#PBF 7x7 LQFP-48 LX C 05-08-1760 Yes
LTC2986HLX-1#PBF 7x7 LQFP-48 LX H 05-08-1760 Yes
LTC2986HLX#PBF 7x7 LQFP-48 LX H 05-08-1760 Yes
LTC2986ILX-1#PBF 7x7 LQFP-48 LX I 05-08-1760 Yes
LTC2986ILX#PBF 7x7 LQFP-48 LX I 05-08-1760 Yes


LTC2986 Package Drawing

订购信息

  • 以 PBF 结尾的器件型号表示这些是无铅型器件。如需了解有关含铅涂层器件的信息,请与凌力尔特公司联系。

  • 型号当中包含 TR 或 TRM 的器件分别采用卷带装500 片微型卷带装的形式进行装运。

  • 如需了解更多的细节,请查阅我们一般订购信息或产品数据手册。

各种封装型式和定价

器件型号 封装 温度 价格 (以 1 ~ 99 片为批量) 价格 (以 1000 片为批量) * RoHS 数据
LTC2986CLX-1#PBF 7x7 LQFP-48 C $26.01 $18.21 Yes
LTC2986CLX#PBF 7x7 LQFP-48 C $23.66 $16.56 Yes
LTC2986HLX-1#PBF 7x7 LQFP-48 H $34.40 $24.08 Yes
LTC2986HLX#PBF 7x7 LQFP-48 H $31.29 $21.90 Yes
LTC2986ILX-1#PBF 7x7 LQFP-48 I $29.92 $20.94 Yes
LTC2986ILX#PBF 7x7 LQFP-48 I $27.21 $19.04 Yes
购买要求提供样品

* 美国价目表所列之价格仅供预算之用,单位为美元 (针对规定批量的美国 FOB 单价),随时可能变更。国际销售价格有可能因为地方税额、费用和汇率而有所不同。如需了解特定批量的价格或货运报价,请您与凌力尔特当地的销售办事处或授权分销商联系

演示电路板

凌力尔特的演示电路板可免费提供给合资格的客户,请您与当地的销售办事处或分销商联系,申请获取演示电路板。另外,某些演示电路板也可通过信用卡在此网站上购买。演示电路板仅供评估之用。器件在实际终端应用中的正确与可靠运作的验证仍然是客户的责任。

器件型号 描述 价格 Documentation
DC2531A LTC2986 Demo Board | LTC2986 Motherboard (DC2508) + 20-Input Breakout Board (DC2210), req. DC2026 $125.00
DC2531A-KIT Starter Kit for LTC2986 | LTC2986 Motherboard (DC2508) + 20-Input Breakout Board (DC2210) + Linduino One (DC2026) $195.00
购买

Companion Boards

器件型号 描述 价格 Documentation
DC2026C Linduino One Isolated USB Demo Board: An Arduino- and QuikEval-Compatible Code Development Platform $75.00
DC2211A LTC2983/84/86 Universal 4-Input Board (req. DC2296, DC2420 or DC2531) $50.00
DC2212A LTC2983/84/86 Thermocouple Board (req. DC2296, DC2420 or DC2531) $75.00
DC2213A LTC2983/84/86 RTD Board (req. DC2296, DC2420 or DC2531) $115.00
DC2214A LTC2983/84/86 Thermistor Board (req. DC2296, DC2420 or DC2531) $75.00
DC2507A LTC2986 and LTC2986-1 Universal Protected Board (req. DC2531 or DC2608) $50.00
购买
点击这里查看我们的演示板完整列表

应用

  • 直接热电偶测量
  • 直接 RTD 测量
  • 直接热敏电阻测量
  • 定制传感器应用

产品通知

请登录您的 MyLinear 帐户,以获得数据表更新通知、新文档发布、以及针对您喜爱产品的 LTspice 模型通告。 如果您还没有 MyLinear 帐户,可以立即 注册

忘记密码吗? 请单击这里
需要帮助吗? 如果有任何问题或意见,请发送电子邮件至 mylinear@linear.com

设计工具

LTC2986 Software

The LTC®2986 demo software is designed to help configure, program and run the LTC2986. It can configure the LTC2986, save the configuration, check for configuration errors, run the LTC2986, output the conversion results into a text file, and create Linduino-ready C code based on the configuration. The software can be used by itself, or used in conjunction with the DC2508 or DC2618 demo circuit.

Linduino

Linduino 是一款可兼容 Arduino 的平台,其用于开发和分配用于 SPI 和 I2C 兼容型集成电路的固件库和代码。Linduino One 电路板可连接 300 多款 QuikEval 演示板卡并支持多种产品类型,包括模数转换器 (ADC)数模转换器 (DAC)功率监视器等等。用于个别器件的固件库采用 C 语言编写并专为可移植到众多的处理器和微控制器而设计。每个固件库具有一种演示程序,此演示程序可上载至 Linduino One 平台以简便快捷地完成电路和软件的验证。

点击这里以了解 Linduino 的更多相关信息

 

代码

Linduino 是凌力尔特的 Arduino 兼容型系统,适用于开发和分发针对凌力尔特集成电路的固件库和代码范例。下面的代码程序可以下载或者“拷贝并粘贴”到您的设计方案之中。请访问 Linduino 主页以获取演示板、手册和设置信息。

该器件得到了系列支持: 提供了可用于该系列中某款器件的代码示例。此代码可能需要进行一些变更以与该特定器件配合工作,不过仍然提供了许多关于某些相互作用将怎样发生的范例。下面的代码有可能依存于完整库中提供的其他驱动程序。

Download DC2212A Linduino.INO File

/*!
LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System
@verbatim

DC2212_THERMOCOUPLE_BOARD.ino:
Generated Linduino code from the LTC2984 Demo Software.
This code  is designed to be used by a Linduino,
but can also be used to understand how to program the LTC2984.


@endverbatim

http://www.linear.com/product/LTC2984

http://www.linear.com/product/LTC2984#demoboards

$Revision: 5797 $
$Date: 2016-09-23 10:30:32 -0700 (Fri, 23 Sep 2016) $
Copyright (c) 2014, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/



/*! @file
    @ingroup LTC2984

*/




#include <Arduino.h>
#include <stdint.h>
#include <stdbool.h>
#include "SPI.h"
#include "Wire.h"
#include "Linduino.h"
#include "LT_SPI.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "stdio.h"
#include "math.h"

#include "configuration_constants_LTC2984.h"
#include "support_functions_LTC2984.h"
#include "table_coeffs_LTC2984.h"

#define CHIP_SELECT QUIKEVAL_CS  // Chip select pin

// Function prototypes
void configure_channels();
void configure_global_parameters();


// -------------- Configure the LTC2984 -------------------------------
void setup()
{
  char demo_name[]="DC2399";     // Demo Board Name stored in QuikEval EEPROM
  quikeval_I2C_init();          // Configure the EEPROM I2C port for 100kHz
  quikeval_SPI_init();          // Configure the spi port for 4MHz SCK
  quikeval_SPI_connect();       // Connect SPI to main data port
  pinMode(CHIP_SELECT, OUTPUT); // Configure chip select pin on Linduino

  Serial.begin(115200);         // Initialize the serial port to the PC
  print_title();
  discover_demo_board(demo_name);

  configure_channels();
  configure_global_parameters();
}


void configure_channels()
{
  uint8_t channel_number;
  uint32_t channel_assignment_data;

  // ----- Channel 1: Assign Type J Thermocouple -----
  channel_assignment_data =
    SENSOR_TYPE__TYPE_J_THERMOCOUPLE |
    TC_COLD_JUNCTION_CH__2 |
    TC_SINGLE_ENDED |
    TC_OPEN_CKT_DETECT__YES |
    TC_OPEN_CKT_DETECT_CURRENT__10UA;
  assign_channel(CHIP_SELECT, 1, channel_assignment_data);
  // ----- Channel 2: Assign Off-Chip Diode -----
  channel_assignment_data =
    SENSOR_TYPE__OFF_CHIP_DIODE |
    DIODE_SINGLE_ENDED |
    DIODE_NUM_READINGS__2 |
    DIODE_AVERAGING_OFF |
    DIODE_CURRENT__20UA_80UA_160UA |
    (uint32_t) 0x100C49 << DIODE_IDEALITY_FACTOR_LSB;   // diode - ideality factor(eta): 1.00299930572509765625
  assign_channel(CHIP_SELECT, 2, channel_assignment_data);
  // ----- Channel 3: Assign Type K Thermocouple -----
  channel_assignment_data =
    SENSOR_TYPE__TYPE_K_THERMOCOUPLE |
    TC_COLD_JUNCTION_CH__9 |
    TC_SINGLE_ENDED |
    TC_OPEN_CKT_DETECT__YES |
    TC_OPEN_CKT_DETECT_CURRENT__10UA;
  assign_channel(CHIP_SELECT, 3, channel_assignment_data);
  // ----- Channel 4: Assign Off-Chip Diode -----
  channel_assignment_data =
    SENSOR_TYPE__OFF_CHIP_DIODE |
    DIODE_SINGLE_ENDED |
    DIODE_NUM_READINGS__2 |
    DIODE_AVERAGING_OFF |
    DIODE_CURRENT__20UA_80UA_160UA |
    (uint32_t) 0x100C49 << DIODE_IDEALITY_FACTOR_LSB;   // diode - ideality factor(eta): 1.00299930572509765625
  assign_channel(CHIP_SELECT, 4, channel_assignment_data);
  // ----- Channel 5: Assign Type J Thermocouple -----
  channel_assignment_data =
    SENSOR_TYPE__TYPE_J_THERMOCOUPLE |
    TC_COLD_JUNCTION_CH__NONE |
    TC_SINGLE_ENDED |
    TC_OPEN_CKT_DETECT__YES |
    TC_OPEN_CKT_DETECT_CURRENT__10UA;
  assign_channel(CHIP_SELECT, 5, channel_assignment_data);
  // ----- Channel 7: Assign Sense Resistor -----
  channel_assignment_data =
    SENSOR_TYPE__SENSE_RESISTOR |
    (uint32_t) 0x1F4000 << SENSE_RESISTOR_VALUE_LSB;    // sense resistor - value: 2000.
  assign_channel(CHIP_SELECT, 7, channel_assignment_data);
  // ----- Channel 9: Assign RTD PT-100 -----
  channel_assignment_data =
    SENSOR_TYPE__RTD_PT_100 |
    RTD_RSENSE_CHANNEL__7 |
    RTD_NUM_WIRES__4_WIRE |
    RTD_EXCITATION_MODE__NO_ROTATION_NO_SHARING |
    RTD_EXCITATION_CURRENT__100UA |
    RTD_STANDARD__EUROPEAN;
  assign_channel(CHIP_SELECT, 9, channel_assignment_data);
  // ----- Channel 10: Assign Type J Thermocouple -----
  channel_assignment_data =
    SENSOR_TYPE__TYPE_J_THERMOCOUPLE |
    TC_COLD_JUNCTION_CH__NONE |
    TC_SINGLE_ENDED |
    TC_OPEN_CKT_DETECT__YES |
    TC_OPEN_CKT_DETECT_CURRENT__10UA;
  assign_channel(CHIP_SELECT, 10, channel_assignment_data);

}




void configure_global_parameters()
{
  // -- Set global parameters
  transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xF0, TEMP_UNIT__C |
                REJECTION__50_60_HZ);
  // -- Set any extra delay between conversions (in this case, 0*100us)
  transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xFF, 0);
}

// -------------- Run the LTC2984 -------------------------------------

void loop()
{
  measure_channel(CHIP_SELECT, 1, TEMPERATURE);      // Ch 1: Type J Thermocouple
  measure_channel(CHIP_SELECT, 2, TEMPERATURE);      // Ch 2: Off-Chip Diode
  measure_channel(CHIP_SELECT, 3, TEMPERATURE);      // Ch 3: Type K Thermocouple
  measure_channel(CHIP_SELECT, 4, TEMPERATURE);      // Ch 4: Off-Chip Diode
  measure_channel(CHIP_SELECT, 5, TEMPERATURE);      // Ch 5: Type J Thermocouple
  measure_channel(CHIP_SELECT, 9, TEMPERATURE);      // Ch 9: RTD PT-100
  measure_channel(CHIP_SELECT, 10, TEMPERATURE);     // Ch 10: Type J Thermocouple
}

Download DC2213A Linduino.INO File

/*!
LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System
@verbatim

DC2213_DEDICATED_RTD_BOARD.ino:
Generated Linduino code from the LTC2984 Demo Software.
This code  is designed to be used by a Linduino,
but can also be used to understand how to program the LTC2984.


@endverbatim

http://www.linear.com/product/LTC2984

http://www.linear.com/product/LTC2984#demoboards

$Revision: 5797 $
$Date: 2016-09-23 10:30:32 -0700 (Fri, 23 Sep 2016) $
Copyright (c) 2014, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/



/*! @file
    @ingroup LTC2984

*/




#include <Arduino.h>
#include <stdint.h>
#include <stdbool.h>
#include "SPI.h"
#include "Wire.h"
#include "Linduino.h"
#include "LT_SPI.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "stdio.h"
#include "math.h"

#include "configuration_constants_LTC2984.h"
#include "support_functions_LTC2984.h"
#include "table_coeffs_LTC2984.h"

#define CHIP_SELECT QUIKEVAL_CS  // Chip select pin

// Function prototypes
void configure_channels();
void configure_global_parameters();


// -------------- Configure the LTC2984 -------------------------------
void setup()
{
  char demo_name[]="DC2399";     // Demo Board Name stored in QuikEval EEPROM
  quikeval_I2C_init();          // Configure the EEPROM I2C port for 100kHz
  quikeval_SPI_init();          // Configure the spi port for 4MHz SCK
  quikeval_SPI_connect();       // Connect SPI to main data port
  pinMode(CHIP_SELECT, OUTPUT); // Configure chip select pin on Linduino

  Serial.begin(115200);         // Initialize the serial port to the PC
  print_title();
  discover_demo_board(demo_name);

  configure_channels();
  configure_global_parameters();
}


void configure_channels()
{
  uint8_t channel_number;
  uint32_t channel_assignment_data;

  // ----- Channel 3: Assign Sense Resistor -----
  channel_assignment_data =
    SENSOR_TYPE__SENSE_RESISTOR |
    (uint32_t) 0x1F4000 << SENSE_RESISTOR_VALUE_LSB;    // sense resistor - value: 2000.
  assign_channel(CHIP_SELECT, 3, channel_assignment_data);
  // ----- Channel 5: Assign RTD PT-100 -----
  channel_assignment_data =
    SENSOR_TYPE__RTD_PT_100 |
    RTD_RSENSE_CHANNEL__3 |
    RTD_NUM_WIRES__4_WIRE_KELVIN_RSENSE |
    RTD_EXCITATION_MODE__ROTATION_SHARING |
    RTD_EXCITATION_CURRENT__250UA |
    RTD_STANDARD__AMERICAN;
  assign_channel(CHIP_SELECT, 5, channel_assignment_data);
  // ----- Channel 8: Assign RTD PT-100 -----
  channel_assignment_data =
    SENSOR_TYPE__RTD_PT_100 |
    RTD_RSENSE_CHANNEL__3 |
    RTD_NUM_WIRES__4_WIRE_KELVIN_RSENSE |
    RTD_EXCITATION_MODE__ROTATION_SHARING |
    RTD_EXCITATION_CURRENT__100UA |
    RTD_STANDARD__AMERICAN;
  assign_channel(CHIP_SELECT, 8, channel_assignment_data);
  // ----- Channel 11: Assign RTD PT-100 -----
  channel_assignment_data =
    SENSOR_TYPE__RTD_PT_100 |
    RTD_RSENSE_CHANNEL__3 |
    RTD_NUM_WIRES__3_WIRE |
    RTD_EXCITATION_MODE__NO_ROTATION_SHARING |
    RTD_EXCITATION_CURRENT__100UA |
    RTD_STANDARD__AMERICAN;
  assign_channel(CHIP_SELECT, 11, channel_assignment_data);

}




void configure_global_parameters()
{
  // -- Set global parameters
  transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xF0, TEMP_UNIT__C |
                REJECTION__50_60_HZ);
  // -- Set any extra delay between conversions (in this case, 0*100us)
  transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xFF, 0);
}

// -------------- Run the LTC2984 -------------------------------------

void loop()
{
  measure_channel(CHIP_SELECT, 5, TEMPERATURE);      // Ch 5: RTD PT-100
  measure_channel(CHIP_SELECT, 8, TEMPERATURE);      // Ch 8: RTD PT-100
  measure_channel(CHIP_SELECT, 11, TEMPERATURE);     // Ch 11: RTD PT-100
}

Download DC2214A Linduino.INO File

/*!
LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System
@verbatim

DC2214_DEDICATED_THERMISTOR_BOARD.ino:
Generated Linduino code from the LTC2984 Demo Software.
This code  is designed to be used by a Linduino,
but can also be used to understand how to program the LTC2984.


@endverbatim

http://www.linear.com/product/LTC2984

http://www.linear.com/product/LTC2984#demoboards

$Revision: 5797 $
$Date: 2016-09-23 10:30:32 -0700 (Fri, 23 Sep 2016) $
Copyright (c) 2014, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/



/*! @file
    @ingroup LTC2984

*/




#include <Arduino.h>
#include <stdint.h>
#include <stdbool.h>
#include "SPI.h"
#include "Wire.h"
#include "Linduino.h"
#include "LT_SPI.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "stdio.h"
#include "math.h"

#include "configuration_constants_LTC2984.h"
#include "support_functions_LTC2984.h"
#include "table_coeffs_LTC2984.h"

#define CHIP_SELECT QUIKEVAL_CS  // Chip select pin

// Function prototypes
void configure_channels();
void configure_global_parameters();


// -------------- Configure the LTC2984 -------------------------------
void setup()
{
  char demo_name[]="DC2399";     // Demo Board Name stored in QuikEval EEPROM
  quikeval_I2C_init();          // Configure the EEPROM I2C port for 100kHz
  quikeval_SPI_init();          // Configure the spi port for 4MHz SCK
  quikeval_SPI_connect();       // Connect SPI to main data port
  pinMode(CHIP_SELECT, OUTPUT); // Configure chip select pin on Linduino

  Serial.begin(115200);         // Initialize the serial port to the PC
  print_title();
  discover_demo_board(demo_name);

  configure_channels();
  configure_global_parameters();
}


void configure_channels()
{
  uint8_t channel_number;
  uint32_t channel_assignment_data;

  // ----- Channel 2: Assign Sense Resistor -----
  channel_assignment_data =
    SENSOR_TYPE__SENSE_RESISTOR |
    (uint32_t) 0x9C4000 << SENSE_RESISTOR_VALUE_LSB;    // sense resistor - value: 10000.
  assign_channel(CHIP_SELECT, 2, channel_assignment_data);
  // ----- Channel 4: Assign Thermistor 44006 10K@25C -----
  channel_assignment_data =
    SENSOR_TYPE__THERMISTOR_44006_10K_25C |
    THERMISTOR_RSENSE_CHANNEL__2 |
    THERMISTOR_DIFFERENTIAL |
    THERMISTOR_EXCITATION_MODE__SHARING_ROTATION |
    THERMISTOR_EXCITATION_CURRENT__AUTORANGE;
  assign_channel(CHIP_SELECT, 4, channel_assignment_data);
  // ----- Channel 6: Assign Thermistor 44006 10K@25C -----
  channel_assignment_data =
    SENSOR_TYPE__THERMISTOR_44006_10K_25C |
    THERMISTOR_RSENSE_CHANNEL__2 |
    THERMISTOR_DIFFERENTIAL |
    THERMISTOR_EXCITATION_MODE__SHARING_ROTATION |
    THERMISTOR_EXCITATION_CURRENT__AUTORANGE;
  assign_channel(CHIP_SELECT, 6, channel_assignment_data);
  // ----- Channel 8: Assign Thermistor 44006 10K@25C -----
  channel_assignment_data =
    SENSOR_TYPE__THERMISTOR_44006_10K_25C |
    THERMISTOR_RSENSE_CHANNEL__2 |
    THERMISTOR_DIFFERENTIAL |
    THERMISTOR_EXCITATION_MODE__SHARING_ROTATION |
    THERMISTOR_EXCITATION_CURRENT__AUTORANGE;
  assign_channel(CHIP_SELECT, 8, channel_assignment_data);
  // ----- Channel 10: Assign Thermistor 44008 30K@25C -----
  channel_assignment_data =
    SENSOR_TYPE__THERMISTOR_44008_30K_25C |
    THERMISTOR_RSENSE_CHANNEL__2 |
    THERMISTOR_DIFFERENTIAL |
    THERMISTOR_EXCITATION_MODE__SHARING_NO_ROTATION |
    THERMISTOR_EXCITATION_CURRENT__AUTORANGE;
  assign_channel(CHIP_SELECT, 10, channel_assignment_data);

}




void configure_global_parameters()
{
  // -- Set global parameters
  transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xF0, TEMP_UNIT__C |
                REJECTION__50_60_HZ);
  // -- Set any extra delay between conversions (in this case, 0*100us)
  transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xFF, 0);
}

// -------------- Run the LTC2984 -------------------------------------

void loop()
{
  measure_channel(CHIP_SELECT, 4, TEMPERATURE);      // Ch 4: Thermistor 44006 10K@25C
  measure_channel(CHIP_SELECT, 6, TEMPERATURE);      // Ch 6: Thermistor 44006 10K@25C
  measure_channel(CHIP_SELECT, 8, TEMPERATURE);      // Ch 8: Thermistor 44006 10K@25C
  measure_channel(CHIP_SELECT, 10, TEMPERATURE);     // Ch 10: Thermistor 44008 30K@25C
}

Download LTC2986 Linduino Header File

/*!
LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System.
@verbatim

configuration_constants_LTC2986.h:
The configuration constants used to configure the LTC2986.
@endverbatim

http://www.linear.com/product/LTC2986

http://www.linear.com/product/LTC2986#demoboards

$Revision: 5795 $
$Date: 2016-09-23 10:17:00 -0700 (Fri, 23 Sep 2016) $
Copyright (c) 2014, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/



/*! @file
    @ingroup LTC2986
    Header for LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System
*/


//**********************************************************************************************************
// -- SENSOR TYPES --
//**********************************************************************************************************
#define SENSOR_TYPE_LSB 27
// RTD
#define SENSOR_TYPE__RTD_PT_10 (uint32_t) 0xA << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_PT_50 (uint32_t) 0xB << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_PT_100 (uint32_t) 0xC << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_PT_200 (uint32_t) 0xD << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_PT_500 (uint32_t) 0xE << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_PT_1000 (uint32_t) 0xF << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_PT_1000_375 (uint32_t) 0x10 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_NI_120 (uint32_t) 0x11 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__RTD_CUSTOM (uint32_t) 0x12 << SENSOR_TYPE_LSB
// Sense Resistor
#define SENSOR_TYPE__SENSE_RESISTOR (uint32_t) 0x1D << SENSOR_TYPE_LSB
// -
#define SENSOR_TYPE__NONE (uint32_t) 0x0 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__ACTIVE_ANALOG (uint32_t) 0x1F << SENSOR_TYPE_LSB
// Direct ADC
#define SENSOR_TYPE__DIRECT_ADC (uint32_t) 0x1E << SENSOR_TYPE_LSB
// Thermistor
#define SENSOR_TYPE__THERMISTOR_44004_2P252K_25C (uint32_t) 0x13 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_44005_3K_25C (uint32_t) 0x14 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_44007_5K_25C (uint32_t) 0x15 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_44006_10K_25C (uint32_t) 0x16 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_44008_30K_25C (uint32_t) 0x17 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_YSI_400_2P252K_25C (uint32_t) 0x18 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_1003K_1K_25C (uint32_t) 0x19 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_CUSTOM_STEINHART_HART (uint32_t) 0x1A << SENSOR_TYPE_LSB
#define SENSOR_TYPE__THERMISTOR_CUSTOM_TABLE (uint32_t) 0x1B << SENSOR_TYPE_LSB
// Thermocouple
#define SENSOR_TYPE__TYPE_J_THERMOCOUPLE (uint32_t) 0x1 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__TYPE_K_THERMOCOUPLE (uint32_t) 0x2 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__TYPE_E_THERMOCOUPLE (uint32_t) 0x3 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__TYPE_N_THERMOCOUPLE (uint32_t) 0x4 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__TYPE_R_THERMOCOUPLE (uint32_t) 0x5 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__TYPE_S_THERMOCOUPLE (uint32_t) 0x6 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__TYPE_T_THERMOCOUPLE (uint32_t) 0x7 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__TYPE_B_THERMOCOUPLE (uint32_t) 0x8 << SENSOR_TYPE_LSB
#define SENSOR_TYPE__CUSTOM_THERMOCOUPLE (uint32_t) 0x9 << SENSOR_TYPE_LSB
// Off-Chip Diode
#define SENSOR_TYPE__OFF_CHIP_DIODE (uint32_t) 0x1C << SENSOR_TYPE_LSB
//**********************************************************************************************************
// -- RTD --
//**********************************************************************************************************
// rtd - rsense channel
#define RTD_RSENSE_CHANNEL_LSB 22
#define RTD_RSENSE_CHANNEL__NONE (uint32_t) 0x0 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__1 (uint32_t) 0x1 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__2 (uint32_t) 0x2 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__3 (uint32_t) 0x3 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__4 (uint32_t) 0x4 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__5 (uint32_t) 0x5 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__6 (uint32_t) 0x6 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__7 (uint32_t) 0x7 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__8 (uint32_t) 0x8 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__9 (uint32_t) 0x9 << RTD_RSENSE_CHANNEL_LSB
#define RTD_RSENSE_CHANNEL__10 (uint32_t) 0xA << RTD_RSENSE_CHANNEL_LSB
// rtd - num wires
#define RTD_NUM_WIRES_LSB 20
#define RTD_NUM_WIRES__2_WIRE (uint32_t) 0x0 << RTD_NUM_WIRES_LSB
#define RTD_NUM_WIRES__3_WIRE (uint32_t) 0x1 << RTD_NUM_WIRES_LSB
#define RTD_NUM_WIRES__4_WIRE (uint32_t) 0x2 << RTD_NUM_WIRES_LSB
#define RTD_NUM_WIRES__4_WIRE_KELVIN_RSENSE (uint32_t) 0x3 << RTD_NUM_WIRES_LSB
// rtd - excitation mode
#define RTD_EXCITATION_MODE_LSB 18
#define RTD_EXCITATION_MODE__NO_ROTATION_NO_SHARING (uint32_t) 0x0 << RTD_EXCITATION_MODE_LSB
#define RTD_EXCITATION_MODE__NO_ROTATION_SHARING (uint32_t) 0x1 << RTD_EXCITATION_MODE_LSB
#define RTD_EXCITATION_MODE__ROTATION_SHARING (uint32_t) 0x2 << RTD_EXCITATION_MODE_LSB
// rtd - excitation current
#define RTD_EXCITATION_CURRENT_LSB 14
#define RTD_EXCITATION_CURRENT__EXTERNAL (uint32_t) 0x0 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__5UA (uint32_t) 0x1 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__10UA (uint32_t) 0x2 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__25UA (uint32_t) 0x3 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__50UA (uint32_t) 0x4 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__100UA (uint32_t) 0x5 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__250UA (uint32_t) 0x6 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__500UA (uint32_t) 0x7 << RTD_EXCITATION_CURRENT_LSB
#define RTD_EXCITATION_CURRENT__1MA (uint32_t) 0x8 << RTD_EXCITATION_CURRENT_LSB
// rtd - standard
#define RTD_STANDARD_LSB 12
#define RTD_STANDARD__EUROPEAN (uint32_t) 0x0 << RTD_STANDARD_LSB
#define RTD_STANDARD__AMERICAN (uint32_t) 0x1 << RTD_STANDARD_LSB
#define RTD_STANDARD__JAPANESE (uint32_t) 0x2 << RTD_STANDARD_LSB
#define RTD_STANDARD__ITS_90 (uint32_t) 0x3 << RTD_STANDARD_LSB
// rtd - custom address
#define RTD_CUSTOM_ADDRESS_LSB 6
// rtd - custom length-1
#define RTD_CUSTOM_LENGTH_1_LSB 0
// rtd - custom values
#define RTD_CUSTOM_VALUES_LSB 31
//**********************************************************************************************************
// -- Sense Resistor --
//**********************************************************************************************************
// sense resistor - value
#define SENSE_RESISTOR_VALUE_LSB 0
//**********************************************************************************************************
// -- - --
//**********************************************************************************************************
// active analog - differential?
#define ACTIVE_ANALOG_DIFFERENTIAL_LSB 26
#define ACTIVE_ANALOG_DIFFERENTIAL (uint32_t) 0x0 << ACTIVE_ANALOG_DIFFERENTIAL_LSB
#define ACTIVE_ANALOG_SINGLE_ENDED (uint32_t) 0x1 << ACTIVE_ANALOG_DIFFERENTIAL_LSB
// active analog - custom address
#define ACTIVE_ANALOG_CUSTOM_ADDRESS_LSB 6
// active analog - custom length-1
#define ACTIVE_ANALOG_CUSTOM_LENGTH_1_LSB 0
// active analog - custom values
#define ACTIVE_ANALOG_CUSTOM_VALUES_LSB 31
//**********************************************************************************************************
// -- Direct ADC --
//**********************************************************************************************************
// Direct ADC - differential?
#define DIRECT_ADC_DIFFERENTIAL_LSB 26
#define DIRECT_ADC_DIFFERENTIAL (uint32_t) 0x0 << DIRECT_ADC_DIFFERENTIAL_LSB
#define DIRECT_ADC_SINGLE_ENDED (uint32_t) 0x1 << DIRECT_ADC_DIFFERENTIAL_LSB
// Direct ADC - custom?
#define DIRECT_ADC_CUSTOM_LSB 25
#define DIRECT_ADC_CUSTOM__NO (uint32_t) 0x0 << DIRECT_ADC_CUSTOM_LSB
#define DIRECT_ADC_CUSTOM__YES (uint32_t) 0x1 << DIRECT_ADC_CUSTOM_LSB
// Direct ADC - custom address
#define DIRECT_ADC_CUSTOM_ADDRESS_LSB 6
// Direct ADC - custom length-1
#define DIRECT_ADC_CUSTOM_LENGTH_1_LSB 0
// Direct ADC - custom values
#define DIRECT_ADC_CUSTOM_VALUES_LSB 31
//**********************************************************************************************************
// -- Thermistor --
//**********************************************************************************************************
// thermistor - rsense channel
#define THERMISTOR_RSENSE_CHANNEL_LSB 22
#define THERMISTOR_RSENSE_CHANNEL__NONE (uint32_t) 0x0 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__1 (uint32_t) 0x1 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__2 (uint32_t) 0x2 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__3 (uint32_t) 0x3 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__4 (uint32_t) 0x4 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__5 (uint32_t) 0x5 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__6 (uint32_t) 0x6 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__7 (uint32_t) 0x7 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__8 (uint32_t) 0x8 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__9 (uint32_t) 0x9 << THERMISTOR_RSENSE_CHANNEL_LSB
#define THERMISTOR_RSENSE_CHANNEL__10 (uint32_t) 0xA << THERMISTOR_RSENSE_CHANNEL_LSB
// thermistor - differential?
#define THERMISTOR_DIFFERENTIAL_LSB 21
#define THERMISTOR_DIFFERENTIAL (uint32_t) 0x0 << THERMISTOR_DIFFERENTIAL_LSB
#define THERMISTOR_SINGLE_ENDED (uint32_t) 0x1 << THERMISTOR_DIFFERENTIAL_LSB
// thermistor - excitation mode
#define THERMISTOR_EXCITATION_MODE_LSB 19
#define THERMISTOR_EXCITATION_MODE__NO_SHARING_NO_ROTATION (uint32_t) 0x0 << THERMISTOR_EXCITATION_MODE_LSB
#define THERMISTOR_EXCITATION_MODE__SHARING_ROTATION (uint32_t) 0x1 << THERMISTOR_EXCITATION_MODE_LSB
#define THERMISTOR_EXCITATION_MODE__SHARING_NO_ROTATION (uint32_t) 0x2 << THERMISTOR_EXCITATION_MODE_LSB
// thermistor - excitation current
#define THERMISTOR_EXCITATION_CURRENT_LSB 15
#define THERMISTOR_EXCITATION_CURRENT__INVALID (uint32_t) 0x0 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__250NA (uint32_t) 0x1 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__500NA (uint32_t) 0x2 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__1UA (uint32_t) 0x3 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__5UA (uint32_t) 0x4 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__10UA (uint32_t) 0x5 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__25UA (uint32_t) 0x6 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__50UA (uint32_t) 0x7 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__100UA (uint32_t) 0x8 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__250UA (uint32_t) 0x9 << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__500UA (uint32_t) 0xA << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__1MA (uint32_t) 0xB << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__AUTORANGE (uint32_t) 0xC << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__INVALID_ (uint32_t) 0xD << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__INVALID__ (uint32_t) 0xE << THERMISTOR_EXCITATION_CURRENT_LSB
#define THERMISTOR_EXCITATION_CURRENT__EXTERNAL (uint32_t) 0xF << THERMISTOR_EXCITATION_CURRENT_LSB
// thermistor - custom address
#define THERMISTOR_CUSTOM_ADDRESS_LSB 6
// thermistor - custom length-1
#define THERMISTOR_CUSTOM_LENGTH_1_LSB 0
// thermistor - custom values
#define THERMISTOR_CUSTOM_VALUES_LSB 31
//**********************************************************************************************************
// -- Thermocouple --
//**********************************************************************************************************
// tc - cold junction ch
#define TC_COLD_JUNCTION_CH_LSB 22
#define TC_COLD_JUNCTION_CH__NONE (uint32_t) 0x0 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__1 (uint32_t) 0x1 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__2 (uint32_t) 0x2 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__3 (uint32_t) 0x3 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__4 (uint32_t) 0x4 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__5 (uint32_t) 0x5 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__6 (uint32_t) 0x6 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__7 (uint32_t) 0x7 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__8 (uint32_t) 0x8 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__9 (uint32_t) 0x9 << TC_COLD_JUNCTION_CH_LSB
#define TC_COLD_JUNCTION_CH__10 (uint32_t) 0xA << TC_COLD_JUNCTION_CH_LSB
// tc - differential?
#define TC_DIFFERENTIAL_LSB 21
#define TC_DIFFERENTIAL (uint32_t) 0x0 << TC_DIFFERENTIAL_LSB
#define TC_SINGLE_ENDED (uint32_t) 0x1 << TC_DIFFERENTIAL_LSB
// tc - open ckt detect?
#define TC_OPEN_CKT_DETECT_LSB 20
#define TC_OPEN_CKT_DETECT__NO (uint32_t) 0x0 << TC_OPEN_CKT_DETECT_LSB
#define TC_OPEN_CKT_DETECT__YES (uint32_t) 0x1 << TC_OPEN_CKT_DETECT_LSB
// tc - open ckt detect current
#define TC_OPEN_CKT_DETECT_CURRENT_LSB 18
#define TC_OPEN_CKT_DETECT_CURRENT__10UA (uint32_t) 0x0 << TC_OPEN_CKT_DETECT_CURRENT_LSB
#define TC_OPEN_CKT_DETECT_CURRENT__100UA (uint32_t) 0x1 << TC_OPEN_CKT_DETECT_CURRENT_LSB
#define TC_OPEN_CKT_DETECT_CURRENT__500UA (uint32_t) 0x2 << TC_OPEN_CKT_DETECT_CURRENT_LSB
#define TC_OPEN_CKT_DETECT_CURRENT__1MA (uint32_t) 0x3 << TC_OPEN_CKT_DETECT_CURRENT_LSB
// tc - custom address
#define TC_CUSTOM_ADDRESS_LSB 6
// tc - custom length-1
#define TC_CUSTOM_LENGTH_1_LSB 0
// tc - custom values
#define TC_CUSTOM_VALUES_LSB 31
//**********************************************************************************************************
// -- Off-Chip Diode --
//**********************************************************************************************************
// diode - differential?
#define DIODE_DIFFERENTIAL_LSB 26
#define DIODE_DIFFERENTIAL (uint32_t) 0x0 << DIODE_DIFFERENTIAL_LSB
#define DIODE_SINGLE_ENDED (uint32_t) 0x1 << DIODE_DIFFERENTIAL_LSB
// diode - num readings
#define DIODE_NUM_READINGS_LSB 25
#define DIODE_NUM_READINGS__2 (uint32_t) 0x0 << DIODE_NUM_READINGS_LSB
#define DIODE_NUM_READINGS__3 (uint32_t) 0x1 << DIODE_NUM_READINGS_LSB
// diode - averaging on?
#define DIODE_AVERAGING_ON_LSB 24
#define DIODE_AVERAGING_OFF (uint32_t) 0x0 << DIODE_AVERAGING_ON_LSB
#define DIODE_AVERAGING_ON (uint32_t) 0x1 << DIODE_AVERAGING_ON_LSB
// diode - current
#define DIODE_CURRENT_LSB 22
#define DIODE_CURRENT__10UA_40UA_80UA (uint32_t) 0x0 << DIODE_CURRENT_LSB
#define DIODE_CURRENT__20UA_80UA_160UA (uint32_t) 0x1 << DIODE_CURRENT_LSB
#define DIODE_CURRENT__40UA_160UA_320UA (uint32_t) 0x2 << DIODE_CURRENT_LSB
#define DIODE_CURRENT__80UA_320UA_640UA (uint32_t) 0x3 << DIODE_CURRENT_LSB
// diode - ideality factor(eta)
#define DIODE_IDEALITY_FACTOR_LSB 0
//**********************************************************************************************************
// -- GLOBAL CONFIGURATION CONSTANTS --
//**********************************************************************************************************
#define REJECTION__50_60_HZ (uint8_t) 0x0
#define REJECTION__60_HZ    (uint8_t) 0x1
#define REJECTION__50_HZ    (uint8_t) 0x2
#define TEMP_UNIT__C        (uint8_t) 0x0
#define TEMP_UNIT__F        (uint8_t) 0x4
#define ENABLE_KELVIN_3_WIRE_RTD_MODE                (uint8_t) 0x10
#define ENABLE_KELVIN_2_WIRE_RTD_MODE                (uint8_t) 0x20
#define ENABLE_KELVIN_DIFFERENTIAL_THERMISTOR_MODE   (uint8_t) 0x40
#define DISABLE_MINUS_999                            (uint8_t) 0x80
//**********************************************************************************************************
// -- STATUS BYTE CONSTANTS --
//**********************************************************************************************************
#define SENSOR_HARD_FAILURE (uint8_t) 0x80
#define ADC_HARD_FAILURE    (uint8_t) 0x40
#define CJ_HARD_FAILURE     (uint8_t) 0x20
#define CJ_SOFT_FAILURE     (uint8_t) 0x10
#define SENSOR_ABOVE        (uint8_t) 0x8
#define SENSOR_BELOW        (uint8_t) 0x4
#define ADC_RANGE_ERROR     (uint8_t) 0x2
#define VALID               (uint8_t) 0x1
//**********************************************************************************************************
// -- ADDRESSES --
//**********************************************************************************************************
#define COMMAND_STATUS_REGISTER          (uint16_t) 0x0000
#define CH_ADDRESS_BASE                  (uint16_t) 0x0200
#define VOUT_CH_BASE                     (uint16_t) 0x0060
#define READ_CH_BASE                     (uint16_t) 0x0010
#define CONVERSION_RESULT_MEMORY_BASE    (uint16_t) 0x0010
//**********************************************************************************************************
// -- MISC CONSTANTS --
//**********************************************************************************************************
#define WRITE_TO_RAM            (uint8_t) 0x02
#define READ_FROM_RAM           (uint8_t) 0x03
#define CONVERSION_CONTROL_BYTE (uint8_t) 0x80

#define VOLTAGE                 (uint8_t) 0x01
#define TEMPERATURE             (uint8_t) 0x02
#define CODE                    (uint8_t) 0x03

Download LTC2986 Linduino Header File

/*!
LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System.
@verbatim

support_functions_LTC2986.h:
This file contains all the support function prototypes used in the main program.
@endverbatim

http://www.linear.com/product/LTC2986

http://www.linear.com/product/LTC2986#demoboards

$Revision: 5795 $
$Date: 2016-09-23 10:17:00 -0700 (Fri, 23 Sep 2016) $
Copyright (c) 2014, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/



/*! @file
    @ingroup LTC2986
    Header for LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System
*/



void print_title();
void assign_channel(uint8_t chip_select, uint8_t channel_number, uint32_t channel_assignment_data);
void write_custom_table(uint8_t chip_select, struct table_coeffs coefficients[64], uint16_t start_address, uint8_t table_length);
void write_custom_steinhart_hart(uint8_t chip_select, uint32_t steinhart_hart_coeffs[6], uint16_t start_address);

void measure_channel(uint8_t chip_select, uint8_t channel_number, uint8_t channel_output);
void convert_channel(uint8_t chip_select, uint8_t channel_number);
void wait_for_process_to_finish(uint8_t chip_select);

void get_result(uint8_t chip_select, uint8_t channel_number, uint8_t channel_output);
void print_conversion_result(uint32_t raw_conversion_result, uint8_t channel_output);
void read_voltage_or_resistance_results(uint8_t chip_select, uint8_t channel_number);
void print_fault_data(uint8_t fault_byte);



uint32_t transfer_four_bytes(uint8_t chip_select, uint8_t read_or_write, uint16_t start_address, uint32_t input_data);
uint8_t transfer_byte(uint8_t chip_select, uint8_t read_or_write, uint16_t start_address, uint8_t input_data);

uint16_t get_start_address(uint16_t base_address, uint8_t channel_number);
bool is_number_in_array(uint8_t number, uint8_t *array, uint8_t array_length);

Download LTC2986 Linduino Header File

/*!

LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System.

LTC2986_table_coeffs.h:
Used for custom tables.


http://www.linear.com/product/LTC2986

http://www.linear.com/product/LTC2986#demoboards

$Revision: 5799 $
$Date: 2016-09-23 10:41:30 -0700 (Fri, 23 Sep 2016) $
Copyright (c) 2014, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/




struct table_coeffs
{
  uint32_t measurement;
  uint32_t temperature;
};


struct channel_table
{
  uint16_t channel;
  uint8_t is_a_temperature_measurement;
};

Download LTC2986 Linduino.CPP

/*!
LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System.
@verbatim

support_functions_LTC2986.cpp:
This file contains all the support functions used in the main program.
@endverbatim

http://www.linear.com/product/LTC2986

http://www.linear.com/product/LTC2986#demoboards

$Revision: 5797 $
$Date: 2016-09-23 10:30:32 -0700 (Fri, 23 Sep 2016) $
Copyright (c) 2014, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/



//! @defgroup LTC2986 LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System

/*! @file
    @ingroup LTC2986
    Library for LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System
*/



#include <Arduino.h>
#include <stdint.h>
#include "Linduino.h"
#include "LT_SPI.h"
#include <SPI.h>
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "configuration_constants_LTC2986.h"
#include "table_coeffs_LTC2986.h"
#include "support_functions_LTC2986.h"

//! Prints the title block when program first starts.
void print_title()
{
  Serial.print(F("\n******************************************************************\n"));
  Serial.print(F(" LTC2986 Demonstration Program                      \n"));
  Serial.print(F("                                                                \n"));
  Serial.print(F(" This program demonstrates how to read the multi-sensor         \n"));
  Serial.print(F(" temperature measurement system.                                \n"));
  Serial.print(F("                                                                \n"));
  Serial.print(F(" Set the baud rate to 115200 and select the newline terminator. \n"));
  Serial.print(F("******************************************************************\n"));
}

// ***********************
// Program the part
// ***********************
void assign_channel(uint8_t chip_select, uint8_t channel_number, uint32_t channel_assignment_data)
{
  uint16_t start_address = get_start_address(CH_ADDRESS_BASE, channel_number);
  transfer_four_bytes(chip_select, WRITE_TO_RAM, start_address, channel_assignment_data);
}


void write_custom_table(uint8_t chip_select, struct table_coeffs coefficients[64], uint16_t start_address, uint8_t table_length)
{
  int8_t i;
  uint32_t coeff;

  output_low(chip_select);

  SPI.transfer(WRITE_TO_RAM);
  SPI.transfer(highByte(start_address));
  SPI.transfer(lowByte(start_address));

  for (i=0; i< table_length; i++)
  {
    coeff = coefficients[i].measurement;
    SPI.transfer((uint8_t)(coeff >> 16));
    SPI.transfer((uint8_t)(coeff >> 8));
    SPI.transfer((uint8_t)coeff);

    coeff = coefficients[i].temperature;
    SPI.transfer((uint8_t)(coeff >> 16));
    SPI.transfer((uint8_t)(coeff >> 8));
    SPI.transfer((uint8_t)coeff);
  }
  output_high(chip_select);
}


void write_custom_steinhart_hart(uint8_t chip_select, uint32_t steinhart_hart_coeffs[6], uint16_t start_address)
{
  int8_t i;
  uint32_t coeff;

  output_low(chip_select);

  SPI.transfer(WRITE_TO_RAM);
  SPI.transfer(highByte(start_address));
  SPI.transfer(lowByte(start_address));

  for (i = 0; i < 6; i++)
  {
    coeff = steinhart_hart_coeffs[i];
    SPI.transfer((uint8_t)(coeff >> 24));
    SPI.transfer((uint8_t)(coeff >> 16));
    SPI.transfer((uint8_t)(coeff >> 8));
    SPI.transfer((uint8_t)coeff);
  }
  output_high(chip_select);
}




// *****************
// Measure channel
// *****************
void measure_channel(uint8_t chip_select, uint8_t channel_number, uint8_t channel_output)
{
  convert_channel(chip_select, channel_number);
  get_result(chip_select, channel_number, channel_output);
}


void convert_channel(uint8_t chip_select, uint8_t channel_number)
{
  // Start conversion
  transfer_byte(chip_select, WRITE_TO_RAM, COMMAND_STATUS_REGISTER, CONVERSION_CONTROL_BYTE | channel_number);

  wait_for_process_to_finish(chip_select);
}


void wait_for_process_to_finish(uint8_t chip_select)
{
  uint8_t process_finished = 0;
  uint8_t data;
  while (process_finished == 0)
  {
    data = transfer_byte(chip_select, READ_FROM_RAM, COMMAND_STATUS_REGISTER, 0);
    process_finished  = data & 0x40;
  }
}


// *********************************
// Get results
// *********************************
void get_result(uint8_t chip_select, uint8_t channel_number, uint8_t channel_output)
{
  uint32_t raw_data;
  uint8_t fault_data;
  uint16_t start_address = get_start_address(CONVERSION_RESULT_MEMORY_BASE, channel_number);
  uint32_t raw_conversion_result;

  raw_data = transfer_four_bytes(chip_select, READ_FROM_RAM, start_address, 0);

  Serial.print(F("\nChannel "));
  Serial.println(channel_number);

  // 24 LSB's are conversion result
  raw_conversion_result = raw_data & 0xFFFFFF;
  print_conversion_result(raw_conversion_result, channel_output);

  // If you're interested in the raw voltage or resistance, use the following
  if (channel_output != VOLTAGE)
  {
    read_voltage_or_resistance_results(chip_select, channel_number);
  }

  // 8 MSB's show the fault data
  fault_data = raw_data >> 24;
  print_fault_data(fault_data);
}


void print_conversion_result(uint32_t raw_conversion_result, uint8_t channel_output)
{
  int32_t signed_data = raw_conversion_result;
  float scaled_result;

  // Convert the 24 LSB's into a signed 32-bit integer
  if (signed_data & 0x800000)
    signed_data = signed_data | 0xFF000000;

  // Translate and print result
  if (channel_output == TEMPERATURE)
  {
    scaled_result = float(signed_data) / 1024;
    Serial.print(F("  Temperature = "));
    Serial.println(scaled_result);
  }
  else if (channel_output == VOLTAGE)
  {
    scaled_result = float(signed_data) / 2097152;
    Serial.print(F("  Direct ADC reading in V = "));
    Serial.println(scaled_result);
  }
  else if (channel_output == CODE)
  {
    Serial.print(F("  Direct ADC code = "));
    Serial.println(signed_data);
  }
}


void read_voltage_or_resistance_results(uint8_t chip_select, uint8_t channel_number)
{
  int32_t raw_data;
  float voltage_or_resistance_result;
  uint16_t start_address = get_start_address(VOUT_CH_BASE, channel_number);

  raw_data = transfer_four_bytes(chip_select, READ_FROM_RAM, start_address, 0);
  voltage_or_resistance_result = (float)raw_data/1024;
  Serial.print(F("  Voltage or resistance = "));
  Serial.println(voltage_or_resistance_result);
}


// Translate the fault byte into usable fault data and print it out
void print_fault_data(uint8_t fault_byte)
{
  //
  Serial.print(F("  FAULT DATA = "));
  Serial.println(fault_byte, BIN);

  if (fault_byte & SENSOR_HARD_FAILURE)
    Serial.println(F("  - SENSOR HARD FALURE"));
  if (fault_byte & ADC_HARD_FAILURE)
    Serial.println(F("  - ADC_HARD_FAILURE"));
  if (fault_byte & CJ_HARD_FAILURE)
    Serial.println(F("  - CJ_HARD_FAILURE"));
  if (fault_byte & CJ_SOFT_FAILURE)
    Serial.println(F("  - CJ_SOFT_FAILURE"));
  if (fault_byte & SENSOR_ABOVE)
    Serial.println(F("  - SENSOR_ABOVE"));
  if (fault_byte & SENSOR_BELOW)
    Serial.println(F("  - SENSOR_BELOW"));
  if (fault_byte & ADC_RANGE_ERROR)
    Serial.println(F("  - ADC_RANGE_ERROR"));
  if (!(fault_byte & VALID))
    Serial.println(F("INVALID READING !!!!!!"));
  if (fault_byte == 0b11111111)
    Serial.println(F("CONFIGURATION ERROR !!!!!!"));
}

// *********************
// SPI RAM data transfer
// *********************
// To write to the RAM, set ram_read_or_write = WRITE_TO_RAM.
// To read from the RAM, set ram_read_or_write = READ_FROM_RAM.
// input_data is the data to send into the RAM. If you are reading from the part, set input_data = 0.

uint32_t transfer_four_bytes(uint8_t chip_select, uint8_t ram_read_or_write, uint16_t start_address, uint32_t input_data)
{
  uint32_t output_data;
  uint8_t tx[7], rx[7];

  tx[6] = ram_read_or_write;
  tx[5] = highByte(start_address);
  tx[4] = lowByte(start_address);
  tx[3] = (uint8_t)(input_data >> 24);
  tx[2] = (uint8_t)(input_data >> 16);
  tx[1] = (uint8_t)(input_data >> 8);
  tx[0] = (uint8_t) input_data;

  spi_transfer_block(chip_select, tx, rx, 7);

  output_data = (uint32_t) rx[3] << 24 |
                (uint32_t) rx[2] << 16 |
                (uint32_t) rx[1] << 8  |
                (uint32_t) rx[0];

  return output_data;
}


uint8_t transfer_byte(uint8_t chip_select, uint8_t ram_read_or_write, uint16_t start_address, uint8_t input_data)
{
  uint8_t tx[4], rx[4];

  tx[3] = ram_read_or_write;
  tx[2] = (uint8_t)(start_address >> 8);
  tx[1] = (uint8_t)start_address;
  tx[0] = input_data;
  spi_transfer_block(chip_select, tx, rx, 4);
  return rx[0];
}


// ******************************
// Misc support functions
// ******************************
uint16_t get_start_address(uint16_t base_address, uint8_t channel_number)
{
  return base_address + 4 * (channel_number-1);
}


bool is_number_in_array(uint8_t number, uint8_t *array, uint8_t array_length)
// Find out if a number is an element in an array
{
  bool found = false;
  for (uint8_t i=0; i< array_length; i++)
  {
    if (number == array[i])
    {
      found = true;
    }
  }
  return found;
}










技术支持