LTC2657 - Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/°C Max Reference

Features

  • Integrated Reference 10ppm/°C Max
  • Maximum INL Error: ±4LSB
  • Guaranteed Monotonic Over Temperature
  • Selectable Internal or External Reference
  • 2.7V to 5.5V Supply Range (LTC2657-L)
  • Integrated Reference Buffers
  • Ultralow Crosstalk between DACs(0.8nV•s)
  • Power-On-Reset to Zero-Scale/Mid-Scale
  • 400kHz I2C Interface
  • Tiny 20-Lead 4mm × 5mm QFN and 20-Lead Thermally enhanced TSSOP packages

Typical Application

LTC2657 Typical Application
LTC2657 Typical Application

Description

The LTC2657 is a family of octal I2C 16-/12-Bit Rail-to- Rail DACs with Integrated 10ppm/°C Max Reference. The DACs have built-in high performance, rail-to-rail, output buffers and are guaranteed monotonic. The LTC2657-L has a full-scale output of 2.5V with the integrated reference and operates from a single 2.7V to 5.5V supply. The LTC2657-H has a full-scale output of 4.096V with the integrated reference and operates from a 4.5V to 5.5V supply. Each DAC can also operate with an external reference, which sets the full-scale output to 2 times the external reference voltage.

The parts use a 2-wire I2C compatible serial interface. The LTC2657 operates in both the standard mode (maximum clock rate of 100kHz) and the fast mode (maximum clock rate of 400kHz). The LTC2657 incorporates a power-on reset circuit that is controlled by the PORSEL pin. If PORSEL is tied to GND the DACs reset to zero-scale at power-up. If PORSEL is tied to VCC, the DACs reset to mid-scale at power-up.

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
LTC2657BCFE-H16#PBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657BCFE-H16#TRPBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657BCFE-L16#PBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657BCFE-L16#TRPBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657BCUFD-H16#PBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657BCUFD-H16#TRPBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657BCUFD-L16#PBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657BCUFD-L16#TRPBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657BIFE-H16#PBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657BIFE-H16#TRPBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657BIFE-L16#PBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657BIFE-L16#TRPBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657BIUFD-H16#PBF 4x5 QFN-20 UFD I 05-08-1711 Yes
LTC2657BIUFD-H16#TRPBF 4x5 QFN-20 UFD I 05-08-1711 Yes
LTC2657BIUFD-L16#PBF 4x5 QFN-20 UFD I 05-08-1711 Yes
LTC2657BIUFD-L16#TRPBF 4x5 QFN-20 UFD I 05-08-1711 Yes
LTC2657CFE-H12#PBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657CFE-H12#TRPBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657CFE-L12#PBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657CFE-L12#TRPBF TSSOP-20 FE C 05-08-1663 (CB) Yes
LTC2657CUFD-H12#PBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657CUFD-H12#TRPBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657CUFD-L12#PBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657CUFD-L12#TRPBF 4x5 QFN-20 UFD C 05-08-1711 Yes
LTC2657IFE-H12#PBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657IFE-H12#TRPBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657IFE-L12#PBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657IFE-L12#TRPBF TSSOP-20 FE I 05-08-1663 (CB) Yes
LTC2657IUFD-H12#PBF 4x5 QFN-20 UFD I 05-08-1711 Yes
LTC2657IUFD-H12#TRPBF 4x5 QFN-20 UFD I 05-08-1711 Yes
LTC2657IUFD-L12#PBF 4x5 QFN-20 UFD I 05-08-1711 Yes
LTC2657IUFD-L12#TRPBF 4x5 QFN-20 UFD I 05-08-1711 Yes


LTC2657 Package Drawing
LTC2657 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
LTC2657BCFE-H16#PBF TSSOP-20 C $26.93 $18.85 Yes
LTC2657BCFE-H16#TRPBF TSSOP-20 C $18.91 Yes
LTC2657BCFE-L16#PBF TSSOP-20 C $26.93 $18.85 Yes
LTC2657BCFE-L16#TRPBF TSSOP-20 C $18.91 Yes
LTC2657BCUFD-H16#PBF 4x5 QFN-20 C $26.93 $18.85 Yes
LTC2657BCUFD-H16#TRPBF 4x5 QFN-20 C $18.91 Yes
LTC2657BCUFD-L16#PBF 4x5 QFN-20 C $26.93 $18.85 Yes
LTC2657BCUFD-L16#TRPBF 4x5 QFN-20 C $18.91 Yes
LTC2657BIFE-H16#PBF TSSOP-20 I $29.50 $20.65 Yes
LTC2657BIFE-H16#TRPBF TSSOP-20 I $20.71 Yes
LTC2657BIFE-L16#PBF TSSOP-20 I $29.50 $20.65 Yes
LTC2657BIFE-L16#TRPBF TSSOP-20 I $20.71 Yes
LTC2657BIUFD-H16#PBF 4x5 QFN-20 I $29.50 $20.65 Yes
LTC2657BIUFD-H16#TRPBF 4x5 QFN-20 I $20.71 Yes
LTC2657BIUFD-L16#PBF 4x5 QFN-20 I $29.50 $20.65 Yes
LTC2657BIUFD-L16#TRPBF 4x5 QFN-20 I $20.71 Yes
LTC2657CFE-H12#PBF TSSOP-20 C $13.07 $9.15 Yes
LTC2657CFE-H12#TRPBF TSSOP-20 C $9.21 Yes
LTC2657CFE-L12#PBF TSSOP-20 C $13.07 $9.15 Yes
LTC2657CFE-L12#TRPBF TSSOP-20 C $9.21 Yes
LTC2657CUFD-H12#PBF 4x5 QFN-20 C $13.07 $9.15 Yes
LTC2657CUFD-H12#TRPBF 4x5 QFN-20 C $9.21 Yes
LTC2657CUFD-L12#PBF 4x5 QFN-20 C $13.07 $9.15 Yes
LTC2657CUFD-L12#TRPBF 4x5 QFN-20 C $9.21 Yes
LTC2657IFE-H12#PBF TSSOP-20 I $14.37 $10.06 Yes
LTC2657IFE-H12#TRPBF TSSOP-20 I $10.12 Yes
LTC2657IFE-L12#PBF TSSOP-20 I $14.37 $10.06 Yes
LTC2657IFE-L12#TRPBF TSSOP-20 I $10.12 Yes
LTC2657IUFD-H12#PBF 4x5 QFN-20 I $14.37 $10.06 Yes
LTC2657IUFD-H12#TRPBF 4x5 QFN-20 I $10.12 Yes
LTC2657IUFD-L12#PBF 4x5 QFN-20 I $14.37 $10.06 Yes
LTC2657IUFD-L12#TRPBF 4x5 QFN-20 I $10.12 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.

Part Number Description Price Documentation
DC1529A-A LTC2657-L16 Demo Board | Octal I2C 16-bit Voltage Output DAC with 1.25V Reference, req DC2026 $150.00
DC1529A-B LTC2657-H16 Demo Board | Octal I2C 16-bit Voltage Output DAC with 2.048V Reference, req DC2026 $150.00
Buy Now

Companion Boards

Part Number Description Price Documentation
DC2026C Linduino One Isolated USB Demo Board: An Arduino- and QuikEval-Compatible Code Development Platform $75.00
Buy Now
Click here to view our complete list of demo boards

Applications

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

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 Code Supported: There is example code available for this part. The code below may rely on other drivers available in the full library.

Download LTC2657 - DC1529A Linduino .INO File

/*!
Linear Technology DC1703A Demonstration Board.
LTC2657: Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference.

@verbatim
NOTES
 Setup:
   Set the terminal baud rate to 115200 and select the newline terminator.
   The program displays calculated voltages which are based on the voltage
   of the reference used, be it internal or external. A precision voltmeter
   is needed to verify the actual measured voltages against the calculated
   voltage displayed. If an external reference is used, a precision voltage
   source is required to apply the external reference voltage. A
   precision voltmeter is also required to measure the external reference
   voltage. No external power supply is required. Any assembly option may
   be used: DC1529A-A, DC1529A-B


 Explanation of Commands:
   1- Select DAC: Select one of eight DACs to test : A, B, C, D, E, F, G, H.

   2- Write to DAC input register: Value is stored in the DAC for updating
      later, allowing multiple channels to be updated at once, either
      through a software "Update All" command or by asserting the LDAC# pin.
      User will be prompted to enter either a code in hex or decimal, or a
      voltage. If a voltage is entered, a code will be calculated based on
      the active scaling and reference parameters - ideal values if no
      calibration was ever stored.

   3- Write and Update: Similar to item 1, but DAC is updated immediately.

   4- Update DAC: Copies the value from the input register into the DAC
      Register. Note that a "write and update" command writes the code to
      BOTH the input register and DAC register, so subsequent "update"
      commands will simply re-copy the same data (no change in output.)

   5- Power Down DAC: Disable DAC output. Power supply current is reduced.
      DAC code present in DAC registers at time of shutdown are preserved.

   6- Set reference mode, either internal or external: Selecting external
      mode prompts for the external reference voltage, which is used directly
      if no individual DAC calibration is stored. The selection and entered
      voltage are stored to EEPROM so it is persistent across reset / power cycles.

   7- Calibrate DAC: Use a precision voltmeter to obtain and enter VOUT
      readings taken with different DAC codes. Set reference mode FIRST,
      as values are stored separately for internal and external reference
      mode. Entries are used to calculate the closest code to send to the
      DAC to achieve an entered voltage.

   8- Enable / Disable calibration: Switch between stored calibration
      values and defaults. Calibration parameters are stored separately
      for internal and external reference modes. Ideal calibration will
      be used if the calibration parameter valid key is not set.


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

@endverbatim

http://www.linear.com/product/LTC2657

http://www.linear.com/product/LTC2657#demoboards

REVISION HISTORY
$Revision: 4919 $
$Date: 2016-04-08 18:32:59 -0700 (Fri, 08 Apr 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 LTC2657
*/

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

#define EEPROM_CAL_KEY_INT  0x5678          //!< Calibration associated with internal reference
#define EEPROM_CAL_KEY_EXT  0x9ABC          //!< Calibration associated with external reference

// DAC Reference State
// Could have been zero or 1, this allows you to use the
// variable "reference_mode" as the command argument to a write
#define REF_INTERNAL LTC2657_CMD_INTERNAL_REFERENCE   //!< Stored reference state is Internal
#define REF_EXTERNAL LTC2657_CMD_EXTERNAL_REFERENCE   //!< Stored reference state is External

// EEPROM memory locations
#define STORED_REF_STATE_BASE     EEPROM_CAL_STATUS_ADDRESS     //!< Base address of the stored reference state
#define INT_CAL_VALID_BASE        STORED_REF_STATE_BASE + 2     //!< Base address of the "internal ref calibration valid" flag
#define INT_CAL_PARAMS_BASE       INT_CAL_VALID_BASE + 2        //!< Base address of the internal ref calibration parameters
#define EXT_CAL_VALID_BASE        INT_CAL_PARAMS_BASE + 32      //!< Base address of the "external ref calibration valid" flag
#define EXT_CAL_PARAMS_BASE       EXT_CAL_VALID_BASE + 2        //!< Base address of the external ref calibration parameters
#define EXT_REF_V_BASE            EXT_CAL_PARAMS_BASE + 32      //!< Base address of the stored external reference voltage

// Function Declaration
int8_t restore_calibration();               // Read the DAC calibration from EEPROM, Return 1 if successful, 0 if not
void store_calibration();                   // Store the DAC calibration to the EEPROM
void print_title();                         // Print the title block
void print_prompt(int16_t selected_dac);    // Prompt the user for an input command
int16_t prompt_voltage_or_code();
uint16_t get_voltage(float LTC2657_lsb, int16_t LTC2657_offset);
uint16_t get_code();
int8_t calibrate_dac(uint8_t index);        // Calibrate the selected DAC using a voltmeter. The routine does a linear curve fit given two data points.

int8_t menu_1_select_dac(int16_t *selected_dac);
int8_t menu_2_write_to_input_register(int16_t selected_dac);
int8_t menu_3_write_and_update_dac(int16_t selected_dac);
int8_t menu_4_update_power_up_dac(int16_t selected_dac);
int8_t menu_5_power_down_dac(int16_t selected_dac);
int8_t menu_6_set_reference_mode();         // int, ext, if ext, prompt for voltage
int8_t menu_7_calibrate_dacs();
int8_t menu_8_enable_calibration();

// Global variables
static uint8_t demo_board_connected;               //!< Set to 1 if the board is connected
static uint8_t shift_count = 0;                    //!< The data align shift count. For 16-bit=0, for 12-bits=4
static uint8_t reference_mode;                     //!< Tells whether to set internal or external reference

// Global calibration variables
static float reference_voltage;                //!< Reference voltage, either internal or external
static int16_t LTC2657_offset[9];                  //!< DAC offset - index 8 for "all DACs"
static float LTC2657_lsb[9];                       //!< The LTC2657 lsb - index 8 for "all DACs"

// Constants

//! Lookup table for DAC address. Allows the "All DACs" address to be indexed right after DAC D in loops.
//! This technique is very useful for devices with non-monotonic channel addresses.
const uint8_t address_map[9] = {LTC2657_DAC_A, LTC2657_DAC_B, LTC2657_DAC_C, LTC2657_DAC_D, LTC2657_DAC_E, LTC2657_DAC_F, LTC2657_DAC_G, LTC2657_DAC_H, LTC2657_DAC_ALL};  //!< Map entered option 0..2 to DAC address

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

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

  quikeval_I2C_init();              // Configure the EEPROM I2C port for 100kHz
  quikeval_I2C_connect();           // Connect I2C to main data port
  Serial.begin(115200);             // Initialize the serial port to the PC
  print_title();
  demo_board_connected = discover_demo_board(demo_name);
  if (demo_board_connected)
  {
    restore_calibration();
    print_prompt(0);
  }
}

//! Repeats Linduino loop
void loop()
{
  int8_t ack=0;
  int16_t user_command;
  static  int16_t selected_dac = 0;     // The selected DAC to be updated (0=A, 1=B ... 8=All).  Initialized to "A".
  // The main control loop
  if (demo_board_connected)             // Do nothing if the demo board is not connected
  {
    if (Serial.available())             // Check for user input
    {
      user_command = read_int();        // Read the user command
      Serial.println(user_command);
      Serial.flush();
      ack = 0;
      switch (user_command)
      {
        case 1:
          ack |= menu_1_select_dac(&selected_dac);
          break;
        case 2:
          ack |= menu_2_write_to_input_register(selected_dac);
          break;
        case 3:
          ack |= menu_3_write_and_update_dac(selected_dac);
          break;
        case 4:
          ack |= menu_4_update_power_up_dac(selected_dac);
          break;
        case 5:
          ack |= menu_5_power_down_dac(selected_dac);
          break;
        case 6:
          ack |= menu_6_set_reference_mode(); // int, ext, if ext, prompt for voltage
          ack |= restore_calibration();
          break;
        case 7:
          ack |= menu_7_calibrate_dacs();
          restore_calibration();
          break;
        case 8:
          menu_8_enable_calibration();
          restore_calibration();
          break;
        default:
          Serial.println("Incorrect Option");
          break;
      }
      if (ack) Serial.println("I2C NACK received, check address\n");
      Serial.println("\n*****************************************************************");
      print_prompt(selected_dac);
    }
  }
}

// Function Definitions

//! Select which DAC to operate on
//! @return 0
int8_t menu_1_select_dac(int16_t *selected_dac)
{
  // Select a DAC to operate on
  Serial.print("Select DAC to operate on (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H, 8=All)");
  *selected_dac = read_int();
  if (*selected_dac == 8)
    Serial.println("All");
  else
    Serial.println(*selected_dac);
  return (0);
}

//! Write data to input register, but do not update DAC output
//! @return ACK bit (0=acknowledge, 1=no acknowledge)
int8_t menu_2_write_to_input_register(int16_t selected_dac)
{
  int8_t ack=0;
  uint16_t dac_code;

  if (prompt_voltage_or_code() == PROMPT_VOLTAGE)
    dac_code = get_voltage(LTC2657_lsb[selected_dac], LTC2657_offset[selected_dac]);
  else
    dac_code = get_code();

  ack |= LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_WRITE, address_map[selected_dac], dac_code << shift_count);
  return (ack);
}

//!Write data to DAC register (which updates output immediately)
//! @return ACK bit (0=acknowledge, 1=no acknowledge)
int8_t menu_3_write_and_update_dac(int16_t selected_dac)
{
  int8_t ack=0;
  uint16_t dac_code;

  if (prompt_voltage_or_code() == PROMPT_VOLTAGE)
    dac_code = get_voltage(LTC2657_lsb[selected_dac], LTC2657_offset[selected_dac]);
  else
    dac_code = get_code();

  ack |= LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_WRITE_UPDATE, address_map[selected_dac], dac_code << shift_count);
  return (ack);
}

//! Update DAC with data that is stored in input register, power up if sleeping
//! @return ACK bit (0=acknowledge, 1=no acknowledge)
int8_t menu_4_update_power_up_dac(int16_t selected_dac)
{
  // Update DAC
  int8_t ack=0;
  ack |= LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_UPDATE, address_map[selected_dac], 0x0000);
  return (ack);
}

//! Power down DAC
//! @return ACK bit (0=acknowledge, 1=no acknowledge)
int8_t menu_5_power_down_dac(int16_t selected_dac)
{
  // Power down DAC
  int8_t ack=0;
  ack |= LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_POWER_DOWN, address_map[selected_dac], 0x0000);
  return (ack);
}

//! Set reference mode and store to EEPROM
//! @return 0
int8_t menu_6_set_reference_mode(void) // int, ext, if ext, prompt for voltage
{
  int16_t user_input;
  Serial.println("Select reference mode - 0 for Internal, 1 for External");
  user_input = read_int();
  if (user_input == 1)
  {
    reference_mode = REF_EXTERNAL;
    Serial.println("External reference mode; enter external reference voltage");
    reference_voltage = read_float();
    Serial.print(reference_voltage, 5);
    Serial.println("V");
    eeprom_write_float(EEPROM_I2C_ADDRESS, reference_voltage, EXT_REF_V_BASE);
  }
  else
  {
    reference_mode = REF_INTERNAL;
    Serial.println("Internal reference mode selected");
  }
  Serial.println("Writing reference mode to EEPROM\n\n");
  eeprom_write_byte(EEPROM_I2C_ADDRESS, reference_mode, STORED_REF_STATE_BASE);
  return(0);
}

//! Calibrate all DACs by measuring two known outputs
//! @return 0
int8_t menu_7_calibrate_dacs()
{
  // Calibrate the DACs using a multi-meter
  uint8_t i;
  for (i = 0; i < 8; i++)
  {
    calibrate_dac(i);   // Run calibration routine
  }
  store_calibration();
  return (0);
}

//! Enable / Disable calibration. Use with caution - behavior is undefined if you enable calibration and an actual
//! calibration cycle has not been performed.
//! @return 0
int8_t menu_8_enable_calibration()
{
  int16_t user_input;
  Serial.println(F("\n\nSelect option -  0: Enable Internal, 1: Disable Internal, 2: Enable External, 3: Disable External"));
  user_input = read_int();
  switch (user_input)
  {
    case 0:
      Serial.println(F("Enabling Internal Cal Params"));
      eeprom_write_int16(EEPROM_I2C_ADDRESS, EEPROM_CAL_KEY, INT_CAL_VALID_BASE);
      break;
    case 1:
      Serial.println(F("Disabling Internal Cal Params"));
      eeprom_write_int16(EEPROM_I2C_ADDRESS, 0x0000, INT_CAL_VALID_BASE);
      break;
    case 2:
      Serial.println(F("Enabling External Cal Params"));
      eeprom_write_int16(EEPROM_I2C_ADDRESS, EEPROM_CAL_KEY, EXT_CAL_VALID_BASE);
      break;
    case 3:
      Serial.println(F("Disabling External Cal Params"));
      eeprom_write_int16(EEPROM_I2C_ADDRESS, 0x0000, EXT_CAL_VALID_BASE);
      break;
  }
  return(0);
}

//! Read stored calibration parameters from nonvolatile EEPROM on demo board
//! @return Return 1 if successful, 0 if not
int8_t restore_calibration()
// Read the DAC calibration from EEPROM
// Return 1 if successful, 0 if not
{
  int8_t ack=0;
  int16_t intvalid, extvalid;
  uint8_t i, eeaddr;
  float dac_count;                                  // The number of codes, 4096 for 12 bits, 65536 for 16 bits

  Serial.println(F("\n\nReading Calibration parameters from EEPROM..."));
  float full_scale; // To avoid confusion - in internal ref mode, FS=Vref, in ext mode, FS=2*Vref
  // Read the cal keys from the EEPROM.
  eeprom_read_int16(EEPROM_I2C_ADDRESS, &intvalid, INT_CAL_VALID_BASE);
  eeprom_read_int16(EEPROM_I2C_ADDRESS, &extvalid, EXT_CAL_VALID_BASE);
  // Read the stored reference state
  eeprom_read_byte(EEPROM_I2C_ADDRESS, (char *) &reference_mode, STORED_REF_STATE_BASE);
  // Read external ref V unconditionally, overwrite with defaults if no cal found
  eeprom_read_float(EEPROM_I2C_ADDRESS, &reference_voltage, EXT_REF_V_BASE);

  if (reference_mode == REF_EXTERNAL)
  {
    Serial.println(F("Restored external ref. Voltage:"));
    Serial.println(reference_voltage, 5);
  }
  else  // EITHER reference is set to internal, OR not programmed in which case default to internal
  {
    reference_mode = REF_INTERNAL; // Redundant if already set
    Serial.println("Internal reference mode set");
  }

  // Write the reference mode to the DAC right away
  ack |= LTC2657_write(LTC2657_I2C_ADDRESS, reference_mode, 0x0F, 0x0000);

  // Set up default values, shift count, DAC count
  // Calibration parameters MAY be changed next, if match
  // between reference mode and stored calibration
  full_scale = reference_voltage * 2.0; // If external ref mode, this applies.

  // The following two IF statements are used to allow the program to run with
  // a QuikEval string that does not contain the demo board option.
  // If the demo board option is found then these values are overwritten.
  if (strcmp(demo_board.product_name, "LTC2657-L") == 0)
  {
    // LTC2657CUF-L16, 16-bits, 2.5V full scale
    shift_count = 0;
    if (reference_mode == REF_INTERNAL) full_scale = 2.5;
    dac_count = 65536;
  }
  if (strcmp(demo_board.product_name, "LTC2657-H") == 0)
  {
    // LTC2657CUF-H16, 16-bits, 4.096V full scale
    shift_count = 0;
    if (reference_mode == REF_INTERNAL) full_scale = 4.096;
    dac_count = 65536;
  }

  switch (demo_board.option)
  {
    case 'A':
      // LTC2657CUF-L16, 16-bits, 2.5V full scale
      shift_count = 0;
      if (reference_mode == REF_INTERNAL) full_scale = 2.5;
      dac_count = 65536;
      break;
    case 'B':
      // LTC2657CUF-H16, 16-bits, 4.096V full scale
      shift_count = 0;
      if (reference_mode == REF_INTERNAL) full_scale = 4.096;
      dac_count = 65536;
      break;
    case 'C':
      // LTC2657CUF-L12, 12-bits, 2.5V full scale
      // Note: There are no demo boards for the 12-bit version. These are shown to
      // show how to implement  the 12-bit versions.
      shift_count = 4;
      if (reference_mode == REF_INTERNAL) full_scale = 2.5;
      dac_count = 4096;
      break;
    case 'D':
      // LTC2657CUF-H12, 12-bits, 4.096V full scale
      // Note: There are no demo boards for the 12-bit version. These are shown to
      // show how to implement  the 12-bit versions.
      shift_count = 4;
      if (reference_mode == REF_INTERNAL) full_scale = 4.096;
      dac_count = 4096;
      break;
  }

  for (i = 0; i <= 8; i++)
  {
    LTC2657_offset[i] = 0;
    LTC2657_lsb[i] = full_scale / dac_count;
  }

  // Restore calibration IF reference mode matches stored calibration
  eeaddr = 0;   // Assume no calibration present or mismatch between cal and reference mode

  if ((intvalid == EEPROM_CAL_KEY) && (reference_mode == REF_INTERNAL))
  {
    eeaddr = INT_CAL_PARAMS_BASE;
    Serial.println(F("Found internal calibration, restoring...)"));
  }
  else if ((extvalid == EEPROM_CAL_KEY) && (reference_mode == REF_EXTERNAL))
  {
    eeaddr = EXT_CAL_PARAMS_BASE;
    Serial.println(F("Found external calibration, restoring...)"));
  }
  else Serial.println(F("Calibration not found for this\nreference mode, using ideal calibration"));

  if (eeaddr != 0) // If cal key was enabled and reference mode is correct, read offset and lsb
  {
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[0], eeaddr);
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[1], eeaddr + 2);
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[2], eeaddr + 4);
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[3], eeaddr + 6);
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[4], eeaddr + 8);
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[5], eeaddr + 10);
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[6], eeaddr + 12);
    eeprom_read_int16(EEPROM_I2C_ADDRESS, &LTC2657_offset[7], eeaddr + 14);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[0], eeaddr + 16);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[1], eeaddr + 20);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[2], eeaddr + 24);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[3], eeaddr + 28);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[4], eeaddr + 32);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[5], eeaddr + 36);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[6], eeaddr + 40);
    eeprom_read_float(EEPROM_I2C_ADDRESS, &LTC2657_lsb[7], eeaddr + 44);
    LTC2657_offset[8] = LTC2657_offset[0]; // Copy cal value for DAC A to cal value for
    LTC2657_lsb[8] = LTC2657_lsb[0];       // DAC ALL
    Serial.println("Calibration Restored");
  }
  for (i=0; i<=8; ++i)
  {
    Serial.print("DAC ");
    Serial.print((char) ('A' + i));
    Serial.print(" offset: ");
    Serial.print(LTC2657_offset[i]);
    Serial.print(" , lsb: ");
    Serial.print(LTC2657_lsb[i]*1000, 4);
    Serial.println(" mv");
  }
  Serial.println("(DAC I applies to ALL DACs selections)");
  if (eeaddr != 0) return (1);
  return (ack);
}

//! Store measured calibration parameters to nonvolatile EEPROM on demo board
void store_calibration()
// Store the DAC calibration to the EEPROM
{
  uint8_t eeaddr;
  if (reference_mode == REF_INTERNAL)
  {
    eeprom_write_int16(EEPROM_I2C_ADDRESS, EEPROM_CAL_KEY, INT_CAL_VALID_BASE);
    eeaddr = INT_CAL_PARAMS_BASE;
  }
  else
  {
    eeprom_write_int16(EEPROM_I2C_ADDRESS, EEPROM_CAL_KEY, EXT_CAL_VALID_BASE);
    eeaddr = EXT_CAL_PARAMS_BASE;
  }

  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[0], eeaddr);   // Offset
  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[1], eeaddr + 2);
  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[2], eeaddr + 4);
  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[3], eeaddr + 6);
  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[4], eeaddr + 8);
  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[5], eeaddr + 10);
  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[6], eeaddr + 12);
  eeprom_write_int16(EEPROM_I2C_ADDRESS, LTC2657_offset[7], eeaddr + 14);
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[0], eeaddr + 16);     // lsb
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[1], eeaddr + 20);
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[2], eeaddr + 24);
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[3], eeaddr + 28);
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[4], eeaddr + 32);
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[5], eeaddr + 36);
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[6], eeaddr + 40);
  eeprom_write_float(EEPROM_I2C_ADDRESS, LTC2657_lsb[7], eeaddr + 44);
  Serial.println(F("Calibration Stored to EEPROM"));
}

//! Prompt user to enter a voltage or digital code to send to DAC
//! @return prompt type
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);
}

//! Get voltage from user input, calculate DAC code based on lsb, offset
//! @return Returns DAC voltage
uint16_t get_voltage(float LTC2657_lsb, int16_t LTC2657_offset)
{
  float dac_voltage;

  Serial.print(F("Enter Desired DAC output voltage: "));
  dac_voltage = read_float();
  Serial.print(dac_voltage);
  Serial.println(" V");
  Serial.flush();
  return(LTC2657_voltage_to_code(dac_voltage, LTC2657_lsb, LTC2657_offset));
}

//! Get code to send to DAC directly, in decimal, hex, or binary
//! @return Returns DAC code from user
uint16_t get_code()
{
  uint16_t returncode;
  Serial.println("Enter Desired DAC Code");
  Serial.print("(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
  returncode = (uint16_t) read_int();
  Serial.print("0x");
  Serial.println(returncode, HEX);
  Serial.flush();
  return(returncode);
}

//! Prints the title block when program first starts.
void print_title()
{
  Serial.println("");
  Serial.println(F("*****************************************************************"));
  Serial.println(F("* DC1529 Demonstration Program                                  *"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("* This program demonstrates how to send data to the LTC2657     *"));
  Serial.println(F("* Octal 16/12-bit DAC found on the DC1529 demo board.            *"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("*****************************************************************"));
}

//! Prints main menu.
void print_prompt(int16_t selected_dac)
{
  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-Set reference mode"));
  Serial.println(F("  7-Calibrate DAC"));
  Serial.println(F("  8-Enable / Disable calibration"));

  Serial.println("\nPresent Values:");
  Serial.print("  Selected DAC: ");
  if (selected_dac != 8)
    Serial.println((char) (selected_dac + 0x41));
  else
    Serial.println("All");
  Serial.print("  DAC Reference: ");
  if (reference_mode == REF_INTERNAL)
    Serial.println("Internal");
  else
  {
    Serial.print(F("External "));
    Serial.print(reference_voltage, 5);
    Serial.println(F("V reference, please verify"));
  }
  Serial.print(F("Enter a command:"));
  Serial.flush();
}

//! Calibrate the selected DAC using a voltmeter. The routine
//! does a linear curve fit given two data points.
//! @return ACK bit (0=acknowledge, 1=no acknowledge)
int8_t calibrate_dac(uint8_t index)
{
  int8_t ack=0;
  uint16_t code1 = 0x0200;                            //! Calibration code 1
  uint16_t code2 = 0xFFFF;                            //! Calibration code 2
  float voltage1;                                     //! Calibration voltage 1
  float voltage2;                                     //! Calibration voltage 2
  Serial.println("");
  Serial.print("Calibrating DAC ");
  Serial.println((char) (0x41 + index));
  // Left align 12-bit code1 to 16 bits & write to DAC
  ack |= LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_WRITE_UPDATE, index, code1 << shift_count);
  Serial.print("DAC code set to 0x");
  Serial.println(code1, HEX);
  Serial.print("Enter measured DAC voltage:");
  voltage1 = read_float();
  Serial.print(voltage1, 6);
  Serial.println(" V");
  // Left align 12-bit code2 to 16 bits & write to DAC
  ack |= LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_WRITE_UPDATE, index, code2 << shift_count);
  Serial.print("DAC code set to 0x");
  Serial.println(code2, HEX);
  Serial.print("Enter measured DAC voltage:");
  voltage2 = read_float();
  Serial.print(voltage2, 6);
  Serial.println(" V");
  LTC2657_calibrate(code1, code2, voltage1, voltage2, &LTC2657_lsb[index], &LTC2657_offset[index]);
  return(ack);
}

Download LTC2657 Linduino .CPP File

/*!
LTC2657: Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference

@verbatim

The LTC2657 is a family of octal I2C 16-/12-Bit Rail-to-Rail DACs with
Integrated 10ppm/C Max Reference. The DACs have built-in high performance,
rail-to-rail, output buffers and are guaranteed monotonic. The LTC2657-L has a
full-scale output of 2.5V with the integrated reference and operates from a
single 2.7V to 5.5V supply. The LTC2657-H has a full-scale output of 4.096V with
the integrated reference and operates from a 4.5V to 5.5V supply. Each DAC can
also operate with an external reference, which sets the full-scale output to 2
times the external reference voltage.

The parts use a 2-wire I2C compatible serial interface. The LTC2657 operates in
both the standard mode (maximum clock rate of 100kHz) and the fast mode (maximum
clock rate of 400kHz). The LTC2657 incorporates a power-on reset circuit that is
controlled by the PORSEL pin. If PORSEL is tied to GND the DACs reset to
zero-scale at power-up. If PORSEL is tied to VCC, the DACs reset to mid-scale at
power-up.

@endverbatim

http://www.linear.com/product/LTC2657

http://www.linear.com/product/LTC2657#demoboards

REVISION HISTORY
$Revision: 3659 $
$Date: 2015-07-01 10:19:20 -0700 (Wed, 01 Jul 2015) $

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 LTC2657 LTC2657: Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference

/*! @file
    @ingroup LTC2657
    Library for LTC2657 Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference
*/

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

// Write a 16-bit dac_code to the LTC2657.
// The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
int8_t LTC2657_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);
}

// Calculate a LTC2657 DAC code given the desired output voltage and DAC address (0-7)
uint16_t LTC2657_voltage_to_code(float dac_voltage, float LTC2657_lsb, int16_t LTC2657_offset)
{
  int32_t dac_code;
  float float_code;
  float_code = dac_voltage / LTC2657_lsb;                                                             //! 1) Calculate the DAC code
  float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);       //! 2) Round
  dac_code = (int32_t)float_code - LTC2657_offset;                                                    //! 3) Subtract offset
  if (dac_code < 0)                                                                                   //! 4) If DAC code < 0, Then DAC code = 0
    dac_code = 0;
  return ((uint16_t)dac_code);                                                                        //! 5) Cast DAC code as uint16_t
}

// Calculate the LTC2657 DAC output voltage given the DAC code and DAC address (0-7)
float LTC2657_code_to_voltage(uint16_t dac_code, float LTC2657_lsb, int16_t LTC2657_offset)
{
  float dac_voltage;
  dac_voltage = ((float)(dac_code + LTC2657_offset)* LTC2657_lsb);                                    //! 1) Calculates the dac_voltage
  return (dac_voltage);
}

// Calculate the LTC2657 offset and LSB voltage given two measured voltages and their corresponding codes
void LTC2657_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2657_lsb, int16_t *LTC2657_offset)
{
  float temp_offset;
  *LTC2657_lsb = (voltage2 - voltage1) / ((float) (dac_code2 - dac_code1));                           //! 1) Calculate the LSB
  temp_offset = voltage1/(*LTC2657_lsb) - (float)dac_code1;                                           //! 2) Calculate the offset
  temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);  //! 3) Round offset
  *LTC2657_offset = (int16_t)temp_offset;                                                             //! 4) Cast as int16_t
}

Download LTC2657 Linduino Header File

/*!
LTC2657: Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference

@verbatim

The LTC2657 is a family of octal I2C 16-/12-Bit Rail-to-Rail DACs with
Integrated 10ppm/C Max Reference. The DACs have built-in high performance,
rail-to-rail, output buffers and are guaranteed monotonic. The LTC2657-L has a
full-scale output of 2.5V with the integrated reference and operates from a
single 2.7V to 5.5V supply. The LTC2657-H has a full-scale output of 4.096V with
the integrated reference and operates from a 4.5V to 5.5V supply. Each DAC can
also operate with an external reference, which sets the full-scale output to 2
times the external reference voltage.

The parts use a 2-wire I2C compatible serial interface. The LTC2657 operates in
both the standard mode (maximum clock rate of 100kHz) and the fast mode (maximum
clock rate of 400kHz). The LTC2657 incorporates a power-on reset circuit that is
controlled by the PORSEL pin. If PORSEL is tied to GND the DACs reset to
zero-scale at power-up. If PORSEL is tied to VCC, the DACs reset to mid-scale at
power-up.

I2C DATA FORMAT (MSB First):
             Byte #1                                    Byte #2

LTC2657-16 : START  SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK  C3 C2 C1 C0 A3 A2 A1 A0 SACK
LTC2657-12 : START  SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK  C3 C2 C1 C0 A3 A2 A1 A0 SACK

Byte #3                             Byte #4
MSB                                 LSB
D15 D14 D13 D12 D11 D10 D9 D8 SACK  D7 D6 D5 D4 D3 D2 D1 D0 SACK  STOP
D11 D10 D9  D8  D7  D6  D5 D4 SACK  D3 D2 D1 D0 X  X  X  X  SACK  STOP

START: I2C Start
SAx  : I2C Address
W    : I2C Write (0)
SACK : I2C Slave Generated Acknowledge (Active Low)
Cx   : DAC Command Code
Ax   : DAC Address (0=DACA, 1=DACB, 2=DACC, 3=DACD, 4=DACE, 5=DACF, 6=DACG, 7=DACH, 0xFF=All DACs)
Dx   : DAC Data Bits
X    : Don't care
STOP : I2C Stop

Example Code:

Set DAC A to to 2V for 16-bit DAC.

    shift_count = 0;    // 16-bit DAC does not have to be shifted
    dac_voltage = 2.0;  // Sets dac voltage variable to 2v

    dac_code = LTC2657_voltage_to_code(dac_voltage, LTC2657_lsb, LTC2657_offset);   // Calculate DAC code from voltage, lsb, and offset
    ack = LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_WRITE_UPDATE, LTC2657_DAC_A, dac_code);    // Set DAC A with DAC code

@endverbatim

http://www.linear.com/product/LTC2657

http://www.linear.com/product/LTC2657#demoboards

REVISION HISTORY
$Revision: 3659 $
$Date: 2015-07-01 10:19:20 -0700 (Wed, 01 Jul 2015) $

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 LTC2657
    Header for LTC2657 Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference
*/

#ifndef LTC2657_H
#define LTC2657_H

#include <Wire.h>

//! @name I2C_Addresses
//!@{
// I2C Address Choices:
// To choose an address, comment out all options except the
// configuration on the demo board.

//  Address assignment
// LTC2657 I2C Address                //  AD2       AD1       AD0
#define LTC2657_I2C_ADDRESS 0x10      //  GND       GND       GND
// #define LTC2657_I2C_ADDRESS 0x11    //  GND       GND       Float
// #define LTC2657_I2C_ADDRESS 0x12    //  GND       GND       Vcc
// #define LTC2657_I2C_ADDRESS 0x13    //  GND       Float     GND
// #define LTC2657_I2C_ADDRESS 0x20    //  GND       Float     Float
// #define LTC2657_I2C_ADDRESS 0x21    //  GND       Float     Vcc
// #define LTC2657_I2C_ADDRESS 0x22    //  GND       Vcc       GND
// #define LTC2657_I2C_ADDRESS 0x23    //  GND       Vcc       Float
// #define LTC2657_I2C_ADDRESS 0x30    //  GND       Vcc       Vcc
// #define LTC2657_I2C_ADDRESS 0x31    //  Float     GND       GND
// #define LTC2657_I2C_ADDRESS 0x32    //  Float     GND       Float
// #define LTC2657_I2C_ADDRESS 0x33    //  Float     GND       Vcc
// #define LTC2657_I2C_ADDRESS 0x40    //  Float     Float     GND
// #define LTC2657_I2C_ADDRESS 0x41    //  Float     Float     Float
// #define LTC2657_I2C_ADDRESS 0x42    //  Float     Float     Vcc
// #define LTC2657_I2C_ADDRESS 0x43    //  Float     Vcc       GND
// #define LTC2657_I2C_ADDRESS 0x50    //  Float     Vcc       Float
// #define LTC2657_I2C_ADDRESS 0x51    //  Float     Vcc       Vcc
// #define LTC2657_I2C_ADDRESS 0x52    //  Vcc       GND       GND
// #define LTC2657_I2C_ADDRESS 0x53    //  Vcc       GND       Float
// #define LTC2657_I2C_ADDRESS 0x60    //  Vcc       GND       Vcc
// #define LTC2657_I2C_ADDRESS 0x61    //  Vcc       Float     GND
// #define LTC2657_I2C_ADDRESS 0x62    //  Vcc       Float     Float
// #define LTC2657_I2C_ADDRESS 0x63    //  Vcc       Float     Vcc
// #define LTC2657_I2C_ADDRESS 0x70    //  Vcc       Vcc       GND
// #define LTC2657_I2C_ADDRESS 0x71    //  Vcc       Vcc       Float
// #define LTC2657_I2C_ADDRESS 0x72    //  Vcc       Vcc       Vcc

#define LTC2657_I2C_GLOBAL_ADDRESS  0x73
//! @}

//! @name LTC2657 Command Codes
//! @{
//! OR'd together with the DAC address to form the command byte
#define  LTC2657_CMD_WRITE               0x00  // Write to input register n
#define  LTC2657_CMD_UPDATE              0x10  // Update (power up) DAC register n
#define  LTC2657_CMD_WRITE_UPDATE        0x30  // Write to input register n, update (power up) all
#define  LTC2657_CMD_POWER_DOWN          0x40  // Power down n
#define  LTC2657_CMD_POWER_DOWN_ALL      0x50  // Power down chip (all DACs and reference)
#define  LTC2657_CMD_INTERNAL_REFERENCE  0x60  // Select internal reference (power up reference)
#define  LTC2657_CMD_EXTERNAL_REFERENCE  0x70  // Select external reference (power down internal reference)
#define  LTC2657_CMD_NO_OPERATION        0xF0  // No operation
//! @}

//! @name LTC2657 DAC Addresses
//! @{
//! Which DAC to operate on
#define  LTC2657_DAC_A     0x00
#define  LTC2657_DAC_B     0x01
#define  LTC2657_DAC_C     0x02
#define  LTC2657_DAC_D     0x03
#define  LTC2657_DAC_E     0x04
#define  LTC2657_DAC_F     0x05
#define  LTC2657_DAC_G     0x06
#define  LTC2657_DAC_H     0x07
#define  LTC2657_DAC_ALL   0x0F
//! @}

// Command Example - write to DAC address D and update all.
// dac_command = LTC2657_CMD_WRITE_UPDATE | LTC2657_DAC_D;

//! Write a 16-bit dac_code to the LTC2657.
//! @return ACK bit (0=acknowledge, 1=no acknowledge)
int8_t  LTC2657_write(uint8_t  i2c_address,                   //!< I2C address of DAC
                      uint8_t  dac_command,                   //!< Command Nibble, left-justified, lower nibble set to zero
                      uint8_t  dac_address,                   //!< DAC Address Nibble, right justified, upper nibble set to zero
                      uint16_t dac_code                       //!< 16-bit DAC code
                     );

//! Calculate a LTC2657 DAC code given the desired output voltage and DAC address (0-3)
//! @return The 16-bit code to send to the DAC
uint16_t LTC2657_voltage_to_code(float dac_voltage,       //!< Voltage to send to DAC
                                 float LTC2657_lsb,       //!< LSB value (volts)
                                 int16_t LTC2657_offset   //!< Offset (volts)
                                );

//! Calculate the LTC2657 DAC output voltage given the DAC code, offset, and LSB value
//! @return Calculated voltage
float LTC2657_code_to_voltage(uint16_t dac_code,          //!< DAC code
                              float LTC2657_lsb,          //!< LSB value (volts)
                              int16_t LTC2657_offset      //!< Offset (volts)
                             );

//! Calculate the LTC2657 offset and LSB voltages given two measured voltages and their corresponding codes
//! @return Void
void LTC2657_calibrate(uint16_t dac_code1,                //!< First DAC code
                       uint16_t dac_code2,                //!< Second DAC code
                       float voltage1,                    //!< First voltage
                       float voltage2,                    //!< Second voltage
                       float *LTC2657_lsb,                //!< Returns resulting LSB (volts)
                       int16_t *LTC2657_offset            //!< Returns resulting Offset (volts)
                      );

#endif  // LTC2657_H

Technical Support