128 #define REF_EXTERNAL LTC2662_REF_DISABLE 129 #define REF_INTERNAL 0
198 Serial.begin(115200);
212 uint8_t fault_reg = 0;
213 static uint8_t selected_dac = 0;
215 if (Serial.available())
218 Serial.println(user_command);
219 Serial.print(F(
"\n"));
221 switch (user_command)
263 Serial.println(F(
"Incorrect Option"));
267 Serial.println(F(
"\n************************************************************"));
279 Serial.print(F(
"Select DAC to operate on (0 to 4, 5 for ALL DACs)"));
281 if (*selected_dac == 5)
282 Serial.println(F(
"All"));
284 Serial.println(*selected_dac);
292 uint8_t fault_reg = 0;
299 if (selected_dac <= 4)
313 for (uint8_t
i = 0;
i <= 4 ;
i++)
332 uint8_t fault_reg = 0;
339 if (selected_dac <= 4)
354 for (uint8_t
i = 0;
i <= 4 ;
i++)
372 uint8_t fault_reg = 0;
374 if (selected_dac <= 4)
385 uint8_t fault_reg = 0;
387 if (selected_dac <= 4)
398 uint8_t fault_reg = 0;
400 Serial.println(F(
"0 - Power down the internal reference"));
401 Serial.println(F(
"1 - Power up the internal reference"));
403 if (user_command > 1)
405 if (user_command < 0)
408 if (user_command == 1)
412 Serial.println(F(
"Internal reference has been powered up"));
418 Serial.println(F(
"Internal reference has been powered down"));
428 uint8_t fault_reg = 0;
430 Serial.println(F(
"0- Hi-Z"));
431 Serial.println(F(
"1- 0mA to 3.125mA"));
432 Serial.println(F(
"2- 0mA to 6.25mA"));
433 Serial.println(F(
"3- 0mA to 12.5mA"));
434 Serial.println(F(
"4- 0mA to 25mA"));
435 Serial.println(F(
"5- 0mA to 50mA"));
436 Serial.println(F(
"6- 0mA to 100mA"));
437 Serial.println(F(
"7- 0mA to 200mA"));
438 Serial.println(F(
"8- Switch to V-"));
439 Serial.println(F(
"9- 0mA to 300mA"));
440 Serial.print(F(
"Select a SoftSpan Range: "));
443 if (user_command > 9)
445 if (user_command < 0)
447 Serial.println(user_command);
450 if (user_command == 9)
452 if (selected_dac <= 4)
459 for (uint8_t
i = 0;
i <= 4;
i++)
471 uint8_t fault_reg = 0;
473 Serial.println(F(
"Toggle Select bit sets the register to be written for the corresponding DAC."));
474 Serial.println(F(
"0 for Register A or 1 for Register B."));
475 Serial.println(F(
"Note: DAC Update from Register B requires TGB = 1"));
476 Serial.println(F(
" DAC Update from Register A requires TCB = 0"));
477 Serial.print(F(
"Enter Toggle Select Byte as hex (0xMM) or binary (B10101010): "));
490 uint8_t fault_reg = 0;
492 Serial.println(F(
"MUX Control:"));
493 Serial.println(F(
"0- Disable(Hi-Z)"));
494 Serial.println(F(
"1- OUT0 Current Mesurement"));
495 Serial.println(F(
"2- OUT1 Current Mesurement"));
496 Serial.println(F(
"3- OUT2 Current Mesurement"));
497 Serial.println(F(
"4- OUT3 Current Mesurement"));
498 Serial.println(F(
"5- OUT4 Current Mesurement"));
499 Serial.println(F(
"6- VCC"));
500 Serial.println(F(
"7- IOVCC"));
501 Serial.println(F(
"8- VREF"));
502 Serial.println(F(
"9- VREFLO"));
503 Serial.println(F(
"10- Die Temperatur"));
504 Serial.println(F(
"16- VDD0"));
505 Serial.println(F(
"17- VDD1"));
506 Serial.println(F(
"18- VDD2"));
507 Serial.println(F(
"19- VDD3"));
508 Serial.println(F(
"20- VDD4"));
509 Serial.println(F(
"21- V+"));
510 Serial.println(F(
"22- V-"));
511 Serial.println(F(
"23- GND"));
512 Serial.println(F(
"24- OUT0 Pin Voltage"));
513 Serial.println(F(
"25- OUT1 Pin Voltage"));
514 Serial.println(F(
"26- OUT2 Pin Voltage"));
515 Serial.println(F(
"27- OUT3 Pin Voltage"));
516 Serial.println(F(
"28- OUT4 Pin Voltage"));
517 Serial.print(F(
"Enter a command: "));
521 if (user_command < 0)
523 user_command = user_command & 0x1F;
524 Serial.println(user_command);
534 uint8_t fault_reg = 0;
535 Serial.println(F(
"0- Disable Global Toggle"));
536 Serial.println(F(
"1- Enable Global Toggle"));
537 Serial.print(F(
"Enter a command: "));
540 if (user_command > 1)
542 if (user_command < 0)
544 Serial.println(user_command);
556 Serial.println(F(
"\n0- Enable Restoration"));
557 Serial.println(F(
"1- Disable Restoration"));
558 Serial.println(F(
"2- Store DAC Settings"));
563 Serial.println(F(
"Enabling EEPROM restoration"));
568 Serial.println(F(
"Disabling EEPROM restoration"));
575 Serial.println(F(
"Stored Settings to EEPROM"));
585 uint8_t
i, errorcount = 0;
587 Serial.println(F(
"Welcome to the LTC2662 Demo Board Test Program."));
588 Serial.print(F(
"Found board assembly type "));
591 Serial.println(F(
"Checking EEPROM contents..."));
599 if (strcmp(
"LTC2662-16,Cls,D2662,01,01,DC,DC2692A-A,--------",
ui_buffer))
601 Serial.println(F(
"FAILED EEPROM Contents"));
606 if (strcmp(
"LTC2662-12,Cls,D2662,01,01,DC,DC2692A-B,--------",
ui_buffer))
608 Serial.println(F(
"FAILED EEPROM Contents"));
614 Serial.println(F(
"EEPROM good!"));
616 Serial.println(F(
"Ensure all jumpers are in the Upper position (INT ref, VDDx=V+"));
617 Serial.println(F(
"Writing ramp of currents to DAC outputs. Verify DAC0 = 10mA, DAC1 = 20mA,"));
618 Serial.println(F(
"DAC2 = 30mA ... DAC4 = 50MAV. Type 1, enter when done."));
622 for (i=0; i <= 4; ++
i)
630 Serial.println(F(
"Setting MUX to VREF."));
631 Serial.println(F(
"Verify MUX output is between 1.24V and 1.26V"));
636 Serial.println(F(
"Type 1, enter when done."));
639 Serial.println(F(
"Remove the load from OUT0"));
640 Serial.println(F(
"The Fault LED should light up"));
641 Serial.println(F(
"Type 1, enter when done."));
652 Serial.print(F(
"Type 1 to enter current, 2 to enter code: "));
655 Serial.println(user_input);
659 if (selected_dac >= 5)
661 Serial.println(F(
"\nCaution! current SoftSpan could be different for different DACs"));
662 Serial.println(F(
"Ensure All DACs can be set to desired currents"));
663 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
664 Serial.print(F(
"Toggle Register Select Bits 0=A, 1 = B: 0b"));
671 if (selected_dac >= 5)
673 Serial.println(F(
"DAC 0 is used for SoftSpan values for all DACs."));
685 Serial.print(F(
"Enter Desired DAC output current: "));
687 Serial.print(dac_current);
688 Serial.println(F(
" mA"));
691 if (selected_dac <= 4)
714 Serial.println(F(
"Enter Desired DAC Code"));
715 Serial.print(F(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): "));
717 Serial.print(F(
"0x"));
718 Serial.println(returncode, HEX);
727 Serial.println(F(
"*****************************************************************"));
728 Serial.println(F(
"* DC2692 Demonstration Program *"));
729 Serial.println(F(
"* *"));
730 Serial.println(F(
"* This program demonstrates how to send data to the LTC2662 *"));
731 Serial.println(F(
"* five Channel 16/12-bit DAC found on the DC2692 demo board. *"));
732 Serial.println(F(
"* *"));
733 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
734 Serial.println(F(
"* *"));
735 Serial.println(F(
"*****************************************************************"));
742 Serial.println(F(
"\nCommand Summary:"));
743 Serial.println(F(
" 1-Select DAC"));
744 Serial.println(F(
" 2-Write to input register (no update)"));
745 Serial.println(F(
" 3-Write and update DAC"));
746 Serial.println(F(
" 4-Update / power up DAC"));
747 Serial.println(F(
" 5-Power down DAC"));
748 Serial.println(F(
" 6-Set reference mode"));
749 Serial.println(F(
" 7-Set SoftSpan"));
750 Serial.println(F(
" 8-Toggle selected register"));
751 Serial.println(F(
" 9-Set Mux"));
752 Serial.println(F(
" 10-Global toggle bit settings"));
753 Serial.println(F(
" 11-Enable, disable, or store to EEPROM"));
754 Serial.println(F(
"\nPresent Values:"));
755 Serial.print(F(
" Selected DAC: "));
758 if (selected_dac >= 4 )
760 Serial.println(F(
"All"));
761 Serial.print(F(
" SoftSpan range: "));
763 Serial.println(F(
"Hi-Z"));
765 Serial.println(F(
"Switch to V-"));
768 Serial.print(F(
"0 mA to "));
770 Serial.println(F(
" mA"));
775 Serial.println(selected_dac);
776 Serial.print(F(
" SoftSpan range: "));
778 Serial.println(F(
"Hi-Z"));
780 Serial.println(F(
"Switch to V-"));
783 Serial.print(F(
"0 mA to "));
788 Serial.println(F(
" mA"));
791 Serial.print(F(
" Toggle Register: "));
792 for (uint8_t
i = 0;
i <= 4;
i++)
795 Serial.print(F(
"B"));
797 Serial.print(F(
"A"));
801 Serial.print(F(
" Global Toggle Bit: "));
804 Serial.print(F(
" Reference: "));
806 Serial.println(F(
"Internal"));
808 Serial.println(F(
"External"));
810 Serial.print(F(
"\nEnter a command: "));
829 for (uint8_t i = 0; i <= 15; i++)
833 for (uint8_t i = 0; i <= 15 ; i++)
839 for (uint8_t i = 0; i <= 15 ; i++)
852 Serial.println(F(
"DAC settings loaded from EEPROM"));
855 Serial.println(F(
"EEPROM data not found"));
862 Serial.println(F(
"******** Open-Circuit detected on OUT0 ********"));
864 Serial.println(F(
"******** Open-Circuit detected on OUT1 ********"));
866 Serial.println(F(
"******** Open-Circuit detected on OUT2 ********"));
868 Serial.println(F(
"******** Open-Circuit detected on OUT3 ********"));
870 Serial.println(F(
"******** Open-Circuit detected on OUT4 ********"));
872 Serial.println(F(
"******** Over Temperature. Die > 160 C ********"));
874 Serial.println(F(
"******** 10V Power Limit Exceeded on VDD to IOUT ********"));
876 Serial.println(F(
"******** Invalid SPI Sequence Length ********"));
892 #define INTEGRATOR_CONTROL 2 // Pin to control integrator on settling time circuit 895 #define SETTLE_TRIGGER 3 // High to low edge close to DAC active edge. Can also be 900 int16_t user_input, initial,
final;
902 int8_t settle_channel;
904 Serial.println(F(
"Select test to run:"));
905 Serial.println(F(
"0: presently programmed DAC values"));
906 Serial.println(F(
"1: 0-200mA rising, CH1"));
907 Serial.println(F(
"2: 200mA-0 falling, CH1"));
908 Serial.println(F(
"3: 145mA-155mA rising, CH1"));
909 Serial.println(F(
"4: 155mA-145mA falling, CH1"));
910 Serial.println(F(
"5: 0-3.125mA rising, CH3"));
911 Serial.println(F(
"6: 3.125-0 falling, CH3"));
954 Serial.println(
"Using presently programmed DAC values");
964 Serial.println(
"Settling time test running, send any character to terminate.");
967 while (!Serial.available())
980 Serial.println(
"Exiting Settling time test.");
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.
char option
Demo Circuit option (A)
static void print_title()
Prints the title block when program first starts.
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 INTEGRATOR_CONTROL
unsigned char user_command
#define LTC2662_CMD_UPDATE_ALL
Update all DACs.
#define EEPROM_I2C_ADDRESS
static uint8_t menu_10_global_toggle_settings()
Enable / Disable the global toggle bit.
#define REF_EXTERNAL
External mode.
int8_t LTC2662_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2662.
uint16_t toggle_word
Toggle control word.
int16_t cal_key
The key that keeps track of the calibration.
#define LTC2662_CMD_MUX
Select MUX channel (controlled by 5 LSbs in data word)
#define LTC2662_CMD_GLOBAL_TOGGLE
Software toggle control via global toggle bit.
static void menu_14_demo_board_test()
#define LTC2662_CMD_SPAN
Write span to dac n.
Header File for Linduino Libraries and Demo Code.
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
static uint16_t get_current(uint8_t selected_dac)
Get current from user input, calculate DAC code based on lsb, offset.
static uint8_t menu_4_update_power_up_dac(uint8_t selected_dac)
Update DAC with data that is stored in input register, power up if sleeping.
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 loop()
Repeats Linduino loop.
#define LTC2662_SPAN_100MA
#define LTC2662_CMD_CONFIG
Configure reference / toggle.
#define LTC2662_CMD_WRITE_ALL_UPDATE_ALL
Write to all input reg, update all DACs.
static uint8_t menu_8_toggle_select_word()
Enter toggle select word, which also sets the register that will be written if bit is 0...
#define REF_INTERNAL
Internal mode.
#define LTC2662_CMD_UPDATE_N
Update (power up) DAC register n.
uint8_t mux_state
Multiplexer address AND enable bit.
#define LTC2662_SPAN_200MA
const float LTC2662_MAX_OUTPUT[10]
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 int16_t prompt_current_or_code(uint8_t selected_dac)
Prompt user to enter a current or digital code to send to DAC.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
#define LTC2662_CMD_SPAN_ALL
Set span for all DACs.
static void menu_11_enable_disable_eeprom_restore()
Enable / Disable restoration of DAC values from EEPROM Use with caution - behaviour is undefined if y...
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.
#define LTC2662_CMD_WRITE_N_UPDATE_N
Write to input register n, update (power-up)
static uint8_t menu_5_power_down_dac(uint8_t selected_dac)
Power down DAC.
#define LTC2662_SPAN_3_125MA
uint8_t soft_span_range[5]
SoftSpan range.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
LTC2662: 5-Channel 16-/12-Bit 300mA SoftSpan Current Source DACs.
uint16_t dac_code_a[16]
DAC Register A.
static uint8_t menu_3_write_and_update_dac(uint8_t selected_dac)
Write data to DAC register (which updates output immediately)
uint16_t LTC2662_current_to_code(float dac_current, float max_output)
Calculate a LTC2662 DAC code given the desired output current.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC2662_CMD_TOGGLE_SEL
Select which DACs can be toggled (via toggle pin or global toggle bit)
static uint8_t menu_7_set_softspan_range(uint8_t selected_dac)
Set SoftSpan Range.
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...
char byte_array[sizeof(data_struct_type)]
Array used to store the structure.
uint16_t dac_code_b[16]
DAC Register B.
#define LTC2662_CS
Define the SPI CS pin.
static void display_fault(uint8_t fault)
Display fault conditions.
uint8_t global_toggle_bit
Global toggle bit.
static void menu_13_settling_test()
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
static uint8_t menu_6_set_reference_mode()
Set reference mode.
#define LTC2662_CMD_WRITE_N
Write to input register n.
static void restore_dac_from_eeprom()
Read the alert settings from EEPROM.
struct eeprom_data_union::data_struct_type data_struct
Name of structure.
static uint8_t menu_9_set_mux()
Sets the channel for the MUX.
#define LTC2662_CMD_WRITE_ALL
Write to all input registers.
static void setup()
Initialize Linduino.
static uint8_t menu_2_write_to_input_register(uint8_t selected_dac)
Write data to input register, but do not update DAC output.
#define LTC2662_CMD_POWER_DOWN_N
Power down n.
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 LTC2662_CMD_POWER_DOWN_ALL
Power down chip (all DAC's, MUX and reference)
static void print_prompt(int8_t selected_dac)
Prints main menu.
static void menu_1_select_dac(uint8_t *selected_dac)
Select which DAC to operate on.