144 Serial.begin(115200);
155 if (Serial.available())
158 if (user_command !=
'm')
159 Serial.println(user_command);
161 switch (user_command)
176 Serial.println(F(
"Invalid Option"));
180 Serial.println(F(
"*************************"));
194 uint8_t
x, y, startcount, endcount;
201 Serial.println(F(
" Read Input in Single-Ended, Unipolar mode:"));
202 Serial.println(F(
" Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
207 Serial.println(F(
" Read Input in Differential, Unipolar mode:"));
208 Serial.println(F(
" Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
216 Serial.println(F(
" Read Input in Single-Ended, Bipolar mode:"));
221 Serial.println(F(
" Read Input in Differential, Bipolar mode:"));
226 if (user_command == 8)
241 for (x = startcount; x <= endcount; x++)
248 display_code = display_code & 0xFFF;
250 Serial.print(F(
" Received Code: b"));
251 Serial.println(display_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++)
275 display_code = display_code & 0xFFF;
277 Serial.print(F(
" Received Code: b"));
278 Serial.println(display_code, BIN);
281 Serial.print(F(
" Voltage read between Chs "));
283 Serial.print(adc_voltage, 4);
284 Serial.println(F(
"V"));
296 Serial.println(F(
"\n 0 = Single-Ended"));
297 Serial.println(F(
" 1 = Differential"));
298 Serial.print(F(
" Enter a Command: "));
301 Serial.println(user_command);
302 switch (user_command)
305 Serial.println(F(
" Single-Ended mode selected"));
309 Serial.println(F(
" Differential mode selected"));
314 Serial.println(
" Invalid Option");
328 Serial.println(F(
"\n 0 = Bipolar"));
329 Serial.println(F(
" 1 = Unipolar"));
330 Serial.print(F(
" Enter a Command: "));
333 Serial.println(user_command);
334 switch (user_command)
337 Serial.println(F(
" Bipolar mode selected"));
341 Serial.println(F(
" Unipolar mode selected"));
345 Serial.println(
" Invalid Option");
361 Serial.print(F(
" ADC Command: B"));
363 Serial.println(F(
" LTC2308 Is Now In Sleep Mode"));
364 Serial.println(F(
" Enter RETURN to exit Sleep Mode"));
371 Serial.println(F(
"*****************************************************************"));
372 Serial.println(F(
"* DC1186A Demonstration Program *"));
373 Serial.println(F(
"* *"));
374 Serial.println(F(
"* This program demonstrates how to send data and receive data *"));
375 Serial.println(F(
"* from the LTC2308 12-bit ADC. *"));
376 Serial.println(F(
"* *"));
377 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
378 Serial.println(F(
"* *"));
379 Serial.println(F(
"*****************************************************************"));
386 Serial.println(F(
"1-Read ADC Input "));
387 Serial.println(F(
"2-Select Single-Ended / Differential measurement (default is Single_Ended)"));
388 Serial.println(F(
"3-Select Unipolar / Bipolar measurement (default is Unipolar)"));
389 Serial.println(F(
"4-Select Sleep Mode"));
391 Serial.print(F(
"Enter a command: "));
401 Serial.println(F(
" *************************"));
402 Serial.println(F(
" 0 = 0P-1N"));
403 Serial.println(F(
" 1 = 2P-3N"));
404 Serial.println(F(
" 2 = 4P-5N"));
405 Serial.println(F(
" 3 = 6P-7N"));
406 Serial.println(F(
" 4 = 1P-0N"));
407 Serial.println(F(
" 5 = 3P-2N"));
408 Serial.println(F(
" 6 = 5P_4N"));
409 Serial.println(F(
" 7 = 7P = 6N"));
410 Serial.println(F(
" 8 = ALL Even_P-Odd_N"));
411 Serial.println(F(
" m = Main Menu"));
413 Serial.print(F(
" Enter a Command: "));
416 Serial.println(user_command);
417 if (user_command ==
'm')
420 switch (user_command)
423 Serial.println(F(
" 0P-1N selected"));
426 Serial.println(F(
" 2P-3N selected"));
429 Serial.println(F(
" 4P-5N selected"));
432 Serial.println(F(
" 6P-7N selected"));
435 Serial.println(F(
" 1P-0N selected"));
438 Serial.println(F(
" 3P-2N selected"));
441 Serial.println(F(
" 5P-4N selected"));
444 Serial.println(F(
" 7P-6N selected"));
447 Serial.println(F(
" ALL Even_P-Odd_N selected"));
450 Serial.println(F(
" Invalid Option"));
453 return(user_command);
464 Serial.print(F(
" 0P-1N:"));
467 Serial.print(F(
" 2P-3N:"));
470 Serial.print(F(
" 4P-5N:"));
473 Serial.print(F(
" 6P-7N:"));
476 Serial.print(F(
" 1P-0N:"));
479 Serial.print(F(
" 3P-2N:"));
482 Serial.print(F(
" 5P-4N:"));
485 Serial.print(F(
" 7P-6N:"));
495 Serial.println(F(
" *************************"));
496 Serial.println(F(
" 0 = CH0"));
497 Serial.println(F(
" 1 = CH1"));
498 Serial.println(F(
" 2 = CH2"));
499 Serial.println(F(
" 3 = CH3"));
500 Serial.println(F(
" 4 = CH4"));
501 Serial.println(F(
" 5 = CH5"));
502 Serial.println(F(
" 6 = CH6"));
503 Serial.println(F(
" 7 = CH7"));
504 Serial.println(F(
" 8 = ALL"));
505 Serial.println(F(
" m = Main Menu"));
507 Serial.print(F(
" Enter a Command: "));
510 Serial.println(user_command);
511 if (user_command ==
'm')
514 switch (user_command)
517 Serial.println(F(
" CH0 selected"));
520 Serial.println(F(
" CH1 selected"));
523 Serial.println(F(
" CH2 selected"));
526 Serial.println(F(
" CH3 selected"));
529 Serial.println(F(
" CH4 selected"));
532 Serial.println(F(
" CH5 selected"));
535 Serial.println(F(
" CH6 selected"));
538 Serial.println(F(
" CH7 selected"));
541 Serial.println(F(
" All selected"));
544 Serial.println(F(
" Invalid Option"));
548 return(user_command);
static uint8_t print_user_command_single_ended()
Display selected single-ended channel.
unsigned char user_command
void LTC2308_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
static uint8_t adc_command
static void menu_4_sleep()
Put LTC2308 to sleep (low power)
Header File for Linduino Libraries and Demo Code.
#define LTC2308_UNIPOLAR_MODE
static void print_channel_selection(uint8_t menu)
Display selected differential channels.
static void setup()
Initialize Linduino.
#define LTC2308_NORMAL_MODE
static uint8_t single_ended_differential
LTC2308 Unipolar or Bipolar mode selection.
static uint8_t LTC2308_bits
Resolution (12 bits)
static uint8_t print_user_command_differential()
Display selected differential channels.
#define LTC2308_SLEEP_MODE
static void print_prompt()
Prints main menu.
#define LTC2308_DIFFERENTIAL_MODE
static void loop()
Repeats Linduino loop.
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.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
static void menu_1_read_input()
Read channels.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC2308_BIPOLAR_MODE
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
static int32_t display_code
static void print_title()
Prints the title block when program first starts.
float LTC2308_code_to_voltage(uint16_t adc_code, float vref, uint8_t uni_bipolar)
Calculates the LTC2308 input's unipolar voltage given the binary data and lsb weight.
static float LTC2308_vref
#define LTC2308_CS
Define the SPI CS pin.
static void menu_2_select_single_ended_differential()
Sets LTC2308 to Single-Ended or Differential.
#define LTC2308_SINGLE_ENDED_MODE
static void menu_3_select_uni_bipolar()
Select unipolar (0-REFCOMP) or bipolar (+/- 0.5 x REFCOMP) mode.
static uint8_t uni_bipolar
Default set for unipolar mode.
LTC2308: 16-bit 8-channel 100ksps ADC.