| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC1859.h
Go to the documentation of this file.
1 /*!
2 LTC1859: 16-bit 8-channel 100ksps ADC
3
4 @verbatim
5
6 The LTC1857/1858/LTC1859 are pin-compatible, 8-channel 12-/14-/16-bit A/D converters
7 with serial I/O, and an internal reference. The ADCs typically draw only 1.3mA
8 from a single 5V supply. The 8-channel input multiplexer can be configured for
9 either single-ended or differential inputs and unipolar or bipolar conversions
10 (or combinations thereof). The automatic nap and sleep modes benefit power
11 sensitive applications.
12
13 The LTC1859's DC performance is outstanding with a +/-2LSB INL specification and
14 no missing codes over temperature. The signal-to-noise ratio (SNR) for the
15 LTC1859 is typically 89dB, with the internal reference.
16
17 SPI DATA FORMAT (MSB First):
18
19 Byte #1 Byte #2
20 Data Out : D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
21 Data In : SD OS S1 S0 UNI GAIN NAP SLP X X X X X X X X
22
23 SD : Single/Differential Bit
24 OS : ODD/Sign Bit
25 Sx : Address Select Bit
26 UNI : Unipolar/Bipolar Bit
27 GAIN : Input Span Bit
28 NAP : Nap Mode 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 = LTC1859_CH0 | LTC1859_UNIPOLAR_MODE | LTC1859_LOW_GAIN_MODE | LTC1859_NORMAL_MODE; // Single-ended, CH0, unipolar, low gain, normal mode.
39 LTC1859_read(LTC1859_CS, adc_command, &adc_code); // Throws out last reading
40 LTC1859_read(LTC1859_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 = LTC1859_unipolar_code_to_voltage(adc_code, LTC1859_lsb, LTC1859_offset_unipolar_code);
44
45 @endverbatim
46
47 http://www.linear.com/product/LTC1859
48
49 http://www.linear.com/product/LTC1859#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 LTC1859
88 Header for LTC1859: 16-bit 8-channel 100ksps ADC
89 */
90
91 #ifndef LTC1859_H
92 #define LTC1859_H
93
94 #include <SPI.h>
95
96 //! Define the SPI CS pin
97 #ifndef LTC1859_CS
98 #define LTC1859_CS QUIKEVAL_CS
99 #endif
100
101 //! @name LTC1859 Single-Ended Channel Addresses
102 //! @{
103 // Single-Ended Channel Address
104 #define LTC1859_CH0 0x80
105 #define LTC1859_CH1 0xC0
106 #define LTC1859_CH2 0x90
107 #define LTC1859_CH3 0xD0
108 #define LTC1859_CH4 0xA0
109 #define LTC1859_CH5 0xE0
110 #define LTC1859_CH6 0xB0
111 #define LTC1859_CH7 0xF0
112 //!@}
113
114 //! @name LTC1859 Differential Channel Addresses
115 //! @{
116 // Differential Channel Address
117 #define LTC1859_P0_N1 0x00
118 #define LTC1859_P1_N0 0x40
119
120 #define LTC1859_P2_N3 0x10
121 #define LTC1859_P3_N2 0x50
122
123 #define LTC1859_P4_N5 0x20
124 #define LTC1859_P5_N4 0x60
125
126 #define LTC1859_P6_N7 0x30
127 #define LTC1859_P7_N6 0x70
128 //!@}
129
130 //! @name LTC1859 Uni/GAIN config bits
131 //! @{
132 // Unipolar Mode Command
133 #define LTC1859_UNIPOLAR_MODE 0x08
134 #define LTC1859_BIPOLAR_MODE 0x00
135 // Single-Ended Mode Command
136 #define LTC1859_SINGLE_ENDED_MODE 0x80
137 #define LTC1859_DIFFERENTIAL_MODE 0x00
138 // Gain Mode Command
139 #define LTC1859_LOW_RANGE_MODE 0x00
140 #define LTC1859_HIGH_RANGE_MODE 0x04
141 //!@}
142
143 //! @name LTC1859 Sleep/Nap config bits
144 //! @{
145 // Sleep Mode Command
146 #define LTC1859_SLEEP_MODE 0x01
147 #define LTC1859_NORMAL_MODE 0x00
148 // Nap Mode Command
149 #define LTC1859_NAP_MODE 0x02
150 //!@}
151
152 /*
153 Example command
154 adc_command = LTC1859_CH0 | LTC1859_UNIPOLAR_MODE | LTC1859_LOW_GAIN_MODE | LTC1859_NORMAL_MODE; // Single-ended, CH0, unipolar, low gain, normal mode.
155 */
156
157
158 //! Builds the ADC command and returns an 8 bit command
159 //! @return 8 bit command
160 uint8_t LTC1859_build_command(uint8_t ch_designate,
161 uint8_t uni_bipolar,
162 uint8_t range_low_high
163 );
164
165
166 //! Reads the ADC and returns 16-bit data
167 //! @return void
168 void LTC1859_read(uint8_t cs, //!< Chip Select Pin
169 uint8_t adc_command, //!< Channel address, config bits ORed together
170 uint16_t *adc_code //!< Returns code read from ADC (from previous conversion)
171 );
172
173
174 //! Calculates the LTC1859 input's unipolar voltage given the binary data and lsb weight.
175 //! @return Floating point voltage
176 float LTC1859_code_to_voltage(uint16_t adc_code, //!< Raw ADC code
177 float vref,
178 uint8_t range_low_high, //!<)
179 uint8_t uni_bipolar //!<
180 );
181
182 #endif // LTC1859_H
adc_command
static uint8_t adc_command
Definition: DC2071AA.ino:111
LTC1859_build_command
uint8_t LTC1859_build_command(uint8_t ch_designate, uint8_t uni_bipolar, uint8_t range_low_high)
Builds the ADC command and returns an 8 bit command.
Definition: LTC1859.cpp:77
uni_bipolar
static uint8_t uni_bipolar
Default set for unipolar mode.
Definition: DC682A.ino:121
LTC1859_code_to_voltage
float LTC1859_code_to_voltage(uint16_t adc_code, float vref, uint8_t range_low_high, uint8_t uni_bipolar)
Calculates the LTC1859 input&#39;s unipolar voltage given the binary data and lsb weight.
Definition: LTC1859.cpp:93
range_low_high
static uint8_t range_low_high
Default set for high range mode.
Definition: DC682A.ino:123
LTC1859_read
void LTC1859_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
Definition: LTC1859.cpp:86
vref
float vref
Definition: LTC2492_Thermocouple_Meter.ino:129
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113