| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2366.cpp
Go to the documentation of this file.
1 /*!
2 LTC2360-12: 12-Bit, 100Ksps ADC.
3 LTC2361-12: 12-Bit, 250Ksps ADC.
4 LTC2362-12: 12-Bit, 500Ksps ADC
5 LTC2365-12: 12-Bit, 1Msps ADC
6 LTC2366-12: 12-Bit, 3Msps ADC
7
8 @verbatim
9
10 The following parts (DUT) are pin-compatible, 12-bit A/D converters with serial I/O, and an internal reference:
11 LTC2360-12: 12-Bit, 100Ksps ADC.
12 LTC2361-12: 12-Bit, 250Ksps ADC.
13 LTC2362-12: 12-Bit, 500Ksps ADC
14 LTC2365-12: 12-Bit, 1Msps ADC
15 LTC2366-12: 12-Bit, 3Msps ADC
16
17 @endverbatim
18
19 http://www.linear.com/product/LTC2360-12
20 http://www.linear.com/product/LTC2361-12
21 http://www.linear.com/product/LTC2362-12
22 http://www.linear.com/product/LTC2365-12
23 http://www.linear.com/product/LTC2366-12
24
25 http://www.linear.com/product/LTC2360-12#demoboards
26 http://www.linear.com/product/LTC2361-12#demoboards
27 http://www.linear.com/product/LTC2362-12#demoboards
28 http://www.linear.com/product/LTC2365-12#demoboards
29 http://www.linear.com/product/LTC2366-12#demoboards
30
31
32 Copyright 2018(c) Analog Devices, Inc.
33
34 All rights reserved.
35
36 Redistribution and use in source and binary forms, with or without
37 modification, are permitted provided that the following conditions are met:
38 - Redistributions of source code must retain the above copyright
39 notice, this list of conditions and the following disclaimer.
40 - Redistributions in binary form must reproduce the above copyright
41 notice, this list of conditions and the following disclaimer in
42 the documentation and/or other materials provided with the
43 distribution.
44 - Neither the name of Analog Devices, Inc. nor the names of its
45 contributors may be used to endorse or promote products derived
46 from this software without specific prior written permission.
47 - The use of this software may or may not infringe the patent rights
48 of one or more patent holders. This license does not release you
49 from the requirement that you obtain separate licenses from these
50 patent holders to use this software.
51 - Use of the software either in source or binary form, must be run
52 on or directly connected to an Analog Devices Inc. component.
53
54 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
55 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
56 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
57 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
58 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
60 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
61 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
62 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 */
65
66 //! @ingroup Analog_to_Digital_Converters
67 //! @{
68 //! @defgroup LTC2366 LTC2366: 12-Bit 3Msps ADC
69 //! @}
70
71 /*! @file
72 @ingroup LTC2366
73 Library for LTC2366: 12-Bit 3Msps ADC
74 */
75
76 #include <Arduino.h>
77 #include <stdint.h>
78 #include "Linduino.h"
79 #include "LT_SPI.h"
80 #include "LTC2366.h"
81 #include <SPI.h>
82
83
84 // Reads the ADC and returns 16-bit data
85 void LTC2366_read(uint8_t cs, uint16_t *ptr_adc_code)
86 {
87 uint16_t dummy_command = 0;
88
89 spi_transfer_word(cs, dummy_command, ptr_adc_code);
90
91 return;
92
93 }
94
95
96 // Calculates the voltage corresponding to an adc code in offset binary, given the reference voltage (in volts)
97 float LTC2366_code_to_voltage(uint16_t adc_code, float vref)
98 {
99 float voltage;
100
101 adc_code = adc_code << 2; //the data is left justified to bit_13 of a 16 bit word
102
103 voltage = (float)adc_code;
104 voltage = voltage / (pow(2,16)-1); //! 2) This calculates the input as a fraction of the reference voltage (dimensionless)
105 voltage = voltage * vref; //! 3) Multiply fraction by Vref to get the actual voltage at the input (in volts)
106
107 return(voltage);
108 }
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC2366.h
LTC2360-12: 12-Bit, 100Ksps ADC.
LTC2366_read
void LTC2366_read(uint8_t cs, uint16_t *ptr_adc_code)
Reads the LTC2366 and returns 32-bit data in offset binary format.
Definition: LTC2366.cpp:85
spi_transfer_word
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
Definition: LT_SPI.cpp:98
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LTC2366_code_to_voltage
float LTC2366_code_to_voltage(uint16_t adc_code, float vref)
Calculates the LTC2366 input voltage given the binary data and lsb weight.
Definition: LTC2366.cpp:97
voltage
static float voltage
Definition: DC2289AA.ino:71
vref
float vref
Definition: LTC2492_Thermocouple_Meter.ino:129
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113