| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2418.h
Go to the documentation of this file.
1 /*!
2 LTC2418: 16-Channel 24-Bit No Latency Delta-Sigma ADC
3
4 @verbatim
5
6 The LTC2414/LTC2418 are 8-/16-channel (4-/8-differential) micropower 24-bit
7 delta-sigma analog-to-digital converters. They operate from 2.7V to 5.5V and
8 include an integrated oscillator, 2ppm INL and 0.2ppm RMS noise. They use
9 delta-sigma technology and provide single cycle settling time for multiplexed
10 applications. Through a single pin, the LTC2414/LTC2418 can be configured for
11 better than 110dB differential mode rejection at 50Hz or 60Hz +/-2%, or they can
12 be driven by an external oscillator for a user-defined rejection frequency. The
13 internal oscillator requires no external frequency setting components.
14
15 SPI DATA FORMAT (MSB First):
16
17 Byte #1 Byte #2 Byte #3 Byte #4
18
19 Data Out : !EOC DMY SIG D22 D21 D20 D19 D18 D17 D16 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 SGL OS S2 S1 S0 PAR
20 Data In : 1 0 EN SGL OS S2 S1 S0 X X X X X X X X X X X X X X X X X X X X X X X X
21
22 !EOC : End of Conversion Bit (Active Low)
23 DMY : Dummy Bit (Always 0)
24 SIG : Sign Bit (1-data positive, 0-data negative)
25 Dx : Data Bits
26 EN : Enable Bit (0-keep previous mode, 1-change mode)
27 SGL : Enable Single-Ended Bit (0-differential, 1-single-ended)
28 OS : ODD/Sign Bit
29 Sx : Address Select Bit
30 PAR : Parity Bit
31
32 Command Byte
33 1 0 EN SGL OS S2 S1 S0 Comments
34 1 0 0 X X X X X Keep Previous Mode
35 1 0 1 0 X X X X Differential Mode
36 1 0 1 1 X X X X Single-Ended Mode
37
38
39 Example Code:
40
41 Read Channel 0 in Single-Ended mode
42
43 uint16_t miso_timeout = 1000;
44 adc_command = LTC2418_CH0; // Build ADC command for channel 0
45
46 if(LTC2418_EOC_timeout(LTC2418_CS, miso_timeout)) // Check for EOC
47 return(1);
48 LTC2418_read(LTC2418_CS, adc_command, &adc_code); // Throws out last reading
49
50 if(LTC2418_EOC_timeout(LTC2418_CS, miso_timeout)) // Check for EOC
51 return(1);
52 LTC2418_read(LTC2418_CS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
53
54 // Convert adc_code to voltage
55 adc_voltage = LTC2418_code_to_voltage(adc_code, LTC2418_lsb , LTC2418_offset_code);
56
57 @endverbatim
58
59 http://www.linear.com/product/LTC2418
60
61 http://www.linear.com/product/LTC2418#demoboards
62
63
64 Copyright 2018(c) Analog Devices, Inc.
65
66 All rights reserved.
67
68 Redistribution and use in source and binary forms, with or without
69 modification, are permitted provided that the following conditions are met:
70 - Redistributions of source code must retain the above copyright
71 notice, this list of conditions and the following disclaimer.
72 - Redistributions in binary form must reproduce the above copyright
73 notice, this list of conditions and the following disclaimer in
74 the documentation and/or other materials provided with the
75 distribution.
76 - Neither the name of Analog Devices, Inc. nor the names of its
77 contributors may be used to endorse or promote products derived
78 from this software without specific prior written permission.
79 - The use of this software may or may not infringe the patent rights
80 of one or more patent holders. This license does not release you
81 from the requirement that you obtain separate licenses from these
82 patent holders to use this software.
83 - Use of the software either in source or binary form, must be run
84 on or directly connected to an Analog Devices Inc. component.
85
86 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
87 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
88 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
89 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
90 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
91 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
92 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
93 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
94 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
95 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96 */
97
98 /*! @file
99 @ingroup LTC2418
100 Header for LTC2418: 16-Channel 24-Bit No Latency Delta-Sigma ADC
101 */
102
103 #ifndef LTC2418_H
104 #define LTC2418_H
105
106 #include <SPI.h>
107
108 //! Define the SPI CS pin
109 #ifndef LTC2418_CS
110 #define LTC2418_CS QUIKEVAL_CS
111 #endif
112
113 //! @name LTC2418 Single-Ended configuration bytes
114 //! @{
115 //! Address bytes with enable sequence prepended
116 #define LTC2418_CH0 0xB0
117 #define LTC2418_CH1 0xB8
118 #define LTC2418_CH2 0xB1
119 #define LTC2418_CH3 0xB9
120 #define LTC2418_CH4 0xB2
121 #define LTC2418_CH5 0xBA
122 #define LTC2418_CH6 0xB3
123 #define LTC2418_CH7 0xBB
124 #define LTC2418_CH8 0xB4
125 #define LTC2418_CH9 0xBC
126 #define LTC2418_CH10 0xB5
127 #define LTC2418_CH11 0xBD
128 #define LTC2418_CH12 0xB6
129 #define LTC2418_CH13 0xBE
130 #define LTC2418_CH14 0xB7
131 #define LTC2418_CH15 0xBF
132 //! @}
133
134 //! @name LTC2418 Differential configuration bytes
135 //! @{
136 //! Address bytes with enable sequence prepended
137 #define LTC2418_P0_N1 0xA0
138 #define LTC2418_P1_N0 0xA8
139
140 #define LTC2418_P2_N3 0xA1
141 #define LTC2418_P3_N2 0xA9
142
143 #define LTC2418_P4_N5 0xA2
144 #define LTC2418_P5_N4 0xAA
145
146 #define LTC2418_P6_N7 0xA3
147 #define LTC2418_P7_N6 0xAB
148
149 #define LTC2418_P8_N9 0xA4
150 #define LTC2418_P9_N8 0xAC
151
152 #define LTC2418_P10_N11 0xA5
153 #define LTC2418_P11_N10 0xAD
154
155 #define LTC2418_P12_N13 0xA6
156 #define LTC2418_P13_N12 0xAE
157
158 #define LTC2418_P14_N15 0xA7
159 #define LTC2418_P15_N14 0xAF
160 //! @}
161
162 //! Checks for EOC with a specified timeout
163 //! @return 0=successful, 1=unsuccessful (exceeded timeout)
164 int8_t LTC2418_EOC_timeout(uint8_t cs, //!< Chip Select pin
165 uint16_t miso_timeout //!< Timeout (ms)
166 );
167
168 //! Reads the LTC2418 result and programs the configuration for the next conversion.
169 //! @return void
170 void LTC2418_read(uint8_t cs, //!< Chip Select pin
171 uint8_t adc_command, //!< Command byte
172 uint32_t *adc_code //!< Returns raw 32-bit code read from ADC
173 );
174
175 //! Calculates the LTC2418 input bipolar voltage
176 //! @return Calculated voltage
177 float LTC2418_code_to_voltage(int32_t adc_code, //!< Raw ADC code
178 float LTC2418_lsb, //!< LSB value (volts)
179 int32_t LTC2418_offset_code //!< Offset (Code)
180 );
181
182 //! Calibrate the lsb
183 //! @return Void
184 void LTC2418_cal_voltage(int32_t zero_code, //!< Offset (Code)
185 int32_t fs_code, //!< Code measured with full-scale input applied
186 float zero_voltage, //!< Measured zero voltage
187 float fs_voltage, //!< Measured full-scale voltage
188 float *LTC2418_lsb, //!< Returns LSB value (volts)
189 int32_t *LTC2418_offset_code //!< Returns Offset (Code)
190 );
191
192 #endif // LTC2418_H
LTC2418_cal_voltage
void LTC2418_cal_voltage(int32_t zero_code, int32_t fs_code, float zero_voltage, float fs_voltage, float *LTC2418_lsb, int32_t *LTC2418_offset_code)
Calibrate the lsb.
Definition: LTC2418.cpp:117
adc_command
static uint8_t adc_command
Definition: DC2071AA.ino:111
LTC2418_offset_code
static int32_t LTC2418_offset_code
Ideal offset for a perfect part.
Definition: DC571A.ino:114
LTC2418_EOC_timeout
int8_t LTC2418_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
Definition: LTC2418.cpp:73
LTC2418_code_to_voltage
float LTC2418_code_to_voltage(int32_t adc_code, float LTC2418_lsb, int32_t LTC2418_offset_code)
Calculates the LTC2418 input bipolar voltage.
Definition: LTC2418.cpp:107
LTC2418_lsb
static float LTC2418_lsb
Ideal LSB voltage for a perfect part.
Definition: DC571A.ino:113
LTC2418_read
void LTC2418_read(uint8_t cs, uint8_t adc_command, uint32_t *adc_code)
Reads the LTC2418 result and programs the configuration for the next conversion.
Definition: LTC2418.cpp:92
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113