| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2461.cpp
Go to the documentation of this file.
1 /*!
2 LTC2461: 16-Bit I2C Delta Sigma ADCs with 10ppm/C Max Precision Reference.
3 LTC2463: Differential, 16-Bit I2C Delta Sigma ADCs with 10ppm/C Max Precision Reference.
4 LTC2453: Differential, 16-Bit Delta Sigma ADC With I2C Interface.
5
6 @verbatim
7
8 The LTC2461/LTC2463 are ultra tiny, 16-Bit analog-to-digital converters with an
9 integrated precision reference. They use a single 2.7V to 5.5V supply and
10 communicate through an I2C Interface. The LTC2461 is single-ended with a 0V to
11 1.25V input range and the LTC2463 is differential with a 1.25V input range. Both
12 ADCs include a 1.25V integrated reference with 2ppm/C drift performance and 0.1%
13 initial accuracy. The converters are available in a 12-pin 3mm x 3mm DFN package
14 or an MSOP-12 package. They include an integrated oscillator and perform
15 conversions with no latency for multiplexed applications. The LTC2461/LTC2463
16 include a proprietary input sampling scheme that reduces the average input
17 current several orders of magnitude when compared to conventional delta sigma
18 converters
19
20 @endverbatim
21
22 http://www.linear.com/product/LTC2461
23 http://www.linear.com/product/LTC2463
24 http://www.linear.com/product/LTC2453
25
26 http://www.linear.com/product/LTC2461#demoboards
27 http://www.linear.com/product/LTC2463#demoboards
28 http://www.linear.com/product/LTC2453#demoboards
29
30
31 Copyright 2018(c) Analog Devices, Inc.
32
33 All rights reserved.
34
35 Redistribution and use in source and binary forms, with or without
36 modification, are permitted provided that the following conditions are met:
37 - Redistributions of source code must retain the above copyright
38 notice, this list of conditions and the following disclaimer.
39 - Redistributions in binary form must reproduce the above copyright
40 notice, this list of conditions and the following disclaimer in
41 the documentation and/or other materials provided with the
42 distribution.
43 - Neither the name of Analog Devices, Inc. nor the names of its
44 contributors may be used to endorse or promote products derived
45 from this software without specific prior written permission.
46 - The use of this software may or may not infringe the patent rights
47 of one or more patent holders. This license does not release you
48 from the requirement that you obtain separate licenses from these
49 patent holders to use this software.
50 - Use of the software either in source or binary form, must be run
51 on or directly connected to an Analog Devices Inc. component.
52
53 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
54 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
55 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
56 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
57 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
59 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
60 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
61 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 */
64
65 //! @ingroup Analog_to_Digital_Converters
66 //! @{
67 //! @defgroup LTC2461 LTC2461: 16-Bit I2C Delta Sigma ADCs with 10ppm/C Max Precision Reference
68 //! @}
69
70 /*! @file
71 @ingroup LTC2461
72 Library for LTC2461: 16-Bit I2C Delta Sigma ADCs with 10ppm/C Max Precision Reference
73 */
74
75 #include <Arduino.h>
76 #include <stdint.h>
77 #include "Linduino.h"
78 #include "LT_I2C.h"
79 #include "LTC2461.h"
80 #include <Wire.h>
81
82 int8_t LTC2461_read(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
83 // Reads 16 bits.
84 {
85 int32_t ack = 0;
86
87 ack = i2c_read_word_data(i2c_address, adc_command, adc_code);
88
89 return(ack);
90
91 }
92
93 int8_t LTC2461_command(uint8_t i2c_address, uint8_t adc_command)
94 // Write an 8-bit command to the ADC.
95 // The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
96 {
97 int32_t ack = 0;
98
99 ack = i2c_write_byte(i2c_address, adc_command);
100 return(ack);
101 }
102
103 float LTC2461_code_to_voltage(uint16_t adc_code, float LTC2461_lsb, int32_t LTC2461_offset_code)
104 // Calculates the LTC2461 input unipolar voltage.
105 {
106 float adc_voltage;
107 adc_voltage = (adc_code + LTC2461_offset_code)*(LTC2461_lsb); //! 1) Calculate voltage from ADC code, lsb, offset.
108 return(adc_voltage);
109 }
110
111 void LTC2461_cal_voltage(uint16_t zero_code, uint16_t fs_code, float zero_voltage, float fs_voltage, float *LTC2461_lsb, int32_t *LTC2461_offset_code) // Function definition
112 // Calibrate the lsb
113 {
114 float temp_offset;
115 *LTC2461_lsb = (fs_voltage-zero_voltage)/((float)(fs_code - zero_code)); //! 1) Calculate the LSB
116
117 temp_offset = (zero_voltage/ *LTC2461_lsb) - zero_code; //! 2) Calculate Unipolar offset
118 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset); //! 3) Round
119 *LTC2461_offset_code = (int32_t)temp_offset; //! 4) Cast as int32_t
120 }
i2c_address
uint8_t i2c_address
adc_command
static uint8_t adc_command
Definition: DC2071AA.ino:111
i2c_write_byte
int8_t i2c_write_byte(uint8_t address, uint8_t value)
Write "value" byte to device at "address".
Definition: LT_I2C.cpp:109
LTC2461_read
int8_t LTC2461_read(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
Definition: LTC2461.cpp:82
LTC2461_lsb
static float LTC2461_lsb
Ideal LSB voltage for a perfect part (Vref/(2^16))
Definition: DC1491A.ino:124
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC2461_cal_voltage
void LTC2461_cal_voltage(uint16_t zero_code, uint16_t fs_code, float zero_voltage, float fs_voltage, float *LTC2461_lsb, int32_t *LTC2461_offset_code)
Calibrate the lsb.
Definition: LTC2461.cpp:111
adc_voltage
static float adc_voltage
Definition: DC2071AA.ino:115
LTC2461_command
int8_t LTC2461_command(uint8_t i2c_address, uint8_t adc_command)
Write a 16-bit command to the ADC.
Definition: LTC2461.cpp:93
i2c_read_word_data
int8_t i2c_read_word_data(uint8_t address, uint8_t command, uint16_t *value)
Read a 16-bit word of data from register specified by "command".
Definition: LT_I2C.cpp:172
LTC2461_offset_code
static int32_t LTC2461_offset_code
Ideal offset for a perfect part.
Definition: DC1491A.ino:125
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC2461.h
LTC2461: 16-Bit I2C Delta Sigma ADCs with 10ppm/C Max Precision Reference.
LTC2461_code_to_voltage
float LTC2461_code_to_voltage(uint16_t adc_code, float LTC2461_lsb, int32_t LTC2461_offset_code)
Calculates the LTC2309 input unipolar voltage.
Definition: LTC2461.cpp:103
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113