125 #define EEPROM_CAL_KEY_INT 0x5678 126 #define EEPROM_CAL_KEY_EXT 0x9ABC
131 #define REF_INTERNAL LTC2637_CMD_INTERNAL_REFERENCE 132 #define REF_EXTERNAL LTC2637_CMD_EXTERNAL_REFERENCE
135 #define STORED_REF_STATE_BASE EEPROM_CAL_STATUS_ADDRESS 136 #define INT_CAL_VALID_BASE STORED_REF_STATE_BASE + 2
137 #define INT_CAL_PARAMS_BASE INT_CAL_VALID_BASE + 2
138 #define EXT_CAL_VALID_BASE INT_CAL_PARAMS_BASE + 32
139 #define EXT_CAL_PARAMS_BASE EXT_CAL_VALID_BASE + 2
140 #define EXT_REF_V_BASE EXT_CAL_PARAMS_BASE + 32
191 Serial.begin(115200);
206 static int16_t selected_dac = 0;
210 if (Serial.available())
213 Serial.println(user_command);
216 switch (user_command)
241 Serial.println(
"Incorrect Option");
244 if (ack) Serial.println(
"I2C NACK received, check address\n");
245 Serial.println(
"\n*****************************************************************");
258 Serial.print(
"Select DAC to operate on (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H, 8=All): ");
261 Serial.println((
char) (*selected_dac + 0x41));
263 Serial.println(F(
"All"));
306 Serial.print(
"DAC ");
308 Serial.print((
char) (selected_dac + 0x41));
311 Serial.println(
" powered up!");
322 Serial.print(
"DAC ");
324 Serial.print((
char) (selected_dac + 0x41));
327 Serial.println(
" powered down!");
336 Serial.println(
"Select reference mode - 0 for Internal, 1 for External");
341 Serial.println(F(
"External reference mode selected"));
346 Serial.println(F(
"Internal reference mode selected"));
377 Serial.println(F(
"External reference mode set"));
378 Serial.print(
"Enter external reference voltage: ");
386 Serial.println(
"Internal reference mode set");
402 Serial.println(
"Internal reference voltage = 2.5 V");
413 Serial.println(
"Internal reference voltage = 4.096 V");
424 Serial.println(
"Internal reference voltage = 4.096 V");
435 Serial.println(
"Internal reference voltage = 2.5 V");
447 Serial.print(
"DAC ");
448 Serial.print((
char) (
'A' + i));
449 Serial.print(
" offset: ");
451 Serial.print(
" , lsb: ");
453 Serial.println(
" mv");
463 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code:"));
466 Serial.println(user_input);
480 Serial.print(F(
"Enter Desired DAC output voltage: "));
482 Serial.print(dac_voltage);
483 Serial.println(
" V");
493 Serial.println(
"Enter Desired DAC Code");
494 Serial.print(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
497 Serial.println(returncode, HEX);
506 Serial.println(F(
"*****************************************************************"));
507 Serial.println(F(
"* DC1534 Demonstration Program *"));
508 Serial.println(F(
"* *"));
509 Serial.println(F(
"* This program demonstrates how to send data to the LTC2637 *"));
510 Serial.println(F(
"* Octal 12/10/8-bit DAC found on the DC1534 demo board. *"));
511 Serial.println(F(
"* *"));
512 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
513 Serial.println(F(
"* *"));
514 Serial.println(F(
"*****************************************************************"));
520 Serial.println(F(
"\nCommand Summary:"));
521 Serial.println(F(
" 1-Select DAC"));
522 Serial.println(F(
" 2-Write to input register (no update)"));
523 Serial.println(F(
" 3-Write and update DAC"));
524 Serial.println(F(
" 4-Update / power up DAC"));
525 Serial.println(F(
" 5-Power down DAC"));
526 Serial.println(F(
" 6-Set reference mode"));
527 Serial.println(F(
" 7-Calibrate DAC"));
529 Serial.println(
"\nPresent Values:");
530 Serial.print(
" Selected DAC: ");
531 if (selected_dac != 8)
532 Serial.println((
char) (selected_dac + 0x41));
534 Serial.println(
"All");
535 Serial.print(
" DAC Reference: ");
537 Serial.println(
"Internal");
540 Serial.print(F(
"External "));
542 Serial.println(F(
"V reference, please verify"));
544 Serial.print(F(
"Enter a command:"));
554 uint16_t code1 = 0x0200;
555 uint16_t code2 = 0x0FFF;
559 Serial.print(
"Calibrating DAC ");
560 Serial.println((
char) (0x41 + index));
563 Serial.print(
"DAC code set to 0x");
564 Serial.println(code1, HEX);
565 Serial.print(
"Enter measured DAC voltage:");
567 Serial.print(voltage1, 6);
568 Serial.println(
" V");
571 Serial.print(
"DAC code set to 0x");
572 Serial.println(code2, HEX);
573 Serial.print(
"Enter measured DAC voltage:");
575 Serial.print(voltage2, 6);
576 Serial.println(
" V");
struct demo_board_type demo_board
Instantiate demo board structure.
static int16_t LTC2637_offset[9]
DAC offset - index 8 for "all DACs".
static float LTC2637_lsb[9]
The LTC2637 lsb - index 8 for "all DACs".
static int8_t calibrate_dac(uint8_t index)
Calibrate the selected DAC using a voltmeter.
unsigned char user_command
LTC2637: Octal 12-/10-/8-Bit I2C VOUT DACs with 10ppm/°C Reference.
static int8_t menu_3_write_and_update_dac(int16_t selected_dac)
Write data to DAC register (which updates output immediately)
void LTC2637_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2637_lsb, int16_t *LTC2637_offset)
Calculate the LTC2637 offset and LSB voltages given two measured voltages and their corresponding cod...
static uint8_t demo_board_connected
Set to 1 if the board is connected.
const uint8_t address_map[9]
Lookup table for DAC address.
Header File for Linduino Libraries and Demo Code.
static uint16_t get_voltage(float LTC2637_lsb, int16_t LTC2637_offset)
Get voltage from user input, calculate DAC code based on lsb, offset.
static void print_title()
Prints the title block when program first starts.
static int16_t prompt_voltage_or_code()
Prompt user to enter a voltage or digital code to send to DAC.
#define REF_INTERNAL
Stored reference state is Internal.
static int8_t menu_2_write_to_input_register(int16_t selected_dac)
Write data to input register, but do not update DAC output.
static uint8_t shift_count
The data align shift count.
#define LTC2637_CMD_UPDATE
static int8_t menu_7_calibrate_dacs()
Calibrate all DACs by measuring two known outputs.
static uint8_t reference_mode
Tells whether to set internal or external reference.
static int8_t menu_4_update_power_up_dac(int16_t selected_dac)
Update DAC with data that is stored in input register, power up if sleeping.
int8_t LTC2637_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write a 16-bit dac_code to the LTC2637.
#define LTC2637_CMD_WRITE
static float reference_voltage
Reference voltage, either internal or external.
static uint8_t num_of_channels
static int8_t restore_calibration()
Read stored calibration parameters from nonvolatile EEPROM on demo board.
uint16_t LTC2637_voltage_to_code(float dac_voltage, float LTC2637_lsb, int16_t LTC2637_offset)
Calculate a LTC2637 DAC code given the desired output voltage and DAC address (0-3) ...
static int8_t menu_6_set_reference_mode()
Set reference mode and store to EEPROM.
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 loop()
Repeats Linduino loop.
static int8_t menu_5_power_down_dac(int16_t selected_dac)
Power down DAC.
#define LTC2637_CMD_WRITE_UPDATE
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
static void setup()
Initialize Linduino.
char product_name[15]
LTC Product (LTC2654-L16)
#define LTC2637_CMD_POWER_DOWN
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
static void print_prompt(int16_t selected_dac)
Prints main menu.
#define REF_EXTERNAL
Stored reference state is External.
static int8_t menu_1_select_dac(int16_t *selected_dac)
Select which DAC to operate on.
#define LTC2637_I2C_ADDRESS