Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2604.h
Go to the documentation of this file.
1 /*!
2 LTC2604: Quad 16-Bit Rail-to-Rail DACs in 16-Lead SSOP
3 
4 @verbatim
5 
6 The LTC2604/LTC2614/LTC2624 are quad 16-,14- and 12-bit 2.5V to 5.5V
7 rail-to-rail voltage output DACs in 16-lead narrow SSOP packages. These
8 parts have separate reference inputs for each DAC. They have built-in
9 high performance output buffers and are guaranteed monotonic.
10 
11 These parts establish advanced performance standards for output drive,
12 crosstalk and load regulation in single-supply, voltage output multiples.
13 
14 SPI DATA FORMAT (MSB First):
15 
16 24-Bit Load Sequence:
17 
18  Byte #1 Byte #2 Byte #3
19  Command MSB LSB
20 LTC2604-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
21 LTC2604-14 : C3 C2 C1 C0 A3 A2 A1 A0 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 X X
22 LTC2604-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
23 
24 32-Bit Load Sequence:
25 
26  Byte #1 Byte #2 Byte #3 Byte #4
27  Command MSB LSB
28 LTC2604-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
29 LTC2604-14 : X X X X X X X X C3 C2 C1 C0 A3 A2 A1 A0 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 X X
30 LTC2604-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
31 
32 Cx : DAC Command Code
33 Ax : DAC Address (0=DACA, 1=DACB, 2=DACC, 3=DACD, 0xFF=All DACs)
34 Dx : DAC Data Bits
35 X : Don't care
36 
37 
38 Example Code:
39 
40 Set DAC A to to 2V for 16-bit DAC.
41 
42  shift_count = 0; // 16-bit DAC does not have to be shifted
43  dac_voltage = 2.0; // Sets dac voltage variable to 2v
44 
45  dac_code = LTC2604_voltage_to_code(dac_voltage, LTC2604_lsb, LTC2604_offset); // Calculate DAC code from voltage, lsb, and offset
46  LTC2604_write(LTC2604_CS, LTC2604_CMD_WRITE_UPDATE, LTC2604_DAC_A, dac_code << shift_count); // Set DAC A with DAC code
47 
48 @endverbatim
49 
50 
51 http://www.linear.com/product/LTC2604
52 
53 http://www.linear.com/product/LTC2604#demoboards
54 
55 
56 
57 Copyright 2018(c) Analog Devices, Inc.
58 
59 All rights reserved.
60 
61 Redistribution and use in source and binary forms, with or without
62 modification, are permitted provided that the following conditions are met:
63  - Redistributions of source code must retain the above copyright
64  notice, this list of conditions and the following disclaimer.
65  - Redistributions in binary form must reproduce the above copyright
66  notice, this list of conditions and the following disclaimer in
67  the documentation and/or other materials provided with the
68  distribution.
69  - Neither the name of Analog Devices, Inc. nor the names of its
70  contributors may be used to endorse or promote products derived
71  from this software without specific prior written permission.
72  - The use of this software may or may not infringe the patent rights
73  of one or more patent holders. This license does not release you
74  from the requirement that you obtain separate licenses from these
75  patent holders to use this software.
76  - Use of the software either in source or binary form, must be run
77  on or directly connected to an Analog Devices Inc. component.
78 
79 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
80 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
81 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
82 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
83 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
84 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
85 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
86 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
87 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
88 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89 */
90 
91 /*! @file
92  @ingroup LTC2604
93  Header for LTC2604: Quad 16-Bit Rail-to-Rail DACs in 16-Lead SSOP
94 */
95 
96 
97 #ifndef LTC2604_H
98 #define LTC2604_H
99 
100 #include <SPI.h>
101 
102 //! Define the SPI CS pin
103 #ifndef LTC2604_CS
104 #define LTC2604_CS QUIKEVAL_CS
105 #endif
106 
107 
108 //! @name LTC2604 Command Codes
109 //!@{
110 //! OR'd together with the DAC address to form the command byte
111 #define LTC2604_CMD_WRITE 0x00 //!< Write to input register n
112 #define LTC2604_CMD_UPDATE 0x10 //!< Update (power up) DAC register n
113 #define LTC2604_CMD_WRITE_UPDATE_ALL 0x20 //!< Write to input register n, update (power up) all
114 #define LTC2604_CMD_WRITE_UPDATE 0x30 //!< Write to input register n, update (power up) all
115 #define LTC2604_CMD_POWER_DOWN 0x40 //!< Power down n
116 #define LTC2604_CMD_NO_OPERATION 0xF0 //!< No operation
117 //!@}
118 
119 /*!
120 | DAC Addresses | Value |
121 | :--------------------------: | :------: |
122 | LTC2605_DAC_A | 0x00 |
123 | LTC2605_DAC_B | 0x01 |
124 | LTC2605_DAC_C | 0x02 |
125 | LTC2605_DAC_D | 0x03 |
126 | LTC2605_DAC_ALL | 0x0F |
127 */
128 /*! @name Dac Addresses
129 @{*/
130 
131 // Which DAC to operate on
132 #define LTC2604_DAC_A 0x00
133 #define LTC2604_DAC_B 0x01
134 #define LTC2604_DAC_C 0x02
135 #define LTC2604_DAC_D 0x03
136 #define LTC2604_DAC_ALL 0x0F
137 //
138 
139 //! Write the 16-bit dac_code to the LTC2604
140 //! @return Void
141 void LTC2604_write(uint8_t cs, //!< Chip Select Pin
142  uint8_t dac_command, //!< Command Nibble, left-justified, lower nibble set to zero
143  uint8_t dac_address, //!< DAC Address Nibble, right justified, upper nibble set to zero
144  uint16_t dac_code //!< 16-bit DAC code
145  );
146 
147 //! Calculate a LTC2604 DAC code given the desired output voltage and DAC address (0-3)
148 //! @return The 16-bit code to send to the DAC
149 uint16_t LTC2604_voltage_to_code(float dac_voltage, //!< Voltage to send to DAC
150  float LTC2604_lsb, //!< LSB value (volts)
151  int16_t LTC2604_offset //!< Offset (volts)
152  );
153 
154 //! Calculate the LTC2604 DAC output voltage given the DAC code, offset, and LSB value
155 //! @return Calculated voltage
156 float LTC2604_code_to_voltage(uint16_t dac_code, //!< DAC code
157  float LTC2604_lsb, //!< LSB value (volts)
158  int16_t LTC2604_offset //!< Offset (volts)
159  );
160 
161 #endif //LTC2604_H
float LTC2604_code_to_voltage(uint16_t dac_code, float LTC2604_lsb, int16_t LTC2604_offset)
Calculate the LTC2604 DAC output voltage given the DAC code, offset, and LSB value.
Definition: LTC2604.cpp:103
static float LTC2604_lsb[4]
Definition: DC809A.ino:91
static int16_t LTC2604_offset
Definition: DC809A.ino:90
void LTC2604_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2604.
Definition: LTC2604.cpp:75
uint16_t LTC2604_voltage_to_code(float dac_voltage, float LTC2604_lsb, int16_t LTC2604_offset)
Calculate a LTC2604 DAC code given the desired output voltage and DAC address (0-3) ...
Definition: LTC2604.cpp:90