150 Serial.begin(115200);
171 if (Serial.available())
174 if (user_command !=
'm')
175 Serial.println(user_command);
177 switch (user_command)
195 Serial.println(
"Incorrect Option");
200 Serial.print(F(
"Error: No Acknowledge. Check I2C Address.\n"));
212 Serial.print(F(
"\n*****************************************************************\n"));
213 Serial.print(F(
"* DC1785A Demonstration Program *\n"));
214 Serial.print(F(
"* *\n"));
215 Serial.print(F(
"* This program demonstrates how to send and receive data from *\n"));
216 Serial.print(F(
"* the LTC2991 14-Bit Octal I2C Voltage, Current, and *\n"));
217 Serial.print(F(
"* Temperature Monitor. *\n"));
218 Serial.print(F(
"* *\n"));
219 Serial.print(F(
"* Set the baud rate to 115200 and select the newline terminator.*\n"));
220 Serial.print(F(
"* *\n"));
221 Serial.print(F(
"*****************************************************************\n"));
227 Serial.print(F(
"\n 1-Single-Ended Voltage\n"));
228 Serial.print(F(
" 2-Differential Voltage\n"));
229 Serial.print(F(
" 3-Temperature\n"));
230 Serial.print(F(
" 4-Settings\n"));
231 Serial.print(F(
" 5-PWM\n\n"));
232 Serial.print(F(
"Enter a command:"));
244 Serial.print(F(
"\nSingle-Ended Voltage\n\n"));
245 Serial.print(F(
" 1-V1\n"));
246 Serial.print(F(
" 2-V2\n"));
247 Serial.print(F(
" 3-V3\n"));
248 Serial.print(F(
" 4-V4\n"));
249 Serial.print(F(
" 5-V5\n"));
250 Serial.print(F(
" 6-V6\n"));
251 Serial.print(F(
" 7-V7\n"));
252 Serial.print(F(
" 8-V8\n"));
253 Serial.print(F(
" 9-Vcc\n"));
254 Serial.print(F(
" 10-ALL\n"));
255 Serial.print(F(
" m-Main Menu\n"));
256 Serial.print(F(
"\n\nEnter a command: "));
259 if (user_command ==
'm')
261 Serial.print(F(
"m\n"));
264 Serial.println(user_command);
273 switch (user_command)
281 Serial.print(F(
"\n V1: "));
282 Serial.print(voltage, 4);
283 Serial.print(F(
" V\n"));
291 Serial.print(F(
"\n V2: "));
292 Serial.print(voltage, 4);
293 Serial.print(F(
" V\n"));
301 Serial.print(F(
"\n V3: "));
302 Serial.print(voltage, 4);
303 Serial.print(F(
" V\n"));
311 Serial.print(F(
"\n V4: "));
312 Serial.print(voltage, 4);
313 Serial.print(F(
" V\n"));
320 Serial.print(F(
"\n V5: "));
321 Serial.print(voltage, 4);
322 Serial.print(F(
" V\n"));
329 Serial.print(F(
"\n V6: "));
330 Serial.print(voltage, 4);
331 Serial.print(F(
" V\n"));
338 Serial.print(F(
"\n V7: "));
339 Serial.print(voltage, 4);
340 Serial.print(F(
" V\n"));
347 Serial.print(F(
"\n V8: "));
348 Serial.print(voltage, 4);
349 Serial.print(F(
" V\n"));
355 Serial.print(F(
"\n Vcc: "));
356 Serial.print(voltage, 4);
357 Serial.print(F(
" V\n"));
366 Serial.print(F(
"\n V1: "));
367 Serial.print(voltage, 4);
368 Serial.print(F(
" V\n"));
374 Serial.print(F(
" V2: "));
375 Serial.print(voltage, 4);
376 Serial.print(F(
" V\n"));
382 Serial.print(F(
" V3: "));
383 Serial.print(voltage, 4);
384 Serial.print(F(
" V\n"));
390 Serial.print(F(
" V4: "));
391 Serial.print(voltage, 4);
392 Serial.print(F(
" V\n"));
398 Serial.print(F(
" V5: "));
399 Serial.print(voltage, 4);
400 Serial.print(F(
" V\n"));
406 Serial.print(F(
" V6: "));
407 Serial.print(voltage, 4);
408 Serial.print(F(
" V\n"));
414 Serial.print(F(
" V7: "));
415 Serial.print(voltage, 4);
416 Serial.print(F(
" V\n"));
422 Serial.print(F(
" V8: "));
423 Serial.print(voltage, 4);
424 Serial.print(F(
" V\n"));
430 Serial.print(F(
" Vcc: "));
431 Serial.print(voltage, 4);
432 Serial.print(F(
" V\n"));
435 if (user_command !=
'm')
436 Serial.println(
" Incorrect Option");
440 while ((user_command !=
'm') && (ack != 1));
453 Serial.print(F(
"\nDifferential Voltage\n\n"));
454 Serial.print(F(
" 1-V1-V2\n"));
455 Serial.print(F(
" 2-V3-V4\n"));
456 Serial.print(F(
" 3-V5-V6\n"));
457 Serial.print(F(
" 4-V7-V8\n"));
458 Serial.print(F(
" 5-ALL\n"));
459 Serial.print(F(
" m-Main Menu\n"));
460 Serial.print(F(
"\n\nEnter a command: "));
463 if (user_command ==
'm')
465 Serial.print(F(
"m\n"));
468 Serial.println(user_command);
477 switch (user_command)
484 Serial.print(F(
"\n V1-V2: "));
485 Serial.print(voltage, 4);
486 Serial.print(F(
" V\n"));
493 Serial.print(F(
"\n V3-V4: "));
494 Serial.print(voltage, 4);
495 Serial.print(F(
" V\n"));
502 Serial.print(F(
"\n V5-V6: "));
503 Serial.print(voltage, 4);
504 Serial.print(F(
" V\n"));
511 Serial.print(F(
"\n V7-V8: "));
512 Serial.print(voltage, 4);
513 Serial.print(F(
" V\n"));
522 Serial.print(F(
"\n V1-V2: "));
523 Serial.print(voltage, 4);
524 Serial.print(F(
" V\n"));
530 Serial.print(F(
" V3-V4: "));
531 Serial.print(voltage, 4);
532 Serial.print(F(
" V\n"));
538 Serial.print(F(
" V5-V6: "));
539 Serial.print(voltage, 4);
540 Serial.print(F(
" V\n"));
546 Serial.print(F(
" V7-V8: "));
547 Serial.print(voltage, 4);
548 Serial.print(F(
" V\n"));
551 if (user_command !=
'm')
553 Serial.print(F(
"Incorrect Option\n"));
558 while ((user_command !=
'm') && (ack != 1));
567 boolean isKelvin =
false;
572 Serial.print(F(
"\nTemperature\n\n"));
573 Serial.print(F(
" 1-V1-V2\n"));
574 Serial.print(F(
" 2-V3-V4\n"));
575 Serial.print(F(
" 3-V5-V6\n"));
576 Serial.print(F(
" 4-V7-V8\n"));
577 Serial.print(F(
" 5-Internal\n"));
578 Serial.print(F(
" 6-ALL\n"));
579 Serial.print(F(
" m-Main Menu\n"));
580 Serial.print(F(
"\n\nEnter a command: "));
582 if (user_command ==
'm')
584 Serial.print(F(
"m\n"));
587 Serial.println(user_command);
598 switch (user_command)
608 Serial.print(F(
"\n V1-V2: "));
609 Serial.print(temperature, 2);
610 if (isKelvin) Serial.print(F(
" K\n"));
611 else Serial.print(F(
" C\n"));
620 else isKelvin =
false;
622 Serial.print(F(
"\n V3-V4: "));
623 Serial.print(temperature, 2);
625 if (isKelvin) Serial.print(F(
" K\n"));
626 else Serial.print(F(
" C\n"));
639 Serial.print(F(
"\n V5-V6: "));
640 Serial.print(temperature, 2);
642 if (isKelvin) Serial.print(F(
" K\n"));
643 else Serial.print(F(
" C\n"));
652 else isKelvin =
false;
654 Serial.print(F(
"\n V7-V8: "));
655 Serial.print(temperature, 2);
657 if (isKelvin) Serial.print(F(
" K\n"));
658 else Serial.print(F(
" C\n"));
670 Serial.print(F(
"\n Internal: "));
671 Serial.print(temperature, 2);
673 if (isKelvin) Serial.print(F(
" K\n"));
674 else Serial.print(F(
" C\n"));
686 if (reg_data & LTC2991_V1_V2_KELVIN_ENABLE) isKelvin =
true;
690 Serial.print(F(
"\n V1-V2: "));
691 Serial.print(temperature, 2);
693 if (isKelvin) Serial.print(F(
" K\n"));
694 else Serial.print(F(
" C\n"));
702 if (reg_data & LTC2991_V3_V4_KELVIN_ENABLE) isKelvin =
true;
705 Serial.print(F(
" V3-V4: "));
706 Serial.print(temperature, 2);
707 if (isKelvin) Serial.print(F(
" K\n"));
708 else Serial.print(F(
" C\n"));
716 if (reg_data & LTC2991_V5_V6_KELVIN_ENABLE) isKelvin =
true;
719 Serial.print(F(
" V5-V6: "));
720 Serial.print(temperature, 2);
721 if (isKelvin) Serial.print(F(
" K\n"));
722 else Serial.print(F(
" C\n"));
730 if (reg_data & LTC2991_V7_V8_KELVIN_ENABLE) isKelvin =
true;
733 Serial.print(F(
" V7-V8: "));
734 Serial.print(temperature, 2);
735 if (isKelvin) Serial.print(F(
" K\n"));
736 else Serial.print(F(
" C\n"));
744 if (reg_data & LTC2991_INT_KELVIN_ENABLE) isKelvin =
true;
745 else isKelvin =
false;
747 Serial.print(F(
" Internal: "));
748 Serial.print(temperature, 2);
749 if (isKelvin) Serial.print(F(
" K\n"));
750 else Serial.print(F(
" C\n"));
753 if (user_command !=
'm')
754 Serial.println(
"Incorrect Option");
758 while ((user_command !=
'm') && (ack == 0));
772 Serial.print(F(
"\nSettings\n"));
773 Serial.print(F(
"************************\n"));
774 Serial.print(F(
"* Filter *\n"));
775 Serial.print(F(
"************************\n"));
776 Serial.print(F(
"* 1-V1/V2: "));
781 else Serial.print(F(
"Disabled *\n"));
783 Serial.print(F(
"* 2-V3/V4: "));
786 else Serial.print(F(
"Disabled *\n"));
789 Serial.print(F(
"* 3-V5/V6: "));
792 else Serial.print(F(
"Disabled *\n"));
794 Serial.print(F(
"* 4-V7/V8: "));
797 else Serial.print(F(
"Disabled *\n"));
799 Serial.print(F(
"* 5-Internal: "));
803 else Serial.print(F(
"Disabled *\n"));
805 Serial.print(F(
"************************\n"));
806 Serial.print(F(
"* 6-Deg C/K:"));
811 else Serial.print(F(
" Celsius*\n"));
813 Serial.print(F(
"* m-Main Menu *\n"));
814 Serial.print(F(
"************************\n\n"));
815 Serial.print(F(
"Enter a command: "));
819 if (user_command ==
'm') Serial.print(F(
"m\n"));
820 else Serial.println(user_command);
823 switch (user_command)
860 if (user_command !=
'm')
861 Serial.print(F(
"Incorrect Option\n"));
865 while ((user_command !=
'm') && (ack != 1));
876 int16_t pwm_temp = 0;
877 uint8_t reg_data, reg_data_msb;
881 Serial.print(F(
"\n\nPWM Settings - Select to Toggle\n\n"));
882 Serial.print(F(
" 1-Temp Threshold: "));
893 pwm_temp = (int16_t)((reg_data_msb << 1) | (reg_data &
LTC2991_PWM_0) >> 7);
894 Serial.print(pwm_temp);
898 else Serial.print(F(
" C\n"));
902 Serial.print(F(
"Not Configured"));
906 else Serial.print(F(
" 2-Noninverted\n"));
909 else Serial.print(F(
" 3-Disabled\n"));
911 Serial.print(F(
" m-Main Menu\n"));
912 Serial.print(F(
"\n\nEnter a command: "));
914 if (user_command ==
'm')
916 Serial.print(F(
"m\n"));
920 Serial.println(user_command);
924 switch (user_command)
929 else Serial.print(F(
"\nEnter Temperature Threshold in Celsius: "));
931 Serial.println(pwm_temp);
948 if (user_command !=
'm')
949 Serial.println(
"Incorrect Option");
953 while ((user_command !=
'm') && (ack != 1));
const float LTC2991_TEMPERATURE_lsb
Typical temperature LSB weight in degrees Celsius (and Kelvin).
static void print_title()
Prints the title block when program first starts.
unsigned char user_command
#define LTC2991_ENABLE_ALL_CHANNELS
Use to enable all LTC2991 channels.
const float LTC2991_DIFFERENTIAL_lsb
Typical differential LSB weight in volts.
int8_t LTC2991_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 LTC2991_V7_V8_DIFFERENTIAL_ENABLE
Enable V7-V8 differential mode.
#define LTC2991_V5_V6_KELVIN_ENABLE
Enable V5-V6 for Kelvin.
#define LTC2991_PWM_0
PWM threshold Least Significant Bit.
#define LTC2991_V5_V6_DIFFERENTIAL_ENABLE
Enable V5-V6 differential mode.
#define LTC2991_V1_V2_TEMP_ENABLE
Enable V1-V2 temperature mode.
#define LTC2991_V5_V6_FILTER_ENABLE
Enable filters on V5-V6.
#define LTC2991_Vcc_MSB_REG
Vcc MSB.
static int8_t menu_2_read_differential_voltage()
Read differential voltages.
#define LTC2991_INT_FILTER_ENABLE
Enable Internal Temperature Filter.
float LTC2991_code_to_vcc_voltage(int16_t adc_code, float LTC2991_single_ended_lsb)
Calculates the LTC2991 Vcc voltage.
Header File for Linduino Libraries and Demo Code.
#define LTC2991_V3_V4_DIFFERENTIAL_ENABLE
Enable V3-V4 differential mode.
#define LTC2991_V1_V2_FILTER_ENABLE
Enable filters on V1-V2.
#define LTC2991_V5_MSB_REG
V5, or T_R3 T MSB.
const uint16_t LTC2991_TIMEOUT
Configures the maximum timeout allowed for an LTC2991 read.
#define LTC2991_PWM_THRESHOLD_MSB_REG
PWM Threshold.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
#define LTC2991_V1_V2_DIFFERENTIAL_ENABLE
Enable V1-V2 differential mode.
#define LTC2991_CONTROL_V5678_REG
V5, V6, V7, AND V8 Control Register.
const float LTC2991_SINGLE_ENDED_lsb
Typical single-ended LSB weight in volts.
#define LTC2991_CONTROL_PWM_Tinternal_REG
PWM Threshold and T_internal Control Register.
int8_t LTC2991_register_write(uint8_t i2c_address, uint8_t register_address, uint8_t register_data)
Write one byte to an LTC2991 register.
float LTC2991_code_to_differential_voltage(int16_t adc_code, float LTC2991_differential_lsb)
Calculates the LTC2991 differential input voltage.
#define LTC2991_I2C_ADDRESS
I2C address of the LTC2991.
#define LTC2991_V7_V8_KELVIN_ENABLE
Enable V7-V8 for Kelvin.
float LTC2991_code_to_single_ended_voltage(int16_t adc_code, float LTC2991_single_ended_lsb)
Calculates the LTC2991 single-ended input voltages.
#define LTC2991_PWM_INVERT
Invert PWM.
static int8_t menu_3_read_temperature()
Read temperatures.
#define LTC2991_V4_MSB_REG
V4, V3-V4, or T_R2 Voltage MSB.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define LTC2991_PWM_ENABLE
Enable PWM.
#define LTC2991_V2_MSB_REG
V2, V1-V2, or T_R2 Voltage MSB.
#define LTC2991_V7_MSB_REG
V7, or T_R4 T MSB.
#define LTC2991_V7_V8_FILTER_ENABLE
Enable filters on V7-V8.
#define LTC2991_V3_V4_TEMP_ENABLE
Enable V3-V4 temperature mode.
#define LTC2991_V5_V6_TEMP_ENABLE
Enable V5-V6 temperature mode.
#define LTC2991_V3_V4_FILTER_ENABLE
Enable filters on V3-V4.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC2991_V7_V8_TEMP_ENABLE
Enable V7-V8 temperature mode.
int8_t LTC2991_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 ...
int8_t LTC2991_register_read(uint8_t i2c_address, uint8_t register_address, uint8_t *register_data)
Reads an 8-bit register from the LTC2991 using the standard repeated start format.
static int8_t menu_5_pwm_options()
Configure PWM options.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
static int8_t menu_1_single_ended_voltage()
Read single-ended voltages.
#define LTC2991_REPEAT_MODE
Enable Repeated Aquisition Mode.
#define LTC2991_T_Internal_MSB_REG
T_Internal MSB.
static int8_t menu_4_settings()
Configure settings.
static void loop()
Repeats Linduino loop.
#define LTC2991_V1_V2_KELVIN_ENABLE
Enable V1-V2 for Kelvin.
#define LTC2991_V1_MSB_REG
V1, or T_R1 T MSB.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
#define LTC2991_CONTROL_V1234_REG
V1, V2, V3, and V4 Control Register.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
#define LTC2991_V3_MSB_REG
V3, or T_R2 T MSB.
#define LTC2991_CHANNEL_ENABLE_REG
Channel Enable, Vcc, T_internal Conversion Status, Trigger.
#define LTC2991_V8_MSB_REG
V8, V7-V8, or T_R4 Voltage MSB.
#define LTC2991_V6_MSB_REG
V6, V5-V6, or T_R3 Voltage MSB.
float LTC2991_temperature(int16_t adc_code, float LTC2991_temperature_lsb, boolean unit)
Calculates the LTC2991 temperature.
#define LTC2991_INT_KELVIN_ENABLE
Enable internal temperature for Kelvin.
static void print_prompt()
Prints main menu.
static void setup()
Initialize Linduino.
LTC2991: 14-bit ADC octal I2C voltage, current, and temperature monitor.
#define LTC2991_V3_V4_KELVIN_ENABLE
Enable V3-V4 for Kelvin.