Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2308.h
Go to the documentation of this file.
1 /*!
2 LTC2308: 16-bit 8-channel 100ksps ADC
3 
4 @verbatim
5 
6 The LTC2308 is an 8-channel 12-bit A/D converter with
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 LTC2308'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 LTC2308 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 = LTC2308_CH0 | LTC2308_UNIPOLAR_MODE | LTC2308_LOW_GAIN_MODE | LTC2308_NORMAL_MODE; // Single-ended, CH0, unipolar, low gain, normal mode.
39  LTC2308_read(LTC2308_CS, adc_command, &adc_code); // Throws out last reading
40  LTC2308_read(LTC2308_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 = LTC2308_unipolar_code_to_voltage(adc_code, LTC2308_lsb, LTC2308_offset_unipolar_code);
44 
45 @endverbatim
46 
47 http://www.linear.com/product/LTC2308
48 
49 http://www.linear.com/product/LTC2308#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 LTC2308
88  Header for LTC2308: 16-bit 8-channel 100ksps ADC
89 */
90 
91 #ifndef LTC2308_H
92 #define LTC2308_H
93 
94 #include <SPI.h>
95 
96 //! Define the SPI CS pin
97 #ifndef LTC2308_CS
98 #define LTC2308_CS QUIKEVAL_CS
99 #endif
100 
101 //! @name LTC2308 Single-Ended Channel Addresses
102 //! @{
103 // Single-Ended Channel Address
104 #define LTC2308_CH0 0x80
105 #define LTC2308_CH1 0xC0
106 #define LTC2308_CH2 0x90
107 #define LTC2308_CH3 0xD0
108 #define LTC2308_CH4 0xA0
109 #define LTC2308_CH5 0xE0
110 #define LTC2308_CH6 0xB0
111 #define LTC2308_CH7 0xF0
112 //!@}
113 
114 //! @name LTC2308 Differential Channel Addresses
115 //! @{
116 // Differential Channel Address
117 #define LTC2308_P0_N1 0x00
118 #define LTC2308_P1_N0 0x40
119 
120 #define LTC2308_P2_N3 0x10
121 #define LTC2308_P3_N2 0x50
122 
123 #define LTC2308_P4_N5 0x20
124 #define LTC2308_P5_N4 0x60
125 
126 #define LTC2308_P6_N7 0x30
127 #define LTC2308_P7_N6 0x70
128 //!@}
129 
130 //! @name LTC2308 Uni/GAIN config bits
131 //! @{
132 // Unipolar Mode Command
133 #define LTC2308_UNIPOLAR_MODE 0x08
134 #define LTC2308_BIPOLAR_MODE 0x00
135 // Single-Ended Mode Command
136 #define LTC2308_SINGLE_ENDED_MODE 0x80
137 #define LTC2308_DIFFERENTIAL_MODE 0x00
138 //!@}
139 
140 //! @name LTC2308 Sleep/Nap config bits
141 //! @{
142 // Sleep Mode Command
143 #define LTC2308_SLEEP_MODE 0x01
144 #define LTC2308_NORMAL_MODE 0x00
145 // Nap Mode Command
146 #define LTC2308_NAP_MODE 0x02
147 //!@}
148 
149 /*
150  Example command
151  adc_command = LTC2308_CH0 | LTC2308_UNIPOLAR_MODE | LTC2308_LOW_GAIN_MODE | LTC2308_NORMAL_MODE; // Single-ended, CH0, unipolar, low gain, normal mode.
152  */
153 
154 
155 //! Reads the ADC and returns 16-bit data
156 //! @return void
157 void LTC2308_read(uint8_t cs, //!< Chip Select Pin
158  uint8_t adc_command, //!< Channel address, config bits ORed together
159  uint16_t *adc_code //!< Returns code read from ADC (from previous conversion)
160  );
161 
162 
163 //! Calculates the LTC2308 input's unipolar voltage given the binary data and lsb weight.
164 //! @return Floating point voltage
165 float LTC2308_code_to_voltage(uint16_t adc_code, //!< Raw ADC code
166  float vref, //!<
167  uint8_t uni_bipolar //!<
168  );
169 
170 #endif // LTC2308_H
static uint8_t adc_command
Definition: DC2071AA.ino:111
static uint8_t uni_bipolar
Default set for unipolar mode.
Definition: DC682A.ino:121
float LTC2308_code_to_voltage(uint16_t adc_code, float vref, uint8_t uni_bipolar)
Calculates the LTC2308 input&#39;s unipolar voltage given the binary data and lsb weight.
Definition: LTC2308.cpp:84
void LTC2308_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
Definition: LTC2308.cpp:77
static uint32_t adc_code
Definition: DC2071AA.ino:113