Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2499.h
Go to the documentation of this file.
1 /*!
2 LTC2499: 24-Bit, 16-Channel Delta Sigma ADCs with Easy Drive Input Current Cancellation
3 
4 @verbatim
5 
6 The LTC2499 is a 16-channel (eight differential), 24-bit, No Latency DS TM
7 ADC with Easy Drive technology and a 2-wire, I2C interface. The patented
8 sampling scheme eliminates dynamic input current errors and the
9 shortcomings of on-chip buffering through automatic cancellation of
10 differential input current. This allows large external source impedances
11 and rail-to-rail input signals to be directly digitized while maintaining
12 exceptional DC accuracy.
13 
14 I2C DATA FORMAT (MSB FIRST);
15 
16 Data Out:
17 Byte #1 Byte #2
18 
19 START SA6 SA5 SA4 SA3 SA2 SA1 SA0 R SACK SGN MSB D23 D22 D21 D20 D19 D18 MACK
20 
21 Byte #3 Byte #4
22 D17 D16 D15 D14 D13 D12 D11 D10 MACK D9 D8 D7 D6 D5 D4 D3 D2
23 
24 Byte #5
25 MACK D1 D0 SUB5 SUB4 SUB3 SUB2 SUB1 SUB0 MNACK STOP
26 
27 
28 Data In:
29 Byte #1 Byte #2
30  MSB
31 START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK C12 C11 C10 C9 C8 C7 C6 C5 SACK
32 
33 Byte #3
34 C4 C3 C2 C1 C0 X X X SACK STOP
35 
36 START : I2C Start
37 REPEAT Start : I2C Repeat Start
38 STOP : I2C Stop
39 SACK : I2C Slave Generated Acknowledge (Active Low)
40 MACK : I2C Master Generated Acknowledge (Active Low)
41 MNACK : I2C Master Generated Not Acknowledge
42 SAx : I2C Address
43 W : I2C Write (0)
44 R : I2C Read (1)
45 Cx : Command Code
46 Dx : Data Bits
47 X : Don't care
48 MSB : Most Significant Bit
49 
50 Example Code:
51 
52 Read Channel 0 in Single-Ended with 1X speed mode and rejection frequency of 50Hz
53 
54  adc_command_high = LTC2499_CH0; // Build ADC command for channel 0
55  adc_command_low = LTC2499_R50 | LTC2499_SPEED_1X; // Set to 1X mode with 50hz rejection
56  ack |= LTC2499_read(i2c_address, adc_command_high, adc_command_low, &adc_code); // Throws out last reading
57 
58  ack |= LTC2499_read(i2c_address, adc_command_high, adc_command_low, &adc_code); // Obtains the current reading and stores to adc_code variable
59 
60  if(!ack)
61  adc_voltage = LTC2499_code_to_voltage(adc_code, LTC2499_vref); // Convert adc_code to voltage
62 
63 @endverbatim
64 
65 http://www.linear.com/product/LTC2499
66 
67 http://www.linear.com/product/LTC2499#demoboards
68 
69 
70 Copyright 2018(c) Analog Devices, Inc.
71 
72 All rights reserved.
73 
74 Redistribution and use in source and binary forms, with or without
75 modification, are permitted provided that the following conditions are met:
76  - Redistributions of source code must retain the above copyright
77  notice, this list of conditions and the following disclaimer.
78  - Redistributions in binary form must reproduce the above copyright
79  notice, this list of conditions and the following disclaimer in
80  the documentation and/or other materials provided with the
81  distribution.
82  - Neither the name of Analog Devices, Inc. nor the names of its
83  contributors may be used to endorse or promote products derived
84  from this software without specific prior written permission.
85  - The use of this software may or may not infringe the patent rights
86  of one or more patent holders. This license does not release you
87  from the requirement that you obtain separate licenses from these
88  patent holders to use this software.
89  - Use of the software either in source or binary form, must be run
90  on or directly connected to an Analog Devices Inc. component.
91 
92 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
93 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
94 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
95 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
96 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
97 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
98 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
99 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
100 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
101 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102 */
103 
104 /*! @file
105  @ingroup LTC2499
106  Header for LTC2499: 24-Bit, 16-Channel Delta Sigma ADCs with Easy Drive Input Current Cancellation
107 */
108 
109 #ifndef LTC2499_H
110 #define LTC2499_H
111 
112 /*! @name I2C_Addresses
113 @{ */
114 
115 //! I2C address of the LTC2497.
116 //! Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
117 //! Uncomment LTC2497_I2C_ADDRESS to match demo board configuration.
118 // Address assignment
119 // LTC2497 I2C Address // AD2 AD1 AD0
120 // #define LTC2497_I2C_ADDRESS 0x14 // Low Low Low
121 // #define LTC2497_I2C_ADDRESS 0x16 // Low Low High
122 // #define LTC2497_I2C_ADDRESS 0x15 // Low Low Float
123 // #define LTC2497_I2C_ADDRESS 0x26 // Low High Low
124 // #define LTC2497_I2C_ADDRESS 0x34 // Low High High
125 // #define LTC2497_I2C_ADDRESS 0x27 // Low High Float
126 // #define LTC2497_I2C_ADDRESS 0x17 // Low Float Low
127 // #define LTC2497_I2C_ADDRESS 0x25 // Low Float High
128 // #define LTC2497_I2C_ADDRESS 0x24 // Low Float Float
129 // #define LTC2497_I2C_ADDRESS 0x56 // High Low Low
130 // #define LTC2497_I2C_ADDRESS 0x64 // High Low High
131 // #define LTC2497_I2C_ADDRESS 0x57 // High Low Float
132 // #define LTC2497_I2C_ADDRESS 0x74 // High High Low
133 #define LTC2497_I2C_ADDRESS 0x76 // High High High
134 // #define LTC2497_I2C_ADDRESS 0x75 // High High Float
135 // #define LTC2497_I2C_ADDRESS 0x65 // High Float Low
136 // #define LTC2497_I2C_ADDRESS 0x67 // High Float High
137 // #define LTC2497_I2C_ADDRESS 0x66 // High Float Float
138 // #define LTC2497_I2C_ADDRESS 0x35 // Float Low Low
139 // #define LTC2497_I2C_ADDRESS 0x37 // Float Low High
140 // #define LTC2497_I2C_ADDRESS 0x36 // Float Low Float
141 // #define LTC2497_I2C_ADDRESS 0x47 // Float High Low
142 // #define LTC2497_I2C_ADDRESS 0x55 // Float High High
143 // #define LTC2497_I2C_ADDRESS 0x54 // Float High Float
144 // #define LTC2497_I2C_ADDRESS 0x44 // Float Float Low
145 // #define LTC2497_I2C_ADDRESS 0x46 // Float Float High
146 // #define LTC2497_I2C_ADDRESS 0x45 // Float Float Float
147 
148 //! LTC2497 Global I2C Address.
149 #define LTC2497_I2C_GLOBAL_ADDRESS 0x77 // Global Address
150 /*! @} */
151 
152 /*! @name Mode Configuration
153  @{
154 */
155 #define LTC2499_KEEP_PREVIOUS_MODE LTC24XX_HS_MULTI_KEEP_PREVIOUS_MODE
156 #define LTC2499_KEEP_PREVIOUS_SPEED_RESOLUTION LTC24XX_HS_MULTI_KEEP_PREVIOUS_SPEED_RESOLUTION
157 #define LTC2499_SPEED_1X LTC24XX_HS_MULTI_SPEED_1X
158 #define LTC2499_SPEED_2X LTC24XX_HS_MULTI_SPEED_2X
159 #define LTC2499_INTERNAL_TEMP 0xC0
160 
161 // Select rejection frequency - 50 and 60, 50, or 60Hz
162 #define LTC2499_R50 LTC24XX_EZ_MULTI_R50
163 #define LTC2499_R60 LTC24XX_EZ_MULTI_R60
164 #define LTC2499_R50_R60 LTC24XX_EZ_MULTI_R55
165 /*!
166  @}
167 */
168 
169 /*! @name Single-Ended Channels Configuration
170 @{ */
171 #define LTC2499_CH0 LTC24XX_MULTI_CH_CH0
172 #define LTC2499_CH1 LTC24XX_MULTI_CH_CH1
173 #define LTC2499_CH2 LTC24XX_MULTI_CH_CH2
174 #define LTC2499_CH3 LTC24XX_MULTI_CH_CH3
175 #define LTC2499_CH4 LTC24XX_MULTI_CH_CH4
176 #define LTC2499_CH5 LTC24XX_MULTI_CH_CH5
177 #define LTC2499_CH6 LTC24XX_MULTI_CH_CH6
178 #define LTC2499_CH7 LTC24XX_MULTI_CH_CH7
179 #define LTC2499_CH8 LTC24XX_MULTI_CH_CH8
180 #define LTC2499_CH9 LTC24XX_MULTI_CH_CH9
181 #define LTC2499_CH10 LTC24XX_MULTI_CH_CH10
182 #define LTC2499_CH11 LTC24XX_MULTI_CH_CH11
183 #define LTC2499_CH12 LTC24XX_MULTI_CH_CH12
184 #define LTC2499_CH13 LTC24XX_MULTI_CH_CH13
185 #define LTC2499_CH14 LTC24XX_MULTI_CH_CH14
186 #define LTC2499_CH15 LTC24XX_MULTI_CH_CH15
187 /*! @} */
188 
189 /*! @name Differential Channel Configuration
190 @{ */
191 #define LTC2499_P0_N1 LTC24XX_MULTI_CH_P0_N1
192 #define LTC2499_P1_N0 LTC24XX_MULTI_CH_P1_N0
193 
194 #define LTC2499_P2_N3 LTC24XX_MULTI_CH_P2_N3
195 #define LTC2499_P3_N2 LTC24XX_MULTI_CH_P3_N2
196 
197 #define LTC2499_P4_N5 LTC24XX_MULTI_CH_P4_N5
198 #define LTC2499_P5_N4 LTC24XX_MULTI_CH_P5_N4
199 
200 #define LTC2499_P6_N7 LTC24XX_MULTI_CH_P6_N7
201 #define LTC2499_P7_N6 LTC24XX_MULTI_CH_P7_N6
202 
203 #define LTC2499_P8_N9 LTC24XX_MULTI_CH_P8_N9
204 #define LTC2499_P9_N8 LTC24XX_MULTI_CH_P9_N8
205 
206 #define LTC2499_P10_N11 LTC24XX_MULTI_CH_P10_N11
207 #define LTC2499_P11_N10 LTC24XX_MULTI_CH_P11_N10
208 
209 #define LTC2499_P12_N13 LTC24XX_MULTI_CH_P12_N13
210 #define LTC2499_P13_N12 LTC24XX_MULTI_CH_P13_N12
211 
212 #define LTC2499_P14_N15 LTC24XX_MULTI_CH_P14_N15
213 #define LTC2499_P15_N14 LTC24XX_MULTI_CH_P15_N14
214 /*! @} */
215 
216 /*Commands
217 Construct a channel / resolution control word by bitwise ORing one choice from the channel configuration
218 and one choice from the Oversample ratio configuration. You can also enable 2Xmode, which will increase
219 sample rate by a factor of 2 but introduce an offset of up to 2mV (refer to datasheet EC table.)
220 
221 Example - read channel 3 single-ended, with 2X mode enabled.
222 adc_command = (LTC2499_CH3 | LTC2499_SPEED_2X);
223 */
224 
225 //! Reads from LTC2499.
226 //! @return 1 if no acknowledge, 0 if acknowledge
227 uint8_t LTC2499_read(uint8_t i2c_address, //!< I2C address (7-bit format) for part
228  uint8_t adc_command_high, //!< High byte command written to LTC2499
229  uint8_t adc_command_low, //!< Low byte command written to LTC2499
230  int32_t *adc_code, //!< 4 byte conversion code read from LTC2499
231  uint16_t timeout //!< Timeout in ms
232  );
233 
234 //! Calculates the voltage corresponding to an adc code, given the reference (in volts)
235 //! @return Returns voltage calculated from ADC code.
236 float LTC2499_code_to_voltage(int32_t adc_code, //!< Code read from adc
237  float vref //!< VRef (in volts)
238  );
239 
240 #endif // LTC2499_H
uint8_t i2c_address
uint8_t LTC2499_read(uint8_t i2c_address, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code, uint16_t timeout)
Reads from LTC2499.
Definition: LTC2499.cpp:80
long timeout
static uint32_t adc_code
Definition: DC2071AA.ino:113
float LTC2499_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an adc code, given the reference (in volts) ...
Definition: LTC2499.cpp:87