| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2373.h
Go to the documentation of this file.
1 /*!
2 LTC2373: 16/18-bit 1Msps 8 channel SAR ADC
3 LTC2372: 16/18-bit 500ksps 8 channel SAR ADC
4 LTC2374: 16 bit 1.6Msps 8 channel SAR ADC
5
6 @verbatim
7
8 The LTC2373_16/18 are pin-compatible, 16/18-bit A/D converters
9 with serial I/O, and an internal reference.
10
11 Example Code:
12
13 Read ADC input.
14
15 adc_command = LTC2373_CH0 | LTC2373_UNIPOLAR_MODE | LTC2373_LOW_GAIN_MODE | LTC2373_NORMAL_MODE; // Single-ended, CH0, unipolar, low gain, normal mode.
16 LTC2373_read(LTC2373_CS, adc_command, &adc_code); // Throws out last reading
17 LTC2373_read(LTC2373_CS, adc_command, &adc_code); // Obtains the current reading and stores to adc_code variable
18
19 // Convert adc_code to voltage
20 adc_voltage = LTC2373_code_to_voltage(adc_code, LTC2373_lsb, LTC2373_offset_unipolar_code);
21
22 @endverbatim
23
24 http://www.linear.com/product/LTC2373-16
25 http://www.linear.com/product/LTC2373_18
26 http://www.linear.com/product/LTC2372-16
27 http://www.linear.com/product/LTC2372-18
28 http://www.linear.com/product/LTC2374-16
29
30 http://www.linear.com/product/LTC2373-16#demoboards
31 http://www.linear.com/product/LTC2373_18#demoboards
32 http://www.linear.com/product/LTC2372-16#demoboards
33 http://www.linear.com/product/LTC2372-18#demoboards
34 http://www.linear.com/product/LTC2374-16#demoboards
35
36
37
38 Copyright 2018(c) Analog Devices, Inc.
39
40 All rights reserved.
41
42 Redistribution and use in source and binary forms, with or without
43 modification, are permitted provided that the following conditions are met:
44 - Redistributions of source code must retain the above copyright
45 notice, this list of conditions and the following disclaimer.
46 - Redistributions in binary form must reproduce the above copyright
47 notice, this list of conditions and the following disclaimer in
48 the documentation and/or other materials provided with the
49 distribution.
50 - Neither the name of Analog Devices, Inc. nor the names of its
51 contributors may be used to endorse or promote products derived
52 from this software without specific prior written permission.
53 - The use of this software may or may not infringe the patent rights
54 of one or more patent holders. This license does not release you
55 from the requirement that you obtain separate licenses from these
56 patent holders to use this software.
57 - Use of the software either in source or binary form, must be run
58 on or directly connected to an Analog Devices Inc. component.
59
60 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
61 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
62 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
63 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
64 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
65 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
66 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
67 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
68 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
69 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70 */
71
72 /*! @file
73 @ingroup LTC2373
74 Header for LTC2373: 16/18-bit 1Msps 8 channel SAR ADC
75 */
76
77 #ifndef LTC2373_H
78 #define LTC2373_H
79
80 #include <SPI.h>
81
82 //! Define the SPI CS pin
83 #ifndef LTC2373_CS
84 #define LTC2373_CS QUIKEVAL_CS
85 #endif
86
87 #define I2C_ADDRESS 0x20 //I2C address in 7 bit format
88 #define I2C_COMMAND 0x80 //Command to write to bus extender
89 #define LTC2373_SEQUENCER_BIT 0x80
90
91 //! @name LTC2373 Channel Addresses
92 //! @{
93 // Channel Address
94 #define LTC2373_CH0 0x40
95 #define LTC2373_CH1 0x48
96 #define LTC2373_CH2 0x50
97 #define LTC2373_CH3 0x58
98 #define LTC2373_CH4 0x60
99 #define LTC2373_CH5 0x68
100 #define LTC2373_CH6 0x70
101 #define LTC2373_CH7 0x78
102
103 #define LTC2373_CH0_1 0x00
104 #define LTC2373_CH1_0 0x20
105
106 #define LTC2373_CH2_3 0x08
107 #define LTC2373_CH3_2 0x28
108
109 #define LTC2373_CH4_5 0x10
110 #define LTC2373_CH5_4 0x30
111
112 #define LTC2373_CH6_7 0x18
113 #define LTC2373_CH7_6 0x38
114 //!@}
115
116 //! @name LTC2373 Uni/GAIN config bits
117 //! @{
118 // Range Command
119 #define LTC2373_RANGE_UNIPOLAR 0x00
120 #define LTC2373_RANGE_BIPOLAR 0x02
121 #define LTC2373_RANGE_DIFF_UNIPOLAR 0x04
122 #define LTC2373_RANGE_DIFF_BIPOLAR 0x06
123
124 // Gain Compression Command
125 #define LTC2373_NO_COMPRESSION 0x00
126 #define LTC2373_GAIN_COMPRESSION 0x01
127 //!@}
128
129 // Builds the ADC command
130 uint8_t LTC2373_build_command(uint8_t sequencer_bit,
131 uint8_t ch_designate,
132 uint8_t range_select,
133 uint8_t gain_compression
134 );
135
136
137 //! Reads the LTC2373 and returns 32-bit data
138 //! @return void
139 void LTC2373_read(uint8_t cs, //!< Chip Select Pin
140 uint8_t adc_command,
141 uint32_t *ptr_adc_code //!< Returns code read from ADC (from previous conversion)
142 );
143
144 //! Configures the LTC2373
145 //! @return void
146 void LTC2373_configure(uint8_t cs,
147 uint32_t adc_command
148 );
149
150 //! Calculates the LTC2373 input voltage given the binary data and lsb weight.
151 //! @return Floating point voltage
152 float LTC2373_code_to_voltage(uint8_t adc_command,
153 uint32_t adc_code, //!< Raw ADC code
154 float vref //!< Reference voltage
155 );
156
157 #endif // LTC2373_H
158
159
adc_command
static uint8_t adc_command
Definition: DC2071AA.ino:111
LTC2373_configure
void LTC2373_configure(uint8_t cs, uint32_t adc_command)
Configures the LTC2373.
Definition: LTC2373.cpp:114
LTC2373_read
void LTC2373_read(uint8_t cs, uint8_t adc_command, uint32_t *ptr_adc_code)
Reads the LTC2373 and returns 32-bit data.
Definition: LTC2373.cpp:89
LTC2373_build_command
uint8_t LTC2373_build_command(uint8_t sequencer_bit, uint8_t ch_designate, uint8_t range_select, uint8_t gain_compression)
Definition: LTC2373.cpp:79
LTC2373_code_to_voltage
float LTC2373_code_to_voltage(uint8_t adc_command, uint32_t adc_code, float vref)
Calculates the LTC2373 input voltage given the binary data and lsb weight.
Definition: LTC2373.cpp:134
vref
float vref
Definition: LTC2492_Thermocouple_Meter.ino:129
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113