| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

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