Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2484.h
Go to the documentation of this file.
1 /*!
2 LTC2484: 24-Bit Delta Sigma ADC with Easy Drive Input Current Cancellation
3 
4 @verbatim
5 
6 The LTC2484 combines a 24-bit no latency delta-sigma analog-to-digital converter
7 with patented Easy Drive technology. The patented sampling scheme eliminates
8 dynamic input current errors and the shortcomings of on-chip buffering through
9 automatic cancellation of differential input current. This allows large external
10 source impedances and input signals with rail-to-rail input range to be directly
11 digitized while maintaining exceptional DC accuracy.
12 
13 The LTC2484 includes an on-chip oscillator. The LTC2484 can be configured to
14 reject line frequencies. 50Hz, 60Hz or simultaneous 50Hz/60Hz line frequency
15 rejection can be selected as well as a 2x speed-up mode.
16 
17 The LTC2484 allows a wide common mode input range (0V to VCC) independent of the
18 reference voltage. The reference can be as low as 100mV or can be tied directly
19 to VCC. The LTC2484 includes an on-chip trimmed oscillator, eliminating the need
20 for external crystals or oscillators. Absolute accuracy and low drift are
21 automatically maintained through continuous, transparent, offset and full-scale
22 calibration.
23 
24  SPI DATA FORMAT (MSB First):
25 
26  Byte #1 Byte #2 Byte #3 Byte #4
27  Data Out : !EOC DMY SIG D23 D22 D21 D20 D19 D18 D17 D16 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 X X X X X
28  Data In : EN X X X IM FOA FOB SPD X X X X X X X X 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  EN : Enable Bit (0-keep previous mode, 1-change mode)
35  IM : Internal Mode Bit (0-ADC input, 1-temperature sensor input)
36  FoA : Line Frequency Rejection Select Bit A
37  FoB : Line Frequency Rejection Select Bit B
38  SPD : Double Output Rate Select Bit (0-normal rate, auto-calibration on, 2x rate, auto_calibration off)
39  X : Don't Care
40 
41  Command Byte
42  EN IM FoA FoB SPD Comments
43  0 X X X X Keep Previous Mode
44  1 0 0 0 0 External Input, 50Hz and 60Hz Rejection, Autocalibration
45  1 0 0 1 0 External Input, 50Hz Rejection, Autocalibration
46  1 0 1 0 0 External Input, 60Hz Rejection, Autocalibration
47  1 0 0 0 1 External Input, 50Hz and 60Hz Rejection, 2x Speed
48  1 0 0 1 1 External Input, 50Hz Rejection, 2x Speed
49  1 0 1 0 1 External Input, 60Hz Rejection, 2x Speed
50  1 1 0 0 X Temperature Input, 50Hz and 60Hz Rejection, Autocalibration
51  1 1 0 1 X Temperature Input, 50Hz Rejection, Autocalibration
52  1 1 1 0 X Temperature Input, 60Hz Rejection, Autocalibration
53  1 X 1 1 X Reserved, Do Not Use
54 
55 
56 Example Code:
57 
58 Read the ADC voltage with 60Hz rejection
59 
60  uint16_t miso_timeout = 1000;
61  // Build ADC command to read the ADC voltage
62  adc_command = LTC2484_ENABLE;
63  adc_command |= LTC2484_EXTERNAL_INPUT;
64  adc_command |= LTC2484_AUTO_CALIBRATION;
65  adc_command |= LTC2484_REJECTION_60HZ;
66 
67 
68  if(LTC2484_EOC_timeout(LTC2484_CS, miso_timeout)) // Check for EOC
69  return(1);
70  LTC2484_read(LTC2484_CS, adc_command, &adc_code); // Throw away last reading
71 
72  if(LTC2484_EOC_timeout(LTC2484_CS, miso_timeout)) // Check for EOC
73  return(1);
74  LTC2484_read(LTC2484_CS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
75 
76  // Convert adc_code to voltage
77  adc_voltage = LTC2484_code_to_voltage(adc_code, LTC2484_lsb, LTC2484_offset_code);
78 
79 Read temperature
80 
81  uint16_t miso_timeout = 1000;
82 
83  // Build ADC command to read temperature
84  adc_command = LTC2484_ENABLE;
85  adc_command |= LTC2484_TEMPERATURE_INPUT;
86  adc_command |= LTC2484_AUTO_CALIBRATION;
87 
88  if(LTC2484_EOC_timeout(LTC2484_CS, miso_timeout)) // Check for EOC
89  return(1);
90  LTC2484_read(LTC2484_CS, adc_command, &adc_code); // Throw away last reading
91 
92  if(LTC2484_EOC_timeout(LTC2484_CS, miso_timeout)) // Check for EOC
93  return(1);
94  LTC2484_read(LTC2484_CS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
95 
96  // Convert adc_code to temperature
97  adc_temperature = LTC2484_temperature(adc_code, LTC2484_t0, LTC2484_r0);
98 
99 @endverbatim
100 
101 http://www.linear.com/product/LTC2484
102 
103 http://www.linear.com/product/LTC2484#demoboards
104 
105 
106 Copyright 2018(c) Analog Devices, Inc.
107 
108 All rights reserved.
109 
110 Redistribution and use in source and binary forms, with or without
111 modification, are permitted provided that the following conditions are met:
112  - Redistributions of source code must retain the above copyright
113  notice, this list of conditions and the following disclaimer.
114  - Redistributions in binary form must reproduce the above copyright
115  notice, this list of conditions and the following disclaimer in
116  the documentation and/or other materials provided with the
117  distribution.
118  - Neither the name of Analog Devices, Inc. nor the names of its
119  contributors may be used to endorse or promote products derived
120  from this software without specific prior written permission.
121  - The use of this software may or may not infringe the patent rights
122  of one or more patent holders. This license does not release you
123  from the requirement that you obtain separate licenses from these
124  patent holders to use this software.
125  - Use of the software either in source or binary form, must be run
126  on or directly connected to an Analog Devices Inc. component.
127 
128 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
129 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
130 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
131 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
132 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
133 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
134 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
135 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
136 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
137 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
138  */
139 
140 /*! @file
141  @ingroup LTC2484
142  Header for 2484 24-Bit Delta Sigma ADC with Easy Drive Input Current Cancellation
143 */
144 
145 
146 #ifndef LTC2484_H
147 #define LTC2484_H
148 
149 //! define the SPI CS pin
150 #ifndef LTC2484_CS
151 #define LTC2484_CS QUIKEVAL_CS
152 #endif
153 
154 //! @name LTC2484 Command constants
155 //!@{
156 //! Command constants. OR together to form the adc_command byte.
157 #define LTC2484_ENABLE 0x80
158 #define LTC2484_DISABLE 0x00
159 
160 #define LTC2484_EXTERNAL_INPUT 0x00
161 #define LTC2484_TEMPERATURE_INPUT 0x08
162 
163 #define LTC2484_REJECTION_50HZ_60HZ 0x00
164 #define LTC2484_REJECTION_50HZ 0x02
165 #define LTC2484_REJECTION_60HZ 0x04
166 
167 #define LTC2484_AUTO_CALIBRATION 0x00
168 #define LTC2484_SPEED_2X 0x01
169 //! @}
170 
171 // Commands
172 // Construct enable with any other command to form an int command. You can also enable 2Xmode,
173 // which will increase sample rate by a factor of 2.
174 
175 //! Checks for EOC with a specified timeout
176 //! @return Returns 0=successful, 1=unsuccessful (exceeded timeout)
177 int8_t LTC2484_EOC_timeout(uint8_t cs, //!< Chip Select pin
178  uint16_t miso_timeout //!< Timeout (in millisends)
179  );
180 
181 //! Read LTC2484 result, program configuration for next conversion
182 // Example - read channel external input with 60Hz rejection and 2X enabled.
183 // adc_command = (LTC2484_EXTERNAL_INPUT | LTC2484_REJECTION_60HZ) | LTC2484_SPEED_2X;
184 //! @return void
185 void LTC2484_read(uint8_t cs, //!< Chip Select pin
186  uint8_t adc_command, //!< Command byte
187  int32_t *adc_code //!< Returns raw 32-bit code read from ADC
188  );
189 
190 //! Calculates the LTC2484 input bipolar voltage
191 //! @return Calculated voltage
192 float LTC2484_code_to_voltage(int32_t adc_code, //!< Raw ADC code
193  float LTC2484_lsb, //!< LSB value (volts)
194  int32_t LTC2484_offset_code //!< Offset (Code)
195  );
196 
197 //! Calculate the LTC2484 temperature.
198 //! @return Calculated Temperature
199 float LTC2484_temperature(int32_t adc_code, //!< ADC code
200  float LTC2484_t0, //!< Temperature calibration value
201  float LTC2484_r0 //!< Voltage for temperature calibration value
202  );
203 
204 //! Calibrate the lsb
205 //! @return Void
206 void LTC2484_cal_voltage(int32_t zero_code, //!< Offset (Code)
207  int32_t fs_code, //!< Code measured with full-scale input applied
208  float zero_voltage, //!< Measured zero voltage
209  float fs_voltage, //!< Actual voltage applied during full-scale measurement
210  float *LTC2484_lsb, //!< Returns LSB value (volts)
211  int32_t *LTC2484_offset_code //!< Returns Offset (Code)
212  );
213 
214 //! Calibrate temperature
215 //! @return Void
216 void LTC2484_cal_temperature(int32_t adc_code, //!< ADC code
217  float temperature, //!< Actual temperature
218  float *LTC2484_t0, //!< Temperature calibration value
219  float *LTC2484_r0 //!< Voltage for temperature calibration value
220  );
221 
222 #endif // LTC2484_H
static uint8_t adc_command
Definition: DC2071AA.ino:111
void LTC2484_cal_voltage(int32_t zero_code, int32_t fs_code, float zero_voltage, float fs_voltage, float *LTC2484_lsb, int32_t *LTC2484_offset_code)
Calibrate the lsb.
Definition: LTC2484.cpp:109
void LTC2484_cal_temperature(int32_t adc_code, float temperature, float *LTC2484_t0, float *LTC2484_r0)
Calibrate temperature.
Definition: LTC2484.cpp:123
static float LTC2484_t0
Nominal temperature.
Definition: DC939A.ino:133
static int32_t LTC2484_offset_code
Ideal offset.
Definition: DC939A.ino:132
static float LTC2484_r0
ADC code at the nominal temperature (420mV default)
Definition: DC939A.ino:134
float LTC2484_code_to_voltage(int32_t adc_code, float LTC2484_lsb, int32_t LTC2484_offset_code)
Calculates the LTC2484 input bipolar voltage.
Definition: LTC2484.cpp:96
static float LTC2484_lsb
Ideal LSB size, 5V/(2^29) for a 5V reference.
Definition: DC939A.ino:131
void LTC2484_read(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
Read LTC2484 result, program configuration for next conversion.
Definition: LTC2484.cpp:90
int8_t LTC2484_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
Definition: LTC2484.cpp:84
float LTC2484_temperature(int32_t adc_code, float LTC2484_t0, float LTC2484_r0)
Calculate the LTC2484 temperature.
Definition: LTC2484.cpp:102
static uint32_t adc_code
Definition: DC2071AA.ino:113