139 #define REF_EXTERNAL LTC2668_REF_DISABLE 140 #define REF_INTERNAL 0
173 struct data_struct_type
209 Serial.begin(115200);
223 static uint8_t selected_dac = 0;
225 if (Serial.available())
228 Serial.println(user_command);
229 Serial.print(F(
"\n"));
231 switch (user_command)
279 Serial.println(F(
"Incorrect Option"));
282 Serial.println(F(
"\n************************************************************"));
294 Serial.print(F(
"Select DAC to operate on (0 to 15, 16 for ALL DACs)"));
296 if (*selected_dac == 16)
297 Serial.println(F(
"All"));
299 Serial.println(*selected_dac);
312 if (selected_dac <= 15)
326 for (uint8_t
i = 0;
i <= 15 ;
i++)
349 if (selected_dac <= 15)
364 for (uint8_t
i = 0;
i <= 15 ;
i++)
381 if (selected_dac <= 15)
391 if (selected_dac <= 15)
401 Serial.println(F(
"0 - Power down the internal reference"));
402 Serial.println(F(
"1 - Power up the internal reference"));
404 if (user_command > 1)
406 if (user_command < 0)
409 if (user_command == 1)
413 Serial.println(F(
"Internal reference has been powered up"));
419 Serial.println(F(
"Internal reference has been powered down"));
428 Serial.println(F(
"0- 0V to 5V"));
429 Serial.println(F(
"1- 0V to 10V"));
430 Serial.println(F(
"2- -5V to 5V"));
431 Serial.println(F(
"3- -10V to 10V"));
432 Serial.println(F(
"4- -2.5V to 2.5V"));
433 Serial.print(F(
"Select a SoftSpan Range: "));
436 if (user_command > 4)
438 if (user_command < 0)
440 Serial.println(user_command);
442 if (selected_dac <= 15)
449 for (uint8_t
i = 0; 0 <= 15;
i++)
461 Serial.println(F(
"Toggle Select bit sets the register to be written for the corresponding DAC."));
462 Serial.println(F(
"0 for Register A or 1 for Register B."));
463 Serial.println(F(
"Note: DAC Update from Register B requires TGB = 1"));
464 Serial.println(F(
" DAC Update from Register A requires TCB = 0"));
465 Serial.print(F(
"Enter Toggle Select Byte as hex (0xMM) or binary (B10101010): "));
476 Serial.println(F(
"0- Disable Mux"));
477 Serial.println(F(
"1- Enable Mux"));
478 Serial.print(F(
"Enter a command: "));
481 if (user_command == 1)
483 Serial.print(F(
"Select MUX channel(0-CH0, 1-CH1,...15-CH15 : "));
486 if (user_command > 15)
488 if (user_command < 0);
491 Serial.println(user_command);
499 Serial.println(F(
"The MUX has been disabled"));
506 Serial.println(F(
"0- Disable Global Toggle"));
507 Serial.println(F(
"1- Enable Global Toggle"));
508 Serial.print(F(
"Enter a command: "));
511 if (user_command > 1)
513 if (user_command < 0)
515 Serial.println(user_command);
526 Serial.println(F(
"\n0- Enable Restoration"));
527 Serial.println(F(
"1- Disable Restoration"));
528 Serial.println(F(
"2- Store DAC Settings"));
533 Serial.println(F(
"Enabling EEPROM restoration"));
538 Serial.println(F(
"Disabling EEPROM restoration"));
545 Serial.println(F(
"Stored Settings to EEPROM"));
553 for (i=0; i <= 15; ++
i)
557 Serial.println(
"A voltage ramp was set to the LTC2668");
571 #define INTEGRATOR_CONTROL 2 // Pin to control integrator on settling time circuit 574 #define SETTLE_TRIGGER 3 // High to low edge close to DAC active edge. Can also be 576 #define SETTLE_CHANNEL 0 // Which DAC to test for settling (only one at a time to prevent 695 uint8_t
i, errorcount = 0;
697 Serial.println(F(
"Welcome to the LTC2668 Demo Board Test Program."));
698 Serial.print(F(
"Found board assembly type "));
701 Serial.println(F(
"Checking EEPROM contents..."));
709 if (strcmp(
"LTC2668-16,Cls,D2668,01,01,DC,DC2025A-A,--------",
ui_buffer))
711 Serial.println(F(
"FAILED EEPROM Contents"));
716 if (strcmp(
"LTC2668-12,Cls,D2668,01,01,DC,DC2025A-B,--------",
ui_buffer))
718 Serial.println(F(
"FAILED EEPROM Contents"));
725 Serial.println(F(
"EEPROM good!"));
727 Serial.println(F(
"Ensure all jumpers are in the LEFT position (INT ref, MSP0,1,2 = 1."));
728 Serial.println(F(
"Writing ramp of voltages to DAC outputs. Verify DAC0 = 0.10V, DAC1 = 0.20V,"));
729 Serial.println(F(
"DAC2 = 0.3V ... DAC15 = 1.60V. Type 1, enter when done."));
733 for (i=0; i <= 15; ++
i)
741 Serial.println(F(
"Setting SoftSpan range to +/-10V, DAC15 to -10V, and MUX to DAC15."));
742 Serial.println(F(
"Verify MUX output is between -9.95V and -10.05V"));
748 Serial.println(F(
"Type 1, enter when done."));
753 Serial.println(F(
"Verifying correct resolution LTC2668 installed"));
754 Serial.println(F(
"output set to 0V, press REL(delta) button on meter"));
755 Serial.println(F(
"Type 1, enter when done."));
762 Serial.println(F(
"16 bit device - verify output voltage is GREATER than 1mV"));
765 Serial.println(F(
"12 bit device - verify output voltage is LESS than 1mV"));
768 Serial.println(F(
"Type 1, enter when done."));
777 Serial.print(F(
"Testing readback by writing 0-10,000, NOP commands\n"));
779 for (i=0; i<=10000; ++
i)
785 Serial.print(F(
"Oops, got an error somewhere!"));
789 Serial.print(F(
"No errors!!"));
800 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code: "));
803 Serial.println(user_input);
807 if (selected_dac >= 16)
809 Serial.println(F(
"\nCaution! Voltage SoftSpan could be different for different DACs"));
810 Serial.println(F(
"Ensure All DACs can be set to desired voltages"));
811 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
812 Serial.print(F(
"Toggle Register Select Bits 0=A, 1 = B: 0b"));
819 if (selected_dac >= 16)
821 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
833 Serial.print(F(
"Enter Desired DAC output voltage: "));
835 Serial.print(dac_voltage);
836 Serial.println(F(
" V"));
839 if (selected_dac <= 15)
854 Serial.println(F(
"Enter Desired DAC Code"));
855 Serial.print(F(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): "));
857 Serial.print(F(
"0x"));
858 Serial.println(returncode, HEX);
867 Serial.println(F(
"*****************************************************************"));
868 Serial.println(F(
"* DC2025 Demonstration Program *"));
869 Serial.println(F(
"* *"));
870 Serial.println(F(
"* This program demonstrates how to send data to the LTC2668 *"));
871 Serial.println(F(
"* Sixteen Channel 16/12-bit DAC found on the DC2025 demo board. *"));
872 Serial.println(F(
"* *"));
873 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
874 Serial.println(F(
"* *"));
875 Serial.println(F(
"*****************************************************************"));
882 Serial.println(F(
"\nCommand Summary:"));
883 Serial.println(F(
" 1-Select DAC"));
884 Serial.println(F(
" 2-Write to input register (no update)"));
885 Serial.println(F(
" 3-Write and update DAC"));
886 Serial.println(F(
" 4-Update / power up DAC"));
887 Serial.println(F(
" 5-Power down DAC"));
888 Serial.println(F(
" 6-Set reference mode"));
889 Serial.println(F(
" 7-Set SoftSpan"));
890 Serial.println(F(
" 8-Toggle selected register"));
891 Serial.println(F(
" 9-Set Mux"));
892 Serial.println(F(
" 10-Global toggle bit settings"));
893 Serial.println(F(
" 11-Enable, disable, or store to EEPROM"));
894 Serial.println(F(
" 12-Voltage Ramp"));
895 Serial.println(F(
"\nPresent Values:"));
896 Serial.print(F(
" Selected DAC: "));
899 if (selected_dac >= 15 )
901 Serial.println(F(
"All"));
902 Serial.print(F(
" SoftSpan range: "));
904 Serial.print(F(
" V to "));
906 Serial.println(F(
" V"));
910 Serial.println(selected_dac);
911 Serial.print(F(
" SoftSpan range: "));
913 Serial.print(F(
" V to "));
915 Serial.println(F(
" V"));
917 Serial.print(F(
" Toggle Register: "));
918 for (uint8_t
i = 0;
i <= 15;
i++)
921 Serial.print(F(
"B"));
923 Serial.print(F(
"A"));
927 Serial.print(F(
" Global Toggle Bit: "));
930 Serial.print(F(
" Reference: "));
932 Serial.println(F(
"Internal"));
934 Serial.println(F(
"External"));
936 Serial.print(F(
"\nEnter a command: "));
955 for (uint8_t i = 0; i <= 15; i++)
959 for (uint8_t i = 0; i <= 15 ; i++)
965 for (uint8_t i = 0; i <= 15 ; i++)
978 Serial.println(F(
"DAC settings loaded from EEPROM"));
981 Serial.println(F(
"EEPROM data not found"));
struct demo_board_type demo_board
Instantiate demo board structure.
#define LTC2668_SPAN_PLUS_MINUS_10V
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.
static void menu_15_loopback_test()
#define LTC2668_CMD_CONFIG
Configure reference / toggle.
#define LTC2668_CMD_SPAN
Write span to dac n.
char option
Demo Circuit option (A)
#define LTC2668_CMD_NO_OPERATION
No operation.
#define LTC2668_CMD_MUX
Select MUX channel (controlled by 5 LSbs in data word)
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.
#define REF_INTERNAL
Internal mode.
unsigned char user_command
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
#define EEPROM_I2C_ADDRESS
#define LTC2668_CMD_WRITE_N
Write to input register n.
uint16_t toggle_word
Toggle control word.
#define LTC2668_SPAN_0_TO_10V
#define LTC2668_CMD_UPDATE_N
Update (power up) DAC register n.
static void menu_7_set_softspan_range(uint8_t selected_dac)
Set SoftSpan Range.
int16_t cal_key
The key that keeps track of the calibration.
Header File for Linduino Libraries and Demo Code.
static void menu_6_set_reference_mode()
Set reference mode.
static void menu_3_write_and_update_dac(uint8_t selected_dac)
Write data to DAC register (which updates output immediately)
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.
#define LTC2668_CMD_TOGGLE_SEL
Select which DACs can be toggled (via toggle pin or global toggle bit)
static void menu_1_select_dac(uint8_t *selected_dac)
Select which DAC to operate on.
int8_t LTC2668_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2668.
static void menu_14_demo_board_test()
static int16_t prompt_voltage_or_code(uint8_t selected_dac)
Prompt user to enter a voltage or digital code to send to DAC.
#define LTC2668_CMD_WRITE_ALL
Write to all input registers.
uint8_t mux_state
Multiplexer address AND enable bit.
static void menu_9_set_mux()
Enable / Disable and sets the channel for the MUX.
static void print_prompt(int8_t selected_dac)
Prints main menu.
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.
LTC2668: 16-Channel SPI 16-/12-Bit +/-10V Vout SoftSpan DACs with 10ppm/C Max Reference.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC2668_CMD_SPAN_ALL
Set span for all DACs.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
#define LTC2668_CMD_GLOBAL_TOGGLE
Software toggle control via global toggle bit.
#define LTC2668_SPAN_0_TO_5V
static void menu_5_power_down_dac(uint8_t selected_dac)
Power down DAC.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Used to manipulate EEPROM data.
#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.
const float LTC2668_MIN_OUTPUT[5]
static void menu_10_global_toggle_settings()
Enable / Disable the global toggle bit.
static void loop()
Repeats Linduino loop.
static void menu_8_toggle_select_word()
Enter toggle select word, which also sets the register that will be written if bit is 0...
static void restore_dac_from_eeprom()
Read the alert settings from EEPROM.
#define REF_EXTERNAL
External mode.
uint8_t soft_span_range[5]
SoftSpan range.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static void menu_2_write_to_input_register(uint8_t selected_dac)
Write data to input register, but do not update DAC output.
static void print_title()
Prints the title block when program first starts.
uint16_t dac_code_a[16]
DAC Register A.
static void menu_13_settling_test()
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.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
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 LTC2668_CMD_POWER_DOWN_ALL
Power down chip (all DAC's, MUX and reference)
#define LTC2668_CMD_WRITE_N_UPDATE_N
Write to input register n, update (power-up)
uint16_t LTC2668_voltage_to_code(float dac_voltage, float min_output, float max_output)
Calculate a LTC2668 DAC code given the desired output voltage and DAC address (0-3) ...
#define LTC2668_CMD_UPDATE_ALL
Update all DACs.
char byte_array[sizeof(data_struct_type)]
Array used to store the structure.
uint16_t dac_code_b[16]
DAC Register B.
static uint16_t get_voltage(uint8_t selected_dac)
Get voltage from user input, calculate DAC code based on lsb, offset.
uint8_t global_toggle_bit
Global toggle bit.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
const float LTC2668_MAX_OUTPUT[5]
struct eeprom_data_union::data_struct_type data_struct
Name of structure.
#define LTC2668_CMD_POWER_DOWN_N
Power down n.
static void setup()
Initialize Linduino.
static void menu_11_enable_disable_eeprom_restore()
Enable / Disable restoration of DAC values from EEPROM Use with caution - behaviour is undefined if y...
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...
char ui_buffer[UI_BUFFER_SIZE]
#define LTC2668_MUX_ENABLE
static void menu_12_voltage_ramp()
Sets a voltage ramp to all the channels.
#define LTC2668_CMD_WRITE_ALL_UPDATE_ALL
Write to all input reg, update all DACs.
#define LTC2668_CS
Define the SPI CS pin.