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