145 Serial.begin(115200);
154 uint8_t acknowledge = 0;
156 if (Serial.available())
159 if (user_command !=
'm')
160 Serial.println(user_command);
162 switch (user_command)
180 Serial.println(F(
"Invalid Option"));
184 if (acknowledge != 0) Serial.println(F(
"Error: No Acknowledge. Check I2C Address."));
185 Serial.println(F(
"*************************"));
198 uint8_t
x, y, startcount, endcount;
201 uint8_t acknowledge = 0;
207 Serial.println(F(
" Read Input in Single-Ended, Unipolar mode:"));
208 Serial.println(F(
" Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
213 Serial.println(F(
" Read Input in Differential, Unipolar mode:"));
214 Serial.println(F(
" Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
222 Serial.println(F(
" Read Input in Single-Ended, Bipolar mode:"));
227 Serial.println(F(
" Read Input in Differential, Bipolar mode:"));
232 if (user_command == 8)
247 for (x = startcount; x <= endcount; x++)
254 display_code = display_code & 0xFFF;
256 Serial.print(F(
" Received Code: b"));
257 Serial.println(display_code, BIN);
260 Serial.print(F(
" Voltage read on "));
261 Serial.print(F(
"Ch"));
263 Serial.print(F(
": "));
264 Serial.print(adc_voltage, 4);
265 Serial.println(F(
"V"));
277 display_code = display_code & 0xFFF;
279 Serial.print(F(
" Received Code: b"));
280 Serial.println(display_code, BIN);
283 Serial.print(F(
" Voltage read between Chs "));
285 Serial.print(adc_voltage, 4);
286 Serial.println(F(
"V"));
298 Serial.println(F(
"\n 0 = Single-Ended"));
299 Serial.println(F(
" 1 = Differential"));
300 Serial.print(F(
" Enter a Command: "));
303 Serial.println(user_command);
304 switch (user_command)
307 Serial.println(F(
" Single-Ended mode selected"));
311 Serial.println(F(
" Differential mode selected"));
316 Serial.println(
" Invalid Option");
329 Serial.println(F(
"\n 0 = Unipolar"));
330 Serial.println(F(
" 1 = Bipolar"));
331 Serial.print(F(
" Enter a Command: "));
334 Serial.println(user_command);
335 switch (user_command)
338 Serial.println(F(
" Unipolar mode selected"));
342 Serial.println(F(
" Bipolar mode selected"));
347 Serial.println(
" Invalid Option");
359 Serial.print(F(
" Enter the I2C address of the part in decimal format, from 0 to 127 (default is 8)\n"));
361 Serial.print(F(
" Address entered: "));
362 Serial.println(user_command);
371 int8_t acknowledge = 0;
378 Serial.print(F(
" ADC Command: b"));
380 Serial.println(F(
" LTC2309 is now in sleep mode"));
381 Serial.println(F(
" Enter RETURN to exit Sleep Mode"));
394 Serial.println(F(
"*****************************************************************"));
395 Serial.println(F(
"* DC1337A Demonstration Program *"));
396 Serial.println(F(
"* This program demonstrates how to send data and receive data *"));
397 Serial.println(F(
"* from the LTC2309 12-bit ADC. *"));
398 Serial.println(F(
"* *"));
399 Serial.println(F(
"* *"));
400 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
401 Serial.println(F(
"* *"));
402 Serial.println(F(
"*****************************************************************"));
408 Serial.println(F(
"1-Read ADC Input "));
409 Serial.println(F(
"2-Select Single-Ended / Differential measurement (default is Single_Ended)"));
410 Serial.println(F(
"3-Select Unipolar / Bipolar measurement (default is Unipolar)"));
411 Serial.println(F(
"4-Sleep Mode"));
412 Serial.println(F(
"5-Set I2C address (default is 8)"));
414 Serial.print(F(
"Enter a command: "));
422 Serial.println(F(
" *************************"));
423 Serial.println(F(
" 0 = 0P-1N"));
424 Serial.println(F(
" 1 = 2P-3N"));
425 Serial.println(F(
" 2 = 4P-5N"));
426 Serial.println(F(
" 3 = 6P-7N"));
427 Serial.println(F(
" 4 = 1P-0N"));
428 Serial.println(F(
" 5 = 3P-2N"));
429 Serial.println(F(
" 6 = 5P_4N"));
430 Serial.println(F(
" 7 = 7P = 6N"));
431 Serial.println(F(
" 8 = ALL Even_P-Odd_N"));
432 Serial.println(F(
" m = Main Menu"));
434 Serial.print(F(
" Enter a Command: "));
437 Serial.println(user_command);
438 switch (user_command)
441 Serial.println(F(
" 0P-1N selected"));
444 Serial.println(F(
" 2P-3N selected"));
447 Serial.println(F(
" 4P-5N selected"));
450 Serial.println(F(
" 6P-7N selected"));
453 Serial.println(F(
" 1P-0N selected"));
456 Serial.println(F(
" 3P-2N selected"));
459 Serial.println(F(
" 5P-4N selected"));
462 Serial.println(F(
" 7P-6N selected"));
465 Serial.println(F(
" ALL Even_P-Odd_N selected"));
468 Serial.println(F(
" Invalid Option"));
471 return(user_command);
482 Serial.print(F(
" 0P-1N:"));
485 Serial.print(F(
" 2P-3N:"));
488 Serial.print(F(
" 4P-5N:"));
491 Serial.print(F(
" 6P-7N:"));
494 Serial.print(F(
" 1P-0N:"));
497 Serial.print(F(
" 3P-2N:"));
500 Serial.print(F(
" 5P-4N:"));
503 Serial.print(F(
" 7P-6N:"));
515 Serial.println(F(
"*************************"));
516 Serial.println(F(
" 0 = CH0"));
517 Serial.println(F(
" 1 = CH1"));
518 Serial.println(F(
" 2 = CH2"));
519 Serial.println(F(
" 3 = CH3"));
520 Serial.println(F(
" 4 = CH4"));
521 Serial.println(F(
" 5 = CH5"));
522 Serial.println(F(
" 6 = CH6"));
523 Serial.println(F(
" 7 = CH7"));
524 Serial.println(F(
" 8 = ALL"));
525 Serial.println(F(
" m = Main Menu"));
527 Serial.print(F(
" Enter a Command: "));
530 Serial.println(user_command);
531 if (user_command ==
'm')
534 switch (user_command)
537 Serial.println(F(
" CH0 selected"));
540 Serial.println(F(
" CH1 selected"));
543 Serial.println(F(
" CH2 selected"));
546 Serial.println(F(
" CH3 selected"));
549 Serial.println(F(
" CH4 selected"));
552 Serial.println(F(
" CH5 selected"));
555 Serial.println(F(
" CH6 selected"));
558 Serial.println(F(
" CH7 selected"));
561 Serial.println(F(
" All selected"));
564 Serial.println(F(
" Invalid Option"));
568 return(user_command);
#define LTC2309_I2C_ADDRESS
#define LTC2309_SINGLE_ENDED_MODE
unsigned char user_command
int8_t LTC2309_read(uint8_t i2c_address, uint8_t adc_command, uint16_t *ptr_adc_code)
Reads 12-bit code from LTC2309, programs channel and mode for next conversion.
static uint8_t adc_command
static void menu_5_set_address()
Header File for Linduino Libraries and Demo Code.
static uint8_t print_user_command_differential()
Display selected differential channels.
static uint8_t i2c_address
I2C address in 7 bit format for part.
static void print_channel_selection(uint8_t menu)
Display selected differential channels.
#define LTC2309_UNIPOLAR_MODE
const uint8_t BUILD_COMMAND_SINGLE_ENDED[8]
Builds the command for single-ended mode.
static uint8_t single_ended_differential
LTC2309 Unipolar or Bipolar mode selection.
static int8_t menu_1_read_input()
Read channels.
#define LTC2309_SLEEP_MODE
#define LTC2309_DIFFERENTIAL_MODE
static float LTC2309_vref
static void menu_2_select_single_ended_differential()
Sets LTC2309 to Single-Ended or Differential.
static void menu_4_set_address()
Set the I2C 7 bit address.
#define LTC2309_BIPOLAR_MODE
static void print_title()
Prints the title block when the program first starts.
static int8_t menu_4_sleep()
static int8_t menu_5_sleep()
Sets LTC2309 Sleep Mode.
static uint8_t uni_bipolar
LTC2309 Unipolar or Bipolar mode selection.
LTC2309: 8-channel, 12-Bit SAR ADC with I2C interface LTC2301: 1-Channel, 12-Bit ADCs with I2C Compat...
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
static void menu_3_select_uni_bipolar()
Sets LTC2309 to Bipolar or Unipolar.
static int32_t display_code
const uint8_t BUILD_COMMAND_DIFF[8]
Build the command for differential mode.
#define LTC2309_EXIT_SLEEP_MODE
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
static uint8_t LTC2309_bits
Resolution (12 bits)
static void print_prompt()
Prints main menu.
static void loop()
Repeats Linduino loop.
static void setup()
Initialize Linduino.
static uint8_t print_user_command_single_ended()
Display selected differential channels.
float LTC2309_code_to_voltage(uint16_t adc_code, float vref, uint8_t uni_bipolar)
Calculates the LTC2309 input voltage.