146 Serial.begin(115200);
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 Serial.println(F(
"*************************"));
198 uint8_t
x, y, startcount, endcount;
205 Serial.println(F(
" Read Input in Single-Ended, Unipolar mode:"));
206 Serial.println(F(
" Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
211 Serial.println(F(
" Read Input in Differential, Unipolar mode:"));
212 Serial.println(F(
" Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
220 Serial.println(F(
" Read Input in Single-Ended, Bipolar mode:"));
225 Serial.println(F(
" Read Input in Differential, Bipolar mode:"));
230 if (user_command == 8)
245 for (x = startcount; x <= endcount; x++)
250 Serial.print(F(
" Received Code: b"));
251 Serial.println(adc_code, BIN);
254 Serial.print(F(
" Voltage read on "));
255 Serial.print(F(
"Ch"));
257 Serial.print(F(
": "));
258 Serial.print(adc_voltage, 4);
259 Serial.println(F(
"V"));
268 for (x = startcount; x <= endcount; x++)
273 Serial.print(F(
" Received Code: b"));
274 Serial.println(adc_code,BIN);
277 Serial.print(F(
" Voltage read between Chs "));
279 Serial.print(adc_voltage, 4);
280 Serial.println(F(
"V"));
292 Serial.println(F(
"\n 0 = Single-Ended"));
293 Serial.println(F(
" 1 = Differential"));
294 Serial.print(F(
" Enter a Command: "));
297 Serial.println(user_command);
298 switch (user_command)
301 Serial.println(F(
" Single-Ended mode selected"));
305 Serial.println(F(
" Differential mode selected"));
310 Serial.println(
" Invalid Option");
324 Serial.println(F(
"\n 0 = Unipolar"));
325 Serial.println(F(
" 1 = Bipolar"));
326 Serial.print(F(
" Enter a Command: "));
329 Serial.println(user_command);
330 switch (user_command)
333 Serial.println(F(
" Unipolar mode selected"));
337 Serial.println(F(
" Bipolar mode selected"));
341 Serial.println(
" Invalid Option");
354 Serial.println(F(
"\n 0 = High Range"));
355 Serial.println(F(
" 1 = Low Range"));
356 Serial.print(F(
" Enter a Command: "));
358 Serial.println(user_command);
360 switch (user_command)
363 Serial.println(F(
" High Range selected"));
367 Serial.println(F(
" Low Range selected"));
372 Serial.println(
" Invalid Option");
389 Serial.print(F(
" ADC Command: B"));
391 Serial.println(F(
" LTC1859 Is Now In Sleep Mode"));
392 Serial.println(F(
" Enter RETURN to exit Sleep Mode"));
402 Serial.println(F(
"*****************************************************************"));
403 Serial.println(F(
"* DC682A Demonstration Program *"));
404 Serial.println(F(
"* *"));
405 Serial.println(F(
"* This program demonstrates how to send data and receive data *"));
406 Serial.println(F(
"* from the LTC1859 16-bit ADC. *"));
407 Serial.println(F(
"* *"));
408 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
409 Serial.println(F(
"* *"));
410 Serial.println(F(
"*****************************************************************"));
417 Serial.println(F(
"1-Read ADC Input "));
418 Serial.println(F(
"2-Select Single-Ended / Differential measurement (default is Single_Ended)"));
419 Serial.println(F(
"3-Select Unipolar / Bipolar measurement (default is Unipolar)"));
420 Serial.println(F(
"4-Set Input Range (default is High Range)"));
421 Serial.println(F(
"5-Select Sleep Mode"));
423 Serial.print(F(
"Enter a command: "));
433 Serial.println(F(
"*************************"));
434 Serial.println(F(
" 0 = 0P-1N"));
435 Serial.println(F(
" 1 = 2P-3N"));
436 Serial.println(F(
" 2 = 4P-5N"));
437 Serial.println(F(
" 3 = 6P-7N"));
438 Serial.println(F(
" 4 = 1P-0N"));
439 Serial.println(F(
" 5 = 3P-2N"));
440 Serial.println(F(
" 6 = 5P_4N"));
441 Serial.println(F(
" 7 = 7P = 6N"));
442 Serial.println(F(
" 8 = ALL Even_P-Odd_N"));
443 Serial.println(F(
" m = Main Menu"));
445 Serial.print(F(
" Enter a Command: "));
448 Serial.println(user_command);
449 if (user_command ==
'm')
452 switch (user_command)
455 Serial.println(F(
" 0P-1N selected"));
458 Serial.println(F(
" 2P-3N selected"));
461 Serial.println(F(
" 4P-5N selected"));
464 Serial.println(F(
" 6P-7N selected"));
467 Serial.println(F(
" 1P-0N selected"));
470 Serial.println(F(
" 3P-2N selected"));
473 Serial.println(F(
" 5P-4N selected"));
476 Serial.println(F(
" 7P-6N selected"));
479 Serial.println(F(
" ALL Even_P-Odd_N selected"));
482 Serial.println(F(
" Invalid Option"));
485 return(user_command);
496 Serial.print(F(
" 0P-1N:"));
499 Serial.print(F(
" 2P-3N:"));
502 Serial.print(F(
" 4P-5N:"));
505 Serial.print(F(
" 6P-7N:"));
508 Serial.print(F(
" 1P-0N:"));
511 Serial.print(F(
" 3P-2N:"));
514 Serial.print(F(
" 5P-4N:"));
517 Serial.print(F(
" 7P-6N:"));
528 Serial.println(F(
"*************************"));
529 Serial.println(F(
" 0 = CH0"));
530 Serial.println(F(
" 1 = CH1"));
531 Serial.println(F(
" 2 = CH2"));
532 Serial.println(F(
" 3 = CH3"));
533 Serial.println(F(
" 4 = CH4"));
534 Serial.println(F(
" 5 = CH5"));
535 Serial.println(F(
" 6 = CH6"));
536 Serial.println(F(
" 7 = CH7"));
537 Serial.println(F(
" 8 = ALL"));
538 Serial.println(F(
" m = Main Menu"));
540 Serial.print(F(
" Enter a Command: "));
543 Serial.println(user_command);
544 if (user_command ==
'm')
547 switch (user_command)
550 Serial.println(F(
" CH0 selected"));
553 Serial.println(F(
" CH1 selected"));
556 Serial.println(F(
" CH2 selected"));
559 Serial.println(F(
" CH3 selected"));
562 Serial.println(F(
" CH4 selected"));
565 Serial.println(F(
" CH5 selected"));
568 Serial.println(F(
" CH6 selected"));
571 Serial.println(F(
" CH7 selected"));
574 Serial.println(F(
" All selected"));
577 Serial.println(F(
" Invalid Option"));
581 return(user_command);
static void loop()
Repeats Linduino loop.
unsigned char user_command
static uint8_t adc_command
static uint8_t single_ended_differential
LTC1859 Unipolar or Bipolar mode selection.
static uint8_t uni_bipolar
Default set for unipolar mode.
#define LTC1859_SINGLE_ENDED_MODE
static uint8_t print_user_command_differential()
Display selected differential channels.
Header File for Linduino Libraries and Demo Code.
#define LTC1859_HIGH_RANGE_MODE
#define LTC1859_DIFFERENTIAL_MODE
static void menu_2_select_single_ended_differential()
Sets LTC1859 to Single-Ended or Differential.
const uint8_t BUILD_COMMAND_DIFF[8]
Lookup table to build the command for differential mode with the selected uni/bipolar mode...
const uint8_t BUILD_COMMAND_SINGLE_ENDED[8]
Lookup table to build the command for single-ended mode, input with respect to GND.
static void menu_1_read_input()
Read channels.
static void print_prompt()
Prints main menu.
static uint8_t range_low_high
Default set for high range mode.
static float LTC1859_bits
Resolution (16 bits)
void LTC1859_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
LTC1859: 16-bit 8-channel 100ksps ADC.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static void menu_5_sleep()
Put LTC1859 to sleep (low power)
#define LTC1859_UNIPOLAR_MODE
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC1859_CS
Define the SPI CS pin.
static void menu_3_select_uni_bipolar()
Select unipolar (0-REFCOMP) or bipolar (+/- 0.5 x REFCOMP) mode.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
#define LTC1859_NORMAL_MODE
#define LTC1859_BIPOLAR_MODE
static float LTC1859_vref
static void menu_4_select_range()
Select low range or high range mode.
float LTC1859_code_to_voltage(uint16_t adc_code, float vref, uint8_t range_low_high, uint8_t uni_bipolar)
Calculates the LTC1859 input's unipolar voltage given the binary data and lsb weight.
static void print_channel_selection(uint8_t menu)
Display selected differential channels.
static void print_title()
Prints the title block when program first starts.
#define LTC1859_SLEEP_MODE
#define LTC1859_LOW_RANGE_MODE
static uint8_t print_user_command_single_ended()
Display selected single-ended channel.
static void setup()
Initialize Linduino.