141 Serial.begin(115200);
160 if (Serial.available())
163 if (user_command !=
'm')
164 Serial.println(user_command);
166 switch (user_command)
181 Serial.println(
"Incorrect Option");
186 Serial.print(F(
"Error: No Acknowledge. Check I2C Address.\n"));
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"));
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:"));
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: "));
240 if (user_command ==
'm')
242 Serial.print(F(
"m\n"));
245 Serial.println(user_command);
256 switch (user_command)
262 Serial.print(F(
"\n V1: "));
263 Serial.print(voltage, 4);
264 Serial.print(F(
" V\n"));
270 Serial.print(F(
"\n V2: "));
271 Serial.print(voltage, 4);
272 Serial.print(F(
" V\n"));
278 Serial.print(F(
"\n V3: "));
279 Serial.print(voltage, 4);
280 Serial.print(F(
" V\n"));
286 Serial.print(F(
"\n V4: "));
287 Serial.print(voltage, 4);
288 Serial.print(F(
" V\n"));
294 Serial.print(F(
"\n Vcc: "));
295 Serial.print(voltage, 4);
296 Serial.print(F(
" V\n"));
302 Serial.print(F(
"\n V1: "));
303 Serial.print(voltage, 4);
304 Serial.print(F(
" V\n"));
310 Serial.print(F(
" V2: "));
311 Serial.print(voltage, 4);
312 Serial.print(F(
" V\n"));
318 Serial.print(F(
" V3: "));
319 Serial.print(voltage, 4);
320 Serial.print(F(
" V\n"));
326 Serial.print(F(
" V4: "));
327 Serial.print(voltage, 4);
328 Serial.print(F(
" V\n"));
334 Serial.print(F(
" Vcc: "));
335 Serial.print(voltage, 4);
336 Serial.print(F(
" V\n"));
339 if (user_command !=
'm')
340 Serial.println(
" Incorrect Option");
344 while ((user_command !=
'm') && (ack != 1));
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: "));
365 if (user_command ==
'm')
367 Serial.print(F(
"m\n"));
370 Serial.println(user_command);
384 switch (user_command)
390 Serial.print(F(
"\n V1-V2: "));
391 Serial.print(voltage, 4);
392 Serial.print(F(
" V\n"));
398 Serial.print(F(
"\n V3-V4: "));
399 Serial.print(voltage, 4);
400 Serial.print(F(
" V\n"));
406 Serial.print(F(
"\n V1-V2: "));
407 Serial.print(voltage, 4);
408 Serial.print(F(
" V\n"));
414 Serial.print(F(
" V3-V4: "));
415 Serial.print(voltage, 4);
416 Serial.print(F(
" V\n"));
419 if (user_command !=
'm')
421 Serial.print(F(
"Incorrect Option\n"));
426 while ((user_command !=
'm') && (ack != 1));
435 boolean isKelvin =
false;
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: "));
448 if (user_command ==
'm')
450 Serial.print(F(
"m\n"));
453 Serial.println(user_command);
456 int8_t data_valid = 0;
471 switch (user_command)
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"));
489 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=
true;
490 else isKelvin =
false;
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"));
501 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=
true;
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"));
514 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=
true;
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"));
527 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=
true;
528 else isKelvin =
false;
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"));
540 if (reg_data & LTC2990_KELVIN_ENABLE) isKelvin=
true;
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"));
549 if (user_command !=
'm')
550 Serial.println(
"Incorrect Option");
554 while ((user_command !=
'm') && (ack == 0));
566 Serial.println(F(
"\nSettings:"));
567 Serial.println(F(
"0-Celsius"));
568 Serial.println(F(
"1-Kelvin"));
569 Serial.print(F(
"\nEnter a command: "));
571 Serial.println(user_command);
577 Serial.println(F(
"The LTC2990 is in Kelvin Mode"));
583 Serial.println(F(
"The LTC2990 is in Celsius Mode"));
#define LTC2990_TR1_TR2
Read TR1 and TR2.
#define LTC2990_V3_MSB_REG
V3, V3-V4, or T_R2 T MSB.
unsigned char user_command
#define LTC2990_TEMP_FORMAT_MASK
Use mask when changing temp formats.
static void print_prompt()
Prints main menu.
float LTC2990_code_to_single_ended_voltage(int16_t adc_code, float LTC2990_single_ended_lsb)
Calculates the LTC2990 single-ended input voltages.
static int8_t menu_2_read_differential_voltage()
Read differential voltages.
Header File for Linduino Libraries and Demo Code.
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 ...
float LTC2990_code_to_vcc_voltage(int16_t adc_code, float LTC2990_single_ended_lsb)
Calculates the LTC2990 Vcc voltage.
LTC2990: 14-bit ADC Quad I2C voltage, current, and temperature monitor.
#define LTC2990_CELSIUS_ENABLE
Enable for Celsius.
static void print_title()
Prints the title block when program first starts.
#define LTC2990_V2_MSB_REG
V2, V1-V2, or T_R2 Voltage MSB.
const float LTC2990_VCC_lsb
Typical VCC LSB weight in volts.
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.
#define LTC2990_V4_MSB_REG
V4, V3-V4, or T_R2 Voltage MSB.
#define LTC2990_TINT_MSB_REG
Internal Temperature MSB.
int8_t LTC2990_register_write(uint8_t i2c_address, uint8_t register_address, uint8_t register_data)
Write one byte to an LTC2990 register.
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.
#define LTC2990_VOLTAGE_MODE_MASK
Use mode mask when changing modes.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
#define LTC2990_VCC_MSB_REG
Vcc MSB.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
const float LTC2990_TEMPERATURE_lsb
Typical temperature LSB weight in degrees Celsius (and Kelvin).
static int8_t menu_1_single_ended_voltage()
Read single-ended voltages.
#define LTC2990_V1_MSB_REG
V1, V1-V2, or T_R1 T MSB.
const uint16_t LTC2990_TIMEOUT
Configures the maximum timeout allowed for an LTC2990 read.
static void setup()
Initialize Linduino.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
const float LTC2990_SINGLE_ENDED_lsb
Typical single-ended LSB weight in volts.
#define LTC2990_V1_V2_V3_V4
Read V1, V2, V3 and V4.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC2990_V1V2_V3V4
Read V1-V2 and V3-V4.
#define LTC2990_I2C_ADDRESS
I2C address of the LTC2990.
#define LTC2990_KELVIN_ENABLE
Enable for Kelvin.
const float LTC2990_DIODE_VOLTAGE_lsb
Typical remote diode LSB weight in volts.
static int8_t menu_3_read_temperature()
Read temperatures.
static void loop()
Repeats Linduino loop.
#define LTC2990_TRIGGER_REG
Triggers a conversion.
float LTC2990_temperature(int16_t adc_code, float LTC2990_temperature_lsb, boolean unit)
Calculates the LTC2990 temperature.
#define LTC2990_ENABLE_ALL
All measurements per Mode are enabled.
const float LTC2990_DIFFERENTIAL_lsb
Typical differential LSB weight in volts.
#define LTC2990_CONTROL_REG
Controls Mode, Single/Repeat, Celsius/Kelvin.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
float LTC2990_code_to_differential_voltage(int16_t adc_code, float LTC2990_differential_lsb)
Calculates the LTC2990 differential input voltage.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
static int8_t menu_4_settings()
Configure settings.