| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC1783A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1783A Demonstration Board.
3 LTC2376-16: 16-Bit, 250Ksps ADC
4 LTC2376-18: 18-Bit, 250Ksps ADC
5 LTC2377-16: 16-Bit, 500Ksps ADC
6 LTC2377-18: 18-Bit, 500Ksps ADC
7 LTC2380-16: 16-Bit, 1Msps ADC
8 LTC2380-18: 18-Bit, 1Msps ADC
9 LTC2379-18: 18-Bit, 1.6Msps ADC
10 LTC2380-16: 16-Bit, 2Msps ADC
11 Max SCK rate is 100MHz.
12
13 @verbatim
14
15 NOTES
16 Setup:
17 Set the terminal baud rate to 115200 and select the newline terminator. Equipment
18 required is a voltage source (preferably low-noise) and a precision voltmeter.
19 Ensure all jumpers on the demo board are installed in their default positions
20 from the factory. Refer to Demo Manual DC1783A.
21
22 How to test:
23 The voltage source should be connected between inputs AIN+ and AIN-. Ensure both
24 inputs are within their specified absolute input voltage range. (It is easiest
25 to tie the voltage source negative terminal to COM.) Ensure the voltage
26 source is set within the range of 0V to +5V (differential voltage range).
27 (Swapping input voltages results in a reversed polarity reading.)
28
29 USER INPUT DATA FORMAT:
30 decimal : 1024
31 hex : 0x400
32 octal : 02000 (leading 0 "zero")
33 binary : B10000000000
34 float : 1024.0
35
36 @endverbatim
37 http://www.linear.com/product/LTC2376-16
38 http://www.linear.com/product/LTC2376-18
39 http://www.linear.com/product/LTC2377-16
40 http://www.linear.com/product/LTC2377-18
41 http://www.linear.com/product/LTC2380-16
42 http://www.linear.com/product/LTC2380-18
43 http://www.linear.com/product/LTC2379-18
44 http://www.linear.com/product/LTC2380-16
45
46 http://www.linear.com/product/LTC2376-16#demoboards
47 http://www.linear.com/product/LTC2376-18#demoboards
48 http://www.linear.com/product/LTC2377-16#demoboards
49 http://www.linear.com/product/LTC2377-18#demoboards
50 http://www.linear.com/product/LTC2380-16#demoboards
51 http://www.linear.com/product/LTC2380-18#demoboards
52 http://www.linear.com/product/LTC2379-18#demoboards
53 http://www.linear.com/product/LTC2380-16#demoboards
54
55
56 Copyright 2018(c) Analog Devices, Inc.
57
58 All rights reserved.
59
60 Redistribution and use in source and binary forms, with or without
61 modification, are permitted provided that the following conditions are met:
62 - Redistributions of source code must retain the above copyright
63 notice, this list of conditions and the following disclaimer.
64 - Redistributions in binary form must reproduce the above copyright
65 notice, this list of conditions and the following disclaimer in
66 the documentation and/or other materials provided with the
67 distribution.
68 - Neither the name of Analog Devices, Inc. nor the names of its
69 contributors may be used to endorse or promote products derived
70 from this software without specific prior written permission.
71 - The use of this software may or may not infringe the patent rights
72 of one or more patent holders. This license does not release you
73 from the requirement that you obtain separate licenses from these
74 patent holders to use this software.
75 - Use of the software either in source or binary form, must be run
76 on or directly connected to an Analog Devices Inc. component.
77
78 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
79 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
80 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
81 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
82 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
83 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
84 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
85 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
86 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
87 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88 */
89
90 /*! @file
91 @ingroup LTC2380
92 */
93
94 #include <Arduino.h>
95 #include <stdint.h>
96 #include "Linduino.h"
97 #include "LT_SPI.h"
98 #include "UserInterface.h"
99 #include "LT_I2C.h"
100 #include "QuikEval_EEPROM.h"
101 #include "LTC2380.h"
102 #include <SPI.h>
103 #include <Wire.h>
104
105 // Function Declaration
106 void print_title(); // Print the title block
107 void print_prompt(); // Prompt the user for an input command
108 void print_user_command(uint8_t menu); // Display selected differential channels
109
110 void menu_1_read_input();
111 void menu_2_select_gain_compression();
112 void menu_3_select_bits();
113
114 // Global variables
115 static uint8_t LTC2380_dgc = 0; //!< Default set for no gain compression
116 static uint8_t LTC2380_bits = 18; //!< Default set for 18 bits
117 float LTC2380_vref = 5;
118
119
120 //! Initialize Linduino
121 void setup()
122 {
123 uint32_t adc_code;
124 quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
125 quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
126 quikeval_SPI_connect(); // Connect SPI to main data port
127 Serial.begin(115200); // Initialize the serial port to the PC
128 print_title();
129 print_prompt();
130 }
131
132
133 //! Repeats Linduino loop
134 void loop()
135 {
136 uint16_t user_command;
137 {
138 if (Serial.available())
139 {
140 user_command = read_int(); // Read the user command
141 if (user_command != 'm')
142 Serial.println(user_command); // Prints the user command to com port
143 switch (user_command)
144 {
145 case 1:
146 menu_1_read_input();
147 break;
148 case 2:
149 menu_2_select_gain_compression();
150 break;
151 case 3:
152 menu_3_select_bits();
153 break;
154 default:
155 Serial.println("Invalid Option");
156 break;
157 }
158 Serial.println();
159 print_prompt();
160 }
161 }
162 }
163
164
165 // Function Definitions
166 //! Read channel
167 //! @return void
168 void menu_1_read_input()
169 {
170 uint8_t user_command;
171 int32_t adc_code; // The LTC2380 code
172 int32_t display_code;
173 float adc_voltage; // The LTC2380 voltage
174
175 // Read and display a selected channel
176 LTC2380_read(LTC2380_CS, &adc_code); //discard the first reading
177 delay(100);
178 LTC2380_read(LTC2380_CS, &adc_code);
179
180 display_code = adc_code >> (32 - LTC2380_bits);
181 if (LTC2380_bits == 16)
182 display_code = display_code & 0xFFFF;
183 else
184 display_code = display_code & 0x3FFFF;
185
186 Serial.print(F(" Received Code: b"));
187 Serial.println(display_code, BIN);
188
189 // Convert the received code to voltage
190 adc_voltage = LTC2380_code_to_voltage(adc_code, LTC2380_dgc, LTC2380_vref);
191
192 Serial.print(F(" Equivalent voltage: "));
193 Serial.print(adc_voltage, 4);
194 Serial.println(F("V"));
195 }
196
197
198 //! Select gain compression
199 //! @return void
200 void menu_2_select_gain_compression()
201 {
202 uint8_t user_command;
203
204 Serial.println(F(" 0 = No Gain Compression"));
205 Serial.println(F(" 1 = Gain Compression"));
206 Serial.print(F(" Enter a Command, based upon the position of jumper JP6: "));
207
208 user_command = read_int(); // Read user input
209 Serial.println(user_command); // Prints the user command to com port
210 switch (user_command)
211 {
212 case 0:
213 Serial.println(F(" No Gain compression"));
214 LTC2380_dgc = 0;
215 break;
216 case 1:
217 Serial.println(F(" Gain compression"));
218 LTC2380_dgc = 1;
219 break;
220 default:
221 {
222 Serial.println(" Invalid Option");
223 return;
224 }
225 break;
226 }
227 }
228
229
230 //! Select number of bits
231 //! @return void
232 void menu_3_select_bits()
233 {
234 uint8_t user_command;
235
236 Serial.println(F(" 16 = 237X-16"));
237 Serial.println(F(" 18 = 237X-18"));
238 Serial.print(F(" Enter a Command, based upon the resolution of the part under test: "));
239
240 user_command = read_int(); // Read user input
241 Serial.println(user_command); // Prints the user command to com port
242 switch (user_command)
243 {
244 case 16:
245 Serial.println(F(" 16 bits selected"));
246 LTC2380_bits = 16;
247 break;
248 case 18:
249 Serial.println(F(" 18 bits selected"));
250 LTC2380_bits = 18;
251 break;
252 default:
253 {
254 Serial.println(" Invalid Option");
255 return;
256 }
257 break;
258 }
259 }
260
261
262 //! Prints the title block when program first starts.
263 void print_title()
264 {
265 Serial.println();
266 Serial.println(F("*****************************************************************"));
267 Serial.println(F("* DC1783A Demonstration Program *"));
268 Serial.println(F("* *"));
269 Serial.println(F("* This program demonstrates how to receive data *"));
270 Serial.println(F("* from the following ADCs: *"));
271 Serial.println(F("* LTC2376-16 *"));
272 Serial.println(F("* LTC2376-18 *"));
273 Serial.println(F("* LTC2377-16 *"));
274 Serial.println(F("* LTC2376-18 *"));
275 Serial.println(F("* LTC2378-16 *"));
276 Serial.println(F("* LTC2378-18 *"));
277 Serial.println(F("* LTC2379-18 *"));
278 Serial.println(F("* LTC2380-16 *"));
279 Serial.println(F("* *"));
280 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
281 Serial.println(F("* *"));
282 Serial.println(F("*****************************************************************"));
283 }
284
285
286 //! Prints main menu.
287 void print_prompt()
288 {
289 Serial.println(F("*************************"));
290 Serial.println(F("1-Read ADC Input"));
291 Serial.println(F("2-Select No Gain Compression / Gain Compression (Default is no compression)"));
292 Serial.println(F("3-Select Number of bits (Default is 18 bits)\n"));
293 Serial.print(F("Enter a command:"));
294 }
295
LTC2380_bits
static uint8_t LTC2380_bits
Default set for 18 bits.
Definition: DC1783A.ino:116
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
setup
static void setup()
Initialize Linduino.
Definition: DC1783A.ino:121
menu_1_read_input
static void menu_1_read_input()
Read channel.
Definition: DC1783A.ino:168
Linduino.h
Header File for Linduino Libraries and Demo Code.
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC1783A.ino:263
menu_2_select_gain_compression
static void menu_2_select_gain_compression()
Select gain compression.
Definition: DC1783A.ino:200
menu_3_select_bits
static void menu_3_select_bits()
Select number of bits.
Definition: DC1783A.ino:232
adc_voltage
static float adc_voltage
Definition: DC2071AA.ino:115
LTC2380_CS
#define LTC2380_CS
Define the SPI CS pin.
Definition: LTC2380.h:117
LTC2380_read
void LTC2380_read(uint8_t cs, int32_t *ptr_adc_code)
Reads the LTC2380 and returns 32-bit data in 2&#39;s complement format.
Definition: LTC2380.cpp:114
print_user_command
static void print_user_command(uint8_t menu)
LTC2380_vref
static float LTC2380_vref
Definition: DC1783A.ino:117
QuikEval_EEPROM.h
QuikEval EEPROM Library.
quikeval_SPI_init
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
loop
static void loop()
Repeats Linduino loop.
Definition: DC1783A.ino:134
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LTC2380_dgc
static uint8_t LTC2380_dgc
Default set for no gain compression.
Definition: DC1783A.ino:115
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC1783A.ino:287
quikeval_SPI_connect
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
LTC2380_code_to_voltage
float LTC2380_code_to_voltage(int32_t adc_code, uint8_t gain_compression, float vref)
Calculates the LTC2380 input voltage given the binary data and lsb weight.
Definition: LTC2380.cpp:136
display_code
static int32_t display_code
Definition: DC2071AA.ino:114
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
LTC2380.h
LTC2376-16: 16-Bit, 250Ksps ADC LTC2376-18: 18-Bit, 250Ksps ADC LTC2376-20: 20-Bit, 250Ksps ADC LTC2377-16: 16-Bit, 500Ksps ADC LTC2377-18: 18-Bit, 500Ksps ADC LTC2377-20: 20-Bit, 500Ksps ADC LTC2378-16: 16-Bit, 1Msps ADC LTC2378-18: 18-Bit, 1Msps ADC LTC2378-20: 20-Bit, 1Msps ADC LTC2379-18: 18-Bit, 1.6Msps ADC LTC2380-16: 16-Bit, 2Msps ADC.
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113