| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2605.h
Go to the documentation of this file.
1 /*!
2 LTC2605: Octal 16-/14-/12-Bit Rail-to Rail DACs in 16-Lead SSOP
3
4 @verbatim
5
6 The LTC2605/LTC2615/LTC2625 are octal 16-, 14- and 12-bit, 2.7V to 5.5V
7 rail-to-rail voltage-output DACs in 16-lead narrow SSOP packages. They have
8 built-in high performance output buffers and are guaranteed monotonic.
9
10 These parts establish new board-density benchmarks for 16-/14-bit DACs and
11 advance performance standards for output drive, crosstalk and load regulation
12 in single supply, voltage-output multiples.
13
14
15 I2C DATA FORMAT (MSB First):
16
17 Byte #1 Byte #2
18 MSB
19 LTC2655-16 : START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK C3 C2 C1 C0 A3 A2 A1 A0 SACK
20 LTC2655-12 : START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK C3 C2 C1 C0 A3 A2 A1 A0 SACK
21
22
23 Byte #3 Byte #4
24 LSB
25 D15 D14 D13 D12 D11 D10 D9 D8 SACK D7 D6 D5 D4 D3 D2 D1 D0 SACK STOP
26 D11 D10 D9 D8 D7 D6 D5 D4 SACK D3 D2 D1 D0 X X X X SACK STOP
27
28 START: I2C Start
29 SAx : I2C Address
30 W : I2C Write (0)
31 SACK : I2C Slave Generated Acknowledge (Active Low)
32 Cx : DAC Command Code
33 Ax : DAC Address (0=DACA, 1=DACB, 2=DACC, 3=DACD, 0xFF=All DACs)
34 Dx : DAC Data Bits
35 X : Don't care
36 STOP : I2C Stop
37
38
39 Example Code:
40
41 Set DAC A to to 2V for 16-bit DAC.
42
43 shift_count = 0; // 16-bit DAC does not have to be shifted
44 dac_voltage = 2.0; // Sets dac voltage variable to 2v
45
46 dac_code = LTC2605_voltage_to_code(dac_voltage, LTC2605_lsb, LTC2605_offset); // Calculate DAC code from voltage, lsb, and offset
47 ack = LTC2655_write(LTC2605_I2C_ADDRESS, LTC2605_CMD_WRITE_UPDATE, LTC2605_DAC_A, dac_code); // Set DAC A with DAC code
48
49 @endverbatim
50
51
52 http://www.linear.com/product/LTC2605
53
54 http://www.linear.com/product/LTC2605#demoboards
55
56
57
58
59 Copyright 2018(c) Analog Devices, Inc.
60
61 All rights reserved.
62
63 Redistribution and use in source and binary forms, with or without
64 modification, are permitted provided that the following conditions are met:
65 - Redistributions of source code must retain the above copyright
66 notice, this list of conditions and the following disclaimer.
67 - Redistributions in binary form must reproduce the above copyright
68 notice, this list of conditions and the following disclaimer in
69 the documentation and/or other materials provided with the
70 distribution.
71 - Neither the name of Analog Devices, Inc. nor the names of its
72 contributors may be used to endorse or promote products derived
73 from this software without specific prior written permission.
74 - The use of this software may or may not infringe the patent rights
75 of one or more patent holders. This license does not release you
76 from the requirement that you obtain separate licenses from these
77 patent holders to use this software.
78 - Use of the software either in source or binary form, must be run
79 on or directly connected to an Analog Devices Inc. component.
80
81 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
82 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
83 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
84 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
85 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
86 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
87 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
88 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
89 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
90 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91 */
92 /*! @file
93 @ingroup LTC2605
94 Header for LTC2605: Octal 16-/14-/12-Bit Rail-to Rail DACs in 16-Lead SSOP
95 */
96
97 #ifndef LTC2605_H
98 #define LTC2605_H
99
100 #include <Wire.h>
101 //!Use table to select address
102 /*!
103 |LTC2604 I2C Address Assignment| Value | AD2 | AD1 | AD0 |
104 | :--------------------------: | :------: | :------: |:------: | :------: |
105 | LTC2605_I2C_ADDRESS | 0x10 | GND | GND | GND |
106 | LTC2605_I2C_ADDRESS | 0x11 | GND | GND | Float |
107 | LTC2605_I2C_ADDRESS | 0x12 | GND | GND | Vcc |
108 | LTC2605_I2C_ADDRESS | 0x13 | GND | Float | GND |
109 | LTC2605_I2C_ADDRESS | 0x20 | GND | Float | Float |
110 | LTC2605_I2C_ADDRESS | 0x21 | GND | Float | Vcc |
111 | LTC2605_I2C_ADDRESS | 0x22 | GND | Vcc | GND |
112 | LTC2605_I2C_ADDRESS | 0x23 | GND | Vcc | Float |
113 | LTC2605_I2C_ADDRESS | 0x30 | GND | Vcc | Vcc |
114 | LTC2605_I2C_ADDRESS | 0x31 | Float | GND | GND |
115 | LTC2605_I2C_ADDRESS | 0x32 | Float | GND | Float |
116 | LTC2605_I2C_ADDRESS | 0x33 | Float | GND | Vcc |
117 | LTC2605_I2C_ADDRESS | 0x40 | Float | Float | GND |
118 | LTC2605_I2C_ADDRESS | 0x41 | Float | Float | Float |
119 | LTC2605_I2C_ADDRESS | 0x42 | Float | Float | Vcc |
120 | LTC2605_I2C_ADDRESS | 0x43 | Float | Vcc | GND |
121 | LTC2605_I2C_ADDRESS | 0x50 | Float | Vcc | Float |
122 | LTC2605_I2C_ADDRESS | 0x51 | Float | Vcc | Vcc |
123 | LTC2605_I2C_ADDRESS | 0x52 | Vcc | GND | GND |
124 | LTC2605_I2C_ADDRESS | 0x53 | Vcc | GND | Float |
125 | LTC2605_I2C_ADDRESS | 0x60 | Vcc | GND | Vcc |
126 | LTC2605_I2C_ADDRESS | 0x61 | Vcc | Float | GND |
127 | LTC2605_I2C_ADDRESS | 0x62 | Vcc | Float | Float |
128 | LTC2605_I2C_ADDRESS | 0x63 | Vcc | Float | Vcc |
129 | LTC2605_I2C_ADDRESS | 0x70 | Vcc | Vcc | GND |
130 | LTC2605_I2C_ADDRESS | 0x71 | Vcc | Vcc | Float |
131 | LTC2605_I2C_ADDRESS | 0x72 | Vcc | Vcc | Vcc |
132 | LTC2605_I2C_GLOBAL_ADDRESS | 0x73 | X | X | X |
133 */
134 /*! @name LTC2604 Address Assignments
135 @{ */
136
137 // I2C Address Choices:
138 // To choose an address, comment out all options except the
139 // configuration on the demo board.
140
141 // Address assignment
142 // LTC2605 I2C Address // AD2 AD1 AD0
143 // #define LTC2605_I2C_ADDRESS 0x10 // GND GND GND
144 // #define LTC2605_I2C_ADDRESS 0x11 // GND GND Float
145 // #define LTC2605_I2C_ADDRESS 0x12 // GND GND Vcc
146 // #define LTC2605_I2C_ADDRESS 0x13 // GND Float GND
147 // #define LTC2605_I2C_ADDRESS 0x20 // GND Float Float
148 // #define LTC2605_I2C_ADDRESS 0x21 // GND Float Vcc
149 // #define LTC2605_I2C_ADDRESS 0x22 // GND Vcc GND
150 // #define LTC2605_I2C_ADDRESS 0x23 // GND Vcc Float
151 // #define LTC2605_I2C_ADDRESS 0x30 // GND Vcc Vcc
152 // #define LTC2605_I2C_ADDRESS 0x31 // Float GND GND
153 // #define LTC2605_I2C_ADDRESS 0x32 // Float GND Float
154 // #define LTC2605_I2C_ADDRESS 0x33 // Float GND Vcc
155 // #define LTC2605_I2C_ADDRESS 0x40 // Float Float GND
156 // #define LTC2605_I2C_ADDRESS 0x41 // Float Float Float
157 // #define LTC2605_I2C_ADDRESS 0x42 // Float Float Vcc
158 // #define LTC2605_I2C_ADDRESS 0x43 // Float Vcc GND
159 // #define LTC2605_I2C_ADDRESS 0x50 // Float Vcc Float
160 // #define LTC2605_I2C_ADDRESS 0x51 // Float Vcc Vcc
161 // #define LTC2605_I2C_ADDRESS 0x52 // Vcc GND GND
162 // #define LTC2605_I2C_ADDRESS 0x53 // Vcc GND Float
163 // #define LTC2605_I2C_ADDRESS 0x60 // Vcc GND Vcc
164 // #define LTC2605_I2C_ADDRESS 0x61 // Vcc Float GND
165 // #define LTC2605_I2C_ADDRESS 0x62 // Vcc Float Float
166 // #define LTC2605_I2C_ADDRESS 0x63 // Vcc Float Vcc
167 // #define LTC2605_I2C_ADDRESS 0x70 // Vcc Vcc GND
168 // #define LTC2605_I2C_ADDRESS 0x71 // Vcc Vcc Float
169 #define LTC2605_I2C_ADDRESS 0x72 // Vcc Vcc Vcc
170 //#define LTC2605_I2C_GLOBAL_ADDRESS 0x73
171
172
173
174
175
176
177 //! @name LTC2655 Command Codes
178 //! @{
179 //! OR'd together with the DAC address to form the command byte
180 #define LTC2605_CMD_WRITE 0x00 //!< Write to input register n
181 #define LTC2605_CMD_UPDATE 0x10 //!< Update (power up) DAC register n
182 #define LTC2605_CMD_WRITE_UPDATE 0x30 //!< Write to input register n, update (power up) all
183 #define LTC2605_CMD_POWER_DOWN 0x40 //!< Power down n
184 #define LTC2605_CMD_POWER_DOWN_ALL 0x50 //!< Power down chip (all DACs and reference)
185 #define LTC2605_CMD_INTERNAL_REFERENCE 0x60 //!< Select internal reference (power up reference)
186 #define LTC2605_CMD_EXTERNAL_REFERENCE 0x70 //!< Select external reference (power down internal reference)
187 #define LTC2605_CMD_NO_OPERATION 0xF0 //!< No operation
188 //! @}
189
190 /*!
191 | DAC Addresses | Value |
192 | :--------------------------: | :------: |
193 | LTC2605_DAC_A | 0x00 |
194 | LTC2605_DAC_B | 0x01 |
195 | LTC2605_DAC_C | 0x02 |
196 | LTC2605_DAC_D | 0x03 |
197 | LTC2605_DAC_E | 0x04 |
198 | LTC2605_DAC_F | 0x05 |
199 | LTC2605_DAC_G | 0x06 |
200 | LTC2605_DAC_H | 0x07 |
201 | LTC2605_DAC_ALL | 0x0F |
202 */
203 /*! @name Dac Addresses
204 @{*/
205
206 // Which DAC to operate on
207 #define LTC2605_DAC_A 0x00
208 #define LTC2605_DAC_B 0x01
209 #define LTC2605_DAC_C 0x02
210 #define LTC2605_DAC_D 0x03
211 #define LTC2605_DAC_E 0x04
212 #define LTC2605_DAC_F 0x05
213 #define LTC2605_DAC_G 0x06
214 #define LTC2605_DAC_H 0x07
215 #define LTC2605_DAC_ALL 0x0F
216
217
218 //! Write a 16-bit dac_code to the LTC2605.
219 //! @return ACK bit (0=acknowledge, 1=no acknowledge)
220 int8_t LTC2605_write(uint8_t i2c_address, //!< I2C address of DAC
221 uint8_t dac_command, //!< Command Nibble, left-justified, lower nibble set to zero
222 uint8_t dac_address, //!< DAC Address Nibble, right justified, upper nibble set to zero
223 uint16_t dac_code //!< 16-bit DAC code
224 );
225
226 //! Calculate a LTC2605 DAC code given the desired output voltage
227 //! @return The 16-bit code to send to the DAC
228 uint16_t LTC2605_voltage_to_code(float dac_voltage, //!< Voltage to send to DAC
229 float LTC2605_lsb, //!< LSB value
230 int16_t LTC2605_offset //!< Offset
231 );
232
233 //! Calculate the LTC2605 DAC output voltage given the DAC code, offset, and LSB value
234 //! @return Calculated voltage
235 float LTC2605_code_to_voltage(uint16_t dac_code, //!< DAC code
236 float LTC2605_lsb, //!< LSB value
237 int16_t LTC2605_offset //!< Offset
238 );
239
240 #endif //LTC2605_H
241
i2c_address
uint8_t i2c_address
LTC2605_offset
static int16_t LTC2605_offset
DAC offset.
Definition: DC935A.ino:128
LTC2605_code_to_voltage
float LTC2605_code_to_voltage(uint16_t dac_code, float LTC2605_lsb, int16_t LTC2605_offset)
Calculate the LTC2605 DAC output voltage given the DAC code, offset, and LSB value.
Definition: LTC2605.cpp:98
LTC2605_voltage_to_code
uint16_t LTC2605_voltage_to_code(float dac_voltage, float LTC2605_lsb, int16_t LTC2605_offset)
Calculate a LTC2605 DAC code given the desired output voltage.
Definition: LTC2605.cpp:85
LTC2605_write
int8_t LTC2605_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 LTC2605.
Definition: LTC2605.cpp:76
LTC2605_lsb
static float LTC2605_lsb
Definition: DC935A.ino:129