Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2758.h
Go to the documentation of this file.
1 /*!
2 LTC2758: Dual Serial 18-Bit SoftSpan IOUT DAC
3 
4 @verbatim
5 
6 The LTC2758 is a dual, current-output, serial-input precision multiplying DAC
7 with selectable output ranges. Ranges can either be programmed in software for
8 maximum flexibility (each of the DACs can be programmed to any one of six output
9 ranges) or hardwired through pin-strapping. Two unipolar ranges are available
10 (0V to 5V and 0V to 10V), and four bipolar ranges (±2.5V, ±5V, ±10V and –2.5V
11 to 7.5V). These ranges are obtained when an external precision 5V reference is
12 used. The output ranges for other reference voltages are easy to calculate by
13 observing that each range is a multiple of the external reference voltage. The
14 ranges can then be expressed: 0 to 1×, 0 to 2×, ±0.5×, ±1×, ±2×, and –0.5× to 1.5×.
15 
16 The LTC2758 has 5 internal registers for each DAC, a total of 10 registers (see
17 Block Diagram). Each DAC channel has two sets of double-buffered registers, one
18 set for the code data, and one for the output range of the DAC, plus one readback
19 register.
20 
21 SPI DATA FORMAT (MSB First):
22 
23  Byte #1 Byte #2 Byte #3 Byte #4
24 Data In (Write code): C3 C2 C1 C0 A3 A2 A1 A0 D17 D16 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 X X X X X X
25 Data In (Wrire Span): C3 C2 C1 C0 A3 A2 A1 A0 X X X X X X X X X X X X S3 S2 S1 S0 X X X X X X X X
26 
27 Cx : Command Code Bits
28 Ax : Address Code Bits
29 Sx : Span Select Bits
30 Dx : Data Bits
31 X : Don't care
32 
33 Example Code:
34 
35  LTC2758_write(LTC2758_CS, LTC2758_WRITE_SPAN_DAC, DAC_SELECTED, span);
36  data = LTC2758_voltage_to_code(voltage, DAC_RANGE_LOW, DAC_RANGE_HIGH);
37  LTC2758_write(LTC2758_CS, LTC2758_WRITE_CODE_UPDATE_DAC, DAC_SELECTED, data);
38 
39 @endverbatim
40 
41 http://www.linear.com/product/LTC2758
42 
43 http://www.linear.com/product/LTC2758#demoboards
44 
45 
46 Copyright 2018(c) Analog Devices, Inc.
47 
48 All rights reserved.
49 
50 Redistribution and use in source and binary forms, with or without
51 modification, are permitted provided that the following conditions are met:
52  - Redistributions of source code must retain the above copyright
53  notice, this list of conditions and the following disclaimer.
54  - Redistributions in binary form must reproduce the above copyright
55  notice, this list of conditions and the following disclaimer in
56  the documentation and/or other materials provided with the
57  distribution.
58  - Neither the name of Analog Devices, Inc. nor the names of its
59  contributors may be used to endorse or promote products derived
60  from this software without specific prior written permission.
61  - The use of this software may or may not infringe the patent rights
62  of one or more patent holders. This license does not release you
63  from the requirement that you obtain separate licenses from these
64  patent holders to use this software.
65  - Use of the software either in source or binary form, must be run
66  on or directly connected to an Analog Devices Inc. component.
67 
68 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
69 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
70 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
71 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
72 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
73 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
74 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
75 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
76 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
77 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78 */
79 
80 /*! @file
81  @ingroup LTC2758
82  Header for LTC2758: Dual Serial 18-Bit SoftSpan IOUT DAC
83 */
84 
85 #ifndef LTC2758_H
86 #define LTC2758_H
87 
88 //! Define the SPI CS pin
89 #ifndef LTC2758_CS
90 #define LTC2758_CS QUIKEVAL_CS
91 #endif
92 
93 //! @name LTC2758 DAC Addresses
94 #define ADDRESS_DACA 0x00
95 #define ADDRESS_DACB 0x02
96 #define ADDRESS_DAC_ALL 0x0E
97 //! @}
98 
99 //! @name LTC2758 Command Codes
100 //! OR'd together with the DAC address to form the command byte
101 #define LTC2758_WRITE_SPAN_DAC 0x20 //!< Write Span DAC n
102 #define LTC2758_WRITE_CODE_DAC 0x30 //!< Write Code DAC n
103 #define LTC2758_UPDATE_DAC 0x40 //!< Update DAC n
104 #define LTC2758_UPDATE_ALL 0x50 //!< Update All DACs
105 #define LTC2758_WRITE_SPAN_UPDATE_DAC 0x60 //!< Write Span DAC n and Update DAC n
106 #define LTC2758_WRITE_CODE_UPDATE_DAC 0x70 //!< Write Code DAC n and Update DAC n
107 
108 #define LTC2758_WRITE_SPAN_UPDATE_ALL 0x80 //!< Write Span DAC n and Update All DACs
109 #define LTC2758_WRITE_CODE_UPDATE_ALL 0x90 //!< Write Code DAC n and Update All DACs
110 #define LTC2758_READ_INPUT_SPAN_REG 0xA0 //!< Read Input Span Register DAC n
111 #define LTC2758_READ_INPUT_CODE_REG 0xB0 //!< Read Input Code Register DAC n
112 #define LTC2758_READ_DAC_SPAN_REG 0xC0 //!< Read DAC Span Register DAC n
113 #define LTC2758_READ_DAC_CODE_REG 0xD0 //!< Read DAC Code Register DAC n
114 #define LTC2758_PREVIOUS_CMD 0xF0 //!< Set by previous command
115 //! @}
116 
117 //! Transmits 32 bit input stream: 4-bit command + 4-bit don't-care + 18-bit data + 6 don't care
118 //! @return void
119 void LTC2758_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint32_t data);
120 
121 //! Calculate the LTC2758 DAC output voltage given the DAC code and and the minimum / maximum
122 //! outputs for a given softspan range.
123 //! @return Floating point voltage
124 float LTC2758_code_to_voltage(uint32_t dac_code, float min_output, float max_output);
125 
126 //! Calculate a LTC2758 DAC code given the desired output voltage and the minimum / maximum
127 //! outputs for a given softspan range.
128 //! @return 32 bit data
129 uint32_t LTC2758_voltage_to_code(float dac_voltage, float min_output, float max_output);
130 
131 #endif // LTC2758_H
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
float LTC2758_code_to_voltage(uint32_t dac_code, float min_output, float max_output)
Calculate the LTC2758 DAC output voltage given the DAC code and and the minimum / maximum outputs for...
Definition: LTC2758.cpp:89
void LTC2758_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint32_t data)
Transmits 32 bit input stream: 4-bit command + 4-bit don&#39;t-care + 18-bit data + 6 don&#39;t care...
Definition: LTC2758.cpp:77
uint32_t LTC2758_voltage_to_code(float dac_voltage, float min_output, float max_output)
Calculate a LTC2758 DAC code given the desired output voltage and the minimum / maximum outputs for a...
Definition: LTC2758.cpp:97