| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2654.h
Go to the documentation of this file.
1 /*!
2 LTC2654: Quad SPI 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference
3
4 @verbatim
5
6 The LTC2654 is a family of quad 16-/12-bit rail-to-rail DACs with integrated
7 10ppm/C maximum reference. The DACs have built-in high performance, rail-to-
8 rail, output buffers and are guaranteed monotonic. The LTC2654-L has a full-
9 scale output of 2.5V with the integrated reference and operates from a single
10 2.7V to 5.5V supply. The LTC2654-H has a full-scale output of 4.096V with the
11 integrated reference and operates from a 4.5V to 5.5V supply. Each DAC can also
12 operate with an external reference, which sets the full-scale output to 2 times
13 the external reference voltage. These DACs communicate via a SPI/MICROWIRE
14 compatible 4-wire serial interface which operates at clock rates up to 50MHz.
15 The LTC2654 incorporates a power-on reset circuit that is controlled by the
16 PORSEL pin. If PORSEL is tied to GND, the DACs reset to zero-scale. If PORSEL is
17 tied to VCC, the DACs reset to mid-scale.
18
19 SPI DATA FORMAT (MSB First):
20
21 24-Bit Load Sequence:
22
23 Byte #1 Byte #2 Byte #3
24 Command MSB LSB
25 LTC2654-16 : C3 C2 C1 C0 A3 A2 A1 A0 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
26 LTC2654-12 : C3 C2 C1 C0 A3 A2 A1 A0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 X X X X
27
28 32-Bit Load Sequence:
29
30 Byte #1 Byte #2 Byte #3 Byte #4
31 Command MSB LSB
32 LTC2654-16 : X X X X X X X X C3 C2 C1 C0 A3 A2 A1 A0 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
33 LTC2654-12 : X X X X X X X X C3 C2 C1 C0 A3 A2 A1 A0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 X X X X
34
35 Cx : DAC Command Code
36 Ax : DAC Address (0=DACA, 1=DACB, 2=DACC, 3=DACD, 0xFF=All DACs)
37 Dx : DAC Data Bits
38 X : Don't care
39
40
41 Example Code:
42
43 Set DAC A to to 2V for 16-bit DAC.
44
45 shift_count = 0; // 16-bit DAC does not have to be shifted
46 dac_voltage = 2.0; // Sets dac voltage variable to 2v
47
48 dac_code = LTC2654_voltage_to_code(dac_voltage, LTC2654_lsb, LTC2654_offset); // Calculate DAC code from voltage, lsb, and offset
49 LTC2654_write(LTC2654_CS, LTC2654_CMD_WRITE_UPDATE, LTC2654_DAC_A, dac_code << shift_count); // Set DAC A with DAC code
50
51 @endverbatim
52
53 http://www.linear.com/product/LTC2654
54
55 http://www.linear.com/product/LTC2654#demoboards
56
57
58 Copyright 2018(c) Analog Devices, Inc.
59
60 All rights reserved.
61
62 Redistribution and use in source and binary forms, with or without
63 modification, are permitted provided that the following conditions are met:
64 - Redistributions of source code must retain the above copyright
65 notice, this list of conditions and the following disclaimer.
66 - Redistributions in binary form must reproduce the above copyright
67 notice, this list of conditions and the following disclaimer in
68 the documentation and/or other materials provided with the
69 distribution.
70 - Neither the name of Analog Devices, Inc. nor the names of its
71 contributors may be used to endorse or promote products derived
72 from this software without specific prior written permission.
73 - The use of this software may or may not infringe the patent rights
74 of one or more patent holders. This license does not release you
75 from the requirement that you obtain separate licenses from these
76 patent holders to use this software.
77 - Use of the software either in source or binary form, must be run
78 on or directly connected to an Analog Devices Inc. component.
79
80 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
81 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
82 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
83 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
84 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
85 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
86 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
87 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
88 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
89 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90 */
91
92 /*! @file
93 @ingroup LTC2654
94 Header for LTC2654 Quad SPI 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference
95 */
96
97 #ifndef LTC2654_H
98 #define LTC2654_H
99
100 #include <SPI.h>
101
102 //! Define the SPI CS pin
103 #ifndef LTC2654_CS
104 #define LTC2654_CS QUIKEVAL_CS
105 #endif
106
107 //! @name LTC2654 Command Codes
108 //!@{
109 //! OR'd together with the DAC address to form the command byte
110 #define LTC2654_CMD_WRITE 0x00 //!< Write to input register n
111 #define LTC2654_CMD_UPDATE 0x10 //!< Update (power up) DAC register n
112 #define LTC2654_CMD_WRITE_UPDATE_ALL 0x20 //!< Write to input register n, update (power up) all
113 #define LTC2654_CMD_WRITE_UPDATE 0x30 //!< Write to input register n, update (power up) all
114 #define LTC2654_CMD_POWER_DOWN 0x40 //!< Power down n
115 #define LTC2654_CMD_POWER_DOWN_ALL 0x50 //!< Power down chip (all DACs and reference)
116 #define LTC2654_CMD_INTERNAL_REFERENCE 0x60 //!< Select internal reference (power up reference)
117 #define LTC2654_CMD_EXTERNAL_REFERENCE 0x70 //!< Select external reference (power down internal reference)
118 #define LTC2654_CMD_NO_OPERATION 0xF0 //!< No operation
119 //!@}
120
121 //! @name LTC2654 DAC addresses
122 //! @{
123 //! Which DAC to operate on
124 #define LTC2654_DAC_A 0x00
125 #define LTC2654_DAC_B 0x01
126 #define LTC2654_DAC_C 0x02
127 #define LTC2654_DAC_D 0x03
128 #define LTC2654_DAC_ALL 0x0F
129 //! @}
130
131 //! Write the 16-bit dac_code to the LTC2654
132 //! @return Void
133 void LTC2654_write(uint8_t cs, //!< Chip Select Pin
134 uint8_t dac_command, //!< Command Nibble, left-justified, lower nibble set to zero
135 uint8_t dac_address, //!< DAC Address Nibble, right justified, upper nibble set to zero
136 uint16_t dac_code //!< 16-bit DAC code
137 );
138
139 //! Calculate a LTC2654 DAC code given the desired output voltage and DAC address (0-3)
140 //! @return The 16-bit code to send to the DAC
141 uint16_t LTC2654_voltage_to_code(float dac_voltage, //!< Voltage to send to DAC
142 float LTC2654_lsb, //!< LSB value (volts)
143 int16_t LTC2654_offset //!< Offset (volts)
144 );
145
146 //! Calculate the LTC2654 DAC output voltage given the DAC code, offset, and LSB value
147 //! @return Calculated voltage
148 float LTC2654_code_to_voltage(uint16_t dac_code, //!< DAC code
149 float LTC2654_lsb, //!< LSB value (volts)
150 int16_t LTC2654_offset //!< Offset (volts)
151 );
152
153 //! Calculate the LTC2654 offset and LSB voltage given two measured voltages and their corresponding codes
154 //! @return Void
155 void LTC2654_calibrate(uint16_t dac_code1, //!< First DAC code
156 uint16_t dac_code2, //!< Second DAC code
157 float voltage1, //!< First voltage
158 float voltage2, //!< Second voltage
159 float *LTC2654_lsb, //!< Returns resulting LSB (volts)
160 int16_t *LTC2654_offset //!< Returns resulting Offset (volts)
161 );
162 #endif // LTC2654_H
LTC2654_write
void LTC2654_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2654.
Definition: LTC2654.cpp:79
LTC2654_offset
static int16_t LTC2654_offset[5]
DAC offset - index 4 for "all DACs".
Definition: DC1678A.ino:162
LTC2654_voltage_to_code
uint16_t LTC2654_voltage_to_code(float dac_voltage, float LTC2654_lsb, int16_t LTC2654_offset)
Calculate a LTC2654 DAC code given the desired output voltage and DAC address (0-3) ...
Definition: LTC2654.cpp:94
LTC2654_code_to_voltage
float LTC2654_code_to_voltage(uint16_t dac_code, float LTC2654_lsb, int16_t LTC2654_offset)
Calculate the LTC2654 DAC output voltage given the DAC code, offset, and LSB value.
Definition: LTC2654.cpp:107
LTC2654_lsb
static float LTC2654_lsb[5]
The LTC2654 lsb - index 4 for "all DACs".
Definition: DC1678A.ino:163
LTC2654_calibrate
void LTC2654_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2654_lsb, int16_t *LTC2654_offset)
Calculate the LTC2654 offset and LSB voltage given two measured voltages and their corresponding code...
Definition: LTC2654.cpp:115