116 #define REF_INTERNAL LTC2636_CMD_INTERNAL_REFERENCE 117 #define REF_EXTERNAL LTC2636_CMD_EXTERNAL_REFERENCE
164 Serial.begin(115200);
178 static int16_t selected_dac = 0;
182 if (Serial.available())
185 Serial.println(user_command);
187 switch (user_command)
212 Serial.println(
"Incorrect Option");
215 Serial.println(
"\n*****************************************************************");
227 Serial.print(F(
"Select DAC to operate on (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H, 8=All): "));
230 Serial.println((
char) (*selected_dac + 0x41));
232 Serial.println(F(
"All"));
256 Serial.print(
"Code: ");
257 Serial.println(dac_code, HEX);
266 Serial.print(
"DAC ");
268 Serial.print((
char) (selected_dac + 0x41));
271 Serial.println(
" powered up!");
279 Serial.print(
"DAC ");
281 Serial.print((
char) (selected_dac + 0x41));
284 Serial.println(
" powered down!");
291 Serial.println(
"Select reference mode - 0 for Internal, 1 for External");
296 Serial.println(F(
"External reference mode selected"));
301 Serial.println(F(
"Internal reference mode selected"));
328 Serial.println(F(
"External reference mode set"));
329 Serial.print(
"Enter external reference voltage: ");
337 Serial.println(
"Internal reference mode set");
350 Serial.println(
"Internal reference voltage = 2.5 V");
361 Serial.println(
"Internal reference voltage = 4.096 V");
372 Serial.println(
"Internal reference voltage = 4.096 V");
383 Serial.println(
"Internal reference voltage = 4.096 V");
399 Serial.println(F(
"*****************************************************************"));
400 Serial.println(F(
"* DC1678 Demonstration Program *"));
401 Serial.println(F(
"* *"));
402 Serial.println(F(
"* This program demonstrates how to send data to the LTC2636 *"));
403 Serial.println(F(
"* quad 16/12-bit DAC found on the DC1678 demo board. *"));
404 Serial.println(F(
"* *"));
405 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
406 Serial.println(F(
"* *"));
407 Serial.println(F(
"*****************************************************************"));
413 Serial.println(F(
"\nCommand Summary:"));
414 Serial.println(F(
" 1-Select DAC"));
415 Serial.println(F(
" 2-Write to input register (no update)"));
416 Serial.println(F(
" 3-Write and update DAC"));
417 Serial.println(F(
" 4-Update / power up DAC"));
418 Serial.println(F(
" 5-Power down DAC"));
419 Serial.println(F(
" 6-Set reference mode"));
420 Serial.println(F(
" 7-Calibrate DAC"));
422 Serial.println(
"\nPresent Values:");
423 Serial.print(
" Selected DAC: ");
425 Serial.println((
char) (selected_dac + 0x41));
427 Serial.println(
"All");
428 Serial.print(
" DAC Reference: ");
430 Serial.println(
"Internal");
433 Serial.print(F(
"External "));
435 Serial.println(F(
"V reference, please verify"));
437 Serial.print(F(
"Enter a command: "));
446 Serial.print(F(
"Type 1 to enter voltage, 2 to enter code:"));
449 Serial.println(user_input);
463 Serial.print(F(
"Enter Desired DAC output voltage: "));
465 Serial.print(dac_voltage, 3);
466 Serial.println(
" V");
476 Serial.println(
"Enter Desired DAC Code");
477 Serial.print(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
480 Serial.println(returncode, HEX);
491 uint16_t code1 = 0x0200;
492 uint16_t code2 = 0x0FFF;
496 Serial.print(
"Calibrating DAC ");
497 Serial.println((
char) (0x41 + index));
500 Serial.print(
"DAC code set to 0x");
501 Serial.println(code1, HEX);
502 Serial.print(
"Enter measured DAC voltage:");
504 Serial.print(voltage1, 6);
505 Serial.println(
" V");
508 Serial.print(
"DAC code set to 0x");
509 Serial.println(code2, HEX);
510 Serial.print(
"Enter measured DAC voltage:");
512 Serial.print(voltage2, 6);
513 Serial.println(
" V");
#define LTC2636_CMD_WRITE_UPDATE
Write to input register n, update (power up) all.
struct demo_board_type demo_board
Instantiate demo board structure.
LTC2636: Octal 12-/10-/8-Bit SPI VOUT DACs with 10ppm/°C Reference.
static uint8_t shift_count
The data align shift count.
static float LTC2636_lsb[9]
The LTC2636 lsb - index 8 for "all DACs".
unsigned char user_command
static int16_t prompt_voltage_or_code()
Prompt user to enter a voltage or digital code to send to DAC.
static void menu_2_write_to_input_register(int16_t selected_dac)
Write data to input register, but do not update DAC output.
#define REF_INTERNAL
Stored reference state is Internal.
Header File for Linduino Libraries and Demo Code.
static void menu_3_write_and_update_dac(int16_t selected_dac)
Write data to DAC register (which updates output immediately)
static int8_t calibrate_dac(uint8_t index)
Calibrate the selected DAC using a voltmeter.
static uint8_t demo_board_connected
Set to 1 if the board is connected.
static void print_prompt(int16_t selected_dac)
Prints main menu.
static int8_t menu_7_calibrate_dacs()
Calibrate all DACs by measuring two known outputs.
#define LTC2636_CS
Define the SPI CS pin.
static int16_t LTC2636_offset[9]
DAC offset - index 8 for "all DACs".
static void menu_1_select_dac(int16_t *selected_dac)
Select which DAC to operate on.
static void print_title()
Prints the title block when program first starts.
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
static uint8_t num_of_channels
#define LTC2636_CMD_UPDATE
Update (power up) DAC register n.
static float reference_voltage
Reference voltage, either internal or external.
uint16_t LTC2636_voltage_to_code(float dac_voltage, float LTC2636_lsb, int16_t LTC2636_offset)
Calculate a LTC2636 DAC code given the desired output voltage, offset, and LSB value.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
#define LTC2636_CMD_WRITE
Write to input register n.
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 restore_calibration()
Read stored calibration parameters from nonvolatile EEPROM on demo board.
static void loop()
Repeats Linduino loop.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
void LTC2636_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2636_lsb, int16_t *LTC2636_offset)
Calculate the LTC2636 offset and LSB voltages given two measured voltages and their corresponding cod...
static uint16_t get_voltage(float LTC2636_lsb, int16_t LTC2636_offset)
Get voltage from user input, calculate DAC code based on lsb, offset.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
static void menu_6_set_reference_mode()
Set reference mode and store to EEPROM.
static void setup()
Initialize Linduino.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
char product_name[15]
LTC Product (LTC2654-L16)
static void menu_5_power_down_dac(int16_t selected_dac)
Power down DAC.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
const uint8_t address_map[9]
Lookup table for DAC address.
#define LTC2636_CMD_POWER_DOWN
Power down n.
#define REF_EXTERNAL
Stored reference state is External.
static uint8_t reference_mode
Tells whether to set internal or external reference.
void LTC2636_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2636.
static void menu_4_update_power_up_dac(int16_t selected_dac)
Update DAC with data that is stored in input register, power up if sleeping.