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