LTC2627 - 12-Bit Dual Rail-to-Rail with I²C Interface

Features

  • Smallest Pin-Compatible Dual DACs:
    LTC2607: 16 Bits
    LTC2617: 14 Bits
    LTC2627: 12 Bits
  • Guaranteed Monotonic Over Temperature
  • 27 Selectable Addresses
  • 400kHz I2C Interface
  • Wide 2.7V to 5.5V Supply Range
  • Low Power Operation: 260μA per DAC at 3V
  • Power Down to 1μA, Max
  • High Rail-to-Rail Output Drive (±15mA, Min)
  • Ultralow Crosstalk (30μV)
  • Double-Buffered Data Latches
  • Asynchronous DAC Update Pin
  • LTC2607/LTC2617/LTC2627: Power-On Reset to Zero Scale
  • LTC2607-1/LTC2617-1/LTC2627-1: Power-On Reset to Mid-Scale
  • Tiny (3mm × 4mm) 12-Lead DFN Package
Designed for Automotive and Transportation Applications
AEC-Q100 generic family data available for specific packages


Typical Application

LTC2627 Typical Application
LTC2627 Typical Application

Description

The LTC2607/LTC2617/LTC2627 are dual 16-, 14- and 12-bit, 2.7V to 5.5V rail-to-rail voltage output DACs in a 12-lead DFN package. They have built-in high performance output buffers and are guaranteed monotonic.

These parts establish new board-density benchmarks for 16- and 14-bit DACs and advance performance standards for output drive and load regulation in single-supply, voltage-output DACs.

The parts use a 2-wire, I2C compatible serial interface. The LTC2607/LTC2617/LTC2627 operate in both the standard mode (clock rate of 100kHz) and the fast mode (clock rate of 400kHz). An asynchronous DAC update pin (LDAC) is also included.

The LTC2607/LTC2617/LTC2627 incorporate a power-on reset circuit. During power-up, the voltage outputs rise less than 10mV above zero scale; and after power-up, they stay at zero scale until a valid write and update take place. The power-on reset circuit resets the LTC2607-1/LTC2617-1/ LTC2627-1 to mid-scale. The voltage outputs stay at midscale until a valid write and update takes place.

Packaging

CAD Symbols and Footprints: The downloadable Zip file below contains the schematic symbol and PCB footprints.

For complete and up to date package information and drawings, please refer to our packaging page

Part Number Package Code Temp Package
Drawing
RoHS
LTC2627CDE-1#PBF 4x3 DFN-12 DE/UE C 05-08-1695 Yes
LTC2627CDE-1#TRPBF 4x3 DFN-12 DE/UE C 05-08-1695 Yes
LTC2627CDE#PBF 4x3 DFN-12 DE/UE C 05-08-1695 Yes
LTC2627CDE#TRPBF 4x3 DFN-12 DE/UE C 05-08-1695 Yes
LTC2627IDE-1#PBF 4x3 DFN-12 DE/UE I 05-08-1695 Yes
LTC2627IDE-1#TRPBF 4x3 DFN-12 DE/UE I 05-08-1695 Yes
LTC2627IDE#PBF 4x3 DFN-12 DE/UE I 05-08-1695 Yes
LTC2627IDE#TRPBF 4x3 DFN-12 DE/UE I 05-08-1695 Yes


LTC2627 Package Drawing

Order Info

  • Part numbers ending in PBF are lead free. Solder plated terminal finish (SnPb) versions are non-standard and special terms and conditions and pricing applies if available. Please contact LTC marketing for information.
  • Part numbers containing TR or TRM are shipped in tape and reel or 500 unit mini tape and reel, respectively
  • Please refer to our general ordering information or the product datasheet for more details

Package Variations and Pricing

Part Number Package Temp Price
(1-99)
Price
(1k)*
RoHS
LTC2627CDE-1#PBF 4x3 DFN-12 C $4.39 $3.08 Yes
LTC2627CDE-1#TRPBF 4x3 DFN-12 C $3.14 Yes
LTC2627CDE#PBF 4x3 DFN-12 C $4.39 $3.08 Yes
LTC2627CDE#TRPBF 4x3 DFN-12 C $3.14 Yes
LTC2627IDE-1#PBF 4x3 DFN-12 I $5.29 $3.70 Yes
LTC2627IDE-1#TRPBF 4x3 DFN-12 I $3.76 Yes
LTC2627IDE#PBF 4x3 DFN-12 I $5.29 $3.70 Yes
LTC2627IDE#TRPBF 4x3 DFN-12 I $3.76 Yes
Buy NowRequest Samples
* The USA list pricing shown is for BUDGETARY USE ONLY, shown in United States dollars (FOB USA per unit for the stated volume), and is subject to change. International prices may differ due to local duties, taxes, fees and exchange rates. For volume-specific price or delivery quotes, please contact your local Linear Technology sales office or authorized distributor.

Demo Boards

Linear Technology offers many demo boards free of charge to qualified customers. Contact your local sales office or distributor to inquire about a demo board. Certain demo boards are also available for sale via credit card on this website. Demo boards are for evaluation purposes only. It remains the customer’s responsibility to verify proper and reliable operation in the actual end application.

Click here to view our complete list of demo boards

Designed for Automotive and Transportation Applications

Please contact your local sales representative for more information regarding reliability reports and AEC-Q100 data or to inquire about parts that are not included. For more information, view our Automotive and Transportation page

Part Number Package Temp Price
(1-99)
Price
(1k)*
RoHS
LTC2627IDE-1#PBF 4x3 DFN-12 I $5.29 $3.70 Yes
LTC2627IDE-1#TRPBF 4x3 DFN-12 I $3.76 Yes
LTC2627IDE#PBF 4x3 DFN-12 I $5.29 $3.70 Yes
LTC2627IDE#TRPBF 4x3 DFN-12 I $3.76 Yes
Buy NowRequest Samples
* The USA list pricing shown is for BUDGETARY USE ONLY, shown in United States dollars (FOB USA per unit for the stated volume), and is subject to change. International prices may differ due to local duties, taxes, fees and exchange rates. For volume-specific price or delivery quotes, please contact your local Linear Technology sales office or authorized distributor.

Applications

  • Mobile Communications
  • Process Control and Industrial Automation
  • Instrumentation
  • Automatic Test Equipment

Product Notifications

Please login to your MyLinear account for notifications of datasheet updates, new document releases and LTspice model announcements for your favorite products. If you do not have a MyLinear account you may Sign Up Now.

Forgot your password? Click here.
Need help? Email mylinear@linear.com with questions and comments.

Design Tools

Linduino

Linduino is an Arduino compatible platform for developing and distributing firmware libraries and code for SPI and I²C-compatible integrated circuits. The Linduino One board interfaces to more than 300 QuikEval demonstration cards, supporting a variety of product types including analog-to-digital converters (ADCs)digital-to-analog converters (DACs)power monitors, and more. Firmware libraries for individual devices are written in C and designed to be portable to a wide variety of processors and microcontrollers. Each library has a demonstration program that can be uploaded to the Linduino One platform to allow the circuit and software to be quickly and easily verified.

Click here for more information on Linduino

Code

Linduino is Linear Technology's Arduino compatible system for developing and distributing firmware libraries and example code for Linear Technology’s integrated circuits. The code below can be downloaded or copied and pasted into your project. Please visit the Linduino Home Page for demo board, manual and setup information.

This part is Family Supported: There is example code available for a part in this family. The code may require some changes to work with this specific part, however it still provides many good examples of how certain interactions should take place. The code below may rely on other drivers available in the full library.

Download LTC2607 - DC934A Linduino .INO File

/*!
Linear Technology DC934 Demonstration Board.
LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface

Linear Technology DC936 Demonstration Board.
LTC2609: Quad 16-/14-/12-Bit Rail-to-Rail DACs with I²C Interface.

Linear Technology DC812 Demonstration Board.
LTC2606: 16-Bit Rail-to-Rail DACs with I²C Interface.

@verbatim

NOTES
  Setup:
   Set the terminal baud rate to 115200 and select the newline terminator.
   Calibration requires a precision voltmeter.
   No external power supply is required.

USER INPUT DATA FORMAT:
 decimal : 1024
 hex     : 0x400
 octal   : 02000  (leading 0 "zero")
 binary  : B10000000000
 float   : 1024.0

@endverbatim

http://www.linear.com/product/LTC2607
http://www.linear.com/product/LTC2609
http://www.linear.com/product/LTC2606

http://www.linear.com/product/LTC2607#demoboards
http://www.linear.com/product/LTC2609#demoboards
http://www.linear.com/product/LTC2606#demoboards

REVISION HISTORY
$Revision: 4780 $
$Date: 2016-03-14 13:58:55 -0700 (Mon, 14 Mar 2016) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

/*! @file
    @ingroup LTC2607
*/

#include <Arduino.h>
#include <stdint.h>
#include "Linduino.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "LT_SPI.h"
#include "LTC2607.h"
#include "LTC2422.h"
#include "QuikEval_EEPROM.h"
#include <Wire.h>
#include <SPI.h>

// Function Declaration
void print_title();
void print_prompt(int16_t selected_dac);
int16_t prompt_voltage_or_code();
uint16_t get_voltage(float LTC2607_lsb, int32_t LTC2607_offset);
uint16_t get_code();

uint8_t menu_1_select_dac(int16_t *selected_dac);
uint8_t menu_2_write_to_input_register(int16_t selected_dac);
uint8_t menu_3_write_and_update_dac(int16_t selected_dac);
uint8_t menu_4_update_power_up_dac(int16_t selected_dac);
uint8_t menu_5_power_down_dac(int16_t selected_dac);
uint8_t menu_6_read_adc();
uint8_t menu_7_sweep();
uint8_t menu_8_calibrate_all();

//! Used to keep track to print voltage or print code
enum prompt
{
  PROMPT_VOLTAGE = 0, /**< 0 */
  PROMPT_CODE = 1     /**< 1 */
};

// Global Constants
const uint16_t LTC2422_TIMEOUT= 1000;   //!< Configures the maximum timeout (ms) allowed for an LTC2607 read.

//! Look-up table for DAC_A, DAC_B, or both command byte option
const uint8_t address_map[3] = {LTC2607_DAC_A, LTC2607_DAC_B, LTC2607_ALL_DACS};  //!< Builds the command for dac address

const uint16_t MISO_TIMEOUT = 1000;     //!< The MISO timout in ms

// ***Global Variables***

//! The LTC2607 least significant bit value with 5V full-scale.
//! Initialized to typical value from datasheet.  Can be calibrated through option menu.
static float LTC2607_lsb[3] = {LTC2607_TYPICAL_lsb, LTC2607_TYPICAL_lsb, LTC2607_TYPICAL_lsb};  //!< Builds the lsb. Index 2 is used for All DACs

//! The LTC2422 least significant bit value with 5V full-scale.
//! Initialized to typical value from datasheet.  Can be calibrated through option menu.
static float LTC2422_lsb = LTC2422_TYPICAL_lsb;

//! The LTC2422 offset variable.
//! Initialized to typical value from datasheet.  Can be calibrated through option menu.
static int32_t LTC2607_offset[3] = {LTC2607_TYPICAL_OFFSET, LTC2607_TYPICAL_OFFSET, LTC2607_TYPICAL_OFFSET}; //!< Builds the offset. Index 2 is used for All DACs

static int8_t demo_board_connected; //!< Set to 1 if the board is connected

//! Initialize Linduino
void setup()
// Setup the Program
{
  char demo_name[] = "DC934";             // Demo Board Name stored in QuikEval EEPROM

  output_high(LTC2422_CS);                //! Pulls LTC2442 Chip Select High

  quikeval_I2C_init();                    //! Initializes Linduino I2C port.

  quikeval_SPI_init();                    //! Configures the SPI port for 4MHz SCK
  quikeval_SPI_connect();                 //! Connects SPI to QuikEval port

  Serial.begin(115200);                   //! Initializes the serial port to the PC
  print_title();                          //! Displays the title

  demo_board_connected = discover_demo_board(demo_name); //! Checks if correct demo board is connected.

  if (demo_board_connected)               //! Prints the prompt if the correct demo board is connected
  {
    print_prompt(0);                      // Prints prompt and indicates that "A" is selected.
  }
}

//! Repeats Linduino loop
void loop()
{
  uint8_t i2c_ack = 0;
  uint8_t spi_error_code = 0;
  static int16_t selected_dac = 0;  // The selected DAC to be updated (0=A, 1=B, 2=All).  Initialized to "A".

  // The main control loop
  if (demo_board_connected)         //! Does nothing if the demo board is not connected.
  {
    if (Serial.available())         //! Checks if user input is available.
    {
      int16_t user_command;         // User input command

      user_command = read_int();    //! Reads the user command (if available).
      Serial.println(user_command);
      Serial.flush();
      switch (user_command)
      {
        case 1:
          menu_1_select_dac(&selected_dac);  // Select a DAC to update
          break;

        case 2:
          i2c_ack |= menu_2_write_to_input_register(selected_dac);  // Write to input register only
          break;

        case 3:
          i2c_ack |= menu_3_write_and_update_dac(selected_dac);
          break;

        case 4:
          i2c_ack |= menu_4_update_power_up_dac(selected_dac);      // Update/Power up DAC
          break;

        case 5:
          i2c_ack |= menu_5_power_down_dac(selected_dac);           // Power down DAC
          break;

        case 6:
          spi_error_code = menu_6_read_adc();
          break;

        case 7:
          i2c_ack |= menu_7_sweep();
          spi_error_code |= i2c_ack;
          break;

        case 8:
          i2c_ack |= menu_8_calibrate_all();
          spi_error_code |= i2c_ack;
          break;

        default:
          Serial.println("Incorrect Option");
          break;
      }

      if (i2c_ack != 0) Serial.println(F("Error: No Acknowledge. Check I2C Address."));
      if (spi_error_code != 0) Serial.println(F("Error: SPI communication error."));

      Serial.println();
      Serial.println(F("*************************"));
      print_prompt(selected_dac);
    }
  }
}

// Function Definitions

//! Prompts user to find out if they want to enter DAC code as a "voltage" or a "code"
//! @return PROMPT_CODE or PROMPT_VOLTAGE that indicates whether the user requested for the next entry to be a CODE or VOLTAGE
int16_t prompt_voltage_or_code()
{
  int16_t user_input;
  Serial.print(F("Type 1 to enter voltage, 2 to enter code:"));
  Serial.flush();
  user_input = read_int();
  Serial.println(user_input);

  if (user_input != 2)
    return(PROMPT_VOLTAGE);
  else
    return(PROMPT_CODE);
}

//! Read desired DAC output voltage from user input.
//! @return the code that can be written to the LTC2607 DAC
uint16_t get_voltage(float LTC2607_lsb,         //!< lsb weight of the LTC2607 (possibly calibrated)
                     int32_t LTC2607_offset)    //!< offset of LTC2607 (possibly calibrated)
{
  float dac_voltage;

  Serial.print(F("Enter Desired DAC output voltage: ")); //! Prompt user to enter a voltage
  dac_voltage = read_float();   //! Read a float from the serial terminal
  Serial.print(dac_voltage);
  Serial.println(F(" V"));
  Serial.flush();
  return(LTC2607_voltage_to_code(dac_voltage, LTC2607_lsb, LTC2607_offset)); //! Return the DAC code that results in that voltage.
}

//! @todo Review this file.
//! Reads desired DAC code from user input.
//! @return the adc CODE entered by the user.  (Note, this is a CODE not a VOLTAGE.)
uint16_t get_code()
{
  uint16_t returncode;
  Serial.println(F("Enter Desired DAC Code"));
  Serial.print(F("(Format 32768, 0x8000, 0100000, or B1000000000000000): "));
  returncode = (uint16_t) read_int();
  Serial.print(F("0x"));
  Serial.println(returncode, HEX);
  Serial.flush();
  return(returncode);
}

//! Prints the title block
void print_title()
{
  Serial.println(F("*****************************************************************"));
  Serial.println(F("* DC934A Demonstration Program                                  *"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("* This program demonstrates communication with the LTC2607      *"));
  Serial.println(F("* 16-Bit Dual Rail-to-Rail DAC with I2C Interface. This board   *"));
  Serial.println(F("* also features an LTC2422 2-Channel 20-Bit uPower No Latency   *"));
  Serial.println(F("* Delta Sigma ADC for readback.                                 *"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("* Set the baud rate to 115200 select the newline terminator.    *"));
  Serial.println(F("*****************************************************************"));
}

//! Prints the main menu, and prompts the user for an input command
void print_prompt(int16_t selected_dac) //!< this parameter is passed so that it can be printed at the bottom of the menu.
{
  Serial.println(F("\nCommand Summary:"));

  Serial.println(F("  1-Select DAC"));
  Serial.println(F("  2-Write to input register (no update)"));
  Serial.println(F("  3-Write and update DAC"));
  Serial.println(F("  4-Update/Power up DAC"));
  Serial.println(F("  5-Power Down DAC"));
  Serial.println(F("  6-Read ADC"));
  Serial.println(F("  7-Sweep"));
  Serial.println(F("  8-Calibrate ALL"));
  Serial.println();
  Serial.print(F("  Selected DAC: "));
  if (selected_dac != 2)
    Serial.println((char) (selected_dac + 0x41));
  else
    Serial.println(F("All"));
  Serial.println();
  Serial.print(F("Enter a command:"));
}

//! Menu 1: Select DAC to update.
//! Prompts user for DAC A, DAC B, or both.  This is only a user menu.  This function does not communicate with the LTC2607.
//! @return always returns 0. Fail return code is not implemented.
uint8_t menu_1_select_dac(int16_t *selected_dac) //!< Overwritten with 0, 1, or 2 to indicate whether the user wants commands to act upon DAC A, DAC B, or both DACs respectively.
{
  quikeval_I2C_connect();  //! Connects I2C port to the QuikEval connector
  Serial.print(F("Select DAC to be updated (0=A, 1=B, 2=All)"));
  *selected_dac = read_int();
  if (*selected_dac > 2) *selected_dac=2;  // If user enters and invalid option, default to ALL.
  if (*selected_dac == 2)
    Serial.println(F("All"));
  else
    Serial.println(*selected_dac);
  return(0);  // Always returns success, consider adding a fail code later.
}

//! Menu 2: Write to input register only.  Does not update the output voltage.
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
uint8_t menu_2_write_to_input_register(int16_t selected_dac) //!< DAC to be updated. 0=A, 1=B, 2=All
{
  uint16_t dac_code;
  uint8_t ack = 0;
  quikeval_I2C_connect();             //! Connects I2C port to the QuikEval connector

  //! Read voltage or DAC code from user
  if (prompt_voltage_or_code() == PROMPT_VOLTAGE)
    dac_code = get_voltage(LTC2607_lsb[selected_dac], LTC2607_offset[selected_dac]);
  else
    dac_code = get_code();

  //! Write a code to the LTC2607 internal register.  Output voltage is not updated by the "write" command.
  ack = LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_COMMAND, address_map[selected_dac], dac_code);
  return(ack);
}

//! Menu 3: Write to input register and update output voltage.
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
uint8_t menu_3_write_and_update_dac(int16_t selected_dac)  //!< DAC to be updated. 0=A, 1=B, 2=All
{
  uint8_t ack;
  uint16_t dac_code;
  quikeval_I2C_connect();             //! Connects I2C port to the QuikEval connector

  //! Read voltage or DAC code from user
  if (prompt_voltage_or_code() == PROMPT_VOLTAGE)
    dac_code = get_voltage(LTC2607_lsb[selected_dac], LTC2607_offset[selected_dac]);
  else
    dac_code = get_code();

  //! Write a code to the LTC2607 internal register and update the output voltage.
  ack = LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, address_map[selected_dac], dac_code);    // Write a code to the LTC2607
  return(ack);
}

//! Menu 4: Update/Power Up DAC
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
uint8_t menu_4_update_power_up_dac(int16_t selected_dac)  //!< DAC to be updated. 0=A, 1=B, 2=All
{
  uint8_t ack;

  quikeval_I2C_connect();           //! Connects I2C port to the QuikEval connector
  ack = LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_UPDATE_COMMAND, address_map[selected_dac], 0);   //! Update output voltage from internal register.  Data is ignored.
  return(ack);
}

//! Menu 5: Power Down DAC
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
uint8_t menu_5_power_down_dac(int16_t selected_dac)
{
  uint8_t ack;
  quikeval_I2C_connect();     //! Connects I2C port to the QuikEval connector
  ack = LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_POWER_DOWN_COMMAND, address_map[selected_dac], 0);    //! Power down selected DAC.  Data is ignored.
  return(ack);
}

//! Menu 6: Read voltage from the ADC
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
uint8_t menu_6_read_adc()
{
  float adc_voltage;
  int32_t adc_code;
  uint8_t adc_channel;
  uint32_t  adc_code_array[2];   // Array for ADC data. Useful because you don't know which channel until the LTC2422 tells you.
  uint8_t acknowledge;

  // Read ADC
  quikeval_SPI_connect();       //! Connect SPI to QuikEval connector

  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);            //! Throw out the stale data

  if (acknowledge = LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))  // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);            //! Read both channels from the ADC.  The ADC channel will toggle with each reading.
  adc_code_array[adc_channel] = adc_code;                           //! Note that we're not sure which channel is first prior to reading.

  if (acknowledge = LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))  // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);            //! Therefore, we use adc_channel (reported by LTC2422 during read operation) as index into two element array.
  adc_code_array[adc_channel] = adc_code;                           //! One element holds channel A ADC code and the other holds the channel B ADC code.

  //! Print ADC A voltage.
  Serial.println();
  Serial.print(F("     ADC A : Code: 0x"));
  Serial.println(adc_code_array[1], HEX);
  Serial.print(F("             Voltage: "));
  adc_voltage = LTC2422_code_to_voltage(adc_code_array[1], LTC2422_lsb);
  Serial.println(adc_voltage, 6);

  //! Print ADC B voltage.
  Serial.println();
  Serial.print(F("     ADC B : Code: 0x"));
  Serial.println(adc_code_array[0], HEX);
  Serial.print(F("             Voltage: "));
  adc_voltage = LTC2422_code_to_voltage(adc_code_array[0], LTC2422_lsb);
  Serial.println(adc_voltage, 6);
  return(0);
}

//! Menu 7: Voltage Sweep
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
uint8_t menu_7_sweep()
{
  uint8_t ack = 0;
  Serial.print(F("Enter the desired number of sample points: "));

  //! Reads number of sample points from user.
  uint16_t sample;
  sample = read_int();
  if (sample == 0)
    sample = 1;
  Serial.println(sample);
  if (sample > 65535)
    sample = 65535;

  //! Calculates size of each step.
  uint16_t sample_code;
  sample_code = 65535/sample;

  int32_t adc_code;
  uint8_t adc_channel;
  quikeval_SPI_connect();                                   //! Connect SPI to QuikEval connector

  if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))        // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);    //! Take one ADC reading. Throw away the data, but check the channel.
  //! If the data was from channel 1, take another reading so that the next reading will be channel 0.
  if (adc_channel == 1)
  {
    if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))      // Check for EOC
      return(1);
    LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);  // IF we just read channel 1 (DAC A),
    // a conversion on channel B has just started. We want the FIRST reading in the table to be DAC A, so flush
    // this conversion, starting another conversion on DAC A. The Autozero phase takes 4/60 of a second (66.7ms) so there
    // is some time to print the header and set the DAC outputs.
  }
  Serial.println(F("Code, DAC A,DAC B"));

  float adc_voltage;
  uint16_t dac_code;
  uint16_t i;
  //! For loop steps one voltage step at a time.
  for (i = 0; i <= sample; i++)
  {
    quikeval_I2C_connect();                                 //! Connects I2C port to the QuikEval connector
    dac_code = (sample_code*i);
    if (dac_code > 65535)
      dac_code = 65535;

    //! Write DAC code to both channels.
    ack |= LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_ALL_DACS, dac_code);

    quikeval_SPI_connect();                                 //! Connect SPI to QuikEval connector

    if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))      // Check for EOC
      return(1);
    //! Read ADC channel 0 (DAC A) voltage and print it.
    LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);

    Serial.print(dac_code);
    Serial.print(F(","));
    adc_voltage = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
    Serial.print(adc_voltage, 6);
    Serial.print(F(","));

    if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))      // Check for EOC
      return(1);
    //! Read ADC channel 1 (DAC B) voltage and print it.
    LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);
    adc_voltage = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
    Serial.println(adc_voltage, 6);
    Serial.flush();

    //! If they get out of sync, print "Out of sync!". This only happens if something bad occurs.
    if (adc_channel == 1)
    {
      Serial.println(F("Out of sync!!"));
      quikeval_I2C_connect();
      ack |= LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_ALL_DACS, 0x0000); //Set output to zero
      return(1);
    }
  }
  quikeval_I2C_connect();
  ack |= LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_ALL_DACS, 0x0000); //Set output to zero
  Serial.println();
  Serial.println(F("Copy and save data points to a .csv file"));
  Serial.println(F("and open in Excel to plot points."));
  return(ack);
}

//! Menu 8: Calibrate All
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
uint8_t menu_8_calibrate_all()
{
  uint8_t ack = 0;
  float voltage1[2];                                  // Calibration voltage 1
  float voltage2[2];                                  // Calibration voltage 2
  const uint16_t CAL_LOW_DAC_CODE = 0x00FF;           // LTC2607 calibration code used for low-side force/measure.
  const uint16_t CAL_HIGH_DAC_CODE = 0xFF00;          // LTC2607 calibration code used for high-side force/measure.

  // Calibrate All
  Serial.println(F("Measure and Enter Reference "));
  Serial.print(F("Voltage for The ADC: "));

  float ref_voltage;
  ref_voltage = read_float();
  Serial.println(ref_voltage, 6);
  LTC2422_calculate_lsb(ref_voltage, &LTC2422_lsb);

  quikeval_I2C_connect();                 //! Connects I2C port to the QuikEval connector

  ack |= LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_DAC_A, CAL_LOW_DAC_CODE);
  ack |= LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_DAC_B, CAL_LOW_DAC_CODE);
  Serial.println();
  Serial.print(F("Calibrating DACs ... "));
  delay(2000);

  quikeval_SPI_connect();                 //! Connect SPI to QuikEval connector

  delay(50);

  int32_t adc_code;
  uint8_t adc_channel;
  if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))        // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);    // Throw away last reading
  if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))        // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);
  if (adc_channel == 0)
    voltage1[1] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
  if (adc_channel == 1)
    voltage1[0] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
  if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))        // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);
  if (adc_channel == 0)
    voltage1[1] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
  if (adc_channel == 1)
    voltage1[0] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);

  quikeval_I2C_connect();                                   //! Connects I2C port to the QuikEval connector

  ack |= LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_DAC_A, CAL_HIGH_DAC_CODE);   // Set DAC to Full Scale
  ack |= LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_DAC_B, CAL_HIGH_DAC_CODE);   // Set DAC to Full Scale

  delay(2000);
  quikeval_SPI_connect();                                   //! Connect SPI to QuikEval connector

  delay(50);

  if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))        // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);    // Throw away last reading
  if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))        // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);
  if (adc_channel == 0)
    voltage2[1] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
  if (adc_channel == 1)
    voltage2[0] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
  if (LTC2422_EOC_timeout(LTC2422_CS, MISO_TIMEOUT))        // Check for EOC
    return(1);
  LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code);
  if (adc_channel == 0)
    voltage2[1] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
  if (adc_channel == 1)
    voltage2[0] = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);

  LTC2607_calibrate(CAL_LOW_DAC_CODE, CAL_HIGH_DAC_CODE, voltage1[0], voltage2[0], &LTC2607_lsb[0], &LTC2607_offset[0]);
  LTC2607_calibrate(CAL_LOW_DAC_CODE, CAL_HIGH_DAC_CODE, voltage1[1], voltage2[1], &LTC2607_lsb[1], &LTC2607_offset[1]);
  // Store All DACs lsb and offset from LTC2607_lsb[0] and LTC2607_offset[0]
  LTC2607_lsb[2] = LTC2607_lsb[0];
  LTC2607_offset[2] = LTC2607_offset[0];
  Serial.println(F("Calibration Complete"));

  Serial.print(F("lsb DAC A: "));
  Serial.print(LTC2607_lsb[0], 6);
  Serial.print(F(" V   offset: "));
  Serial.println(LTC2607_offset[0]);

  Serial.print(F("lsb DAC B: "));
  Serial.print(LTC2607_lsb[1], 6);
  Serial.print(F(" V   offset: "));
  Serial.println(LTC2607_offset[1]);

  Serial.print(F("All DACs: "));
  Serial.print(LTC2607_lsb[2], 6);
  Serial.print(F(" V   offset: "));
  Serial.println(LTC2607_offset[2]);
  return(ack);
}

Download LTC2607 Linduino .CPP File

/*!
LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface.
LTC2609: Quad 16-/14-/12-Bit Rail-to-Rail DACs with I²C Interface.
LTC2606: 16-Bit Rail-to-Rail DACs with I²C Interface.

@verbatim

The LTC2607/LTC2617/LTC2627 are dual 16-, 14- and 12-bit, 2.7V to 5.5V
rail-to-rail voltage output DACs in a 12-lead DFN package. They have built-in
high performance output buffers and are guaranteed monotonic.

These parts establish new board-density benchmarks for 16- and 14-bit DACs and
advance performance standards for output drive and load regulation in single-
supply, voltage-output DACs.

The parts use a 2-wire, I2C compatible serial interface. The
LTC2607/LTC2617/LTC2627 operate in both the standard mode (clock rate of 100kHz)
and the fast mode (clock rate of 400kHz). An asynchronous DAC update pin (LDAC)
is also included.

The LTC2607/LTC2617/LTC2627 incorporate a power-on reset circuit. During power-
up, the voltage outputs rise less than 10mV above zero scale; and after power-
up, they stay at zero scale until a valid write and update take place. The
power-on reset circuit resets the LTC2607-1/LTC2617-1/ LTC2627-1 to mid-scale.
The voltage outputs stay at midscale until a valid write and update takes place.

@endverbatim

http://www.linear.com/product/LTC2607
http://www.linear.com/product/LTC2609
http://www.linear.com/product/LTC2606

http://www.linear.com/product/LTC2607#demoboards
http://www.linear.com/product/LTC2609#demoboards
http://www.linear.com/product/LTC2606#demoboards

REVISION HISTORY
$Revision: 4780 $
$Date: 2016-03-14 13:58:55 -0700 (Mon, 14 Mar 2016) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/
//! @defgroup LTC2607 LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface

/*! @file
    @ingroup LTC2607
    Library for LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface
*/

#include <Arduino.h>
#include <stdint.h>
#include <math.h>
#include "Linduino.h"
#include "LT_I2C.h"
#include "LTC2607.h"
#include <Wire.h>

// Writes command, DAC address, and DAC code to the LTC2607.
// Configures command (write, update, power down, etc.), address (DAC A, DAC B, or BOTH), and 16-bit dac_code for output voltage.
int8_t LTC2607_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
{
  int8_t ack;

  ack = i2c_write_word_data(i2c_address, (dac_command | dac_address), dac_code);
  return(ack);
}

// Calculates an LTC2607 DAC code for the desired output voltage.
// Based on the desired output voltage, the offset, and lsb parameters, return the corresponding DAC code that should be written to the LTC2607.
uint16_t LTC2607_voltage_to_code(float dac_voltage, float LTC2607_lsb, int32_t LTC2607_offset)
{
  int32_t dac_code;
  float float_code;
  float_code = dac_voltage / LTC2607_lsb - LTC2607_offset;                                        //! 1) Calculate the DAC code
  float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);   //! 2) Round
  dac_code = (uint16_t) (float_code);                                                             //! 3) Convert to unsigned integer
  if (dac_code > 65535)
    dac_code = 65535;
  if (dac_code < 0)
    dac_code = 0;
  return ((uint16_t)dac_code);
}

// Calculates the LTC2607 offset and lsb voltage given two measured voltages and their corresponding DAC codes.
// Prior to calling this function, write two DAC codes to the LTC2607, and measure the output voltage for each DAC code.
// When passed the DAC codes and measured voltages as parameters, this function calculates the calibrated lsb and offset values.
void LTC2607_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2607_lsb, int32_t *LTC2607_offset)
{
  float temp_offset;
  *LTC2607_lsb = (voltage2 - voltage1) / ((float) (dac_code2 - dac_code1));                             //! 1) Calculate the LSB
  temp_offset = voltage1/(*LTC2607_lsb) - dac_code1;                                                    //! 2) Calculate the offset
  temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);    //! 3) Round
  *LTC2607_offset = (int32_t)temp_offset;                                                               //! 4) Cast as int32_t
}

Download LTC2607 Linduino Header File

/*!
LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface.
LTC2609: Quad 16-/14-/12-Bit Rail-to-Rail DACs with I²C Interface.
LTC2606: 16-Bit Rail-to-Rail DACs with I²C Interface.

@verbatim

The LTC2607/LTC2617/LTC2627 are dual 16-, 14- and 12-bit, 2.7V to 5.5V
rail-to-rail voltage output DACs in a 12-lead DFN package. They have built-in
high performance output buffers and are guaranteed monotonic.

These parts establish new board-density benchmarks for 16- and 14-bit DACs and
advance performance standards for output drive and load regulation in single-
supply, voltage-output DACs.

The parts use a 2-wire, I2C compatible serial interface. The
LTC2607/LTC2617/LTC2627 operate in both the standard mode (clock rate of 100kHz)
and the fast mode (clock rate of 400kHz). An asynchronous DAC update pin (LDAC)
is also included.

The LTC2607/LTC2617/LTC2627 incorporate a power-on reset circuit. During power-
up, the voltage outputs rise less than 10mV above zero scale; and after power-
up, they stay at zero scale until a valid write and update take place. The
power-on reset circuit resets the LTC2607-1/LTC2617-1/ LTC2627-1 to mid-scale.
The voltage outputs stay at midscale until a valid write and update takes place.

I2C DATA FORMAT (MSB First):

       Byte #1                             Byte #2                          Byte #3                              Byte #4

START  SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK  C3 C2 C1 C0  A3  A2 A1 A0  SACK  D15 D14 D13 D12 D11 D10 D9 D8  SACK  D7 D6  D5  D4  D3  D2  D1  D0 SACK STOP

SACK : Slave Acknowlege
SAx  : I2C Address
W    : I2C Write (0)
R    : I2C Read  (1)
SACK : I2C Slave Generated Acknowledge (Active Low)
Cx   : DAC Command Code
Ax   : DAC Address
Dx   : DAC Data Bits
X    : Don't care


Example Code:

Set DAC A to Full Scale.

    dac_code = 0x0FFFF; // Set dac code to full scale

    // Write dac code to the LTC2607 and update dac
    ack = LTC2607_write(LTC2607_I2C_GLOBAL_ADDRESS, LTC2607_WRITE_UPDATE_COMMAND, LTC2607_DAC_A, dac_code);

@endverbatim

http://www.linear.com/product/LTC2607
http://www.linear.com/product/LTC2609
http://www.linear.com/product/LTC2606

http://www.linear.com/product/LTC2607#demoboards
http://www.linear.com/product/LTC2609#demoboards
http://www.linear.com/product/LTC2606#demoboards

REVISION HISTORY
 $Revision: 4780 $
 $Date: 2016-03-14 13:58:55 -0700 (Mon, 14 Mar 2016) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

/*! @file
    @ingroup LTC2607
    Header File for LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface
*/

#ifndef LTC2607_H
#define LTC2607_H

#include <Wire.h>

/*! @name I2C_Addresses
@{ */

//! I2C address of the LTC2607.
//! Configured with the CA0, CA1, and CA2 pins. See Table 1 of datasheet.
//! Uncomment LTC2607_I2C_ADDRESS to match demo board configuration.
//  Address assignment
// LTC2607 I2C Address                 //  AD2       AD1       AD0
#define LTC2607_I2C_ADDRESS 0x10      //  LOW       LOW       LOW
// #define LTC2607_I2C_ADDRESS 0x11    //  LOW       LOW       Float
// #define LTC2607_I2C_ADDRESS 0x12    //  LOW       LOW       HIGH
// #define LTC2607_I2C_ADDRESS 0x13    //  LOW       Float     LOW
// #define LTC2607_I2C_ADDRESS 0x20    //  LOW       Float     Float
// #define LTC2607_I2C_ADDRESS 0x21    //  LOW       Float     High
// #define LTC2607_I2C_ADDRESS 0x22    //  LOW       HIGH      LOW
// #define LTC2607_I2C_ADDRESS 0x23    //  LOW       HIGH      Float
// #define LTC2607_I2C_ADDRESS 0x30    //  LOW       High      HIGH
// #define LTC2607_I2C_ADDRESS 0x31    //  Float     LOW       LOW
// #define LTC2607_I2C_ADDRESS 0x32    //  Float     LOW       Float
// #define LTC2607_I2C_ADDRESS 0x33    //  Float     LOW       HIGH
// #define LTC2607_I2C_ADDRESS 0x40    //  Float     Float     LOW
// #define LTC2607_I2C_ADDRESS 0x41    //  Float     Float     Float
// #define LTC2607_I2C_ADDRESS 0x42    //  Float     Float     HIGH
// #define LTC2607_I2C_ADDRESS 0x43    //  Float     High      LOW
// #define LTC2607_I2C_ADDRESS 0x50    //  Float     High      Float
// #define LTC2607_I2C_ADDRESS 0x51    //  Float     High      HIGH
// #define LTC2607_I2C_ADDRESS 0x52    //  High      LOW       LOW
// #define LTC2607_I2C_ADDRESS 0x53    //  High      LOW       Float
// #define LTC2607_I2C_ADDRESS 0x60    //  High      LOW       High
// #define LTC2607_I2C_ADDRESS 0x61    //  High      Float     LOW
// #define LTC2607_I2C_ADDRESS 0x62    //  High      Float     Float
// #define LTC2607_I2C_ADDRESS 0x63    //  High      Float     High
// #define LTC2607_I2C_ADDRESS 0x70    //  High      High      LOW
// #define LTC2607_I2C_ADDRESS 0x71    //  High      High      Float
// #define LTC2607_I2C_ADDRESS 0x72    //  High      High      High

//! LTC2607 Global I2C Address.
#define LTC2607_I2C_GLOBAL_ADDRESS 0x73    //  Global Address

/*! @} */
/*! @name DAC Command
@{ */

#define LTC2607_WRITE_COMMAND             0x00 //!< Command to write to internal register of LTC2607, but not update output voltage yet.
#define LTC2607_UPDATE_COMMAND            0x10 //!< Command to update (and power up) LTC2607. Output voltage will be set to the value stored in the internal register by previous write command.
#define LTC2607_WRITE_UPDATE_COMMAND      0x30 //!< Command to write and update (and power up) the LTC2607. The output voltage will immediate change to the value being written to the internal register.
#define LTC2607_POWER_DOWN_COMMAND        0x40 //!< Command to power down the LTC2607.

/*! @} */
/*! @name DAC Address
@{ */

// DAC Address
#define LTC2607_DAC_A                     0x00 //!< Command (and DAC code) will modify DAC A
#define LTC2607_DAC_B                     0x01 //!< Command (and DAC code) will modify DAC B
#define LTC2607_ALL_DACS                  0x0F //!< Command (and DAC code) will modify both DAC A and DAC B

/*! @} */

const float LTC2607_TYPICAL_lsb = 7.6295109E-5; //!< The LTC2607 typical least significant bit value with 5V full-scale
const float LTC2607_TYPICAL_OFFSET = 0;         //!< The LTC2607 typical offset voltage

//! Writes command, DAC address, and DAC code to the LTC2607.
//! Configures command (write, update, power down, etc.), address (DAC A, DAC B, or BOTH), and 16-bit dac_code for output voltage.
//! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
int8_t LTC2607_write(uint8_t i2c_address,  //!< I2C address of the LTC2607. Configured by CA0, CA1, and CA2 pins. See Table 1 of datasheet.
                     uint8_t dac_command,   //!< DAC command (4-bits) that will be written to LTC2607. (Write, update, power down, etc.)
                     uint8_t dac_address,   //!< DAC address (4-bits) that will be written to LTC2607. Configures DAC A, DAC B, or both.
                     uint16_t dac_code      //!< DAC code that will be written to LTC2607. This configures the output voltage.
                    );

//! Calculates an LTC2607 DAC code for the desired output voltage.
//! Based on the desired output voltage, the offset, and lsb parameters, return the corresponding DAC code that should be written to the LTC2607.
//! @return DAC code for desired output voltage
uint16_t LTC2607_voltage_to_code(float dac_voltage,     //!< Desired DAC output voltage.
                                 float LTC2607_lsb,     //!< The LSB weight. Use calibrated value for best results, otherwise use typical value from datasheet.
                                 int32_t LTC2607_offset //!< The offset voltage. Use calibrated value for best results, otherwise use typical value from datasheet.
                                );

//! Calculates the LTC2607 offset and lsb voltage given two measured voltages and their corresponding DAC codes.
//! Prior to calling this function, write two DAC codes to the LTC2607, and measure the output voltage for each DAC code.
//! When passed the DAC codes and measured voltages as parameters, this function calculates the calibrated lsb and offset values.
void LTC2607_calibrate(uint16_t dac_code1,      //!< DAC Code 1.
                       uint16_t dac_code2,      //!< DAC Code 2.
                       float voltage1,          //!< Measured output voltage corresponding to DAC Code 1.
                       float voltage2,          //!< Measured output voltage corresponding to DAC Code 2.
                       float *LTC2607_lsb,      //!< Overwritten with new calculated lsb voltage.
                       int32_t *LTC2607_offset  //!< Overwritten with new calculated offset voltage.
                      );

#endif  // LTC2607_H

Technical Support