133 #define REF_EXTERNAL LTC2666_REF_DISABLE 134 #define REF_INTERNAL 0
167 struct data_struct_type
203 Serial.begin(115200);
217 static uint8_t selected_dac = 0;
219 if (Serial.available())
222 Serial.println(user_command);
223 Serial.print(F(
"\n"));
225 switch (user_command)
273 Serial.println(F(
"Incorrect Option"));
276 Serial.println(F(
"\n************************************************************"));
288 Serial.print(F(
"Select DAC to operate on (0 to 7, 8 for ALL DACs): "));
290 if (*selected_dac == 8)
291 Serial.println(F(
"All"));
293 Serial.println(*selected_dac);
306 if (selected_dac <= 7)
320 for (uint8_t
i = 0;
i <= 7 ;
i++)
343 if (selected_dac <= 7)
358 for (uint8_t
i = 0;
i <= 7 ;
i++)
375 if (selected_dac <= 7)
385 if (selected_dac <= 7)
395 Serial.println(F(
"0 - Power down the internal reference"));
396 Serial.println(F(
"1 - Power up the internal reference"));
398 if (user_command > 1)
400 if (user_command < 0)
403 if (user_command == 1)
407 Serial.println(F(
"Internal reference has been powered up"));
413 Serial.println(F(
"Internal reference has been powered down"));
422 Serial.println(F(
"0- 0V to 5V"));
423 Serial.println(F(
"1- 0V to 10V"));
424 Serial.println(F(
"2- -5V to 5V"));
425 Serial.println(F(
"3- -10V to 10V"));
426 Serial.println(F(
"4- -2.5V to 2.5V"));
427 Serial.print(F(
"Select a SoftSpan Range: "));
430 if (user_command > 4)
432 if (user_command < 0)
434 Serial.println(user_command);
436 if (selected_dac <= 7)
443 for (uint8_t
i = 0; 0 <= 7;
i++)
455 Serial.println(F(
"Toggle Select bit sets the register to be written for the corresponding DAC."));
456 Serial.println(F(
"0 for Register A or 1 for Register B."));
457 Serial.println(F(
"Note: DAC Update from Register B requires TGB = 1"));
458 Serial.println(F(
" DAC Update from Register A requires TCB = 0"));
459 Serial.print(F(
"Enter Toggle Select Byte as hex (0xMM) or binary (B10101010): "));
473 Serial.println(F(
"0- Disable Mux"));
474 Serial.println(F(
"1- Enable Mux"));
475 Serial.print(F(
"Enter a command: "));
478 if (user_command == 1)
480 Serial.print(F(
"Select MUX channel(0-CH0, 1-CH1,...,7-CH7, 8-REFLO, 9-REF, 10-TEMP Monitor, 11-V+, 12-V- : "));
483 if (user_command > 12)
485 if (user_command < 0)
488 Serial.println(user_command);
496 Serial.println(F(
"The MUX has been disabled"));
503 Serial.println(F(
"0- Disable Global Toggle"));
504 Serial.println(F(
"1- Enable Global Toggle"));
505 Serial.print(F(
"Enter a command: "));
508 if (user_command > 1)
510 if (user_command < 0)
512 Serial.println(user_command);
523 Serial.println(F(
"\n0- Enable Restoration"));
524 Serial.println(F(
"1- Disable Restoration"));
525 Serial.println(F(
"2- Store DAC Settings"));
530 Serial.println(F(
"Enabling EEPROM restoration"));
535 Serial.println(F(
"Disabling EEPROM restoration"));
542 Serial.println(F(
"Stored Settings to EEPROM"));
550 for (i=0; i <= 7; ++
i)
554 Serial.println(
"A voltage ramp was set to the LTC2666");
568 #define INTEGRATOR_CONTROL 2 // Pin to control integrator on settling time circuit 571 #define SETTLE_TRIGGER 3 // High to low edge close to DAC active edge. Can also be 573 #define SETTLE_CHANNEL 0 // Which DAC to test for settling (only one at a time to prevent 578 int16_t user_input, initial,
final;
580 Serial.println(F(
"Select test to run:"));
581 Serial.println(F(
"0: presently programmed DAC values"));
582 Serial.println(F(
"1: 0-5 rising"));
583 Serial.println(F(
"2: 0-5 falling"));
584 Serial.println(F(
"3: 0-10 rising"));
585 Serial.println(F(
"4: 0-10 falling"));
586 Serial.println(F(
"5: bipolar 10 rising"));
587 Serial.println(F(
"6: bipolar 10 falling"));
588 Serial.println(F(
"7: 0-5 1/4 to 3/4 scale, rising"));
589 Serial.println(F(
"8: 0-5 3/4 to 1/4 scale, falling"));
590 Serial.println(F(
"9: bipolar 5 rising"));
591 Serial.println(F(
"10: bipolar 5 falling"));
592 Serial.println(F(
"11: bipolar 2.5 rising"));
593 Serial.println(F(
"12: bipolar 2.5 falling"));
660 Serial.println(
"Using presently programmed DAC values");
672 Serial.println(
"Settling time test running, Press Enter to terminate.");
675 while (!Serial.available())
688 Serial.println(
"Exiting Settling time test.");
695 uint8_t
i, errorcount = 0;
697 Serial.println(F(
"Welcome to the LTC2666 Demo Board Test Program."));
698 Serial.print(F(
"Found board assembly type "));
701 Serial.println(F(
"Checking EEPROM contents..."));
709 if (strcmp(
"LTC2666-16,Cls,D2668,01,01,DC,DC2196A-A,--------",
ui_buffer))
711 Serial.println(F(
"FAILED EEPROM Contents"));
716 if (strcmp(
"LTC2666-12,Cls,D2668,01,01,DC,DC2196A-B,--------",
ui_buffer))
718 Serial.println(F(
"FAILED EEPROM Contents"));
726 Serial.println(F(
"EEPROM good!"));
728 Serial.println(F(
"Ensure all jumpers are in the LEFT position (INT ref, MSP0,1,2 = 1."));
729 Serial.println(F(
"Writing ramp of voltages to DAC outputs. Verify DAC0 = 0.10V, DAC1 = 0.20V,"));
730 Serial.println(F(
"DAC2 = 0.3V ... DAC7 = 0.8V. Type 1, enter when done."));
734 for (i=0; i <= 15; ++
i)
742 Serial.println(F(
"Setting SoftSpan range to +/-10V, DAC7 to -10V, and MUX to DAC7."));
743 Serial.println(F(
"Verify MUX output is between -9.95V and -10.05V"));
749 Serial.println(F(
"Type 1, enter when done."));
754 Serial.println(F(
"Verifying correct resolution LTC2666 installed"));
755 Serial.println(F(
"output set to 0V, press REL(delta) button on meter"));
756 Serial.println(F(
"Type 1, enter when done."));
763 Serial.println(F(
"16 bit device - verify output voltage is GREATER than 1mV"));
766 Serial.println(F(
"12 bit device - verify output voltage is LESS than 1mV"));
770 Serial.println(F(
"Type 1, enter when done."));
779 Serial.print(F(
"Testing readback by writing 0-10,000, NOP commands\n"));
781 for (i=0; i<=10000; ++
i)
787 Serial.print(F(
"Oops, got an error somewhere!"));
791 Serial.print(F(
"No errors!!"));
802 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code: "));
805 Serial.println(user_input);
809 if (selected_dac >= 8)
811 Serial.println(F(
"\nCaution! Voltage SoftSpan could be different for different DACs"));
812 Serial.println(F(
"Ensure All DACs can be set to desired voltages"));
813 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
814 Serial.print(F(
"Toggle Register Select Bits 0=A, 1 = B: 0b"));
821 if (selected_dac >= 8)
823 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
835 Serial.print(F(
"Enter Desired DAC output voltage: "));
837 Serial.print(dac_voltage);
838 Serial.println(F(
" V"));
841 if (selected_dac <= 7)
856 Serial.println(F(
"Enter Desired DAC Code"));
857 Serial.print(F(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): "));
859 Serial.print(F(
"0x"));
860 Serial.println(returncode, HEX);
869 Serial.println(F(
"*****************************************************************"));
870 Serial.println(F(
"* DC2196 Demonstration Program *"));
871 Serial.println(F(
"* *"));
872 Serial.println(F(
"* This program demonstrates how to send data to the LTC2666 *"));
873 Serial.println(F(
"* Eight Channel 16/12-bit DAC found on the DC2196 demo board. *"));
874 Serial.println(F(
"* *"));
875 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
876 Serial.println(F(
"* *"));
877 Serial.println(F(
"*****************************************************************"));
884 Serial.println(F(
"\nCommand Summary:"));
885 Serial.println(F(
" 1-Select DAC"));
886 Serial.println(F(
" 2-Write to input register (no update)"));
887 Serial.println(F(
" 3-Write and update DAC"));
888 Serial.println(F(
" 4-Update / power up DAC"));
889 Serial.println(F(
" 5-Power down DAC"));
890 Serial.println(F(
" 6-Set reference mode"));
891 Serial.println(F(
" 7-Set SoftSpan"));
892 Serial.println(F(
" 8-Toggle selected register"));
893 Serial.println(F(
" 9-Set Mux"));
894 Serial.println(F(
" 10-Global toggle bit settings"));
895 Serial.println(F(
" 11-Enable, disable, or store to EEPROM"));
896 Serial.println(F(
" 12-Voltage Ramp"));
897 Serial.println(F(
"\nPresent Values:"));
898 Serial.print(F(
" Selected DAC: "));
901 if (selected_dac >= 7 )
903 Serial.println(F(
"All"));
904 Serial.print(F(
" SoftSpan range: "));
906 Serial.print(F(
" V to "));
908 Serial.println(F(
" V"));
912 Serial.println(selected_dac);
913 Serial.print(F(
" SoftSpan range: "));
915 Serial.print(F(
" V to "));
917 Serial.println(F(
" V"));
919 Serial.print(F(
" Toggle Register: "));
921 for (uint8_t
i = 8;
i <= 15;
i++)
924 Serial.print(F(
"B"));
926 Serial.print(F(
"A"));
930 Serial.print(F(
" Global Toggle Bit: "));
933 Serial.print(F(
" Reference: "));
935 Serial.println(F(
"Internal"));
937 Serial.println(F(
"External"));
939 Serial.print(F(
"\nEnter a command: "));
958 for (uint8_t i = 0; i <= 7; i++)
962 for (uint8_t i = 0; i <= 7 ; i++)
968 for (uint8_t i = 0; i <= 7 ; i++)
981 Serial.println(F(
"DAC settings loaded from EEPROM"));
984 Serial.println(F(
"EEPROM data not found"));
struct demo_board_type demo_board
Instantiate demo board structure.
static void menu_14_demo_board_test()
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.
char option
Demo Circuit option (A)
#define LTC2666_CMD_MUX
Select MUX channel (controlled by 5 LSbs in data word)
#define LTC2666_CMD_NO_OPERATION
No operation.
#define LTC2666_CMD_GLOBAL_TOGGLE
Software toggle control via global toggle bit.
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.
#define LTC2666_SPAN_PLUS_MINUS_10V
unsigned char user_command
static void menu_10_global_toggle_settings()
Enable / Disable the global toggle bit.
#define EEPROM_I2C_ADDRESS
#define LTC2666_CMD_UPDATE_N
Update (power up) DAC register n.
#define REF_EXTERNAL
External mode.
uint16_t toggle_word
Toggle control word.
static void restore_dac_from_eeprom()
Read the alert settings from EEPROM.
#define LTC2666_SPAN_PLUS_MINUS_2V5
int16_t cal_key
The key that keeps track of the calibration.
static void print_prompt(int8_t selected_dac)
Prints main menu.
Header File for Linduino Libraries and Demo Code.
#define LTC2666_CMD_WRITE_ALL
Write to all input registers.
static void menu_12_voltage_ramp()
Sets a voltage ramp to all the channels.
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_1_select_dac(uint8_t *selected_dac)
Select which DAC to operate on.
LTC2666: 8-Channel SPI 16-/12-Bit +/-10V Vout SoftSpan DACs with 10ppm/C Max Reference.
const float LTC2666_MAX_OUTPUT[5]
static void setup()
Initialize Linduino.
uint8_t mux_state
Multiplexer address AND enable bit.
#define LTC2666_SPAN_0_TO_5V
#define LTC2666_SPAN_0_TO_10V
#define LTC2666_MUX_ENABLE
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 menu_7_set_softspan_range(uint8_t selected_dac)
Set SoftSpan Range.
const float LTC2666_MIN_OUTPUT[5]
int8_t LTC2666_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2666.
#define LTC2666_CMD_SPAN_ALL
Set span for all DACs.
#define LTC2666_CMD_POWER_DOWN_N
Power down n.
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 uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
#define LTC2666_CMD_SPAN
Write span to dac n.
#define LTC2666_CMD_WRITE_ALL_UPDATE_ALL
Write to all input reg, update all DACs.
static void loop()
Repeats Linduino loop.
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.
static void menu_3_write_and_update_dac(uint8_t selected_dac)
Write data to DAC register (which updates output immediately)
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.
static void menu_6_set_reference_mode()
Set reference mode.
#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.
#define INTEGRATOR_CONTROL
uint8_t soft_span_range[5]
SoftSpan range.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC2666_CMD_TOGGLE_SEL
Select which DACs can be toggled (via toggle pin or global toggle bit)
static void menu_2_write_to_input_register(uint8_t selected_dac)
Write data to input register, but do not update DAC output.
#define LTC2666_CMD_POWER_DOWN_ALL
Power down chip (all DAC's, MUX and reference)
static void menu_13_settling_test()
uint16_t dac_code_a[16]
DAC Register A.
#define LTC2666_CS
Define the SPI CS pin.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
static void menu_15_loopback_test()
static void menu_9_set_mux()
Enable / Disable and sets the channel for the MUX.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC2666_SPAN_PLUS_MINUS_5V
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
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.
char byte_array[sizeof(data_struct_type)]
Array used to store the structure.
uint16_t dac_code_b[16]
DAC Register B.
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 global_toggle_bit
Global toggle bit.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
static void print_title()
Prints the title block when program first starts.
#define LTC2666_CMD_CONFIG
Configure reference / toggle.
#define LTC2666_CMD_WRITE_N
Write to input register n.
#define LTC2666_CMD_UPDATE_ALL
Update all DACs.
#define LTC2666_CMD_WRITE_N_UPDATE_N
Write to input register n, update (power-up)
uint16_t LTC2666_voltage_to_code(float dac_voltage, float min_output, float max_output)
Calculate a LTC2666 DAC code given the desired output voltage and DAC address (0-3) ...
struct eeprom_data_union::data_struct_type data_struct
Name of structure.
static uint16_t get_voltage(uint8_t selected_dac)
Get voltage from user input, calculate DAC code based on lsb, offset.
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]