| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2662.h
Go to the documentation of this file.
1 /*!
2 LTC2662: 5-Channel 16-/12-Bit 300mA SoftSpan Current Source DACs
3
4 @verbatim
5
6 The LTC2662 is a family of 5-channel, 16-/12-bit current source digital-to-analog converters with precision
7 integrated reference and accurate full-scale current. The LTC2662 is guaranteed monotonic and offers independent
8 SoftSpan programmability of the current output range from 3.125mA to 300mA.
9
10 The LTC2662 provides a separate VDD0-4 supply for each OUT0-4 channel. The flexible VDD0-4 supply allows
11 operation from 2.85V to 33V. Internal 12 ohm switches allow any OUT0-4 pin to be connected to an optional
12 negative V- supply voltage and sink up to 80mA.
13
14 The SPI/Microwire-compatible 3-wire serial interface operates on logic levels as low as 1.71V, at clock
15 rates up to 50MHz.
16
17
18 SPI DATA FORMAT (MSB First):
19
20 24-Bit Load Sequence:
21
22 Byte #1 Byte #2 Byte #3
23 Command MSB LSB
24 LTC2662-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
25 LTC2662-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
26
27 32-Bit Load Sequence:
28 Byte #1 Byte #2 Byte #3 Byte #4
29 Command MSB LSB
30 LTC2662-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
31 LTC2662-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
32
33 Cx : DAC Command Code
34 Ax : DAC Address (0 to F, corresponding to DAC 0 to DAC 15)
35 Dx : DAC Data Bits
36 X : Don't care
37
38 @endverbatim
39
40 http://www.linear.com/product/LTC2662
41
42 http://www.linear.com/product/LTC2662#demoboards
43
44
45 Copyright 2018(c) Analog Devices, Inc.
46
47 All rights reserved.
48
49 Redistribution and use in source and binary forms, with or without
50 modification, are permitted provided that the following conditions are met:
51 - Redistributions of source code must retain the above copyright
52 notice, this list of conditions and the following disclaimer.
53 - Redistributions in binary form must reproduce the above copyright
54 notice, this list of conditions and the following disclaimer in
55 the documentation and/or other materials provided with the
56 distribution.
57 - Neither the name of Analog Devices, Inc. nor the names of its
58 contributors may be used to endorse or promote products derived
59 from this software without specific prior written permission.
60 - The use of this software may or may not infringe the patent rights
61 of one or more patent holders. This license does not release you
62 from the requirement that you obtain separate licenses from these
63 patent holders to use this software.
64 - Use of the software either in source or binary form, must be run
65 on or directly connected to an Analog Devices Inc. component.
66
67 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
68 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
69 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
70 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
71 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
72 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
73 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
74 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
75 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
76 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77 */
78
79 /*! @file
80 @ingroup LTC2662
81 Header for LTC2662: 5-Channel 16-/12-Bit 300mA SoftSpan Current Source DACs
82 */
83
84 #ifndef LTC2662_H
85 #define LTC2662_H
86
87 //! Define the SPI CS pin
88 #ifndef LTC2662_CS
89 #define LTC2662_CS QUIKEVAL_CS //! SPI Chip Select Pin
90 #endif
91
92 //! @name LTC2662 Command Codes
93 //! OR'd together with the DAC address to form the command byte
94 #define LTC2662_CMD_WRITE_N 0x00 //!< Write to input register n
95 #define LTC2662_CMD_UPDATE_N 0x10 //!< Update (power up) DAC register n
96 #define LTC2662_CMD_WRITE_N_UPDATE_ALL 0x20 //!< Write to input register n, update (power-up) all
97 #define LTC2662_CMD_WRITE_N_UPDATE_N 0x30 //!< Write to input register n, update (power-up)
98 #define LTC2662_CMD_POWER_DOWN_N 0x40 //!< Power down n
99 #define LTC2662_CMD_POWER_DOWN_ALL 0x50 //!< Power down chip (all DAC's, MUX and reference)
100
101 #define LTC2662_CMD_SPAN 0x60 //!< Write span to dac n
102 #define LTC2662_CMD_CONFIG 0x70 //!< Configure reference / toggle
103 #define LTC2662_CMD_WRITE_ALL 0x80 //!< Write to all input registers
104 #define LTC2662_CMD_UPDATE_ALL 0x90 //!< Update all DACs
105 #define LTC2662_CMD_WRITE_ALL_UPDATE_ALL 0xA0 //!< Write to all input reg, update all DACs
106 #define LTC2662_CMD_MUX 0xB0 //!< Select MUX channel (controlled by 5 LSbs in data word)
107 #define LTC2662_CMD_TOGGLE_SEL 0xC0 //!< Select which DACs can be toggled (via toggle pin or global toggle bit)
108 #define LTC2662_CMD_GLOBAL_TOGGLE 0xD0 //!< Software toggle control via global toggle bit
109 #define LTC2662_CMD_SPAN_ALL 0xE0 //!< Set span for all DACs
110 #define LTC2662_CMD_NO_OPERATION 0xF0 //!< No operation
111 //! @}
112
113 //! @name LTC2662 Span Codes
114 //! @{
115 //! Descriptions are valid for a 1.25V reference and 20k R_FSADJ.
116 #define LTC2662_SPAN_HI_Z 0x0000
117 #define LTC2662_SPAN_3_125MA 0x0001
118 #define LTC2662_SPAN_6_25MA 0x0002
119 #define LTC2662_SPAN_12_5MA 0x0003
120 #define LTC2662_SPAN_25MA 0x0004
121 #define LTC2662_SPAN_50MA 0x0005
122 #define LTC2662_SPAN_100MA 0x0006
123 #define LTC2662_SPAN_200MA 0x0007
124 #define LTC2662_SPAN_SW_TO_NEG_V 0x0008
125 #define LTC2662_SPAN_300MA 0x0009
126 //! @}
127
128 //! @name LTC2662 Minimums and Maximums for each Span
129 //! @{
130 //! Lookup tables for minimum and maximum outputs for a given span
131 const float LTC2662_MIN_OUTPUT[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
132 const float LTC2662_MAX_OUTPUT[10] = {0.0, 3.125, 6.25, 12.5, 25.0, 50.0, 100.0, 200.0, 0, 300.0};
133 //! @}
134
135 //! @name LTC2662 Configuration options
136 //! @{
137 //! Used in conjunction with LTC2662_CMD_CONFIG command
138 #define LTC2662_REF_DISABLE 0x0001 //! Disable internal reference to save power when using an ext. ref.
139 #define LTC2662_THERMAL_SHUTDOWN 0x0002 //! Disable thermal shutdown (NOT RECOMMENDED)
140 #define LTC2662_POWERLIMIT_PROTECTION 0x0003 //! Disable power limit protection (NOT RECOMMENDED)
141 #define LTC2662_OPEN_CIRCUIT_DETECT_DISABLE 0x0004 //! Disable open circuit detection
142 //! @}
143
144 //! @name LTC2662 Global Toggle
145 //! @{
146 //! Used in conjunction with LTC2662_CMD_GLOBAL_TOGGLE command, affects DACs whose
147 //! Toggle Select bits have been set to 1
148 #define LTC2662_TOGGLE_REG_A 0x0000 //! Update DAC with register A
149 #define LTC2662_TOGGLE_REG_B 0x0010 //! Update DAC with register B
150 //! @}
151
152 //! Write the 16-bit dac_code to the LTC2662
153 //! @return Zero if readback (SDO) data matches the value previously sent, One if mismatched (indicating data error somewhere)
154 int8_t LTC2662_write(uint8_t cs, //!< Chip select
155 uint8_t dac_command, //!< DAC command word
156 uint8_t dac_address, //!< DAC channel address
157 uint16_t dac_code //!< 2 byte dac code
158 );
159
160 //! Calculate a LTC2662 DAC code given the desired output current
161 //! @return The 16 bit code to send to the DAC
162 uint16_t LTC2662_current_to_code(float dac_current, //!< Desired current
163 float max_output //!< Full scale current
164 );
165
166 //! Calculate the LTC2662 DAC output current given the DAC code and max output.
167 //! @return the output voltage
168 float LTC2662_code_to_current(uint16_t dac_code, //!< DAC code value
169 float max_output //!< Full scale current
170 );
171
172 #endif // LTC2662_H
LTC2662_MIN_OUTPUT
const float LTC2662_MIN_OUTPUT[10]
Definition: LTC2662.h:131
LTC2662_current_to_code
uint16_t LTC2662_current_to_code(float dac_current, float max_output)
Calculate a LTC2662 DAC code given the desired output current.
Definition: LTC2662.cpp:88
LTC2662_write
int8_t LTC2662_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2662.
Definition: LTC2662.cpp:70
LTC2662_MAX_OUTPUT
const float LTC2662_MAX_OUTPUT[10]
Definition: LTC2662.h:132
LTC2662_code_to_current
float LTC2662_code_to_current(uint16_t dac_code, float max_output)
Calculate the LTC2662 DAC output current given the DAC code and max output.
Definition: LTC2662.cpp:102