Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2657.h
Go to the documentation of this file.
1 /*!
2 LTC2657: Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference
3 
4 @verbatim
5 
6 The LTC2657 is a family of octal I2C 16-/12-Bit Rail-to-Rail DACs with
7 Integrated 10ppm/C Max Reference. The DACs have built-in high performance,
8 rail-to-rail, output buffers and are guaranteed monotonic. The LTC2657-L has a
9 full-scale output of 2.5V with the integrated reference and operates from a
10 single 2.7V to 5.5V supply. The LTC2657-H has a full-scale output of 4.096V with
11 the integrated reference and operates from a 4.5V to 5.5V supply. Each DAC can
12 also operate with an external reference, which sets the full-scale output to 2
13 times the external reference voltage.
14 
15 The parts use a 2-wire I2C compatible serial interface. The LTC2657 operates in
16 both the standard mode (maximum clock rate of 100kHz) and the fast mode (maximum
17 clock rate of 400kHz). The LTC2657 incorporates a power-on reset circuit that is
18 controlled by the PORSEL pin. If PORSEL is tied to GND the DACs reset to
19 zero-scale at power-up. If PORSEL is tied to VCC, the DACs reset to mid-scale at
20 power-up.
21 
22 I2C DATA FORMAT (MSB First):
23  Byte #1 Byte #2
24 
25 LTC2657-16 : START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK C3 C2 C1 C0 A3 A2 A1 A0 SACK
26 LTC2657-12 : START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK C3 C2 C1 C0 A3 A2 A1 A0 SACK
27 
28 Byte #3 Byte #4
29 MSB LSB
30 D15 D14 D13 D12 D11 D10 D9 D8 SACK D7 D6 D5 D4 D3 D2 D1 D0 SACK STOP
31 D11 D10 D9 D8 D7 D6 D5 D4 SACK D3 D2 D1 D0 X X X X SACK STOP
32 
33 START: I2C Start
34 SAx : I2C Address
35 W : I2C Write (0)
36 SACK : I2C Slave Generated Acknowledge (Active Low)
37 Cx : DAC Command Code
38 Ax : DAC Address (0=DACA, 1=DACB, 2=DACC, 3=DACD, 4=DACE, 5=DACF, 6=DACG, 7=DACH, 0xFF=All DACs)
39 Dx : DAC Data Bits
40 X : Don't care
41 STOP : I2C Stop
42 
43 Example Code:
44 
45 Set DAC A to to 2V for 16-bit DAC.
46 
47  shift_count = 0; // 16-bit DAC does not have to be shifted
48  dac_voltage = 2.0; // Sets dac voltage variable to 2v
49 
50  dac_code = LTC2657_voltage_to_code(dac_voltage, LTC2657_lsb, LTC2657_offset); // Calculate DAC code from voltage, lsb, and offset
51  ack = LTC2657_write(LTC2657_I2C_ADDRESS, LTC2657_CMD_WRITE_UPDATE, LTC2657_DAC_A, dac_code); // Set DAC A with DAC code
52 
53 @endverbatim
54 
55 http://www.linear.com/product/LTC2657
56 
57 http://www.linear.com/product/LTC2657#demoboards
58 
59 
60 Copyright 2018(c) Analog Devices, Inc.
61 
62 All rights reserved.
63 
64 Redistribution and use in source and binary forms, with or without
65 modification, are permitted provided that the following conditions are met:
66  - Redistributions of source code must retain the above copyright
67  notice, this list of conditions and the following disclaimer.
68  - Redistributions in binary form must reproduce the above copyright
69  notice, this list of conditions and the following disclaimer in
70  the documentation and/or other materials provided with the
71  distribution.
72  - Neither the name of Analog Devices, Inc. nor the names of its
73  contributors may be used to endorse or promote products derived
74  from this software without specific prior written permission.
75  - The use of this software may or may not infringe the patent rights
76  of one or more patent holders. This license does not release you
77  from the requirement that you obtain separate licenses from these
78  patent holders to use this software.
79  - Use of the software either in source or binary form, must be run
80  on or directly connected to an Analog Devices Inc. component.
81 
82 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
83 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
84 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
85 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
86 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
87 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
88 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
89 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
90 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
91 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92 */
93 
94 /*! @file
95  @ingroup LTC2657
96  Header for LTC2657 Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference
97 */
98 
99 #ifndef LTC2657_H
100 #define LTC2657_H
101 
102 #include <Wire.h>
103 
104 //! @name I2C_Addresses
105 //!@{
106 // I2C Address Choices:
107 // To choose an address, comment out all options except the
108 // configuration on the demo board.
109 
110 // Address assignment
111 // LTC2657 I2C Address // AD2 AD1 AD0
112 #define LTC2657_I2C_ADDRESS 0x10 // GND GND GND
113 // #define LTC2657_I2C_ADDRESS 0x11 // GND GND Float
114 // #define LTC2657_I2C_ADDRESS 0x12 // GND GND Vcc
115 // #define LTC2657_I2C_ADDRESS 0x13 // GND Float GND
116 // #define LTC2657_I2C_ADDRESS 0x20 // GND Float Float
117 // #define LTC2657_I2C_ADDRESS 0x21 // GND Float Vcc
118 // #define LTC2657_I2C_ADDRESS 0x22 // GND Vcc GND
119 // #define LTC2657_I2C_ADDRESS 0x23 // GND Vcc Float
120 // #define LTC2657_I2C_ADDRESS 0x30 // GND Vcc Vcc
121 // #define LTC2657_I2C_ADDRESS 0x31 // Float GND GND
122 // #define LTC2657_I2C_ADDRESS 0x32 // Float GND Float
123 // #define LTC2657_I2C_ADDRESS 0x33 // Float GND Vcc
124 // #define LTC2657_I2C_ADDRESS 0x40 // Float Float GND
125 // #define LTC2657_I2C_ADDRESS 0x41 // Float Float Float
126 // #define LTC2657_I2C_ADDRESS 0x42 // Float Float Vcc
127 // #define LTC2657_I2C_ADDRESS 0x43 // Float Vcc GND
128 // #define LTC2657_I2C_ADDRESS 0x50 // Float Vcc Float
129 // #define LTC2657_I2C_ADDRESS 0x51 // Float Vcc Vcc
130 // #define LTC2657_I2C_ADDRESS 0x52 // Vcc GND GND
131 // #define LTC2657_I2C_ADDRESS 0x53 // Vcc GND Float
132 // #define LTC2657_I2C_ADDRESS 0x60 // Vcc GND Vcc
133 // #define LTC2657_I2C_ADDRESS 0x61 // Vcc Float GND
134 // #define LTC2657_I2C_ADDRESS 0x62 // Vcc Float Float
135 // #define LTC2657_I2C_ADDRESS 0x63 // Vcc Float Vcc
136 // #define LTC2657_I2C_ADDRESS 0x70 // Vcc Vcc GND
137 // #define LTC2657_I2C_ADDRESS 0x71 // Vcc Vcc Float
138 // #define LTC2657_I2C_ADDRESS 0x72 // Vcc Vcc Vcc
139 
140 #define LTC2657_I2C_GLOBAL_ADDRESS 0x73
141 //! @}
142 
143 //! @name LTC2657 Command Codes
144 //! @{
145 //! OR'd together with the DAC address to form the command byte
146 #define LTC2657_CMD_WRITE 0x00 // Write to input register n
147 #define LTC2657_CMD_UPDATE 0x10 // Update (power up) DAC register n
148 #define LTC2657_CMD_WRITE_UPDATE 0x30 // Write to input register n, update (power up) all
149 #define LTC2657_CMD_POWER_DOWN 0x40 // Power down n
150 #define LTC2657_CMD_POWER_DOWN_ALL 0x50 // Power down chip (all DACs and reference)
151 #define LTC2657_CMD_INTERNAL_REFERENCE 0x60 // Select internal reference (power up reference)
152 #define LTC2657_CMD_EXTERNAL_REFERENCE 0x70 // Select external reference (power down internal reference)
153 #define LTC2657_CMD_NO_OPERATION 0xF0 // No operation
154 //! @}
155 
156 //! @name LTC2657 DAC Addresses
157 //! @{
158 //! Which DAC to operate on
159 #define LTC2657_DAC_A 0x00
160 #define LTC2657_DAC_B 0x01
161 #define LTC2657_DAC_C 0x02
162 #define LTC2657_DAC_D 0x03
163 #define LTC2657_DAC_E 0x04
164 #define LTC2657_DAC_F 0x05
165 #define LTC2657_DAC_G 0x06
166 #define LTC2657_DAC_H 0x07
167 #define LTC2657_DAC_ALL 0x0F
168 //! @}
169 
170 // Command Example - write to DAC address D and update all.
171 // dac_command = LTC2657_CMD_WRITE_UPDATE | LTC2657_DAC_D;
172 
173 //! Write a 16-bit dac_code to the LTC2657.
174 //! @return ACK bit (0=acknowledge, 1=no acknowledge)
175 int8_t LTC2657_write(uint8_t i2c_address, //!< I2C address of DAC
176  uint8_t dac_command, //!< Command Nibble, left-justified, lower nibble set to zero
177  uint8_t dac_address, //!< DAC Address Nibble, right justified, upper nibble set to zero
178  uint16_t dac_code //!< 16-bit DAC code
179  );
180 
181 //! Calculate a LTC2657 DAC code given the desired output voltage and DAC address (0-3)
182 //! @return The 16-bit code to send to the DAC
183 uint16_t LTC2657_voltage_to_code(float dac_voltage, //!< Voltage to send to DAC
184  float LTC2657_lsb, //!< LSB value (volts)
185  int16_t LTC2657_offset //!< Offset (volts)
186  );
187 
188 //! Calculate the LTC2657 DAC output voltage given the DAC code, offset, and LSB value
189 //! @return Calculated voltage
190 float LTC2657_code_to_voltage(uint16_t dac_code, //!< DAC code
191  float LTC2657_lsb, //!< LSB value (volts)
192  int16_t LTC2657_offset //!< Offset (volts)
193  );
194 
195 //! Calculate the LTC2657 offset and LSB voltages given two measured voltages and their corresponding codes
196 //! @return Void
197 void LTC2657_calibrate(uint16_t dac_code1, //!< First DAC code
198  uint16_t dac_code2, //!< Second DAC code
199  float voltage1, //!< First voltage
200  float voltage2, //!< Second voltage
201  float *LTC2657_lsb, //!< Returns resulting LSB (volts)
202  int16_t *LTC2657_offset //!< Returns resulting Offset (volts)
203  );
204 
205 #endif // LTC2657_H
uint8_t i2c_address
uint16_t LTC2657_voltage_to_code(float dac_voltage, float LTC2657_lsb, int16_t LTC2657_offset)
Calculate a LTC2657 DAC code given the desired output voltage and DAC address (0-3) ...
Definition: LTC2657.cpp:91
float LTC2657_code_to_voltage(uint16_t dac_code, float LTC2657_lsb, int16_t LTC2657_offset)
Calculate the LTC2657 DAC output voltage given the DAC code, offset, and LSB value.
Definition: LTC2657.cpp:104
static int16_t LTC2657_offset[9]
DAC offset - index 8 for "all DACs".
Definition: DC1529A.ino:163
int8_t LTC2657_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write a 16-bit dac_code to the LTC2657.
Definition: LTC2657.cpp:82
void LTC2657_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2657_lsb, int16_t *LTC2657_offset)
Calculate the LTC2657 offset and LSB voltages given two measured voltages and their corresponding cod...
Definition: LTC2657.cpp:112
static float LTC2657_lsb[9]
The LTC2657 lsb - index 8 for "all DACs".
Definition: DC1529A.ino:164