Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2449.h
Go to the documentation of this file.
1 /*!
2 LTC2449: 24-Bit, 16-Channel Delta Sigma ADCs with Selectable Speed/Resolution.
3 LTC2442: 24-Bit, 4-Channel Delta Sigma ADC with Integrated Amplifier
4 LTC2448: 24-Bit, 8-/16-Channel Delta Sigma ADCs with Selectable Speed/Resolution
5 
6 @verbatim
7 
8 The LTC2444/LTC2445/LTC2448/LTC2449 are 8-/16-channel (4-/8-differential)
9 high speed 24-bit No Latency Delta Sigma ADCs. They use a proprietary
10 delta-sigma architecture enabling variable speed/resolution. Through a
11 simple 4-wire serial interface, ten speed/resolution combinations
12 6.9Hz/280nVRMS to 3.5kHz/25uVRMS (4kHz with external oscillator) can be
13 selected with no latency between conversion results or shift in DC accuracy
14 (offset, full-scale, linearity, drift). Additionally, a 2X speed mode can
15 be selected enabling output rates up to 7kHz (8kHz if an external
16 oscillator is used) with one cycle latency.
17 
18 
19 SPI DATA FORMAT (MSB First):
20 
21  Byte #1 Byte #2
22 
23 Data Out : !EOC DMY SIG D28 D27 D26 D25 D24 D23 D22 D21 D20 D19 D18 D17 D16
24 Data In : 1 0 EN SGL OS S2 S1 S0 OSR3 OSR2 OSR1 OSR1 SPD X X X
25 
26 Byte #3 Byte #4
27 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 *D3 *D2 *D1 *D0
28 X X X X X X X X X X X X X X X X
29 
30 !EOC : End of Conversion Bit (Active Low)
31 DMY : Dummy Bit (Always 0)
32 SIG : Sign Bit (1-data positive, 0-data negative)
33 Dx : Data Bits
34 *Dx : Data Bits Below lsb
35 EN : Enable Bit (0-keep previous mode, 1-change mode)
36 SGL : Enable Single-Ended Bit (0-differential, 1-single-ended)
37 OS : ODD/Sign Bit
38 Sx : Address Select Bit
39 0SRX : Over Sampling Rate Bits
40 SPD : Double Output Rate Select Bit (0-Normal rate, auto-calibration on, 2x rate, auto_calibration off)
41 
42 Command Byte #1
43 1 0 EN SGL OS S2 S1 S0 Comments
44 1 0 0 X X X X X Keep Previous Mode
45 1 0 1 0 X X X X Differential Mode
46 1 0 1 1 X X X X Single-Ended Mode
47 
48 | Coversion Rate | RMS | ENOB | OSR | Latency
49 Command Byte #2 |Internal | External | Noise | | |
50 | 9MHz | 10.24MHz | | | |
51 OSR3 OSR2 OSR1 OSR1 SPD | Clock | Clock | | | |
52 0 0 0 0 0 Keep Previous Speed/Resolution
53 0 0 0 1 0 3.52kHz 4kHz 23uV 17 64 none
54 0 0 1 0 0 1.76kHz 2kHz 3.5uV 20.1 128 none
55 0 0 1 1 0 880Hz 1kHz 2uV 21.3 256 none
56 0 1 0 0 0 440Hz 500Hz 1.4uV 21.8 512 none
57 0 1 0 1 0 220Hz 250Hz 1uV 22.4 1024 none
58 0 1 1 0 0 110Hz 125Hz 750nV 22.9 2048 none
59 0 1 1 1 0 55Hz 62.5Hz 510nV 23.4 4096 none
60 1 0 0 0 0 27.5Hz 31.25Hz 375nV 24 8192 none
61 1 0 0 1 0 13.75Hz 15.625Hz 250nV 24.4 16384 none
62 1 1 1 1 0 6.87kHz 7.8125Hz 200nV 24.6 32768 none
63 0 0 0 0 1 Keep Previous Speed/Resolution
64 OSR3 OSR2 OSR1 OSR1 1 2X Mode *all clock speeds double
65 
66 Example Code:
67 
68 Read Channel 0 in Single-Ended with OSR of 65536
69 
70  uint16_t miso_timeout = 1000;
71  adc_command = LTC2449_CH0 | LTC2449_OSR_32768 | LTC2449_SPEED_2X; // Build ADC command for channel 0
72  // OSR = 32768*2 = 65536
73 
74  if(LTC2449_EOC_timeout(LTC2449_CS, miso_timeout)) // Check for EOC
75  return; // Exit if timeout is reached
76  LTC2449_read(LTC2449_CS, adc_command, &adc_code); // Throws out last reading
77 
78  if(LTC2449_EOC_timeout(LTC2449_CS, miso_timeout)) // Check for EOC
79  return; // Exit if timeout is reached
80  LTC2449_read(LTC2449_CS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
81 
82  // Convert adc_code to voltage
83  adc_voltage = LTC2449_code_to_voltage(adc_code, LTC2449_lsb, LTC2449_offset_code);
84 
85 @endverbatim
86 
87 http://www.linear.com/product/LTC2449
88 http://www.linear.com/product/LTC2442
89 http://www.linear.com/product/LTC2448
90 
91 http://www.linear.com/product/LTC2449#demoboards
92 http://www.linear.com/product/LTC2442#demoboards
93 http://www.linear.com/product/LTC2448#demoboards
94 
95 
96 Copyright 2018(c) Analog Devices, Inc.
97 
98 All rights reserved.
99 
100 Redistribution and use in source and binary forms, with or without
101 modification, are permitted provided that the following conditions are met:
102  - Redistributions of source code must retain the above copyright
103  notice, this list of conditions and the following disclaimer.
104  - Redistributions in binary form must reproduce the above copyright
105  notice, this list of conditions and the following disclaimer in
106  the documentation and/or other materials provided with the
107  distribution.
108  - Neither the name of Analog Devices, Inc. nor the names of its
109  contributors may be used to endorse or promote products derived
110  from this software without specific prior written permission.
111  - The use of this software may or may not infringe the patent rights
112  of one or more patent holders. This license does not release you
113  from the requirement that you obtain separate licenses from these
114  patent holders to use this software.
115  - Use of the software either in source or binary form, must be run
116  on or directly connected to an Analog Devices Inc. component.
117 
118 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
119 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
120 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
121 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
122 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
123 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
124 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
125 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
126 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
127 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
128 */
129 
130 /*! @file
131  @ingroup LTC2449
132  Header for LTC2449: 24-Bit, 16-Channel Delta Sigma ADCs with Selectable Speed/Resolution
133 */
134 
135 #ifndef LTC2449_H
136 #define LTC2449_H
137 
138 //! Define the SPI CS pin
139 #ifndef LTC2449_CS
140 #define LTC2449_CS QUIKEVAL_CS
141 #endif
142 
143 /*! @name Mode Configuration
144  @{
145 */
146 #define LTC2449_KEEP_PREVIOUS_MODE 0x8000
147 #define LTC2449_KEEP_PREVIOUS_SPEED_RESOLUTION 0x0000
148 #define LTC2449_SPEED_1X 0x0000
149 #define LTC2449_SPEED_2X 0x0008
150 /*!
151  @}
152 */
153 
154 /*! @name Single-Ended Channels Configuration
155 @{ */
156 #define LTC2449_CH0 0xB000
157 #define LTC2449_CH1 0xB800
158 #define LTC2449_CH2 0xB100
159 #define LTC2449_CH3 0xB900
160 #define LTC2449_CH4 0xB200
161 #define LTC2449_CH5 0xBA00
162 #define LTC2449_CH6 0xB300
163 #define LTC2449_CH7 0xBB00
164 #define LTC2449_CH8 0xB400
165 #define LTC2449_CH9 0xBC00
166 #define LTC2449_CH10 0xB500
167 #define LTC2449_CH11 0xBD00
168 #define LTC2449_CH12 0xB600
169 #define LTC2449_CH13 0xBE00
170 #define LTC2449_CH14 0xB700
171 #define LTC2449_CH15 0xBF00
172 /*! @} */
173 
174 /*! @name Differential Channel Configuration
175 @{ */
176 #define LTC2449_P0_N1 0xA000
177 #define LTC2449_P1_N0 0xA800
178 
179 #define LTC2449_P2_N3 0xA100
180 #define LTC2449_P3_N2 0xA900
181 
182 #define LTC2449_P4_N5 0xA200
183 #define LTC2449_P5_N4 0xAA00
184 
185 #define LTC2449_P6_N7 0xA300
186 #define LTC2449_P7_N6 0xAB00
187 
188 #define LTC2449_P8_N9 0xA400
189 #define LTC2449_P9_N8 0xAC00
190 
191 #define LTC2449_P10_N11 0xA500
192 #define LTC2449_P11_N10 0xAD00
193 
194 #define LTC2449_P12_N13 0xA600
195 #define LTC2449_P13_N12 0xAE00
196 
197 #define LTC2449_P14_N15 0xA700
198 #define LTC2449_P15_N14 0xAF00
199 /*! @} */
200 
201 /*Commands
202 Construct a channel / resolution control word by bitwise ORing one choice from the channel configuration
203 and one choice from the Oversample ratio configuration. You can also enable 2Xmode, which will increase
204 sample rate by a factor of 2 but introduce one cycle of latency.
205 
206 Example - read channel 3 single-ended at OSR2048, with 2X mode enabled.
207 adc_command = (LTC2449_CH3 | LTC2449_OSR_2048) | LTC2449_SPEED_2X;
208 */
209 
210 /*! @name Oversample Ratio (OSR) Commands
211 @{ */
212 #define LTC2449_OSR_64 0xA010
213 #define LTC2449_OSR_128 0xA020
214 #define LTC2449_OSR_256 0xA030
215 #define LTC2449_OSR_512 0xA040
216 #define LTC2449_OSR_1024 0xA050
217 #define LTC2449_OSR_2048 0xA060
218 #define LTC2449_OSR_4096 0xA070
219 #define LTC2449_OSR_8192 0xA080
220 #define LTC2449_OSR_16384 0xA090
221 #define LTC2449_OSR_32768 0xA0F0
222 /*! @}*/
223 
224 //! Checks for EOC with a specified timeout
225 //! @return Returns 0=successful, 1=unsuccessful (exceeded timeout)
226 int8_t LTC2449_EOC_timeout(uint8_t cs, //!< Chip Select pin
227  uint16_t miso_timeout //!< Timeout (in milliseconds)
228  );
229 
230 //! Reads from LTC2449.
231 //! @return void
232 void LTC2449_read(uint8_t cs, //!< Chip Select pin
233  uint16_t adc_command, //!< 2 byte command written to LTC2449
234  uint32_t *adc_code //!< 4 byte conversion code read from LTC2449
235  );
236 
237 //! Calculates the voltage corresponding to an adc code, given lsb weight (in volts) and the calibrated
238 //! ADC offset code (zero code that is subtracted from adc_code).
239 //! @return Returns voltage calculated from ADC code.
240 float LTC2449_code_to_voltage(int32_t adc_code, //!< Code read from adc
241  float LTC2449_lsb, //!< LSB weight (in volts)
242  int32_t LTC2449_offset_code //!< The calibrated offset code (This is the adc code zero code that will be subtraced from adc_code)
243  );
244 
245 //! Calculate the lsb weight and offset code given a full-scale code and a measured zero-code.
246 //! @return Void
247 void LTC2449_cal_voltage(int32_t zero_code, //!< Measured code with the inputs shorted to ground
248  int32_t fs_code, //!< Measured code at nearly full-scale
249  float zero_voltage, //!< Measured zero voltage
250  float fs_voltage, //!< Voltage measured at input (with voltmeter) when fs_code was read from adc
251  float *LTC2449_lsb, //!< Overwritten with lsb weight (in volts)
252  int32_t *LTC2449_offset_code //!< Overwritten with offset code (zero code)
253  );
254 
255 #endif // LTC2449_H
static uint8_t adc_command
Definition: DC2071AA.ino:111
float LTC2449_code_to_voltage(int32_t adc_code, float LTC2449_lsb, int32_t LTC2449_offset_code)
Calculates the voltage corresponding to an adc code, given lsb weight (in volts) and the calibrated A...
Definition: LTC2449.cpp:127
void LTC2449_cal_voltage(int32_t zero_code, int32_t fs_code, float zero_voltage, float fs_voltage, float *LTC2449_lsb, int32_t *LTC2449_offset_code)
Calculate the lsb weight and offset code given a full-scale code and a measured zero-code.
Definition: LTC2449.cpp:136
int8_t LTC2449_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
Definition: LTC2449.cpp:86
void LTC2449_read(uint8_t cs, uint16_t adc_command, uint32_t *adc_code)
Reads from LTC2449.
Definition: LTC2449.cpp:107
static float LTC2449_lsb
The LTC2449 ideal reference voltage.
Definition: DC1410AB.ino:102
static int32_t LTC2449_offset_code
Ideal offset for a perfect part.
Definition: DC742A.ino:127
static uint32_t adc_code
Definition: DC2071AA.ino:113