Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2309.h
Go to the documentation of this file.
1 /*!
2 LTC2309: 8-channel, 12-Bit SAR ADC with I2C interface
3 LTC2301: 1-Channel, 12-Bit ADCs with I2C Compatible Interface
4 
5 @verbatim
6 
7 The LTC2309 is a low noise, low power, 8-channel, 12-bit successive
8 approximation ADC with an I2C compatible serial interface. This ADC includes an
9 internal reference and a fully differential sample-and-hold circuit to reduce
10 common mode noise. The LTC2309 operates from an internal clock to achieve a fast
11 1.3 microsecond conversion time.
12 
13 The LTC2309 operates from a single 5V supply and draws just 300 microamps at a
14 throughput rate of 1ksps. The ADC enters nap mode when not converting, reducing
15 the power dissipation.
16 
17 I2C DATA FORMAT (MSB First):
18 
19 
20  Byte #1 Byte #2
21 START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK SD OS S1 S0 UNI SLP X X SACK
22 
23  Byte #3 Byte #4 Byte #5
24 Repeat Start SA6 SA5 SA4 SA3 SA2 SA1 SA0 R SACK D11 D10 D9 D8 D7 D6 D5 D4 MACK D3 D2 D1 D0 X X X X MNACK STOP
25 
26 SACK : Slave Acknowledge
27 MACK : Master Acknowledge
28 MNACK : Master Not Acknowledge
29 SD : Single, Differential# Bit
30 OS : ODD, Sign# Bit
31 Sx : Address Select Bit
32 COM : CH7/COM Configuration Bit
33 UNI : Unipolar, Bipolar# Bit
34 SLP : Sleep Mode Bit
35 Dx : Data Bits
36 X : Don't care
37 
38 Example Code:
39 
40 Read Channel 0 in Single-Ended Unipolar mode
41 
42  adc_command = LTC2309_CH0 | LTC2309_UNIPOLAR_MODE; // Build ADC command for channel 0
43 
44  ack |= LTC2309_read(LTC2309_I2C_ADDRESS, adc_command, &adc_code); // Throws out last reading
45  ack |= LTC2309_read(LTC2309_I2C_ADDRESS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
46 
47  // Convert adc_code to voltage
48  adc_voltage = LTC2309_unipolar_code_to_voltage(adc_code, LTC2309_lsb, LTC2309_offset_code);
49 
50 @endverbatim
51 
52 http://www.linear.com/product/LTC2309
53 http://www.linear.com/product/LTC2301
54 
55 http://www.linear.com/product/LTC2309#demoboards
56 http://www.linear.com/product/LTC2301#demoboards
57 
58 
59 Copyright 2018(c) Analog Devices, Inc.
60 
61 All rights reserved.
62 
63 Redistribution and use in source and binary forms, with or without
64 modification, are permitted provided that the following conditions are met:
65  - Redistributions of source code must retain the above copyright
66  notice, this list of conditions and the following disclaimer.
67  - Redistributions in binary form must reproduce the above copyright
68  notice, this list of conditions and the following disclaimer in
69  the documentation and/or other materials provided with the
70  distribution.
71  - Neither the name of Analog Devices, Inc. nor the names of its
72  contributors may be used to endorse or promote products derived
73  from this software without specific prior written permission.
74  - The use of this software may or may not infringe the patent rights
75  of one or more patent holders. This license does not release you
76  from the requirement that you obtain separate licenses from these
77  patent holders to use this software.
78  - Use of the software either in source or binary form, must be run
79  on or directly connected to an Analog Devices Inc. component.
80 
81 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
82 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
83 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
84 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
85 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
86 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
87 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
88 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
89 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
90 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91 */
92 
93 /*! @file
94  @ingroup LTC2309
95  Header for LTC2309: 8-channel, 12-Bit SAR ADC with I2C interface
96 */
97 
98 #ifndef LTC2309_H
99 #define LTC2309_H
100 
101 #include <Wire.h>
102 
103 //! @name I2C addresses
104 //! @{
105 //! Un-comment the address corresponding to the LTC2309's address
106 // // Pin State
107 // LTC2309 I2C Address // AD1 AD0
108 
109 #define LTC2309_I2C_ADDRESS 0x08 // LOW LOW
110 // #define LTC2309_I2C_ADDRESS 0x09 // LOW Float
111 // #define LTC2309_I2C_ADDRESS 0x0A // LOW HIGH
112 // #define LTC2309_I2C_ADDRESS 0x0B // Float HIGH
113 // #define LTC2309_I2C_ADDRESS 0x18 // Float Float
114 // #define LTC2309_I2C_ADDRESS 0x19 // Float LOW
115 // #define LTC2309_I2C_ADDRESS 0x1A // HIGH LOW
116 // #define LTC2309_I2C_ADDRESS 0x1B // HIGH Float
117 // #define LTC2309_I2C_ADDRESS 0x14 // High HIGH
118 //!@}
119 
120 //! @name Single-Ended Channel Configuration
121 //! @{
122 // Single-Ended Channel Configuration
123 #define LTC2309_CH0 0x80
124 #define LTC2309_CH1 0xC0
125 #define LTC2309_CH2 0x90
126 #define LTC2309_CH3 0xD0
127 #define LTC2309_CH4 0xA0
128 #define LTC2309_CH5 0xE0
129 #define LTC2309_CH6 0xB0
130 #define LTC2309_CH7 0xF0
131 //!@}
132 
133 //! @name Differential Channel Configuration
134 //! @{
135 // Differential Channel Configuration
136 #define LTC2309_P0_N1 0x00
137 #define LTC2309_P1_N0 0x40
138 
139 #define LTC2309_P2_N3 0x10
140 #define LTC2309_P3_N2 0x50
141 
142 #define LTC2309_P4_N5 0x20
143 #define LTC2309_P5_N4 0x60
144 
145 #define LTC2309_P6_N7 0x30
146 #define LTC2309_P7_N6 0x70
147 //!@}
148 
149 //! @name LTC2309 Configuration Bits
150 //! @{
151 // LTC1867 Configuration Bits
152 #define LTC2309_SLEEP_MODE 0x04
153 #define LTC2309_EXIT_SLEEP_MODE 0x00
154 #define LTC2309_UNIPOLAR_MODE 0x08
155 #define LTC2309_BIPOLAR_MODE 0x00
156 #define LTC2309_SINGLE_ENDED_MODE 0x80
157 #define LTC2309_DIFFERENTIAL_MODE 0x00
158 //!@}
159 
160 // Commands
161 // Construct a channel / uni/bipolar by bitwise ORing one choice from the channel configuration
162 // and one choice from the command.
163 
164 // Example - read channel 3 single-ended
165 // adc_command = LTC2309_CH3 | LTC2309_UNIPOLAR_MODE;
166 
167 // Example - read voltage between channels 5 and 4 with 4 as positive polarity and in bipolar mode.
168 // adc_command = LTC2309_P4_N5 | LTC2309_BIPOLAR_MODE;
169 
170 
171 //! Reads 12-bit code from LTC2309, programs channel and mode for next conversion.
172 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
173 int8_t LTC2309_read(uint8_t i2c_address, //!< I2C address of device
174  uint8_t adc_command, //!< ADC command / address bits
175  uint16_t *ptr_adc_code //!< Returns code read from ADC
176  );
177 
178 
179 //! Calculates the LTC2309 input voltage.
180 //! @return Calculated voltage
181 float LTC2309_code_to_voltage(uint16_t adc_code, //!< Code read from ADC
182  float LTC2309_vref, //!< LSB value (volts)
183  uint8_t uni_bipolar
184  );
185 
186 #endif // LTC2309_H
uint8_t i2c_address
static uint8_t adc_command
Definition: DC2071AA.ino:111
static uint8_t uni_bipolar
Default set for unipolar mode.
Definition: DC682A.ino:121
static float LTC2309_vref
Definition: DC1337A.ino:128
int8_t LTC2309_read(uint8_t i2c_address, uint8_t adc_command, uint16_t *ptr_adc_code)
Reads 12-bit code from LTC2309, programs channel and mode for next conversion.
Definition: LTC2309.cpp:89
float LTC2309_code_to_voltage(uint16_t adc_code, float LTC2309_vref, uint8_t uni_bipolar)
Calculates the LTC2309 input voltage.
Definition: LTC2309.cpp:106
static uint32_t adc_code
Definition: DC2071AA.ino:113