Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2492.h
Go to the documentation of this file.
1 /*!
2 LTC2492: 24-Bit, 4-Channel Delta Sigma ADCs with Easy Drive Input Current Cancellation
3 
4 @verbatim
5 
6 The LTC2492 is a 4-channel (2-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 = LTC2492_CH0 | LTC2492_OSR_32768 | LTC2492_SPEED_2X; // Build ADC command for channel 0
52  // OSR = 32768*2 = 65536
53 
54  if(LTC2492_EOC_timeout(LTC2492_CS, miso_timeout)) // Check for EOC
55  return; // Exit if timeout is reached
56  LTC2492_read(LTC2492_CS, adc_command, &adc_code); // Throws out last reading
57 
58  if(LTC2492_EOC_timeout(LTC2492_CS, miso_timeout)) // Check for EOC
59  return; // Exit if timeout is reached
60  LTC2492_read(LTC2492_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 = LTC2492_code_to_voltage(adc_code, LTC2492_lsb, LTC2492_offset_code);
64 
65 @endverbatim
66 
67 http://www.linear.com/product/LTC2492
68 
69 http://www.linear.com/product/LTC2492#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 LTC2492
108  Header for LTC2492: 24-Bit, 4-Channel Delta Sigma ADCs with Selectable Speed/Resolution
109 */
110 
111 #ifndef LTC2492_H
112 #define LTC2492_H
113 
114 //! Define the SPI CS pin
115 #ifndef LTC2492_CS
116 #define LTC2492_CS QUIKEVAL_CS
117 #endif
118 
119 /*! @name Mode Configuration
120  @{
121 */
122 #define LTC2492_KEEP_PREVIOUS_MODE LTC24XX_HS_MULTI_KEEP_PREVIOUS_MODE
123 #define LTC2492_KEEP_PREVIOUS_SPEED_RESOLUTION LTC24XX_HS_MULTI_KEEP_PREVIOUS_SPEED_RESOLUTION
124 #define LTC2492_SPEED_1X LTC24XX_HS_MULTI_SPEED_1X
125 #define LTC2492_SPEED_2X LTC24XX_HS_MULTI_SPEED_2X
126 #define LTC2492_INTERNAL_TEMP LTC24XX_EZ_MULTI_PTAT
127 
128 // Select rejection frequency - 50 and 60, 50, or 60Hz
129 #define LTC2492_R50 LTC24XX_EZ_MULTI_R50
130 #define LTC2492_R60 LTC24XX_EZ_MULTI_R60
131 #define LTC2492_R50_R60 LTC24XX_EZ_MULTI_R55
132 /*!
133  @}
134 */
135 
136 /*! @name Single-Ended Channels Configuration
137 @{ */
138 #define LTC2492_CH0 LTC24XX_MULTI_CH_CH0
139 #define LTC2492_CH1 LTC24XX_MULTI_CH_CH1
140 #define LTC2492_CH2 LTC24XX_MULTI_CH_CH2
141 #define LTC2492_CH3 LTC24XX_MULTI_CH_CH3
142 /*! @} */
143 
144 /*! @name Differential Channel Configuration
145 @{ */
146 #define LTC2492_P0_N1 LTC24XX_MULTI_CH_P0_N1
147 #define LTC2492_P1_N0 LTC24XX_MULTI_CH_P1_N0
148 
149 #define LTC2492_P2_N3 LTC24XX_MULTI_CH_P2_N3
150 #define LTC2492_P3_N2 LTC24XX_MULTI_CH_P3_N2
151 /*! @} */
152 
153 /*Commands
154 Construct a channel / resolution control word by bitwise ORing one choice from the channel configuration
155 and one choice from the Oversample ratio configuration. You can also enable 2Xmode, which will increase
156 sample rate by a factor of 2 but introduce an offset of up to 2mV (refer to datasheet EC table.)
157 
158 Example - read channel 3 single-ended at OSR2048, with 2X mode enabled.
159 adc_command = (LTC2492_CH3 | LTC2492_SPEED_2X;
160 */
161 
162 //! Checks for EOC with a specified timeout.
163 //! @return Returns 0=successful, 1=unsuccessful (exceeded timeout)
164 int8_t LTC2492_EOC_timeout(uint8_t cs, //!< Chip Select pin
165  uint16_t miso_timeout //!< Timeout (in milliseconds)
166  );
167 
168 //! Reads from LTC2492.
169 void LTC2492_read(uint8_t cs, //!< Chip select
170  uint8_t adc_command_high, //!< High byte command written to LTC2492
171  uint8_t adc_command_low, //!< Low byte command written to LTC2492
172  int32_t *adc_code //!< 4 byte conversion code read from LTC2492
173  );
174 
175 //! Calculates the voltage corresponding to an adc code, given the reference (in volts)
176 //! @return Returns voltage calculated from ADC code.
177 float LTC2492_code_to_voltage(int32_t adc_code, //!< Code read from adc
178  float vref //!< VRef (in volts)
179  );
180 
181 #endif // LTC2492_H
float LTC2492_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an adc code, given the reference (in volts) ...
Definition: LTC2492.cpp:84
void LTC2492_read(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
Reads from LTC2492.
Definition: LTC2492.cpp:78
int8_t LTC2492_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
Definition: LTC2492.cpp:72
static uint32_t adc_code
Definition: DC2071AA.ino:113