158 Serial.begin(115200);
175 if (Serial.available())
178 if (user_command !=
'm')
179 Serial.println(user_command);
180 switch (user_command)
201 Serial.println(
"Incorrect Option");
205 Serial.println(F(
"*************************"));
224 Serial.println(F(
"Single-Ended, Unipolar mode:"));
226 Serial.println(F(
"Single-Ended, Bipolar mode:"));
228 Serial.println(F(
"*************************"));
230 Serial.println(F(
"0-CH0"));
231 Serial.println(F(
"1-CH1"));
232 Serial.println(F(
"2-CH2"));
233 Serial.println(F(
"3-CH3"));
234 Serial.println(F(
"4-CH4"));
235 Serial.println(F(
"5-CH5"));
236 Serial.println(F(
"6-CH6"));
237 Serial.println(F(
"7-CH7"));
238 Serial.println(F(
"8-ALL"));
239 Serial.println(F(
"m-Main Menu"));
240 Serial.print(F(
"Enter a Command: "));
243 if (user_command ==
'm')
246 Serial.println(user_command);
248 if (user_command == 8)
250 Serial.println(F(
"ALL"));
255 for (x = 0; x <= 7; x++)
263 Serial.print(F(
" ****"));
264 Serial.print(F(
"CH"));
266 Serial.print(F(
": "));
267 Serial.print(adc_voltage, 4);
268 Serial.println(F(
"V"));
276 Serial.print(F(
"ADC Command: B"));
277 Serial.println(adc_command, BIN);
281 Serial.print(F(
"Received Code: 0x"));
282 Serial.println(adc_code, HEX);
288 Serial.print(F(
" ****"));
289 Serial.print(F(
"CH"));
290 Serial.print(user_command);
291 Serial.print(F(
": "));
292 Serial.print(adc_voltage, 4);
293 Serial.println(F(
"V"));
310 Serial.println(F(
"Differential, Unipolar mode:"));
312 Serial.println(F(
"Differential, Bipolar mode:"));
314 Serial.println(F(
"*************************"));
315 Serial.println(F(
"0-0P-1N"));
316 Serial.println(F(
"1-2P-3N"));
317 Serial.println(F(
"2-4P-5N"));
318 Serial.println(F(
"3-6P-7N"));
319 Serial.println(F(
"4-1P-0N"));
320 Serial.println(F(
"5-3P-2N"));
321 Serial.println(F(
"6-5P_4N"));
322 Serial.println(F(
"7-7P-6N"));
323 Serial.println(F(
"8-ALL Even_P-Odd_N"));
324 Serial.println(F(
"9-ALL Odd_P-Even_N"));
325 Serial.println(F(
"m-Main Menu"));
326 Serial.println(F(
"Enter a Command: "));
330 if (user_command ==
'm')
332 Serial.println(user_command);
335 if ((user_command == 8) | (user_command == 9))
337 if (user_command == 8)
339 Serial.println(F(
"ALL Even_P-Odd_N"));
344 Serial.println(F(
"ALL Odd_P-Even_N"));
352 for (x = 0; x <= 3; x++)
361 Serial.print(F(
" ****"));
363 Serial.print(F(
": "));
364 Serial.print(adc_voltage, 4);
365 Serial.println(F(
"V"));
372 Serial.print(F(
"ADC Command: B"));
373 Serial.println(adc_command, BIN);
377 Serial.print(F(
"Received Code: 0x"));
378 Serial.println(adc_code, HEX);
384 Serial.print(F(
" ****"));
386 Serial.print(adc_voltage, 4);
387 Serial.println(F(
"V"));
404 Serial.println(F(
"Single-Ended (COM=CH7), Unipolar mode:"));
406 Serial.println(F(
"Single-Ended (COM=CH7), Bipolar mode:"));
409 Serial.println(F(
"*************************"));
411 Serial.println(F(
"CH7 as COM\n"));
412 Serial.println(F(
"0-CH0"));
413 Serial.println(F(
"1-CH1"));
414 Serial.println(F(
"2-CH2"));
415 Serial.println(F(
"3-CH3"));
416 Serial.println(F(
"4-CH4"));
417 Serial.println(F(
"5-CH5"));
418 Serial.println(F(
"6-CH6"));
419 Serial.println(F(
"7-ALL"));
420 Serial.println(F(
"m-Main Menu"));
421 Serial.print(F(
"Enter a Command: "));
424 if (user_command ==
'm')
427 Serial.println(user_command);
430 if (user_command == 7)
432 Serial.println(F(
"ALL with CH7 as COM"));
438 for (x = 0; x <= 6; x++)
447 Serial.print(F(
" ****"));
448 Serial.print(F(
"CH"));
450 Serial.print(F(
" with CH7 as COM: "));
451 Serial.print(adc_voltage, 4);
452 Serial.println(F(
"V"));
459 Serial.print(F(
"ADC Command: B"));
460 Serial.println(adc_command, BIN);
464 Serial.print(F(
"Received Code: 0x"));
465 Serial.println(adc_code, HEX);
471 Serial.print(F(
" ****"));
472 Serial.print(F(
"CH"));
473 Serial.print(user_command);
474 Serial.print(F(
": "));
475 Serial.print(adc_voltage, 4);
476 Serial.println(F(
"V"));
488 float zero_voltage = 0.0;
489 uint16_t zero_bipolar_code;
490 uint16_t zero_unipolar_code;
499 Serial.println(F(
"Apply 100mV to CH0 and connect CH1 to GND."));
500 Serial.println(F(
"Enter the measured input voltage for CH0:"));
502 Serial.println(zero_voltage, 8);
514 Serial.println(F(
"Apply ~4.00V input voltage to CH0."));
515 Serial.println(F(
"Enter the measured input voltage:"));
517 Serial.println(fs_voltage, 8);
526 Serial.print(F(
"ADC unipolar offset : "));
528 Serial.print(F(
"ADC bipolar offset : "));
530 Serial.print(F(
"ADC lsb : "));
532 Serial.println(F(
"nV (32-bits)"));
545 Serial.print(F(
"ADC Command: B"));
547 Serial.println(F(
"LTC1867 Is Now In Sleep Mode"));
548 Serial.println(F(
"Enter RETURN to exit Sleep Mode"));
558 Serial.println(F(
"\n0-Bipolar, 1=Unipolar"));
559 Serial.println(F(
"Enter a Command: "));
563 if (user_command == 1)
578 Serial.println(F(
"Calibration Stored to EEPROM"));
596 Serial.println(F(
"Calibration Restored"));
601 Serial.println(F(
"Calibration not found"));
610 Serial.println(F(
"*****************************************************************"));
611 Serial.println(F(
"* DC806A Demonstration Program *"));
612 Serial.println(F(
"* *"));
613 Serial.println(F(
"* This program demonstrates how to send data and receive data *"));
614 Serial.println(F(
"* from the 16-bit ADC. *"));
615 Serial.println(F(
"* *"));
616 Serial.println(F(
"* *"));
617 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
618 Serial.println(F(
"* *"));
619 Serial.println(F(
"*****************************************************************"));
626 Serial.println(F(
"1-Read Single-Ended "));
627 Serial.println(F(
"2-Read Differential"));
628 Serial.println(F(
"3-Read Single-Ended with Ch7 as COM"));
629 Serial.println(F(
"4-Calibration"));
630 Serial.println(F(
"5-Sleep Mode"));
631 Serial.println(F(
"6-Select Unipolar / Bipolar\n"));
632 Serial.println(F(
"Selected Uni / Bip mode:"));
634 Serial.println(F(
"Unipolar"));
636 Serial.println(F(
"Bipolar"));
638 Serial.print(F(
"Enter a command:"));
648 Serial.print(F(
"0P-1N"));
651 Serial.print(F(
"2P-3N"));
654 Serial.print(F(
"4P-5N"));
657 Serial.print(F(
"6P-7N"));
660 Serial.print(F(
"1P-0N"));
663 Serial.print(F(
"3P-2N"));
666 Serial.print(F(
"5P-4N"));
669 Serial.print(F(
"7P-6N"));
672 Serial.print(F(
": "));
const uint8_t BUILD_COMMAND_DIFF[8]
Lookup table to build the command for differential mode with the selected uni/bipolar mode...
static void loop()
Repeats Linduino loop.
static void setup()
Initialize Linduino.
uint8_t eeprom_read_int16(uint8_t i2c_address, int16_t *read_data, uint16_t address)
Read the two byte integer data from the EEPROM starting at address.
unsigned char user_command
static uint8_t adc_command
static uint8_t uni_bi_polar
The LTC1867 unipolar/bipolar mode selection.
#define EEPROM_I2C_ADDRESS
#define LTC1867_CS
Define the SPI CS pin.
static int32_t LTC1867_offset_unipolar_code
Ideal unipolar offset for a perfect part.
static void menu_3_read_single_ended_com7()
Read Channels in Single-Ended mode with Ch7 as COM.
Header File for Linduino Libraries and Demo Code.
static void menu_5_sleep()
Put LTC1867 to sleep (low power)
uint8_t eeprom_read_float(uint8_t i2c_address, float *read_data, uint16_t address)
Read the four byte float data from the EEPROM starting at address.
float LTC1867_unipolar_code_to_voltage(uint16_t adc_code, float LTC1867_lsb, int32_t LTC1867_offset_unipolar_code)
Calculates the LTC1867 input's unipolar voltage given the binary data and lsb weight.
static void menu_1_read_single_ended()
Read channels in single-ended mode.
uint8_t eeprom_write_int32(uint8_t i2c_address, int32_t write_data, uint16_t address)
Write the 4 byte long data to the EEPROM starting at address.
void LTC1867_cal_voltage(uint16_t zero_unipolar_code, uint16_t zero_bipolar_code, uint16_t fs_code, float zero_voltage, float fs_voltage, float *LTC1867_lsb, int32_t *LTC1867_offset_unipolar_code, int32_t *LTC1867_offset_bipolar_code)
Calibrate the offset and LSB voltage given two measured offset codes, and a full-scale voltage with t...
#define LTC1867_BIPOLAR_MODE
LTC1867: 16-bit 8-channel 200ksps ADC.
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_6_select_uni_bipolar()
Select unipolar (0-REFCOMP) or bipolar (+/- 0.5 x REFCOMP) mode.
static void menu_2_read_differential()
Read channels in differential mode.
uint8_t eeprom_write_float(uint8_t i2c_address, float write_data, uint16_t address)
Write the 4 byte float data to the EEPROM starting at address.
uint8_t eeprom_write_int16(uint8_t i2c_address, int16_t write_data, uint16_t address)
Write the 2 byte integer data to the EEPROM starting at address.
float LTC1867_bipolar_code_to_voltage(uint16_t adc_code, float LTC1867_lsb, int32_t LTC1867_offset_bipolar_code)
Calculates the LTC1867 input's bipolar voltage given the two's compliment data and lsb weight...
#define LTC1867_UNIPOLAR_MODE
static void print_prompt()
Prints main menu.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
#define EEPROM_CAL_STATUS_ADDRESS
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
static void print_title()
Prints the title block when program first starts.
void LTC1867_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC1867_SLEEP_MODE
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
uint8_t eeprom_read_int32(uint8_t i2c_address, int32_t *read_data, uint16_t address)
Read the four byte long data from the EEPROM starting at address.
static float LTC1867_lsb
Ideal LSB voltage for a perfect part.
static void store_calibration()
Store measured calibration parameters to nonvolatile EEPROM on demo board.
static void menu_4_calibrate()
Calibrate ADC given two known inputs @ return void.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
#define LTC1867_EXIT_SLEEP_MODE
static int8_t restore_calibration()
Read stored calibration parameters from nonvolatile EEPROM on demo board.
static void print_user_command(uint8_t menu)
Display selected differential channels.
const uint8_t BUILD_COMMAND_SINGLE_ENDED_COM7[7]
Lookup table to build the command for single-ended mode with channel 7 as common pin.
static int32_t LTC1867_offset_bipolar_code
Ideal bipolar offset for a perfect part.