| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DATASHEET_FIGURE_31.ino
Go to the documentation of this file.
1 /*!
2 LTC2983: Multi-Sensor High Accuracy Digital Temperature Measurement System
3 @verbatim
4
5 DATASHEET_FIGURE_31.ino:
6 Generated Linduino code from the LTC2983 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 LTC2983.
9
10
11 @endverbatim
12
13 http://www.linear.com/product/LTC2983
14
15 http://www.linear.com/product/LTC2983#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 LTC2983
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
74 #include "configuration_constants_LTC2983.h"
75 #include "support_functions_LTC2983.h"
76 #include "table_coeffs_LTC2983.h"
77
78 #define CHIP_SELECT QUIKEVAL_CS // Chip select pin
79
80 // Function prototypes
81 void configure_channels();
82 void configure_global_parameters();
83
84
85 // -------------- Configure the LTC2983 -------------------------------
86 void setup()
87 {
88 char demo_name[]="DC2209"; // 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
98 configure_channels();
99 configure_global_parameters();
100 }
101
102
103 void configure_channels()
104 {
105 uint8_t channel_number;
106 uint32_t channel_assignment_data;
107
108 // ----- Channel 1: Assign Type J Thermocouple -----
109 channel_assignment_data =
110 SENSOR_TYPE__TYPE_J_THERMOCOUPLE |
111 TC_COLD_JUNCTION_CH__2 |
112 TC_SINGLE_ENDED |
113 TC_OPEN_CKT_DETECT__YES |
114 TC_OPEN_CKT_DETECT_CURRENT__10UA;
115 assign_channel(CHIP_SELECT, 1, channel_assignment_data);
116 // ----- Channel 2: Assign Off-Chip Diode -----
117 channel_assignment_data =
118 SENSOR_TYPE__OFF_CHIP_DIODE |
119 DIODE_SINGLE_ENDED |
120 DIODE_NUM_READINGS__2 |
121 DIODE_AVERAGING_ON |
122 DIODE_CURRENT__20UA_80UA_160UA |
123 (uint32_t) 0x100C49 << DIODE_IDEALITY_FACTOR_LSB; // diode - ideality factor(eta): 1.00299930572509765625
124 assign_channel(CHIP_SELECT, 2, channel_assignment_data);
125 // ----- Channel 3: Assign Type N Thermocouple -----
126 channel_assignment_data =
127 SENSOR_TYPE__TYPE_N_THERMOCOUPLE |
128 TC_COLD_JUNCTION_CH__4 |
129 TC_SINGLE_ENDED |
130 TC_OPEN_CKT_DETECT__YES |
131 TC_OPEN_CKT_DETECT_CURRENT__10UA;
132 assign_channel(CHIP_SELECT, 3, channel_assignment_data);
133 // ----- Channel 4: Assign Off-Chip Diode -----
134 channel_assignment_data =
135 SENSOR_TYPE__OFF_CHIP_DIODE |
136 DIODE_SINGLE_ENDED |
137 DIODE_NUM_READINGS__2 |
138 DIODE_AVERAGING_ON |
139 DIODE_CURRENT__20UA_80UA_160UA |
140 (uint32_t) 0x100C49 << DIODE_IDEALITY_FACTOR_LSB; // diode - ideality factor(eta): 1.00299930572509765625
141 assign_channel(CHIP_SELECT, 4, channel_assignment_data);
142 // ----- Channel 5: Assign Type K Thermocouple -----
143 channel_assignment_data =
144 SENSOR_TYPE__TYPE_K_THERMOCOUPLE |
145 TC_COLD_JUNCTION_CH__4 |
146 TC_SINGLE_ENDED |
147 TC_OPEN_CKT_DETECT__YES |
148 TC_OPEN_CKT_DETECT_CURRENT__10UA;
149 assign_channel(CHIP_SELECT, 5, channel_assignment_data);
150 // ----- Channel 6: Assign Type S Thermocouple -----
151 channel_assignment_data =
152 SENSOR_TYPE__TYPE_S_THERMOCOUPLE |
153 TC_COLD_JUNCTION_CH__7 |
154 TC_SINGLE_ENDED |
155 TC_OPEN_CKT_DETECT__YES |
156 TC_OPEN_CKT_DETECT_CURRENT__10UA;
157 assign_channel(CHIP_SELECT, 6, channel_assignment_data);
158 // ----- Channel 7: Assign Off-Chip Diode -----
159 channel_assignment_data =
160 SENSOR_TYPE__OFF_CHIP_DIODE |
161 DIODE_SINGLE_ENDED |
162 DIODE_NUM_READINGS__2 |
163 DIODE_AVERAGING_ON |
164 DIODE_CURRENT__20UA_80UA_160UA |
165 (uint32_t) 0x100C49 << DIODE_IDEALITY_FACTOR_LSB; // diode - ideality factor(eta): 1.00299930572509765625
166 assign_channel(CHIP_SELECT, 7, channel_assignment_data);
167 // ----- Channel 9: Assign Type T Thermocouple -----
168 channel_assignment_data =
169 SENSOR_TYPE__TYPE_T_THERMOCOUPLE |
170 TC_COLD_JUNCTION_CH__7 |
171 TC_DIFFERENTIAL |
172 TC_OPEN_CKT_DETECT__YES |
173 TC_OPEN_CKT_DETECT_CURRENT__10UA;
174 assign_channel(CHIP_SELECT, 9, channel_assignment_data);
175 // ----- Channel 10: Assign Type E Thermocouple -----
176 channel_assignment_data =
177 SENSOR_TYPE__TYPE_E_THERMOCOUPLE |
178 TC_COLD_JUNCTION_CH__14 |
179 TC_SINGLE_ENDED |
180 TC_OPEN_CKT_DETECT__YES |
181 TC_OPEN_CKT_DETECT_CURRENT__10UA;
182 assign_channel(CHIP_SELECT, 10, channel_assignment_data);
183 // ----- Channel 12: Assign Sense Resistor -----
184 channel_assignment_data =
185 SENSOR_TYPE__SENSE_RESISTOR |
186 (uint32_t) 0x1F4000 << SENSE_RESISTOR_VALUE_LSB; // sense resistor - value: 2000.
187 assign_channel(CHIP_SELECT, 12, channel_assignment_data);
188 // ----- Channel 14: Assign RTD PT-100 -----
189 channel_assignment_data =
190 SENSOR_TYPE__RTD_PT_100 |
191 RTD_RSENSE_CHANNEL__12 |
192 RTD_NUM_WIRES__4_WIRE |
193 RTD_EXCITATION_MODE__ROTATION_SHARING |
194 RTD_EXCITATION_CURRENT__100UA |
195 RTD_STANDARD__AMERICAN;
196 assign_channel(CHIP_SELECT, 14, channel_assignment_data);
197 // ----- Channel 16: Assign Type J Thermocouple -----
198 channel_assignment_data =
199 SENSOR_TYPE__TYPE_J_THERMOCOUPLE |
200 TC_COLD_JUNCTION_CH__20 |
201 TC_SINGLE_ENDED |
202 TC_OPEN_CKT_DETECT__YES |
203 TC_OPEN_CKT_DETECT_CURRENT__10UA;
204 assign_channel(CHIP_SELECT, 16, channel_assignment_data);
205 // ----- Channel 18: Assign Sense Resistor -----
206 channel_assignment_data =
207 SENSOR_TYPE__SENSE_RESISTOR |
208 (uint32_t) 0x19000 << SENSE_RESISTOR_VALUE_LSB; // sense resistor - value: 100.
209 assign_channel(CHIP_SELECT, 18, channel_assignment_data);
210 // ----- Channel 20: Assign Thermistor 44006 10K@25C -----
211 channel_assignment_data =
212 SENSOR_TYPE__THERMISTOR_44006_10K_25C |
213 THERMISTOR_RSENSE_CHANNEL__18 |
214 THERMISTOR_DIFFERENTIAL |
215 THERMISTOR_EXCITATION_MODE__NO_SHARING_NO_ROTATION |
216 THERMISTOR_EXCITATION_CURRENT__AUTORANGE;
217 assign_channel(CHIP_SELECT, 20, channel_assignment_data);
218
219 }
220
221
222
223
224 void configure_global_parameters()
225 {
226 // -- Set global parameters
227 transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xF0, TEMP_UNIT__C |
228 REJECTION__50_60_HZ);
229 // -- Set any extra delay between conversions (in this case, 0*100us)
230 transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xFF, 0);
231 }
232
233 // -------------- Run the LTC2983 -------------------------------------
234
235 void loop()
236 {
237 measure_channel(CHIP_SELECT, 1, TEMPERATURE); // Ch 1: Type J Thermocouple
238 measure_channel(CHIP_SELECT, 2, TEMPERATURE); // Ch 2: Off-Chip Diode
239 measure_channel(CHIP_SELECT, 3, TEMPERATURE); // Ch 3: Type N Thermocouple
240 measure_channel(CHIP_SELECT, 4, TEMPERATURE); // Ch 4: Off-Chip Diode
241 measure_channel(CHIP_SELECT, 5, TEMPERATURE); // Ch 5: Type K Thermocouple
242 measure_channel(CHIP_SELECT, 6, TEMPERATURE); // Ch 6: Type S Thermocouple
243 measure_channel(CHIP_SELECT, 7, TEMPERATURE); // Ch 7: Off-Chip Diode
244 measure_channel(CHIP_SELECT, 9, TEMPERATURE); // Ch 9: Type T Thermocouple
245 measure_channel(CHIP_SELECT, 10, TEMPERATURE); // Ch 10: Type E Thermocouple
246 measure_channel(CHIP_SELECT, 14, TEMPERATURE); // Ch 14: RTD PT-100
247 measure_channel(CHIP_SELECT, 16, TEMPERATURE); // Ch 16: Type J Thermocouple
248 measure_channel(CHIP_SELECT, 20, TEMPERATURE); // Ch 20: Thermistor 44006 10K@25C
249 }
WRITE_TO_RAM
#define WRITE_TO_RAM
Definition: configuration_constants_LTC2983.h:326
configure_global_parameters
static void configure_global_parameters()
Definition: DATASHEET_FIGURE_31.ino:224
SENSOR_TYPE__TYPE_K_THERMOCOUPLE
#define SENSOR_TYPE__TYPE_K_THERMOCOUPLE
Definition: configuration_constants_LTC2983.h:89
loop
static void loop()
Definition: DATASHEET_FIGURE_31.ino:235
SENSOR_TYPE__TYPE_S_THERMOCOUPLE
#define SENSOR_TYPE__TYPE_S_THERMOCOUPLE
Definition: configuration_constants_LTC2983.h:93
TEMPERATURE
#define TEMPERATURE
SENSOR_TYPE__TYPE_E_THERMOCOUPLE
#define SENSOR_TYPE__TYPE_E_THERMOCOUPLE
Definition: configuration_constants_LTC2983.h:90
assign_channel
void assign_channel(uint8_t chip_select, uint8_t channel_number, uint32_t channel_assignment_data)
Definition: support_functions_LTC2983.cpp:90
TC_OPEN_CKT_DETECT__YES
#define TC_OPEN_CKT_DETECT__YES
Definition: configuration_constants_LTC2983.h:260
Linduino.h
Header File for Linduino Libraries and Demo Code.
TC_COLD_JUNCTION_CH__14
#define TC_COLD_JUNCTION_CH__14
Definition: configuration_constants_LTC2983.h:246
TC_COLD_JUNCTION_CH__20
#define TC_COLD_JUNCTION_CH__20
Definition: configuration_constants_LTC2983.h:252
setup
static void setup()
Definition: DATASHEET_FIGURE_31.ino:86
RTD_STANDARD__AMERICAN
#define RTD_STANDARD__AMERICAN
Definition: configuration_constants_LTC2983.h:150
DIODE_NUM_READINGS__2
#define DIODE_NUM_READINGS__2
Definition: configuration_constants_LTC2983.h:282
TC_SINGLE_ENDED
#define TC_SINGLE_ENDED
Definition: configuration_constants_LTC2983.h:256
configure_channels
static void configure_channels()
Definition: DATASHEET_FIGURE_31.ino:103
SENSOR_TYPE__OFF_CHIP_DIODE
#define SENSOR_TYPE__OFF_CHIP_DIODE
Definition: configuration_constants_LTC2983.h:98
THERMISTOR_DIFFERENTIAL
#define THERMISTOR_DIFFERENTIAL
Definition: configuration_constants_LTC2983.h:199
RTD_NUM_WIRES__4_WIRE
#define RTD_NUM_WIRES__4_WIRE
Definition: configuration_constants_LTC2983.h:129
configuration_constants_LTC2983.h
LTC2983: Multi-Sensor High Accuracy Digital Temperature Measurement System.
THERMISTOR_EXCITATION_MODE__NO_SHARING_NO_ROTATION
#define THERMISTOR_EXCITATION_MODE__NO_SHARING_NO_ROTATION
Definition: configuration_constants_LTC2983.h:203
table_coeffs_LTC2983.h
QuikEval_EEPROM.h
QuikEval EEPROM Library.
TC_COLD_JUNCTION_CH__7
#define TC_COLD_JUNCTION_CH__7
Definition: configuration_constants_LTC2983.h:239
TC_COLD_JUNCTION_CH__2
#define TC_COLD_JUNCTION_CH__2
Definition: configuration_constants_LTC2983.h:234
RTD_RSENSE_CHANNEL__12
#define RTD_RSENSE_CHANNEL__12
Definition: configuration_constants_LTC2983.h:116
TC_COLD_JUNCTION_CH__4
#define TC_COLD_JUNCTION_CH__4
Definition: configuration_constants_LTC2983.h:236
SENSOR_TYPE__RTD_PT_100
#define SENSOR_TYPE__RTD_PT_100
Definition: configuration_constants_LTC2983.h:64
DIODE_CURRENT__20UA_80UA_160UA
#define DIODE_CURRENT__20UA_80UA_160UA
Definition: configuration_constants_LTC2983.h:291
quikeval_SPI_init
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
support_functions_LTC2983.h
LTC2983: Multi-Sensor High Accuracy Digital Temperature Measurement System.
discover_demo_board
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
Definition: QuikEval_EEPROM.cpp:141
SENSOR_TYPE__THERMISTOR_44006_10K_25C
#define SENSOR_TYPE__THERMISTOR_44006_10K_25C
Definition: configuration_constants_LTC2983.h:81
REJECTION__50_60_HZ
#define REJECTION__50_60_HZ
Definition: configuration_constants_LTC2983.h:299
print_title
static void print_title()
Prints the title block when program first starts.
Definition: _24xx_iso_spi_delay.ino:171
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
measure_channel
void measure_channel(uint8_t chip_select, uint8_t channel_number, uint8_t channel_output)
Definition: support_functions_LTC2983.cpp:152
DIODE_SINGLE_ENDED
#define DIODE_SINGLE_ENDED
Definition: configuration_constants_LTC2983.h:279
DIODE_AVERAGING_ON
#define DIODE_AVERAGING_ON
Definition: configuration_constants_LTC2983.h:287
RTD_EXCITATION_CURRENT__100UA
#define RTD_EXCITATION_CURRENT__100UA
Definition: configuration_constants_LTC2983.h:143
SENSOR_TYPE__TYPE_T_THERMOCOUPLE
#define SENSOR_TYPE__TYPE_T_THERMOCOUPLE
Definition: configuration_constants_LTC2983.h:94
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
THERMISTOR_EXCITATION_CURRENT__AUTORANGE
#define THERMISTOR_EXCITATION_CURRENT__AUTORANGE
Definition: configuration_constants_LTC2983.h:220
SENSOR_TYPE__TYPE_J_THERMOCOUPLE
#define SENSOR_TYPE__TYPE_J_THERMOCOUPLE
Definition: configuration_constants_LTC2983.h:88
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
quikeval_SPI_connect
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
UserInterface.h
RTD_EXCITATION_MODE__ROTATION_SHARING
#define RTD_EXCITATION_MODE__ROTATION_SHARING
Definition: configuration_constants_LTC2983.h:135
TC_OPEN_CKT_DETECT_CURRENT__10UA
#define TC_OPEN_CKT_DETECT_CURRENT__10UA
Definition: configuration_constants_LTC2983.h:263
DIODE_IDEALITY_FACTOR_LSB
#define DIODE_IDEALITY_FACTOR_LSB
Definition: configuration_constants_LTC2983.h:295
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
SENSE_RESISTOR_VALUE_LSB
#define SENSE_RESISTOR_VALUE_LSB
Definition: configuration_constants_LTC2983.h:163
THERMISTOR_RSENSE_CHANNEL__18
#define THERMISTOR_RSENSE_CHANNEL__18
Definition: configuration_constants_LTC2983.h:194
SENSOR_TYPE__TYPE_N_THERMOCOUPLE
#define SENSOR_TYPE__TYPE_N_THERMOCOUPLE
Definition: configuration_constants_LTC2983.h:91
TC_DIFFERENTIAL
#define TC_DIFFERENTIAL
Definition: configuration_constants_LTC2983.h:255
SENSOR_TYPE__SENSE_RESISTOR
#define SENSOR_TYPE__SENSE_RESISTOR
Definition: configuration_constants_LTC2983.h:72
TEMP_UNIT__C
#define TEMP_UNIT__C
Definition: configuration_constants_LTC2983.h:302
CHIP_SELECT
#define CHIP_SELECT
Definition: DATASHEET_FIGURE_31.ino:78
transfer_byte
uint8_t transfer_byte(uint8_t chip_select, uint8_t ram_read_or_write, uint16_t start_address, uint8_t input_data)
Definition: support_functions_LTC2983.cpp:308