Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
2984/DATASHEET_CUSTOM_STEINHART_HART/DATASHEET_CUSTOM_STEINHART_HART.ino
Go to the documentation of this file.
1 /*!
2 LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System
3 @verbatim
4 
5 DATASHEET_CUSTOM_STEINHART_HART.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
82 void configure_channels();
84 
85 
86 // -------------- Configure the LTC2984 -------------------------------
87 void setup()
88 {
89  char demo_name[]="DC2399"; // 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 
102 }
103 
104 
106 {
107  uint8_t channel_number;
108  uint32_t channel_assignment_data;
109 
110  // ----- Channel 4: Assign Sense Resistor -----
111  channel_assignment_data =
113  (uint32_t) 0x9DD000 << SENSE_RESISTOR_VALUE_LSB; // sense resistor - value: 10100.
114  assign_channel(CHIP_SELECT, 4, channel_assignment_data);
115  // ----- Channel 5: Assign Thermistor Custom Steinhart-Hart -----
116  channel_assignment_data =
122  (uint32_t) 0x1E << THERMISTOR_CUSTOM_ADDRESS_LSB; // thermistor - custom address: 30.
123  assign_channel(CHIP_SELECT, 5, channel_assignment_data);
124 
125 }
126 
127 
129 {
130  uint16_t start_address;
131  uint16_t table_length;
132  // int i;
133 
134 
135  // -- Channel 5 Steinhart-Hart --
136  uint32_t ch_5_steinhart_hart_coefficients[] =
137  {
138  985533933, // -- For coefficient 0.00144999998156
139  965509722, // -- For coefficient 0.000268000003416
140  0, // -- For coefficient 0.0
141  875567098, // -- For coefficient 1.63999999359e-07
142  0, // -- For coefficient 0.0
143  0 // -- For coefficient 0.0
144  };
145  start_address = 772; // Real address = 6*30 + 0x250 = 772
146  write_custom_steinhart_hart(CHIP_SELECT, ch_5_steinhart_hart_coefficients, start_address);
147 
148 
149 }
150 
151 
152 
154 {
155  // -- Set global parameters
158  // -- Set any extra delay between conversions (in this case, 0*100us)
160 }
161 
162 // -------------- Run the LTC2984 -------------------------------------
163 
164 void loop()
165 {
166  measure_channel(CHIP_SELECT, 5, TEMPERATURE); // Ch 5: Thermistor Custom Steinhart-Hart
167 }
#define TEMPERATURE
void assign_channel(uint8_t chip_select, uint8_t channel_number, uint32_t channel_assignment_data)
#define SENSOR_TYPE__THERMISTOR_CUSTOM_STEINHART_HART
Header File for Linduino Libraries and Demo Code.
#define THERMISTOR_SINGLE_ENDED
LTC2984: Multi-Sensor High Accuracy Digital Temperature Measurement System.
void write_custom_steinhart_hart(uint8_t chip_select, uint32_t steinhart_hart_coeffs[6], uint16_t start_address)
#define THERMISTOR_CUSTOM_ADDRESS_LSB
#define THERMISTOR_EXCITATION_MODE__NO_SHARING_NO_ROTATION
QuikEval EEPROM Library.
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 THERMISTOR_RSENSE_CHANNEL__4
#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)
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
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 THERMISTOR_EXCITATION_CURRENT__1UA
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
#define SENSE_RESISTOR_VALUE_LSB
#define SENSOR_TYPE__SENSE_RESISTOR
uint8_t transfer_byte(uint8_t chip_select, uint8_t ram_read_or_write, uint16_t start_address, uint8_t input_data)