| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2422.h
Go to the documentation of this file.
1 /*!
2 LTC2422: 1-/2-Channel 20-Bit uPower No Latency Delta-Sigma ADC in MSOP-10
3
4 @verbatim
5
6 The LTC2421/LTC2422 are 1- and 2-channel 2.7V to 5.5V micropower 20-bit analog-
7 to-digital converters with an integrated oscillator, 8ppm INL and 1.2ppm RMS
8 noise. These ultrasmall devices use delta-sigma technology and a new digital
9 filter architecture that settles in a single cycle. This eliminates the latency
10 found in conventional delta-sigma converters and simplifies multiplexed
11 applications. Through a single pin, the LTC2421/LTC2422 can be configured for
12 better than 110dB rejection at 50Hz or 60Hz +/-2%, or can be driven by an
13 external oscillator for a user defined rejection frequency in the range 1Hz to
14 120Hz. The internal oscillator requires no external frequency setting
15 components.
16
17 SPI DATA FORMAT (MSB First):
18
19 Byte #1 Byte #2
20
21 Data Out : !EOC CH SIG EXR D19 D18 D17 D16 D15 D14 D13 D12 D11 D10 D9 D8
22 Data In : X X X X X X X X X X X X X X X X
23
24 Byte #3
25 D7 D6 D5 D4 D3 D2 D1 D0
26 X X X X X X X X
27
28 !EOC : End of Conversion Bit (Active Low)
29 CH : Channel Indicator Bit (0 - CH0 , 1 - CH1)
30 SIG : Sign Bit (1-data positive, 0-data negative)
31 EXR : Extebded Input Range Indicator Bit
32 Dx : Data Bits
33
34 Example Code:
35
36 Read Channel 0.
37
38 uint16_t miso_timeout = 1000;
39 if(LTC2422_EOC_timeout(LTC2422_CS, miso_timeout)) // Check for EOC
40 return; // Handle exception if timeout exceeded without EOC
41 LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code); // Read ADC
42
43 if(adc_channel != 0)
44 {
45 if(LTC2422_EOC_timeout(LTC2422_CS, miso_timeout)) // Check for EOC
46 return; // Handle exception if timeout exceeded without EOC
47 LTC2422_adc_read(LTC2422_CS, &adc_channel, &adc_code); // Reads the ADC again if the first reading was not CH0
48 }
49 adc_voltage = LTC2422_code_to_voltage(adc_code, LTC2422_lsb);
50
51 @endverbatim
52
53 http://www.linear.com/product/LTC2422
54
55 http://www.linear.com/product/LTC2422#demoboard
56
57
58 Copyright 2018(c) Analog Devices, Inc.
59
60 All rights reserved.
61
62 Redistribution and use in source and binary forms, with or without
63 modification, are permitted provided that the following conditions are met:
64 - Redistributions of source code must retain the above copyright
65 notice, this list of conditions and the following disclaimer.
66 - Redistributions in binary form must reproduce the above copyright
67 notice, this list of conditions and the following disclaimer in
68 the documentation and/or other materials provided with the
69 distribution.
70 - Neither the name of Analog Devices, Inc. nor the names of its
71 contributors may be used to endorse or promote products derived
72 from this software without specific prior written permission.
73 - The use of this software may or may not infringe the patent rights
74 of one or more patent holders. This license does not release you
75 from the requirement that you obtain separate licenses from these
76 patent holders to use this software.
77 - Use of the software either in source or binary form, must be run
78 on or directly connected to an Analog Devices Inc. component.
79
80 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
81 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
82 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
83 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
84 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
85 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
86 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
87 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
88 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
89 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90 */
91
92 /*! @file
93 @ingroup LTC2422
94 Library Header File for LTC2422: 1-/2-Channel 20-Bit uPower No Latency Delta-Sigma ADC in MSOP-10
95 */
96
97 #ifndef LTC2422_H
98 #define LTC2422_H
99
100 #include <SPI.h>
101
102 //! Define the SPI CS pin
103 #ifndef LTC2422_CS
104 #define LTC2422_CS QUIKEVAL_CS
105 #endif
106
107 const float LTC2422_TYPICAL_lsb = 4.7683761E-6; //!< The LTC2422 typical least significant bit value with 5V full-scale
108
109 //! Checks for EOC with a specified timeout
110 //! @return success or failure on timeout
111 uint8_t LTC2422_EOC_timeout(uint8_t cs, //!< Chip Select pin
112 uint16_t miso_timeout //!< Timeout (ms)
113 );
114
115 //! Read ADC code from the LTC2422. Does not wait for end-of-conversion.
116 //! To automatically wait for conversion to complete, use the LTC2422_EOC_timeout before this function.
117 //! @return void
118 void LTC2422_adc_read(uint8_t cs, //!< Chip Select pin
119 uint8_t *adc_channel, //!< Returns channel number read.
120 int32_t *code //!< Returns the ADC code read.
121 );
122
123 //! Calculates the voltage given the ADC code and lsb weight.
124 //! @return calculated voltage (based on ADC code and lsb weight).
125 float LTC2422_code_to_voltage(int32_t adc_code, //!< ADC code read from LTC2422.
126 float LTC2422_lsb //!< LSB weight (determined by reference voltage).
127 );
128
129 //! Calculates the lsb weight from the given reference voltage.
130 //! @return Void
131 void LTC2422_calculate_lsb(float LTC2422_reference_voltage, //!< Measured reference voltage.
132 float *LTC2422_lsb //!< Overwritten with the lsb weight in volts.
133 );
134
135 #endif // LTC2422_H
LTC2422_TYPICAL_lsb
const float LTC2422_TYPICAL_lsb
The LTC2422 typical least significant bit value with 5V full-scale.
Definition: LTC2422.h:107
LTC2422_calculate_lsb
void LTC2422_calculate_lsb(float LTC2422_reference_voltage, float *LTC2422_lsb)
Calculates the lsb weight from the given reference voltage.
Definition: LTC2422.cpp:128
LTC2422_EOC_timeout
uint8_t LTC2422_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
Definition: LTC2422.cpp:76
LTC2422_lsb
static float LTC2422_lsb
The LTC2422 least significant bit value with 5V full-scale.
Definition: DC934A.ino:135
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113
LTC2422_adc_read
void LTC2422_adc_read(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Read ADC code from the LTC2422.
Definition: LTC2422.cpp:98
LTC2422_code_to_voltage
float LTC2422_code_to_voltage(int32_t adc_code, float LTC2422_lsb)
Calculates the voltage given the ADC code and lsb weight.
Definition: LTC2422.cpp:119