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