| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino
Go to the documentation of this file.
1 /*!
2 LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System
3 @verbatim
4
5 DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino:
6 Generated Linduino code from the LTC2986 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 LTC2986.
9
10
11 @endverbatim
12
13 http://www.linear.com/product/LTC2986
14
15 http://www.linear.com/product/LTC2986#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 LTC2986
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_LTC2986.h"
75 #include "support_functions_LTC2986.h"
76 #include "table_coeffs_LTC2986.h"
77
78 #define CHIP_SELECT QUIKEVAL_CS // Chip select pin
79
80 // Function prototypes
81 void configure_memory_table();
82 void configure_channels();
83 void configure_global_parameters();
84
85
86 // -------------- Configure the LTC2986 -------------------------------
87 void setup()
88 {
89 char demo_name[]="DC2508"; // Demo Board Name stored in QuikEval EEPROM
90 quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
91 quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
92 quikeval_SPI_connect(); // Connect SPI to main data port
93 pinMode(CHIP_SELECT, OUTPUT); // Configure chip select pin on Linduino
94
95 Serial.begin(115200); // Initialize the serial port to the PC
96 print_title();
97 discover_demo_board(demo_name);
98
99 configure_channels();
100 configure_memory_table();
101 configure_global_parameters();
102 }
103
104
105 void configure_channels()
106 {
107 uint8_t channel_number;
108 uint32_t channel_assignment_data;
109
110 // ----- Channel 2: Assign Sense Resistor -----
111 channel_assignment_data =
112 SENSOR_TYPE__SENSE_RESISTOR |
113 (uint32_t) 0x1F4000 << SENSE_RESISTOR_VALUE_LSB; // sense resistor - value: 2000.
114 assign_channel(CHIP_SELECT, 2, channel_assignment_data);
115 // ----- Channel 6: Assign RTD PT-100 -----
116 channel_assignment_data =
117 SENSOR_TYPE__RTD_PT_100 |
118 RTD_RSENSE_CHANNEL__2 |
119 RTD_NUM_WIRES__3_WIRE |
120 RTD_EXCITATION_MODE__NO_ROTATION_SHARING |
121 RTD_EXCITATION_CURRENT__50UA |
122 RTD_STANDARD__AMERICAN;
123 assign_channel(CHIP_SELECT, 6, channel_assignment_data);
124 // ----- Channel 9: Assign Off-Chip Diode -----
125 channel_assignment_data =
126 SENSOR_TYPE__OFF_CHIP_DIODE |
127 DIODE_SINGLE_ENDED |
128 DIODE_NUM_READINGS__3 |
129 DIODE_AVERAGING_OFF |
130 DIODE_CURRENT__20UA_80UA_160UA |
131 (uint32_t) 0x100C49 << DIODE_IDEALITY_FACTOR_LSB; // diode - ideality factor(eta): 1.00299930572509765625
132 assign_channel(CHIP_SELECT, 9, channel_assignment_data);
133 // ----- Channel 10: Assign Active Analog -----
134 channel_assignment_data =
135 SENSOR_TYPE__ACTIVE_ANALOG |
136 ACTIVE_ANALOG_SINGLE_ENDED |
137 (uint32_t) 0x0 << ACTIVE_ANALOG_CUSTOM_ADDRESS_LSB | // active analog - custom address: 0.
138 (uint32_t) 0x2 << ACTIVE_ANALOG_CUSTOM_LENGTH_1_LSB; // active analog - custom length-1: 2.
139 assign_channel(CHIP_SELECT, 10, channel_assignment_data);
140
141 }
142
143
144 void configure_memory_table()
145 {
146 uint16_t start_address;
147 uint16_t table_length;
148 // int i;
149
150 // -- Channel 10 custom table --
151 table_coeffs ch_10_coefficients[] =
152 {
153 { 0, 0 }, // -- 0.0, 0.0
154 { 3819930, 238746 }, // -- 932.6, 233.15
155 { 6523290, 407706 } // -- 1592.6, 398.15
156 };
157 start_address = (uint16_t) 592; // Real address = 6*0 + 0x250 = 592
158 table_length = (uint8_t) 3; // Real table length = 2 + 1 = 3
159 write_custom_table(CHIP_SELECT, ch_10_coefficients, start_address, table_length);
160
161
162 }
163
164
165
166 void configure_global_parameters()
167 {
168 // -- Set global parameters
169 transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xF0, TEMP_UNIT__C |
170 REJECTION__50_60_HZ |
171 ENABLE_KELVIN_3_WIRE_RTD_MODE |
172 ENABLE_KELVIN_2_WIRE_RTD_MODE |
173 ENABLE_KELVIN_DIFFERENTIAL_THERMISTOR_MODE);
174 // -- Set any extra delay between conversions (in this case, 0*100us)
175 transfer_byte(CHIP_SELECT, WRITE_TO_RAM, 0xFF, 0);
176 }
177
178 // -------------- Run the LTC2986 -------------------------------------
179
180 void loop()
181 {
182 measure_channel(CHIP_SELECT, 6, TEMPERATURE); // Ch 6: RTD PT-100
183 measure_channel(CHIP_SELECT, 9, TEMPERATURE); // Ch 9: Off-Chip Diode
184 measure_channel(CHIP_SELECT, 10, TEMPERATURE); // Ch 10: Active Analog
185 }
WRITE_TO_RAM
#define WRITE_TO_RAM
Definition: configuration_constants_LTC2983.h:326
configure_channels
static void configure_channels()
Definition: DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino:105
TEMPERATURE
#define TEMPERATURE
configure_global_parameters
static void configure_global_parameters()
Definition: DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino:166
ENABLE_KELVIN_DIFFERENTIAL_THERMISTOR_MODE
#define ENABLE_KELVIN_DIFFERENTIAL_THERMISTOR_MODE
Definition: configuration_constants_LTC2986.h:302
ACTIVE_ANALOG_CUSTOM_LENGTH_1_LSB
#define ACTIVE_ANALOG_CUSTOM_LENGTH_1_LSB
Definition: configuration_constants_LTC2986.h:164
SENSOR_TYPE__ACTIVE_ANALOG
#define SENSOR_TYPE__ACTIVE_ANALOG
Definition: configuration_constants_LTC2986.h:74
assign_channel
void assign_channel(uint8_t chip_select, uint8_t channel_number, uint32_t channel_assignment_data)
Definition: support_functions_LTC2983.cpp:90
Linduino.h
Header File for Linduino Libraries and Demo Code.
DIODE_NUM_READINGS__3
#define DIODE_NUM_READINGS__3
Definition: configuration_constants_LTC2983.h:283
RTD_STANDARD__AMERICAN
#define RTD_STANDARD__AMERICAN
Definition: configuration_constants_LTC2983.h:150
setup
static void setup()
Definition: DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino:87
table_coeffs
LTC2983: Multi-Sensor High Accuracy Digital Temperature Measurement System.
Definition: table_coeffs_LTC2983.h:51
loop
static void loop()
Definition: DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino:180
SENSOR_TYPE__OFF_CHIP_DIODE
#define SENSOR_TYPE__OFF_CHIP_DIODE
Definition: configuration_constants_LTC2983.h:98
QuikEval_EEPROM.h
QuikEval EEPROM Library.
SENSOR_TYPE__RTD_PT_100
#define SENSOR_TYPE__RTD_PT_100
Definition: configuration_constants_LTC2983.h:64
support_functions_LTC2986.h
LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System.
configure_memory_table
static void configure_memory_table()
Definition: DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino:144
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
table_coeffs_LTC2986.h
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
CHIP_SELECT
#define CHIP_SELECT
Definition: DC2507A_MULTI_SENSOR_BOARD_3_WIRE_RTD.ino:78
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
write_custom_table
void write_custom_table(uint8_t chip_select, struct table_coeffs coefficients[64], uint16_t start_address, uint8_t table_length)
Definition: support_functions_LTC2983.cpp:97
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
ENABLE_KELVIN_2_WIRE_RTD_MODE
#define ENABLE_KELVIN_2_WIRE_RTD_MODE
Definition: configuration_constants_LTC2986.h:301
DIODE_SINGLE_ENDED
#define DIODE_SINGLE_ENDED
Definition: configuration_constants_LTC2983.h:279
ACTIVE_ANALOG_SINGLE_ENDED
#define ACTIVE_ANALOG_SINGLE_ENDED
Definition: configuration_constants_LTC2986.h:160
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
DIODE_AVERAGING_OFF
#define DIODE_AVERAGING_OFF
Definition: configuration_constants_LTC2983.h:286
RTD_EXCITATION_MODE__NO_ROTATION_SHARING
#define RTD_EXCITATION_MODE__NO_ROTATION_SHARING
Definition: configuration_constants_LTC2983.h:134
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
configuration_constants_LTC2986.h
LTC2986: Multi-Sensor High Accuracy Digital Temperature Measurement System.
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
RTD_NUM_WIRES__3_WIRE
#define RTD_NUM_WIRES__3_WIRE
Definition: configuration_constants_LTC2983.h:128
RTD_RSENSE_CHANNEL__2
#define RTD_RSENSE_CHANNEL__2
Definition: configuration_constants_LTC2983.h:106
SENSE_RESISTOR_VALUE_LSB
#define SENSE_RESISTOR_VALUE_LSB
Definition: configuration_constants_LTC2983.h:163
ACTIVE_ANALOG_CUSTOM_ADDRESS_LSB
#define ACTIVE_ANALOG_CUSTOM_ADDRESS_LSB
Definition: configuration_constants_LTC2986.h:162
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
RTD_EXCITATION_CURRENT__50UA
#define RTD_EXCITATION_CURRENT__50UA
Definition: configuration_constants_LTC2983.h:142
ENABLE_KELVIN_3_WIRE_RTD_MODE
#define ENABLE_KELVIN_3_WIRE_RTD_MODE
Definition: configuration_constants_LTC2986.h:300
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