| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2482.cpp
Go to the documentation of this file.
1 /*!
2 LTC2482: 16-Bit Delta-Sigma ADC with Easy Drive Input Current Cancellation.
3
4 @verbatim
5
6 The LTC2480 is a 16-Bit Delta-Sigma ADC with Easy Drive Input Current Cancellation.
7 The LTC2482 allows a wide common mode input range (0V to VCC) independent of the
8 reference voltage. The reference can be as low as 100mV or can be tied directly to
9 VCC. The noise level is 600nV RMS independent of VREF . This allows direct
10 digitization of low level signals with 16-bit accuracy. The LTC2482 includes an on-chip
11 trimmed oscillator, eliminating the need for external crystals or oscillators and
12 provides 87dB rejection of 50Hz and 60Hz line frequency noise. Absolute accuracy and low
13 drift are automatically maintained through continuous, transparent, offset and
14 full-scale calibration.
15
16 @endverbatim
17
18 http://www.linear.com/product/LTC2482
19
20 http://www.linear.com/product/LTC2482#demoboards
21
22
23 Copyright 2018(c) Analog Devices, Inc.
24
25 All rights reserved.
26
27 Redistribution and use in source and binary forms, with or without
28 modification, are permitted provided that the following conditions are met:
29 - Redistributions of source code must retain the above copyright
30 notice, this list of conditions and the following disclaimer.
31 - Redistributions in binary form must reproduce the above copyright
32 notice, this list of conditions and the following disclaimer in
33 the documentation and/or other materials provided with the
34 distribution.
35 - Neither the name of Analog Devices, Inc. nor the names of its
36 contributors may be used to endorse or promote products derived
37 from this software without specific prior written permission.
38 - The use of this software may or may not infringe the patent rights
39 of one or more patent holders. This license does not release you
40 from the requirement that you obtain separate licenses from these
41 patent holders to use this software.
42 - Use of the software either in source or binary form, must be run
43 on or directly connected to an Analog Devices Inc. component.
44
45 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
46 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
47 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
49 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
50 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
51 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57 //! @ingroup Analog_to_Digital_Converters
58 //! @{
59 //! @defgroup LTC2482 LTC2482: 16-Bit Delta-Sigma ADC with Easy Drive Input Current Cancellation.
60 //! @}
61
62 /*! @file
63 @ingroup LTC2482
64 Library for LTC2482: 16-Bit Delta-Sigma ADC with Easy Drive Input Current Cancellation.
65 */
66
67 #include <stdint.h>
68 #include "Linduino.h"
69 #include "LT_SPI.h"
70
71 // Reads the LTC2482 and returns 24-bit data
72 void LTC2482_read(uint8_t cs, uint32_t *ptr_adc_code)
73 {
74 LT_union_int32_4bytes data, command; // LTC24XX data and command
75 command.LT_uint32 = 0;
76 data.LT_uint32 = 0;
77
78 spi_transfer_block(cs, command.LT_byte, data.LT_byte, (uint8_t)3);
79
80 *ptr_adc_code = data.LT_uint32;
81 }
82
83 // Calculates the LTC2482 input voltage given the binary data, reference voltage and input gain.
84 float LTC2482_code_to_voltage(uint32_t adc_code, float vref)
85 {
86 float voltage;
87
88 voltage = (float)adc_code;
89 voltage = voltage / (pow(2,16)-1); //! 2) This calculates the input as a fraction of the reference voltage (dimensionless)
90 voltage = voltage * vref; //! 3) Multiply fraction by Vref to get the actual voltage at the input (in volts)
91
92 return(voltage);
93 }
LT_union_int32_4bytes::LT_byte
uint8_t LT_byte[4]
4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer ...
Definition: Linduino.h:112
Linduino.h
Header File for Linduino Libraries and Demo Code.
LT_union_int32_4bytes::LT_uint32
uint32_t LT_uint32
32-bit unsigned integer to be converted to four bytes
Definition: Linduino.h:111
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
LTC2482_code_to_voltage
float LTC2482_code_to_voltage(uint32_t adc_code, float vref)
Calculates the LTC2482 input voltage given the binary data, reference voltage and input gain...
Definition: LTC2482.cpp:84
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LT_union_int32_4bytes
This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer) four uint...
Definition: Linduino.h:108
spi_transfer_block
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
Definition: LT_SPI.cpp:125
voltage
static float voltage
Definition: DC2289AA.ino:71
vref
float vref
Definition: LTC2492_Thermocouple_Meter.ino:129
LTC2482_read
void LTC2482_read(uint8_t cs, uint32_t *ptr_adc_code)
Reads the LTC2482 and returns 24-bit data.
Definition: LTC2482.cpp:72
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113