| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC1338.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1338 Demonstration Board.
3 LTC2990: 14-bit ADC Quad I2C Voltage, Current, and Temperature monitor.
4
5 @verbatim
6
7 Setup:
8 Set the terminal baud rate to 115200 and select the newline terminator.
9 A precision voltage source (preferably low-noise) may be used to apply a voltage
10 to input terminals V1-V8. A precision voltmeter may be used to verify applied
11 voltages. An oscilloscope may be used to view the PWM output. Ensure JP5, JP6
12 and JP7 are in the LOW position. Refer to Demo Manual DC1338A
13
14 Explanation of Commands:
15
16 1 - Single-Ended Voltage - Selects the Single-Ended Voltage Menu.
17 1-4: Displays the measured single-ended voltage at one of the V1-V4
18 inputs. When measuring V1 and V8, ensure jumpers are set to VOLT
19 position.
20 5: Vcc - Displays the measured Vcc voltage.
21 6: ALL - Displays the measured voltages at all of the V1-V8 inputs
22 and Vcc.
23
24 2 - Differential Voltage - Selects the Differential Voltage Menu.
25 Maximum full scale differential voltage is 0.300V.
26
27 1-2: Displays the measured differential voltage across one of the V1-V4
28 input pairs. The input common-mode range is 0V to Vcc. It is
29 easiest to ground the lower input. When measuring V1 and V4,
30 ensure jumpers are set to VOLT position.
31 3: ALL - Displays the measured differential voltages at all terminals.
32
33 3 - Temperature - Selects the Temperature Menu
34 To measure temperature using on-board transistors, set JP1, JP2, JP3 and JP4
35 to TEMP position.
36 1: V1-V2 - Measure temperature of Q1 (mounted to demo board) when JP1
37 and JP2 are in TEMP position.
38 2: V3-V4 - Measure temperature of external transistor connected to V3
39 and V4 terminals.
40 3: Internal - Measure temperature using the internal temperature
41 sensor.
42 4: All - Displays temperatures at all connections as well as the
43 internal temperature sensor.
44
45 4 - Settings - Selects the Settings Menu
46 Toggles temperature units between degrees Celsius or degrees Kelvin.
47 1: Toggle temperature units between degrees Celsius and degrees
48 Kelvin.
49
50 USER INPUT DATA FORMAT:
51 decimal : 1024
52 hex : 0x400
53 octal : 02000 (leading 0 "zero")
54 binary : B10000000000
55 float : 1024.0
56
57 @endverbatim
58
59 http://www.linear.com/product/LTC2990
60
61 http://www.linear.com/product/LTC2990#demoboards
62
63
64 Copyright 2018(c) Analog Devices, Inc.
65
66 All rights reserved.
67
68 Redistribution and use in source and binary forms, with or without
69 modification, are permitted provided that the following conditions are met:
70 - Redistributions of source code must retain the above copyright
71 notice, this list of conditions and the following disclaimer.
72 - Redistributions in binary form must reproduce the above copyright
73 notice, this list of conditions and the following disclaimer in
74 the documentation and/or other materials provided with the
75 distribution.
76 - Neither the name of Analog Devices, Inc. nor the names of its
77 contributors may be used to endorse or promote products derived
78 from this software without specific prior written permission.
79 - The use of this software may or may not infringe the patent rights
80 of one or more patent holders. This license does not release you
81 from the requirement that you obtain separate licenses from these
82 patent holders to use this software.
83 - Use of the software either in source or binary form, must be run
84 on or directly connected to an Analog Devices Inc. component.
85
86 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
87 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
88 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
89 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
90 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
91 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
92 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
93 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
94 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
95 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96 */
97
98 /*! @file
99 @ingroup LTC2990
100 */
101
102 #include <Arduino.h>
103 #include <stdint.h>
104 #include "Linduino.h"
105 #include "UserInterface.h"
106 #include "LT_I2C.h"
107 #include "QuikEval_EEPROM.h"
108 #include "LTC2990.h"
109 #include <Wire.h>
110 #include <SPI.h>
111
112 // Function Declaration
113 void print_title(); // Print the title block
114 void print_prompt(); // Prompt the user for an input command
115
116 int8_t menu_1_single_ended_voltage(); // Sub-menu functions
117 int8_t menu_2_read_differential_voltage();
118 int8_t menu_3_read_temperature();
119 int8_t menu_4_settings();
120
121 // Global variables
122 static uint8_t demo_board_connected; //!< Set to 1 if the board is connected
123 const uint16_t LTC2990_TIMEOUT=1000; //!< Configures the maximum timeout allowed for an LTC2990 read.
124
125 // Calibration Variables
126 const float LTC2990_SINGLE_ENDED_lsb = 3.05176E-04; //!< Typical single-ended LSB weight in volts
127 const float LTC2990_DIFFERENTIAL_lsb = 1.90735E-05; //!< Typical differential LSB weight in volts
128 const float LTC2990_VCC_lsb = 3.05176E-04; //!< Typical VCC LSB weight in volts
129 // Used for internal temperature as well as remote diode temperature measurements.
130 const float LTC2990_TEMPERATURE_lsb = 0.0625; //!< Typical temperature LSB weight in degrees Celsius (and Kelvin).
131 // Used to readback diode voltage when in temperature measurement mode.
132 const float LTC2990_DIODE_VOLTAGE_lsb = 3.815E-05; //!< Typical remote diode LSB weight in volts.
133
134 //! Initialize Linduino
135 void setup()
136 {
137 char demo_name[] = "DC1338"; // Demo Board Name stored in QuikEval EEPROM
138 int8_t ack=0;
139 quikeval_I2C_init(); // Initializes Linduino I2C port.
140 quikeval_I2C_connect(); // Connects I2C port to the QuikEval connector
141 Serial.begin(115200); // Initialize the serial port to the PC
142 print_title();
143 demo_board_connected = discover_demo_board(demo_name); // Checks if correct demo board is connected.
144 if (demo_board_connected)
145 {
146 print_prompt();
147 ack |= LTC2990_register_write(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, LTC2990_ENABLE_ALL); // Enables all channels
148 ack |= LTC2990_register_write(LTC2990_I2C_ADDRESS, LTC2990_TRIGGER_REG, 0x01);
149 }
150 }
151
152 //! Repeats Linduino loop
153 void loop()
154 {
155 int8_t ack=0;
156
157 uint8_t user_command;
158 if (demo_board_connected) // Does nothing if the demo board is not connected
159 {
160 if (Serial.available()) // Checks for user input
161 {
162 user_command = read_int(); // Reads the user command
163 if (user_command != 'm')
164 Serial.println(user_command);
165 ack = 0;
166 switch (user_command) // Prints the appropriate submenu
167 {
168 case 1:
169 ack |= menu_1_single_ended_voltage(); // Print single-ended voltage menu
170 break;
171 case 2:
172 ack |= menu_2_read_differential_voltage(); // Differential voltage menu
173 break;
174 case 3:
175 ack |= menu_3_read_temperature(); // Temperature menu
176 break;
177 case 4:
178 ack |= menu_4_settings(); // Settings menu
179 break;
180 default:
181 Serial.println("Incorrect Option");
182 break;
183 }
184 if (ack != 0)
185 {
186 Serial.print(F("Error: No Acknowledge. Check I2C Address.\n"));
187 }
188 print_prompt();
189 }
190 }
191 }
192
193 // Function Definitions
194
195 //! Prints the title block when program first starts.
196 void print_title()
197 {
198 Serial.print(F("\n*****************************************************************\n"));
199 Serial.print(F("* DC1338B Demonstration Program *\n"));
200 Serial.print(F("* *\n"));
201 Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
202 Serial.print(F("* the LTC2990 14-Bit Quad I2C Voltage, Current, and *\n"));
203 Serial.print(F("* Temperature Monitor. *\n"));
204 Serial.print(F("* *\n"));
205 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
206 Serial.print(F("* *\n"));
207 Serial.print(F("*****************************************************************\n"));
208 }
209
210 //! Prints main menu.
211 void print_prompt()
212 {
213 Serial.print(F("\n 1-Single-Ended Voltage\n"));
214 Serial.print(F(" 2-Differential Voltage\n"));
215 Serial.print(F(" 3-Temperature\n"));
216 Serial.print(F(" 4-Settings\n"));
217 Serial.print(F("Enter a command:"));
218 }
219
220 //! Read single-ended voltages
221 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
222 int8_t menu_1_single_ended_voltage()
223 {
224 int8_t ack=0;
225 uint8_t user_command;
226 do
227 {
228 // Displays the single-ended voltage menu
229 Serial.print(F("\nSingle-Ended Voltage\n\n"));
230 Serial.print(F(" 1-V1\n"));
231 Serial.print(F(" 2-V2\n"));
232 Serial.print(F(" 3-V3\n"));
233 Serial.print(F(" 4-V4\n"));
234 Serial.print(F(" 5-Vcc\n"));
235 Serial.print(F(" 6-ALL\n"));
236 Serial.print(F(" m-Main Menu\n"));
237 Serial.print(F("\n\nEnter a command: "));
238
239 user_command = read_int(); // Reads the user command
240 if (user_command == 'm') // Print m if it is entered
241 {
242 Serial.print(F("m\n"));
243 }
244 else
245 Serial.println(user_command); // Print user command
246
247 int16_t code;
248 int8_t data_valid;
249 float voltage;
250
251 // Enable Single-Ended Mode
252 ack |= LTC2990_register_set_clear_bits(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, LTC2990_V1_V2_V3_V4, LTC2990_VOLTAGE_MODE_MASK);
253
254
255 // Reads single-ended voltage from ADC and prints it.
256 switch (user_command)
257 {
258 case 1:
259 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
260 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V1_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
261 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
262 Serial.print(F("\n V1: "));
263 Serial.print(voltage, 4);
264 Serial.print(F(" V\n"));
265 break;
266 case 2:
267 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
268 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V2_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
269 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
270 Serial.print(F("\n V2: "));
271 Serial.print(voltage, 4);
272 Serial.print(F(" V\n"));
273 break;
274 case 3:
275 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
276 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V3_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
277 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
278 Serial.print(F("\n V3: "));
279 Serial.print(voltage, 4);
280 Serial.print(F(" V\n"));
281 break;
282 case 4:
283 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
284 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V4_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
285 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
286 Serial.print(F("\n V4: "));
287 Serial.print(voltage, 4);
288 Serial.print(F(" V\n"));
289 break;
290 case 5:
291 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
292 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_VCC_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
293 voltage = LTC2990_code_to_vcc_voltage(code, LTC2990_SINGLE_ENDED_lsb);
294 Serial.print(F("\n Vcc: "));
295 Serial.print(voltage, 4);
296 Serial.print(F(" V\n"));
297 break;
298 case 6:
299 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
300 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V1_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
301 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
302 Serial.print(F("\n V1: "));
303 Serial.print(voltage, 4);
304 Serial.print(F(" V\n"));
305 if (ack)
306 break;
307 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
308 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V2_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
309 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
310 Serial.print(F(" V2: "));
311 Serial.print(voltage, 4);
312 Serial.print(F(" V\n"));
313 if (ack)
314 break;
315 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
316 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V3_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
317 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
318 Serial.print(F(" V3: "));
319 Serial.print(voltage, 4);
320 Serial.print(F(" V\n"));
321 if (ack)
322 break;
323 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
324 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V4_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
325 voltage = LTC2990_code_to_single_ended_voltage(code, LTC2990_SINGLE_ENDED_lsb);
326 Serial.print(F(" V4: "));
327 Serial.print(voltage, 4);
328 Serial.print(F(" V\n"));
329 if (ack)
330 break;
331 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
332 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_VCC_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
333 voltage = LTC2990_code_to_vcc_voltage(code, LTC2990_SINGLE_ENDED_lsb);
334 Serial.print(F(" Vcc: "));
335 Serial.print(voltage, 4);
336 Serial.print(F(" V\n"));
337 break;
338 default:
339 if (user_command != 'm')
340 Serial.println(" Incorrect Option");
341 break;
342 }
343 }
344 while ((user_command != 'm') && (ack != 1));
345 return(ack);
346 }
347
348 //! Read differential voltages.
349 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
350 int8_t menu_2_read_differential_voltage()
351 {
352 int8_t ack=0;
353 uint8_t user_command;
354 do
355 {
356 // Display differential voltage menu.
357 Serial.print(F("\nDifferential Voltage\n\n"));
358 Serial.print(F(" 1-V1-V2\n"));
359 Serial.print(F(" 2-V3-V4\n"));
360 Serial.print(F(" 3-ALL\n"));
361 Serial.print(F(" m-Main Menu\n"));
362 Serial.print(F("\n\nEnter a command: "));
363
364 user_command = read_int(); // Reads the user command
365 if (user_command == 'm') // Print m if it is entered
366 {
367 Serial.print(F("m\n"));
368 }
369 else
370 Serial.println(user_command); // Print user command
371
372 int8_t data_valid;
373 int16_t code;
374 float voltage;
375
376
377 // Enables differential mode.
378 ack |= LTC2990_register_set_clear_bits(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, LTC2990_V1V2_V3V4, LTC2990_VOLTAGE_MODE_MASK);
379 // Triggers a conversion by writing any value to the trigger register
380 ack |= LTC2990_register_write(LTC2990_I2C_ADDRESS, LTC2990_TRIGGER_REG, 0x00);
381
382 // Flushes one reading following mode change.
383 // Reads differential voltage from ADC and prints it.
384 switch (user_command)
385 {
386 case 1:
387 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
388 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V2_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
389 voltage = LTC2990_code_to_differential_voltage(code, LTC2990_DIFFERENTIAL_lsb);
390 Serial.print(F("\n V1-V2: "));
391 Serial.print(voltage, 4);
392 Serial.print(F(" V\n"));
393 break;
394 case 2:
395 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
396 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V4_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
397 voltage = LTC2990_code_to_differential_voltage(code, LTC2990_DIFFERENTIAL_lsb);
398 Serial.print(F("\n V3-V4: "));
399 Serial.print(voltage, 4);
400 Serial.print(F(" V\n"));
401 break;
402 case 3:
403 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
404 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V2_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
405 voltage = LTC2990_code_to_differential_voltage(code, LTC2990_DIFFERENTIAL_lsb);
406 Serial.print(F("\n V1-V2: "));
407 Serial.print(voltage, 4);
408 Serial.print(F(" V\n"));
409 if (ack)
410 break;
411 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
412 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V4_MSB_REG, &code, &data_valid, LTC2990_TIMEOUT);
413 voltage = LTC2990_code_to_differential_voltage(code, LTC2990_DIFFERENTIAL_lsb);
414 Serial.print(F(" V3-V4: "));
415 Serial.print(voltage, 4);
416 Serial.print(F(" V\n"));
417 break;
418 default:
419 if (user_command != 'm')
420 {
421 Serial.print(F("Incorrect Option\n"));
422 }
423 break;
424 }
425 }
426 while ((user_command != 'm') && (ack != 1));
427 return(ack);
428 }
429
430 //! Read temperatures
431 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
432 int8_t menu_3_read_temperature()
433 {
434 int8_t ack=0;
435 boolean isKelvin = false; // Keeps track of the unit of measurement
436 uint8_t user_command;
437 do
438 {
439 // Displays temperature menu
440 Serial.print(F("\nTemperature\n\n"));
441 Serial.print(F(" 1-V1-V2\n"));
442 Serial.print(F(" 2-V3-V4\n"));
443 Serial.print(F(" 3-Internal\n"));
444 Serial.print(F(" 4-ALL\n"));
445 Serial.print(F(" m-Main Menu\n"));
446 Serial.print(F("\n\nEnter a command: "));
447 user_command = read_int(); // Reads the user command
448 if (user_command == 'm') // Print m if it is entered
449 {
450 Serial.print(F("m\n"));
451 }
452 else
453 Serial.println(user_command); // Print user command
454
455 // Read Temperature
456 int8_t data_valid = 0;
457 int16_t adc_code;
458 uint8_t reg_data;
459 float temperature;
460
461 // Enables temperature mode
462 ack |= LTC2990_register_set_clear_bits(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, LTC2990_TR1_TR2, LTC2990_VOLTAGE_MODE_MASK);
463 // Triggers a conversion by writing any value to the trigger register
464 ack |= LTC2990_register_write(LTC2990_I2C_ADDRESS, LTC2990_TRIGGER_REG, 0x01);
465 // Flushes one reading following mode change.
466 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V1_MSB_REG, &adc_code, &data_valid, LTC2990_TIMEOUT);
467 //ack |= LTC2990_register_write(LTC2990_I2C_ADDRESS, LTC2990_TRIGGER_REG, 0x01);
468 //delay(165); //Wait max conversion time
469
470 // Reads temperature from ADC and prints it.
471 switch (user_command)
472 {
473 case 1:
474 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
475 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V1_MSB_REG, &adc_code, &data_valid, LTC2990_TIMEOUT);
476 ack |= LTC2990_register_read(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, &reg_data);
477 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin= true;
478 else isKelvin=false;
479 temperature = LTC2990_temperature(adc_code, LTC2990_TEMPERATURE_lsb, isKelvin);
480 Serial.print(F("\n V1-V2: "));
481 Serial.print(temperature, 2);
482 if (isKelvin) Serial.print(F(" K\n"));
483 else Serial.print(F(" C\n"));
484 break;
485 case 2:
486 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
487 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V3_MSB_REG, &adc_code, &data_valid, LTC2990_TIMEOUT);
488 ack |= LTC2990_register_read(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, &reg_data);
489 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=true;
490 else isKelvin = false;
491 temperature = LTC2990_temperature(adc_code, LTC2990_TEMPERATURE_lsb, isKelvin);
492 Serial.print(F("\n V3-V4: "));
493 Serial.print(temperature, 2);
494 if (isKelvin) Serial.print(F(" K\n"));
495 else Serial.print(F(" C\n"));
496 break;
497 case 3:
498 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
499 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_TINT_MSB_REG, &adc_code, &data_valid, LTC2990_TIMEOUT);
500 ack |= LTC2990_register_read(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, &reg_data);
501 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=true;
502 else isKelvin=false;
503 temperature = LTC2990_temperature(adc_code, LTC2990_TEMPERATURE_lsb,isKelvin);
504 Serial.print(F("\n Internal: "));
505 Serial.print(temperature, 2);
506 if (isKelvin) Serial.print(F(" K\n"));
507 else Serial.print(F(" C\n"));
508 break;
509 case 4:
510 // All Temperatures
511 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
512 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V1_MSB_REG, &adc_code, &data_valid, LTC2990_TIMEOUT);
513 ack |= LTC2990_register_read(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, &reg_data);
514 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin= true;
515 else isKelvin=false;
516 temperature = LTC2990_temperature(adc_code, LTC2990_TEMPERATURE_lsb, isKelvin);
517 Serial.print(F("\n V1-V2: "));
518 Serial.print(temperature, 2);
519 if (isKelvin) Serial.print(F(" K\n"));
520 else Serial.print(F(" C\n"));
521 if (ack)
522 break;
523
524 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
525 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_V3_MSB_REG, &adc_code, &data_valid, LTC2990_TIMEOUT);
526 ack |= LTC2990_register_read(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, &reg_data);
527 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=true;
528 else isKelvin = false;
529 temperature = LTC2990_temperature(adc_code, LTC2990_TEMPERATURE_lsb, isKelvin);
530 Serial.print(F("\n V3-V4: "));
531 Serial.print(temperature, 2);
532 if (isKelvin) Serial.print(F(" K\n"));
533 else Serial.print(F(" C\n"));
534 if (ack)
535 break;
536
537 // Flush one ADC reading in case it is stale. Then, take a new fresh reading.
538 ack |= LTC2990_adc_read_new_data(LTC2990_I2C_ADDRESS, LTC2990_TINT_MSB_REG, &adc_code, &data_valid, LTC2990_TIMEOUT);
539 ack |= LTC2990_register_read(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, &reg_data);
540 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=true;
541 else isKelvin=false;
542 temperature = LTC2990_temperature(adc_code, LTC2990_TEMPERATURE_lsb,isKelvin);
543 Serial.print(F("\n Internal: "));
544 Serial.print(temperature, 2);
545 if (isKelvin) Serial.print(F(" K\n"));
546 else Serial.print(F(" C\n"));
547 break;
548 default:
549 if (user_command != 'm')
550 Serial.println("Incorrect Option");
551 break;
552 }
553 }
554 while ((user_command != 'm') && (ack == 0));
555 return(ack);
556 }
557
558 //! Configure settings
559 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
560 int8_t menu_4_settings()
561 {
562 uint8_t user_command;
563 int8_t ack=0;
564 uint8_t reg_data;
565
566 Serial.println(F("\nSettings:"));
567 Serial.println(F("0-Celsius"));
568 Serial.println(F("1-Kelvin"));
569 Serial.print(F("\nEnter a command: "));
570 user_command = read_int();
571 Serial.println(user_command);
572
573 if (user_command)
574 {
575 // Set to Kelvin mode
576 ack |= LTC2990_register_set_clear_bits(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, LTC2990_KELVIN_ENABLE, LTC2990_TEMP_FORMAT_MASK);
577 Serial.println(F("The LTC2990 is in Kelvin Mode"));
578 }
579 else
580 {
581 // Set to Celsius mode
582 ack |= LTC2990_register_set_clear_bits(LTC2990_I2C_ADDRESS, LTC2990_CONTROL_REG, LTC2990_CELSIUS_ENABLE, LTC2990_TEMP_FORMAT_MASK);
583 Serial.println(F("The LTC2990 is in Celsius Mode"));
584 }
585 return(ack);
586 }
LTC2990_TR1_TR2
#define LTC2990_TR1_TR2
Read TR1 and TR2.
Definition: LTC2990.h:224
LTC2990_V3_MSB_REG
#define LTC2990_V3_MSB_REG
V3, V3-V4, or T_R2 T MSB.
Definition: LTC2990.h:179
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
LTC2990_TEMP_FORMAT_MASK
#define LTC2990_TEMP_FORMAT_MASK
Use mask when changing temp formats.
Definition: LTC2990.h:194
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC1338.ino:211
LTC2990_code_to_single_ended_voltage
float LTC2990_code_to_single_ended_voltage(int16_t adc_code, float LTC2990_single_ended_lsb)
Calculates the LTC2990 single-ended input voltages.
Definition: LTC2990.cpp:170
menu_2_read_differential_voltage
static int8_t menu_2_read_differential_voltage()
Read differential voltages.
Definition: DC1338.ino:350
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC2990_adc_read_new_data
int8_t LTC2990_adc_read_new_data(uint8_t i2c_address, uint8_t msb_register_address, int16_t *adc_code, int8_t *data_valid, uint16_t timeout)
Reads new data (even after a mode change) by flushing old data and waiting for the data_valid bit to ...
Definition: LTC2990.cpp:124
LTC2990_code_to_vcc_voltage
float LTC2990_code_to_vcc_voltage(int16_t adc_code, float LTC2990_single_ended_lsb)
Calculates the LTC2990 Vcc voltage.
Definition: LTC2990.cpp:185
LTC2990.h
LTC2990: 14-bit ADC Quad I2C voltage, current, and temperature monitor.
LTC2990_CELSIUS_ENABLE
#define LTC2990_CELSIUS_ENABLE
Enable for Celsius.
Definition: LTC2990.h:193
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC1338.ino:196
LTC2990_V2_MSB_REG
#define LTC2990_V2_MSB_REG
V2, V1-V2, or T_R2 Voltage MSB.
Definition: LTC2990.h:177
LTC2990_VCC_lsb
const float LTC2990_VCC_lsb
Typical VCC LSB weight in volts.
Definition: DC1338.ino:128
LTC2990_register_set_clear_bits
int8_t LTC2990_register_set_clear_bits(uint8_t i2c_address, uint8_t register_address, uint8_t bits_to_set, uint8_t bits_to_clear)
Used to set and clear bits in a control register.
Definition: LTC2990.cpp:157
LTC2990_V4_MSB_REG
#define LTC2990_V4_MSB_REG
V4, V3-V4, or T_R2 Voltage MSB.
Definition: LTC2990.h:181
LTC2990_TINT_MSB_REG
#define LTC2990_TINT_MSB_REG
Internal Temperature MSB.
Definition: LTC2990.h:173
LTC2990_register_write
int8_t LTC2990_register_write(uint8_t i2c_address, uint8_t register_address, uint8_t register_data)
Write one byte to an LTC2990 register.
Definition: LTC2990.cpp:147
QuikEval_EEPROM.h
QuikEval EEPROM Library.
LTC2990_register_read
int8_t LTC2990_register_read(uint8_t i2c_address, uint8_t register_address, uint8_t *register_data)
Reads an 8-bit register from the LTC2990 using the standard repeated start format.
Definition: LTC2990.cpp:137
LTC2990_VOLTAGE_MODE_MASK
#define LTC2990_VOLTAGE_MODE_MASK
Use mode mask when changing modes.
Definition: LTC2990.h:227
demo_board_connected
static uint8_t demo_board_connected
Set to 1 if the board is connected.
Definition: DC1338.ino:122
LTC2990_VCC_MSB_REG
#define LTC2990_VCC_MSB_REG
Vcc MSB.
Definition: LTC2990.h:183
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
LTC2990_TEMPERATURE_lsb
const float LTC2990_TEMPERATURE_lsb
Typical temperature LSB weight in degrees Celsius (and Kelvin).
Definition: DC1338.ino:130
menu_1_single_ended_voltage
static int8_t menu_1_single_ended_voltage()
Read single-ended voltages.
Definition: DC1338.ino:222
LTC2990_V1_MSB_REG
#define LTC2990_V1_MSB_REG
V1, V1-V2, or T_R1 T MSB.
Definition: LTC2990.h:175
LTC2990_TIMEOUT
const uint16_t LTC2990_TIMEOUT
Configures the maximum timeout allowed for an LTC2990 read.
Definition: DC1338.ino:123
setup
static void setup()
Initialize Linduino.
Definition: DC1338.ino:135
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC2990_SINGLE_ENDED_lsb
const float LTC2990_SINGLE_ENDED_lsb
Typical single-ended LSB weight in volts.
Definition: DC1338.ino:126
LTC2990_V1_V2_V3_V4
#define LTC2990_V1_V2_V3_V4
Read V1, V2, V3 and V4.
Definition: LTC2990.h:226
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
LTC2990_V1V2_V3V4
#define LTC2990_V1V2_V3V4
Read V1-V2 and V3-V4.
Definition: LTC2990.h:225
UserInterface.h
LTC2990_I2C_ADDRESS
#define LTC2990_I2C_ADDRESS
I2C address of the LTC2990.
Definition: LTC2990.h:157
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
LTC2990_KELVIN_ENABLE
#define LTC2990_KELVIN_ENABLE
Enable for Kelvin.
Definition: LTC2990.h:192
LTC2990_DIODE_VOLTAGE_lsb
const float LTC2990_DIODE_VOLTAGE_lsb
Typical remote diode LSB weight in volts.
Definition: DC1338.ino:132
menu_3_read_temperature
static int8_t menu_3_read_temperature()
Read temperatures.
Definition: DC1338.ino:432
loop
static void loop()
Repeats Linduino loop.
Definition: DC1338.ino:153
LTC2990_TRIGGER_REG
#define LTC2990_TRIGGER_REG
Triggers a conversion.
Definition: LTC2990.h:172
LTC2990_temperature
float LTC2990_temperature(int16_t adc_code, float LTC2990_temperature_lsb, boolean unit)
Calculates the LTC2990 temperature.
Definition: LTC2990.cpp:214
LTC2990_ENABLE_ALL
#define LTC2990_ENABLE_ALL
All measurements per Mode are enabled.
Definition: LTC2990.h:210
LTC2990_DIFFERENTIAL_lsb
const float LTC2990_DIFFERENTIAL_lsb
Typical differential LSB weight in volts.
Definition: DC1338.ino:127
LTC2990_CONTROL_REG
#define LTC2990_CONTROL_REG
Controls Mode, Single/Repeat, Celsius/Kelvin.
Definition: LTC2990.h:171
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
LTC2990_code_to_differential_voltage
float LTC2990_code_to_differential_voltage(int16_t adc_code, float LTC2990_differential_lsb)
Calculates the LTC2990 differential input voltage.
Definition: LTC2990.cpp:200
quikeval_I2C_connect
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
voltage
static float voltage
Definition: DC2289AA.ino:71
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113
menu_4_settings
static int8_t menu_4_settings()
Configure settings.
Definition: DC1338.ino:560