Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DATASHEET_FIGURE_35.ino
Go to the documentation of this file.
1 /*!
2 LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System
3 @verbatim
4 
5 DATASHEET_FIGURE_35.ino:
6 Generated Linduino code from the LTC2984 Demo Software.
7 This code is designed to be used by a Linduino,
8 but can also be used to understand how to program the LTC2984.
9 
10 
11 @endverbatim
12 
13 http://www.linear.com/product/LTC2984
14 
15 http://www.linear.com/product/LTC2984#demoboards
16 
17 Copyright 2018(c) Analog Devices, Inc.
18 
19 All rights reserved.
20 
21 Redistribution and use in source and binary forms, with or without
22 modification, are permitted provided that the following conditions are met:
23  - Redistributions of source code must retain the above copyright
24  notice, this list of conditions and the following disclaimer.
25  - Redistributions in binary form must reproduce the above copyright
26  notice, this list of conditions and the following disclaimer in
27  the documentation and/or other materials provided with the
28  distribution.
29  - Neither the name of Analog Devices, Inc. nor the names of its
30  contributors may be used to endorse or promote products derived
31  from this software without specific prior written permission.
32  - The use of this software may or may not infringe the patent rights
33  of one or more patent holders. This license does not release you
34  from the requirement that you obtain separate licenses from these
35  patent holders to use this software.
36  - Use of the software either in source or binary form, must be run
37  on or directly connected to an Analog Devices Inc. component.
38 
39 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
40 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
41 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
43 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
45 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
46 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
48 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 */
50 
51 
52 
53 /*! @file
54  @ingroup LTC2984
55 
56 */
57 
58 
59 
60 
61 #include <Arduino.h>
62 #include <stdint.h>
63 #include <stdbool.h>
64 #include "SPI.h"
65 #include "Wire.h"
66 #include "Linduino.h"
67 #include "LT_SPI.h"
68 #include "UserInterface.h"
69 #include "LT_I2C.h"
70 #include "QuikEval_EEPROM.h"
71 #include "stdio.h"
72 #include "math.h"
73 
76 #include "table_coeffs_LTC2984.h"
77 
78 #define CHIP_SELECT QUIKEVAL_CS // Chip select pin
79 
80 // Function prototypes
81 void configure_channels();
83 
84 
85 // -------------- Configure the LTC2984 -------------------------------
86 void setup()
87 {
88  char demo_name[]="DC2399"; // Demo Board Name stored in QuikEval EEPROM
89  quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
90  quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
91  quikeval_SPI_connect(); // Connect SPI to main data port
92  pinMode(CHIP_SELECT, OUTPUT); // Configure chip select pin on Linduino
93 
94  Serial.begin(115200); // Initialize the serial port to the PC
95  print_title();
96  discover_demo_board(demo_name);
97 
100 }
101 
102 
104 {
105  uint8_t channel_number;
106  uint32_t channel_assignment_data;
107 
108  // ----- Channel 2: Assign Sense Resistor -----
109  channel_assignment_data =
111  (uint32_t) 0x4E2000 << SENSE_RESISTOR_VALUE_LSB; // sense resistor - value: 5000.
112  assign_channel(CHIP_SELECT, 2, channel_assignment_data);
113  // ----- Channel 4: Assign RTD PT-100 -----
114  channel_assignment_data =
121  assign_channel(CHIP_SELECT, 4, channel_assignment_data);
122  // ----- Channel 7: Assign RTD NI-120 -----
123  channel_assignment_data =
130  assign_channel(CHIP_SELECT, 7, channel_assignment_data);
131  // ----- Channel 9: Assign RTD PT-500 -----
132  channel_assignment_data =
139  assign_channel(CHIP_SELECT, 9, channel_assignment_data);
140  // ----- Channel 11: Assign RTD PT-1000 -----
141  channel_assignment_data =
148  assign_channel(CHIP_SELECT, 11, channel_assignment_data);
149  // ----- Channel 13: Assign Thermistor 44007 5K@25C -----
150  channel_assignment_data =
156  assign_channel(CHIP_SELECT, 13, channel_assignment_data);
157  // ----- Channel 14: Assign Type N Thermocouple -----
158  channel_assignment_data =
164  assign_channel(CHIP_SELECT, 14, channel_assignment_data);
165  // ----- Channel 15: Assign Off-Chip Diode -----
166  channel_assignment_data =
172  (uint32_t) 0x100C49 << DIODE_IDEALITY_FACTOR_LSB; // diode - ideality factor(eta): 1.00299930572509765625
173  assign_channel(CHIP_SELECT, 15, channel_assignment_data);
174  // ----- Channel 17: Assign Sense Resistor -----
175  channel_assignment_data =
177  (uint32_t) 0x1F4000 << SENSE_RESISTOR_VALUE_LSB; // sense resistor - value: 2000.
178  assign_channel(CHIP_SELECT, 17, channel_assignment_data);
179  // ----- Channel 19: Assign RTD PT-100 -----
180  channel_assignment_data =
187  assign_channel(CHIP_SELECT, 19, channel_assignment_data);
188 
189 }
190 
191 
192 
193 
195 {
196  // -- Set global parameters
199  // -- Set any extra delay between conversions (in this case, 0*100us)
201 }
202 
203 // -------------- Run the LTC2984 -------------------------------------
204 
205 void loop()
206 {
207  measure_channel(CHIP_SELECT, 4, TEMPERATURE); // Ch 4: RTD PT-100
208  measure_channel(CHIP_SELECT, 7, TEMPERATURE); // Ch 7: RTD NI-120
209  measure_channel(CHIP_SELECT, 9, TEMPERATURE); // Ch 9: RTD PT-500
210  measure_channel(CHIP_SELECT, 11, TEMPERATURE); // Ch 11: RTD PT-1000
211  measure_channel(CHIP_SELECT, 13, TEMPERATURE); // Ch 13: Thermistor 44007 5K@25C
212  measure_channel(CHIP_SELECT, 14, TEMPERATURE); // Ch 14: Type N Thermocouple
213  measure_channel(CHIP_SELECT, 15, TEMPERATURE); // Ch 15: Off-Chip Diode
214  measure_channel(CHIP_SELECT, 19, TEMPERATURE); // Ch 19: RTD PT-100
215 }
#define TEMPERATURE
void assign_channel(uint8_t chip_select, uint8_t channel_number, uint32_t channel_assignment_data)
#define TC_OPEN_CKT_DETECT__YES
static void loop()
#define SENSOR_TYPE__RTD_PT_500
Header File for Linduino Libraries and Demo Code.
#define DIODE_NUM_READINGS__3
#define RTD_STANDARD__EUROPEAN
LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System.
#define RTD_STANDARD__AMERICAN
#define TC_SINGLE_ENDED
#define RTD_RSENSE_CHANNEL__17
#define SENSOR_TYPE__OFF_CHIP_DIODE
#define THERMISTOR_DIFFERENTIAL
static void configure_channels()
#define RTD_NUM_WIRES__4_WIRE
QuikEval EEPROM Library.
#define SENSOR_TYPE__RTD_PT_100
static void setup()
#define DIODE_CURRENT__20UA_80UA_160UA
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define REJECTION__50_60_HZ
static void print_title()
Prints the title block when program first starts.
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
void measure_channel(uint8_t chip_select, uint8_t channel_number, uint8_t channel_output)
#define TC_COLD_JUNCTION_CH__15
#define DIODE_SINGLE_ENDED
#define DIODE_AVERAGING_ON
#define RTD_EXCITATION_CURRENT__100UA
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
#define THERMISTOR_EXCITATION_CURRENT__AUTORANGE
#define THERMISTOR_RSENSE_CHANNEL__2
#define RTD_EXCITATION_MODE__NO_ROTATION_SHARING
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
#define RTD_EXCITATION_MODE__ROTATION_SHARING
#define TC_OPEN_CKT_DETECT_CURRENT__10UA
#define DIODE_IDEALITY_FACTOR_LSB
#define CHIP_SELECT
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
#define SENSOR_TYPE__RTD_NI_120
#define RTD_NUM_WIRES__3_WIRE
#define RTD_STANDARD__JAPANESE
#define THERMISTOR_EXCITATION_MODE__SHARING_NO_ROTATION
#define RTD_RSENSE_CHANNEL__2
#define SENSE_RESISTOR_VALUE_LSB
#define SENSOR_TYPE__RTD_PT_1000
#define SENSOR_TYPE__TYPE_N_THERMOCOUPLE
#define SENSOR_TYPE__SENSE_RESISTOR
static void configure_global_parameters()
#define RTD_EXCITATION_CURRENT__50UA
uint8_t transfer_byte(uint8_t chip_select, uint8_t ram_read_or_write, uint16_t start_address, uint8_t input_data)
#define RTD_NUM_WIRES__2_WIRE
#define SENSOR_TYPE__THERMISTOR_44007_5K_25C
#define RTD_STANDARD__ITS_90