132 #define REF_EXTERNAL LTC2664_REF_DISABLE 133 #define REF_INTERNAL 0
164 struct data_struct_type
200 Serial.begin(115200);
215 static uint8_t selected_dac = 0;
217 if (Serial.available())
220 Serial.println(user_command);
221 Serial.print(F(
"\n"));
223 switch (user_command)
268 Serial.println(F(
"Incorrect Option"));
271 Serial.println(F(
"\n************************************************************"));
283 Serial.print(F(
"Select DAC to operate on (0 to 3, 4 for ALL DACs): "));
285 if (*selected_dac == 4)
286 Serial.println(F(
"All"));
288 Serial.println(*selected_dac);
301 if (selected_dac <= 3)
315 for (uint8_t
i = 0;
i <= 3 ;
i++)
338 if (selected_dac <= 3)
353 for (uint8_t
i = 0;
i <= 3 ;
i++)
370 if (selected_dac <= 3)
380 if (selected_dac <= 3)
390 Serial.println(F(
"0 - Power down the internal reference"));
391 Serial.println(F(
"1 - Power up the internal reference"));
393 if (user_command > 1)
395 if (user_command < 0)
398 if (user_command == 1)
402 Serial.println(F(
"Internal reference has been powered up"));
408 Serial.println(F(
"Internal reference has been powered down"));
417 Serial.println(F(
"0- 0V to 5V"));
418 Serial.println(F(
"1- 0V to 10V"));
419 Serial.println(F(
"2- -5V to 5V"));
420 Serial.println(F(
"3- -10V to 10V"));
421 Serial.println(F(
"4- -2.5V to 2.5V"));
422 Serial.print(F(
"Select a SoftSpan Range: "));
425 if (user_command > 4)
427 if (user_command < 0)
429 Serial.println(user_command);
431 if (selected_dac <= 3)
438 for (uint8_t
i = 0; 0 <= 3;
i++)
450 Serial.println(F(
"Toggle Select bit sets the register to be written for the corresponding DAC."));
451 Serial.println(F(
"0 for Register A or 1 for Register B."));
452 Serial.println(F(
"Note: DAC Update from Register B requires TGB = 1"));
453 Serial.println(F(
" DAC Update from Register A requires TCB = 0"));
454 Serial.print(F(
"Enter Toggle Select Byte as hex (0xM) or binary (B1010): "));
468 Serial.println(F(
"0- Disable Mux"));
469 Serial.println(F(
"1- Enable Mux"));
470 Serial.print(F(
"Enter a command: "));
473 if (user_command == 1)
475 Serial.print(F(
"Select MUX channel(0-MUXIN0, 1-VOUT0, 2-VOUT1, 3-MUXIN1, 4-MUXIN2, 5-VOUT2, 6-VOUT3, 7-MUXIN3, 8-REFLO, 9-REF, 10-TEMP Monitor, 11-V+, 12-V- : "));
478 if (user_command > 12)
480 if (user_command < 0)
483 Serial.println(user_command);
491 Serial.println(F(
"The MUX has been disabled"));
498 Serial.println(F(
"0- Disable Global Toggle"));
499 Serial.println(F(
"1- Enable Global Toggle"));
500 Serial.print(F(
"Enter a command: "));
503 if (user_command > 1)
505 if (user_command < 0)
507 Serial.println(user_command);
518 Serial.println(F(
"\n0- Enable Restoration"));
519 Serial.println(F(
"1- Disable Restoration"));
520 Serial.println(F(
"2- Store DAC Settings"));
525 Serial.println(F(
"Enabling EEPROM restoration"));
530 Serial.println(F(
"Disabling EEPROM restoration"));
537 Serial.println(F(
"Stored Settings to EEPROM"));
545 for (i=0; i <= 3; ++
i)
549 Serial.println(
"A voltage ramp was set to the LTC2664");
556 uint8_t
i, errorcount = 0;
558 Serial.println(F(
"Welcome to the LTC2664 Demo Board Test Program."));
559 Serial.print(F(
"Found board assembly type "));
562 Serial.println(F(
"Checking EEPROM contents..."));
570 if (strcmp(
"LTC2664-16,Cls,D2668,01,01,DC,DC2376A-A,--------",
ui_buffer))
572 Serial.println(F(
"FAILED EEPROM Contents"));
577 if (strcmp(
"LTC2664-12,Cls,D2668,01,01,DC,DC2376A-B,--------",
ui_buffer))
579 Serial.println(F(
"FAILED EEPROM Contents"));
586 Serial.println(F(
"EEPROM good!"));
588 Serial.println(F(
"Ensure all jumpers are in the LEFT position (INT ref, MSP0,1,2 = 1."));
589 Serial.println(F(
"Writing ramp of voltages to DAC outputs. Verify DAC0 = 0.10V, DAC1 = 0.20V,"));
590 Serial.println(F(
"DAC2 = 0.3V ... DAC7 = 0.8V. Type 1, enter when done."));
594 for (i=0; i <= 3; ++
i)
602 Serial.println(F(
"Setting SoftSpan range to +/-10V, DAC7 to -10V, and MUX to DAC7."));
603 Serial.println(F(
"Verify MUX output is between -9.95V and -10.05V"));
609 Serial.println(F(
"Type 1, enter when done."));
614 Serial.println(F(
"Verifying correct resolution LTC2664 installed"));
615 Serial.println(F(
"output set to 0V, press REL(delta) button on meter"));
616 Serial.println(F(
"Type 1, enter when done."));
623 Serial.println(F(
"16 bit device - verify output voltage is GREATER than 1mV"));
626 Serial.println(F(
"12 bit device - verify output voltage is LESS than 1mV"));
630 Serial.println(F(
"Type 1, enter when done."));
633 Serial.println(F(
"Connect MUXIN0 to REF, verify MUX output is between 2.4 and 2.6V."));
635 Serial.println(F(
"Type 1, enter when done."));
638 Serial.println(F(
"Connect MUXIN1 to REF, verify MUX output is between 2.4 and 2.6V."));
640 Serial.println(F(
"Type 1, enter when done."));
643 Serial.println(F(
"Connect MUXIN2 to REF, verify MUX output is between 2.4 and 2.6V."));
645 Serial.println(F(
"Type 1, enter when done."));
648 Serial.println(F(
"Connect MUXIN3 to REF, verify MUX output is between 2.4 and 2.6V."));
650 Serial.println(F(
"Type 1, enter when done."));
653 Serial.println(F(
"All Done! Returning to main menu..."));
661 Serial.print(F(
"Testing readback by writing 0-10,000, NOP commands\n"));
663 for (i=0; i<=10000; ++
i)
669 Serial.print(F(
"Oops, got an error somewhere!"));
673 Serial.print(F(
"No errors!!"));
684 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code: "));
687 Serial.println(user_input);
691 if (selected_dac >= 8)
693 Serial.println(F(
"\nCaution! Voltage SoftSpan could be different for different DACs"));
694 Serial.println(F(
"Ensure All DACs can be set to desired voltages"));
695 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
696 Serial.print(F(
"Toggle Register Select Bits 0=A, 1 = B: 0b"));
703 if (selected_dac >= 8)
705 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
717 Serial.print(F(
"Enter Desired DAC output voltage: "));
719 Serial.print(dac_voltage);
720 Serial.println(F(
" V"));
723 if (selected_dac <= 3)
738 Serial.println(F(
"Enter Desired DAC Code"));
739 Serial.print(F(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): "));
741 Serial.print(F(
"0x"));
742 Serial.println(returncode, HEX);
751 Serial.println(F(
"*****************************************************************"));
752 Serial.println(F(
"* DC2376 Demonstration Program *"));
753 Serial.println(F(
"* *"));
754 Serial.println(F(
"* This program demonstrates how to send data to the LTC2664 *"));
755 Serial.println(F(
"* Four Channel 16/12-bit DAC found on the DC2376 demo board. *"));
756 Serial.println(F(
"* *"));
757 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
758 Serial.println(F(
"* *"));
759 Serial.println(F(
"*****************************************************************"));
766 Serial.println(F(
"\nCommand Summary:"));
767 Serial.println(F(
" 1-Select DAC"));
768 Serial.println(F(
" 2-Write to input register (no update)"));
769 Serial.println(F(
" 3-Write and update DAC"));
770 Serial.println(F(
" 4-Update / power up DAC"));
771 Serial.println(F(
" 5-Power down DAC"));
772 Serial.println(F(
" 6-Set reference mode"));
773 Serial.println(F(
" 7-Set SoftSpan"));
774 Serial.println(F(
" 8-Toggle selected register"));
775 Serial.println(F(
" 9-Set Mux"));
776 Serial.println(F(
" 10-Global toggle bit settings"));
777 Serial.println(F(
" 11-Enable, disable, or store to EEPROM"));
778 Serial.println(F(
" 12-Voltage Ramp"));
779 Serial.println(F(
"\nPresent Values:"));
780 Serial.print(F(
" Selected DAC: "));
783 if (selected_dac >= 3 )
785 Serial.println(F(
"All"));
786 Serial.print(F(
" SoftSpan range: "));
788 Serial.print(F(
" V to "));
790 Serial.println(F(
" V"));
794 Serial.println(selected_dac);
795 Serial.print(F(
" SoftSpan range: "));
797 Serial.print(F(
" V to "));
799 Serial.println(F(
" V"));
801 Serial.print(F(
" Toggle Register: "));
802 Serial.print(F(
"\nEnter a command: "));
821 for (uint8_t i = 0; i <= 3; i++)
825 for (uint8_t i = 0; i <= 3 ; i++)
831 for (uint8_t i = 0; i <= 3 ; i++)
844 Serial.println(F(
"DAC settings loaded from EEPROM"));
847 Serial.println(F(
"EEPROM data not found"));
struct demo_board_type demo_board
Instantiate demo board structure.
uint8_t eeprom_read_byte_array(uint8_t i2c_address, char *data, uint16_t address, uint8_t num_bytes)
Read a data byte at address from the EEPROM with i2c_address.
#define LTC2664_CMD_WRITE_N_UPDATE_N
Write to input register n, update (power-up)
static void menu_5_power_down_dac(uint8_t selected_dac)
Power down DAC.
char option
Demo Circuit option (A)
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
#define EEPROM_I2C_ADDRESS
const float LTC2664_MIN_OUTPUT[5]
#define REF_EXTERNAL
External mode.
uint16_t toggle_word
Toggle control word.
#define LTC2664_CMD_SPAN_ALL
Set span for all DACs.
int16_t cal_key
The key that keeps track of the calibration.
#define LTC2664_CMD_NO_OPERATION
No operation.
static void menu_6_set_reference_mode()
Set reference mode.
#define LTC2664_CMD_POWER_DOWN_N
Power down n.
#define LTC2664_CMD_CONFIG
Configure reference / toggle.
Header File for Linduino Libraries and Demo Code.
#define LTC2664_CMD_UPDATE_ALL
Update all DACs.
#define LTC2664_SPAN_PLUS_MINUS_10V
static void loop()
Repeats Linduino loop.
uint8_t eeprom_write_byte_array(uint8_t i2c_address, char data[], uint16_t address, uint8_t num_bytes)
Write the data byte array to the EEPROM with i2c_address starting at EEPROM address.
static void menu_14_loopback_test()
static void print_prompt(int8_t selected_dac)
Prints main menu.
static uint16_t get_voltage(uint8_t selected_dac)
Get voltage from user input, calculate DAC code based on lsb, offset.
int8_t LTC2664_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2664.
#define LTC2664_CMD_WRITE_ALL_UPDATE_ALL
Write to all input reg, update all DACs.
static void menu_7_set_softspan_range(uint8_t selected_dac)
Set SoftSpan Range.
uint8_t mux_state
Multiplexer address AND enable bit.
LTC2664: 4-Channel SPI 16-/12-Bit +/-10V Vout SoftSpan DACs with 10ppm/C Max Reference.
#define LTC2664_CMD_GLOBAL_TOGGLE
Software toggle control via global toggle bit.
uint8_t reference_mode
Int.
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.
static void menu_8_toggle_select_word()
Enter toggle select word, which also sets the register that will be written if bit is 0...
#define LTC2664_CS
Define the SPI CS pin.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Used to manipulate EEPROM data.
#define LTC2664_CMD_SPAN
Write span to dac n.
#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.
uint16_t LTC2664_voltage_to_code(float dac_voltage, float min_output, float max_output)
Calculate a LTC2664 DAC code given the desired output voltage and DAC address (0-3) ...
uint8_t soft_span_range[5]
SoftSpan range.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
const float LTC2664_MAX_OUTPUT[5]
static void setup()
Initialize Linduino.
uint16_t dac_code_a[16]
DAC Register A.
static void menu_12_voltage_ramp()
Sets a voltage ramp to all the channels.
#define LTC2664_CMD_WRITE_ALL
Write to all input registers.
static void menu_10_global_toggle_settings()
Enable / Disable the global toggle bit.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define REF_INTERNAL
Internal mode.
static void menu_1_select_dac(uint8_t *selected_dac)
Select which DAC to operate on.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
#define LTC2664_CMD_WRITE_N
Write to input register n.
#define LTC2664_CMD_MUX
Select MUX channel (controlled by 5 LSbs in data word)
static void menu_9_set_mux()
Enable / Disable and sets the channel for the MUX.
#define LTC2664_CMD_UPDATE_N
Update (power up) DAC register n.
static void print_title()
Prints the title block when program first starts.
#define LTC2664_SPAN_0_TO_5V
static void menu_13_demo_board_test()
#define LTC2664_SPAN_0_TO_10V
char byte_array[sizeof(data_struct_type)]
Array used to store the structure.
uint16_t dac_code_b[16]
DAC Register B.
#define LTC2664_MUX_ENABLE
static void menu_3_write_and_update_dac(uint8_t selected_dac)
Write data to DAC register (which updates output immediately)
#define LTC2664_CMD_TOGGLE_SEL
Select which DACs can be toggled (via toggle pin or global toggle bit)
uint8_t global_toggle_bit
Global toggle bit.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
static void restore_dac_from_eeprom()
Read the alert settings from EEPROM.
static void menu_11_enable_disable_eeprom_restore()
Enable / Disable restoration of DAC values from EEPROM Use with caution - behaviour is undefined if y...
#define LTC2664_CMD_POWER_DOWN_ALL
Power down chip (all DAC's, MUX and reference)
struct eeprom_data_union::data_struct_type data_struct
Name of structure.
static int16_t prompt_voltage_or_code(uint8_t selected_dac)
Prompt user to enter a voltage or digital code to send to DAC.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
static void menu_2_write_to_input_register(uint8_t selected_dac)
Write data to input register, but do not update DAC output.
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
uint8_t read_quikeval_id_string(char *buffer)
Read the id string from the EEPROM, then parse the product name, demo board name, and demo board opti...
static void menu_4_update_power_up_dac(uint8_t selected_dac)
Update DAC with data that is stored in input register, power up if sleeping.
char ui_buffer[UI_BUFFER_SIZE]