| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC1867.h
Go to the documentation of this file.
1
2 /*!
3 LTC1867: 16-bit 8-channel 200ksps ADC
4
5 @verbatim
6
7 The LTC1863/LTC1867 are pin-compatible, 8-channel 12-/16-bit A/D converters
8 with serial I/O, and an internal reference. The ADCs typically draw only 1.3mA
9 from a single 5V supply. The 8-channel input multiplexer can be configured for
10 either single-ended or differential inputs and unipolar or bipolar conversions
11 (or combinations thereof). The automatic nap and sleep modes benefit power
12 sensitive applications.
13
14 The LTC1867's DC performance is outstanding with a +/-2LSB INL specification and
15 no missing codes over temperature. The signal-to-noise ratio (SNR) for the
16 LTC1867 is typically 89dB, with the internal reference.
17
18 SPI DATA FORMAT (MSB First):
19
20 Byte #1 Byte #2
21 Data Out : D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
22 Data In : SD OS S1 S0 COM UNI SLP X X X X X X X X X
23
24 SD : Single/Differential Bit
25 OS : ODD/Sign Bit
26 Sx : Address Select Bit
27 COM : CH7/COM Configuration Bit
28 UNI : Unipolar/Bipolar Bit
29 SLP : Sleep Mode Bit
30 Dx : Data Bits
31 X : Don't care
32
33
34 Example Code:
35
36 Read Channel 0 in Single-Ended Unipolar mode when input is with respect to GND
37
38 adc_command = LTC1867_CH0 | LTC1867_UNIPOLAR_MODE; // Build ADC command for channel 0
39 LTC1867_read(LTC1867_CS, adc_command, &adc_code); // Throws out last reading
40 LTC1867_read(LTC1867_CS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
41
42 // Convert adc_code to voltage
43 adc_voltage = LTC1867_unipolar_code_to_voltage(adc_code, LTC1867_lsb, LTC1867_offset_unipolar_code);
44
45 @endverbatim
46
47 http://www.linear.com/product/LTC1867
48
49 http://www.linear.com/product/LTC1867#demoboards
50
51
52 Copyright 2018(c) Analog Devices, Inc.
53
54 All rights reserved.
55
56 Redistribution and use in source and binary forms, with or without
57 modification, are permitted provided that the following conditions are met:
58 - Redistributions of source code must retain the above copyright
59 notice, this list of conditions and the following disclaimer.
60 - Redistributions in binary form must reproduce the above copyright
61 notice, this list of conditions and the following disclaimer in
62 the documentation and/or other materials provided with the
63 distribution.
64 - Neither the name of Analog Devices, Inc. nor the names of its
65 contributors may be used to endorse or promote products derived
66 from this software without specific prior written permission.
67 - The use of this software may or may not infringe the patent rights
68 of one or more patent holders. This license does not release you
69 from the requirement that you obtain separate licenses from these
70 patent holders to use this software.
71 - Use of the software either in source or binary form, must be run
72 on or directly connected to an Analog Devices Inc. component.
73
74 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
75 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
76 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
77 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
78 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
79 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
80 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
81 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
82 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
83 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84 */
85
86 /*! @file
87 @ingroup LTC1867
88 Header for LTC1867: 16-bit 8-channel 200ksps ADC
89 */
90
91 #ifndef LTC1867_H
92 #define LTC1867_H
93
94 #include <SPI.h>
95
96 //! Define the SPI CS pin
97 #ifndef LTC1867_CS
98 #define LTC1867_CS QUIKEVAL_CS
99 #endif
100
101 //! @name LTC1867 Single-Ended Channel Addresses, COM=GND
102 //! @{
103 // Single-Ended Channel Address When CH7/COM Pin Is used As CH7
104 #define LTC1867_CH0 0x80
105 #define LTC1867_CH1 0xC0
106 #define LTC1867_CH2 0x90
107 #define LTC1867_CH3 0xD0
108 #define LTC1867_CH4 0xA0
109 #define LTC1867_CH5 0xE0
110 #define LTC1867_CH6 0xB0
111 #define LTC1867_CH7 0xF0
112 //!@}
113
114 //! @name LTC1867 Differential Channel Addresses
115 //! @{
116 // Differential Channel Address When CH7/COM Pin Is Used As CH7
117 #define LTC1867_P0_N1 0x00
118 #define LTC1867_P1_N0 0x40
119
120 #define LTC1867_P2_N3 0x10
121 #define LTC1867_P3_N2 0x50
122
123 #define LTC1867_P4_N5 0x20
124 #define LTC1867_P5_N4 0x60
125
126 #define LTC1867_P6_N7 0x30
127 #define LTC1867_P7_N6 0x70
128 //!@}
129
130 //! @name LTC1867 Single-Ended Channel Addresses, COM=CH7
131 //! @{
132 // Channel Address When CH7/COM Pin Is Used As Common
133 #define LTC1867_CH0_7COM 0x88
134 #define LTC1867_CH1_7COM 0xC8
135 #define LTC1867_CH2_7COM 0x98
136 #define LTC1867_CH3_7COM 0xD8
137 #define LTC1867_CH4_7COM 0xA8
138 #define LTC1867_CH5_7COM 0xE8
139 #define LTC1867_CH6_7COM 0xB8
140 //!@}
141
142 //! @name LTC1867 Sleep / Unipolar/Bipolar config bits
143 //! @{
144 // Sleep Mode Command
145 #define LTC1867_SLEEP_MODE 0x02
146 #define LTC1867_EXIT_SLEEP_MODE 0x00
147 #define LTC1867_UNIPOLAR_MODE 0x04 // Bitwise OR with channel commands for unipolar mode
148 #define LTC1867_BIPOLAR_MODE 0x00
149 //!@}
150
151 /*
152 Example command
153 adc_command = LTC1867_P0_N1; // Differential Bipolar Mode with CH0 as positive and CH1 as negative.
154 adc_command = LTC1867_P0_N1 | LTC1867_UNIPOLAR_MODE; // Differential Unipolar Mode with CH0 as positive and CH1 as negative.
155 */
156
157 //! Reads the ADC and returns 16-bit data
158 //! @return void
159 void LTC1867_read(uint8_t cs, //!< Chip Select Pin
160 uint8_t adc_command, //!< Channel address, config bits ORed together
161 uint16_t *adc_code //!< Returns code read from ADC (from previous conversion)
162 );
163
164
165 //! Calculates the LTC1867 input's unipolar voltage given the binary data and lsb weight.
166 //! @return Floating point voltage
167 float LTC1867_unipolar_code_to_voltage(uint16_t adc_code, //!< Raw ADC code
168 float LTC1867_lsb, //!< LSB value (volts)
169 int32_t LTC1867_offset_unipolar_code //!< Offset code
170 );
171
172 //! Calculates the LTC1867 input's bipolar voltage given the two's compliment data and lsb weight
173 //! @return Floating point voltage
174 float LTC1867_bipolar_code_to_voltage(uint16_t adc_code, //!< Raw ADC code
175 float LTC1867_lsb, //!< LSB value (volts)
176 int32_t LTC1867_offset_bipolar_code //!< Offset code
177 );
178
179 //! Calibrate the offset and LSB voltage given two measured offset codes, and a full-scale voltage with the corresponding code.
180 //! @return Void
181 void LTC1867_cal_voltage(uint16_t zero_unipolar_code, //!< Code from a unipolar zero reading
182 uint16_t zero_bipolar_code, //!< Code from a bipolar zero reading
183 uint16_t fs_code, //!< full-scale code
184 float zero_voltage, //!< Measured zero voltage
185 float fs_voltage, //!< Measured full-scale voltage
186 float *LTC1867_lsb, //!< Return LSB value (volts)
187 int32_t *LTC1867_offset_unipolar_code, //!< Return Unipolar Offset code, in floating point
188 int32_t *LTC1867_offset_bipolar_code //!< Return Bipolar Offset code, in floating point
189 );
190
191 #endif // LTC1867_H
adc_command
static uint8_t adc_command
Definition: DC2071AA.ino:111
LTC1867_offset_unipolar_code
static int32_t LTC1867_offset_unipolar_code
Ideal unipolar offset for a perfect part.
Definition: DC806A.ino:129
LTC1867_read
void LTC1867_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
Definition: LTC1867.cpp:78
LTC1867_bipolar_code_to_voltage
float LTC1867_bipolar_code_to_voltage(uint16_t adc_code, float LTC1867_lsb, int32_t LTC1867_offset_bipolar_code)
Calculates the LTC1867 input&#39;s bipolar voltage given the two&#39;s compliment data and lsb weight...
Definition: LTC1867.cpp:92
LTC1867_unipolar_code_to_voltage
float LTC1867_unipolar_code_to_voltage(uint16_t adc_code, float LTC1867_lsb, int32_t LTC1867_offset_unipolar_code)
Calculates the LTC1867 input&#39;s unipolar voltage given the binary data and lsb weight.
Definition: LTC1867.cpp:84
LTC1867_lsb
static float LTC1867_lsb
Ideal LSB voltage for a perfect part.
Definition: DC806A.ino:128
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113
LTC1867_cal_voltage
void LTC1867_cal_voltage(uint16_t zero_unipolar_code, uint16_t zero_bipolar_code, uint16_t fs_code, float zero_voltage, float fs_voltage, float *LTC1867_lsb, int32_t *LTC1867_offset_unipolar_code, int32_t *LTC1867_offset_bipolar_code)
Calibrate the offset and LSB voltage given two measured offset codes, and a full-scale voltage with t...
Definition: LTC1867.cpp:105
LTC1867_offset_bipolar_code
static int32_t LTC1867_offset_bipolar_code
Ideal bipolar offset for a perfect part.
Definition: DC806A.ino:130