| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2498.h
Go to the documentation of this file.
1 /*!
2 LTC2498: 24-Bit, 16-Channel Delta Sigma ADCs with Easy Drive Input Current Cancellation
3
4 @verbatim
5
6 The LTC2498 is a 16-channel (8-differential) 24-bit No Latency Delta Sigma
7 TM ADC with Easy Drive technology. The patented sampling scheme eliminates
8 dynamic input current errors and the shortcomings of on-chip buffering
9 through automatic cancellation of differential input current. This allows
10 large external source impedances, and rail-to-rail input signals to be
11 directly digitized while maintaining exceptional DC accuracy.
12
13
14 SPI DATA FORMAT (MSB First):
15
16 Byte #1 Byte #2
17
18 Data Out : !EOC DMY SIG D28 D27 D26 D25 D24 D23 D22 D21 D20 D19 D18 D17 D16
19 Data In : 1 0 EN SGL OS A2 A1 A0 EN2 IM FA FB SPD X X X
20
21 Byte #3 Byte #4
22 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 *D3 *D2 *D1 *D0
23 X X X X X X X X X X X X X X X X
24
25 !EOC : End of Conversion Bit (Active Low)
26 DMY : Dummy Bit (Always 0)
27 SIG : Sign Bit (1-data positive, 0-data negative)
28 Dx : Data Bits
29 *Dx : Data Bits Below lsb
30 EN : Enable Bit (0-keep previous mode, 1-change mode)
31 SGL : Enable Single-Ended Bit (0-differential, 1-single-ended)
32 OS : ODD/Sign Bit
33 Ax : Address Select Bit
34 IM : Internal Temperature Sensor Bit(0-ADC , 1-Temperature Sensor)
35 Fx : Frequency Rejection Bits
36 SPD : Speed Mode Bit (0-1x, 1-2x)
37
38 FIMSPD : Double Output Rate Select Bit (0-Normal rate, auto-calibration on, 2x rate, auto_calibration off)
39
40 Command Byte #1
41 1 0 EN SGL OS S2 S1 S0 Comments
42 1 0 0 X X X X X Keep Previous Mode
43 1 0 1 0 X X X X Differential Mode
44 1 0 1 1 X X X X Single-Ended Mode
45
46 Example Code:
47
48 Read Channel 0 in Single-Ended
49
50 uint16_t miso_timeout = 1000;
51 adc_command = LTC2498_CH0 | LTC2498_OSR_32768 | LTC2498_SPEED_2X; // Build ADC command for channel 0
52 // OSR = 32768*2 = 65536
53
54 if(LTC2498_EOC_timeout(LTC2498_CS, miso_timeout)) // Check for EOC
55 return; // Exit if timeout is reached
56 LTC2498_read(LTC2498_CS, adc_command, &adc_code); // Throws out last reading
57
58 if(LTC2498_EOC_timeout(LTC2498_CS, miso_timeout)) // Check for EOC
59 return; // Exit if timeout is reached
60 LTC2498_read(LTC2498_CS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
61
62 // Convert adc_code to voltage
63 adc_voltage = LTC2498_code_to_voltage(adc_code, LTC2498_lsb, LTC2498_offset_code);
64
65 @endverbatim
66
67 http://www.linear.com/product/LTC2498
68
69 http://www.linear.com/product/LTC2498#demoboards
70
71
72 Copyright 2018(c) Analog Devices, Inc.
73
74 All rights reserved.
75
76 Redistribution and use in source and binary forms, with or without
77 modification, are permitted provided that the following conditions are met:
78 - Redistributions of source code must retain the above copyright
79 notice, this list of conditions and the following disclaimer.
80 - Redistributions in binary form must reproduce the above copyright
81 notice, this list of conditions and the following disclaimer in
82 the documentation and/or other materials provided with the
83 distribution.
84 - Neither the name of Analog Devices, Inc. nor the names of its
85 contributors may be used to endorse or promote products derived
86 from this software without specific prior written permission.
87 - The use of this software may or may not infringe the patent rights
88 of one or more patent holders. This license does not release you
89 from the requirement that you obtain separate licenses from these
90 patent holders to use this software.
91 - Use of the software either in source or binary form, must be run
92 on or directly connected to an Analog Devices Inc. component.
93
94 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
95 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
96 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
97 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
98 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
99 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
100 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
101 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
102 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
103 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104 */
105
106 /*! @file
107 @ingroup LTC2498
108 Header for LTC2498: 24-Bit, 16-Channel Delta Sigma ADCs with Selectable Speed/Resolution
109 */
110
111 #ifndef LTC2498_H
112 #define LTC2498_H
113
114 //! Define the SPI CS pin
115 #ifndef LTC2498_CS
116 #define LTC2498_CS QUIKEVAL_CS
117 #endif
118
119 /*! @name Mode Configuration
120 @{
121 */
122 #define LTC2498_KEEP_PREVIOUS_MODE LTC24XX_HS_MULTI_KEEP_PREVIOUS_MODE
123 #define LTC2498_KEEP_PREVIOUS_SPEED_RESOLUTION LTC24XX_HS_MULTI_KEEP_PREVIOUS_SPEED_RESOLUTION
124 #define LTC2498_SPEED_1X LTC24XX_HS_MULTI_SPEED_1X
125 #define LTC2498_SPEED_2X LTC24XX_HS_MULTI_SPEED_2X
126 #define LTC2498_INTERNAL_TEMP 0xC0
127
128 // Select rejection frequency - 50 and 60, 50, or 60Hz
129 #define LTC2498_R50 LTC24XX_EZ_MULTI_R50
130 #define LTC2498_R60 LTC24XX_EZ_MULTI_R60
131 #define LTC2498_R50_R60 LTC24XX_EZ_MULTI_R55
132 /*!
133 @}
134 */
135
136 /*! @name Single-Ended Channels Configuration
137 @{ */
138 #define LTC2498_CH0 LTC24XX_MULTI_CH_CH0
139 #define LTC2498_CH1 LTC24XX_MULTI_CH_CH1
140 #define LTC2498_CH2 LTC24XX_MULTI_CH_CH2
141 #define LTC2498_CH3 LTC24XX_MULTI_CH_CH3
142 #define LTC2498_CH4 LTC24XX_MULTI_CH_CH4
143 #define LTC2498_CH5 LTC24XX_MULTI_CH_CH5
144 #define LTC2498_CH6 LTC24XX_MULTI_CH_CH6
145 #define LTC2498_CH7 LTC24XX_MULTI_CH_CH7
146 #define LTC2498_CH8 LTC24XX_MULTI_CH_CH8
147 #define LTC2498_CH9 LTC24XX_MULTI_CH_CH9
148 #define LTC2498_CH10 LTC24XX_MULTI_CH_CH10
149 #define LTC2498_CH11 LTC24XX_MULTI_CH_CH11
150 #define LTC2498_CH12 LTC24XX_MULTI_CH_CH12
151 #define LTC2498_CH13 LTC24XX_MULTI_CH_CH13
152 #define LTC2498_CH14 LTC24XX_MULTI_CH_CH14
153 #define LTC2498_CH15 LTC24XX_MULTI_CH_CH15
154 /*! @} */
155
156 /*! @name Differential Channel Configuration
157 @{ */
158 #define LTC2498_P0_N1 LTC24XX_MULTI_CH_P0_N1
159 #define LTC2498_P1_N0 LTC24XX_MULTI_CH_P1_N0
160
161 #define LTC2498_P2_N3 LTC24XX_MULTI_CH_P2_N3
162 #define LTC2498_P3_N2 LTC24XX_MULTI_CH_P3_N2
163
164 #define LTC2498_P4_N5 LTC24XX_MULTI_CH_P4_N5
165 #define LTC2498_P5_N4 LTC24XX_MULTI_CH_P5_N4
166
167 #define LTC2498_P6_N7 LTC24XX_MULTI_CH_P6_N7
168 #define LTC2498_P7_N6 LTC24XX_MULTI_CH_P7_N6
169
170 #define LTC2498_P8_N9 LTC24XX_MULTI_CH_P8_N9
171 #define LTC2498_P9_N8 LTC24XX_MULTI_CH_P9_N8
172
173 #define LTC2498_P10_N11 LTC24XX_MULTI_CH_P10_N11
174 #define LTC2498_P11_N10 LTC24XX_MULTI_CH_P11_N10
175
176 #define LTC2498_P12_N13 LTC24XX_MULTI_CH_P12_N13
177 #define LTC2498_P13_N12 LTC24XX_MULTI_CH_P13_N12
178
179 #define LTC2498_P14_N15 LTC24XX_MULTI_CH_P14_N15
180 #define LTC2498_P15_N14 LTC24XX_MULTI_CH_P15_N14
181 /*! @} */
182
183 /*Commands
184 Construct a channel / resolution control word by bitwise ORing one choice from the channel configuration
185 and one choice from the Oversample ratio configuration. You can also enable 2Xmode, which will increase
186 sample rate by a factor of 2 but introduce an offset of up to 2mV (refer to datasheet EC table.)
187
188 Example - read channel 3 single-ended at OSR2048, with 2X mode enabled.
189 adc_command = (LTC2498_CH3 | LTC2498_SPEED_2X;
190 */
191
192 //! Checks for EOC with a specified timeout.
193 //! @return Returns 0=successful, 1=unsuccessful (exceeded timeout)
194 int8_t LTC2498_EOC_timeout(uint8_t cs, //!< Chip Select pin
195 uint16_t miso_timeout //!< Timeout (in milliseconds)
196 );
197
198 //! Reads from LTC2498.
199 void LTC2498_read(uint8_t cs, //!< Chip select
200 uint8_t adc_command_high, //!< High byte command written to LTC2498
201 uint8_t adc_command_low, //!< Low byte command written to LTC2498
202 int32_t *adc_code //!< 4 byte conversion code read from LTC2498
203 );
204
205 //! Calculates the voltage corresponding to an adc code, given the reference (in volts)
206 //! @return Returns voltage calculated from ADC code.
207 float LTC2498_code_to_voltage(int32_t adc_code, //!< Code read from adc
208 float vref //!< VRef (in volts)
209 );
210
211 #endif // LTC2498_H
LTC2498_read
void LTC2498_read(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
Reads from LTC2498.
Definition: LTC2498.cpp:79
LTC2498_EOC_timeout
int8_t LTC2498_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
Definition: LTC2498.cpp:72
LTC2498_code_to_voltage
float LTC2498_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an adc code, given the reference (in volts) ...
Definition: LTC2498.cpp:85
vref
float vref
Definition: LTC2492_Thermocouple_Meter.ino:129
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113