| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC2071AA.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC2071A Demonstration Board.
3
4 LTC2373: 16/18-bit 1Msps 8 channel SAR ADC
5 LTC2372: 16/18-bit 500ksps 8 channel SAR ADC
6 LTC2374: 16 bit 1.6Msps 8 channel SAR ADC
7
8 Max SCK rate is 100MHz.
9
10 @verbatim
11
12 NOTES
13 Setup:
14 Set the terminal baud rate to 115200 and select the newline terminator.
15 Equipment required is a precision voltage source (null box) and a precision voltmeter (to monitor voltage source).
16 No external power supply is required.
17 Ensure JP1 is installed in the default position from the factory.
18
19 How to test:
20 The voltage source should be connected with positive and negative leads to the positive & negative ADC inputs. Ensure the differential voltage is within the
21 range of -VREF to +VREF. Swapping input voltages results in a reversed polarity reading.
22
23 How to calibrate:
24 Enter menu item number "3 - Calibrate" and follow the prompts.
25 Calibration is now stored in EEPROM. Upon startup the calibration values will be restored.
26
27 USER INPUT DATA FORMAT:
28 decimal : 1024
29 hex : 0x400
30 octal : 02000 (leading 0 "zero")
31 binary : B10000000000
32 float : 1024.0
33
34 @endverbatim
35
36 http://www.linear.com/product/LTC2373-16
37 http://www.linear.com/product/LTC2373_18
38 http://www.linear.com/product/LTC2372-16
39 http://www.linear.com/product/LTC2372-18
40 http://www.linear.com/product/LTC2374-16
41
42 http://www.linear.com/product/LTC2373-16#demoboards
43 http://www.linear.com/product/LTC2373_18#demoboards
44 http://www.linear.com/product/LTC2372-16#demoboards
45 http://www.linear.com/product/LTC2372-18#demoboards
46 http://www.linear.com/product/LTC2374-16#demoboards
47
48
49 Copyright 2018(c) Analog Devices, Inc.
50
51 All rights reserved.
52
53 Redistribution and use in source and binary forms, with or without
54 modification, are permitted provided that the following conditions are met:
55 - Redistributions of source code must retain the above copyright
56 notice, this list of conditions and the following disclaimer.
57 - Redistributions in binary form must reproduce the above copyright
58 notice, this list of conditions and the following disclaimer in
59 the documentation and/or other materials provided with the
60 distribution.
61 - Neither the name of Analog Devices, Inc. nor the names of its
62 contributors may be used to endorse or promote products derived
63 from this software without specific prior written permission.
64 - The use of this software may or may not infringe the patent rights
65 of one or more patent holders. This license does not release you
66 from the requirement that you obtain separate licenses from these
67 patent holders to use this software.
68 - Use of the software either in source or binary form, must be run
69 on or directly connected to an Analog Devices Inc. component.
70
71 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
72 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
73 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
74 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
75 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
77 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
78 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
79 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81 */
82
83 /*! @file
84 @ingroup LTC2373
85 */
86
87 #include <Arduino.h>
88 #include <stdint.h>
89 #include "Linduino.h"
90 #include "LT_SPI.h"
91 #include "UserInterface.h"
92 #include "LT_I2C.h"
93 #include "QuikEval_EEPROM.h"
94 #include "LTC2373.h"
95 #include <SPI.h>
96 #include <Wire.h>
97
98 // Function Declaration
99 void print_title(); // Print the title block
100 void print_prompt(); // Prompt the user for an input command
101 void print_user_command(uint8_t menu); // Display selected differential channels
102
103 void menu_1_read_adc();
104 void menu_2_program_sequencer();
105 void menu_3_read_sequencer();
106 void menu_4_select_bits();
107 void menu_5_select_range();
108 void menu_6_select_gain_compression();
109
110 // Global variables
111 static uint8_t adc_command;
112 static uint8_t user_command;
113 static uint32_t adc_code; // The LTC2373 code
114 static int32_t display_code;
115 float adc_voltage; // The LTC2373 voltage
116 float LTC2373_vref = 4.096; //reference voltage in volts
117 static uint8_t LTC2373_range_select = LTC2373_RANGE_UNIPOLAR; //!< Default set for single-ended unipolar mode
118 static uint8_t LTC2373_gain_compression = LTC2373_NO_COMPRESSION; //!< Default set for no compression mode
119 static uint8_t LTC2373_bits = 18; //!< Default set for 18 bits
120 static uint8_t LTC2373_sequencer_bit = LTC2373_SEQUENCER_BIT;
121
122 // Constants
123 //! Lookup table to build the command for single-ended mode, input with respect to GND
124 const uint8_t COMMAND_SINGLE_ENDED[8] = {LTC2373_CH0, LTC2373_CH1, LTC2373_CH2, LTC2373_CH3,
125 LTC2373_CH4, LTC2373_CH5, LTC2373_CH6, LTC2373_CH7
126 }; //!< Builds the command for single-ended mode, input with respect to GND
127
128 //! Lookup table to build the command for differential mode
129 const uint8_t COMMAND_DIFF[8] = {LTC2373_CH0_1, LTC2373_CH2_3, LTC2373_CH4_5, LTC2373_CH6_7,
130 LTC2373_CH1_0, LTC2373_CH3_2, LTC2373_CH5_4, LTC2373_CH7_6
131 }; //!< Builds the command for differential mode
132
133
134 //! Initialize Linduino
135 void setup()
136 {
137 quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
138 quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
139 quikeval_SPI_connect(); // Connect SPI to main data port
140 Serial.begin(115200); // Initialize the serial port to the PC
141 print_title();
142 print_prompt();
143 }
144
145
146 //! Repeats Linduino loop
147 void loop()
148 {
149 // uint16_t user_command;
150 {
151 if (Serial.available())
152 {
153 user_command = read_int(); // Read the user command
154 if (user_command != 'm')
155 Serial.println(user_command); // Prints the user command to com port
156 switch (user_command)
157 {
158 case 1:
159 menu_1_read_adc();
160 break;
161 case 2:
162 menu_2_program_sequencer();
163 break;
164 case 3:
165 menu_3_read_sequencer();
166 break;
167 case 4:
168 menu_4_select_bits();
169 break;
170 case 5:
171 menu_5_select_range();
172 break;
173 case 6:
174 menu_6_select_gain_compression();
175 break;
176 default:
177 Serial.println("Invalid Option");
178 break;
179 }
180 Serial.println();
181 print_prompt();
182 }
183 }
184 }
185
186
187 // Function Definitions
188 //! Read channels in single-ended mode
189 //! @return void
190 void menu_1_read_adc()
191 {
192 uint8_t single_ended = 0;
193 uint8_t i; //!< iteration variable
194
195 i2c_write_byte(I2C_ADDRESS, I2C_COMMAND); //disable the CPLD communication
196
197 while (1)
198 {
199 switch (LTC2373_range_select)
200 {
201 case LTC2373_RANGE_UNIPOLAR:
202 single_ended = 1;
203 Serial.println("");
204 Serial.println("");
205 Serial.println(F(" Single-Ended, Unipolar mode, 0 to Vref:"));
206 Serial.println(F(" 0-CH0"));
207 Serial.println(F(" 1-CH1"));
208 Serial.println(F(" 2-CH2"));
209 Serial.println(F(" 3-CH3"));
210 Serial.println(F(" 4-CH4"));
211 Serial.println(F(" 5-CH5"));
212 Serial.println(F(" 6-CH6"));
213 Serial.println(F(" 7-CH7"));
214 Serial.println(F(" 8-ALL"));
215 Serial.println(F(" m-Main Menu"));
216 break;
217
218 case LTC2373_RANGE_BIPOLAR:
219 single_ended = 1;
220 Serial.println("");
221 Serial.println("");
222 Serial.println(F(" Single-Ended, Bipolar mode, -Vref/2 to +Vref/2:"));
223 Serial.println(F(" 0-CH0"));
224 Serial.println(F(" 1-CH1"));
225 Serial.println(F(" 2-CH2"));
226 Serial.println(F(" 3-CH3"));
227 Serial.println(F(" 4-CH4"));
228 Serial.println(F(" 5-CH5"));
229 Serial.println(F(" 6-CH6"));
230 Serial.println(F(" 7-CH7"));
231 Serial.println(F(" 8-ALL"));
232 Serial.println(F(" m-Main Menu"));
233 break;
234
235 case LTC2373_RANGE_DIFF_UNIPOLAR:
236 Serial.println("");
237 Serial.println("");
238 Serial.println(F(" Differential, Unipolar mode, 0 to Vref:"));
239 Serial.println(F(" 0-0P-1N"));
240 Serial.println(F(" 1-2P-3N"));
241 Serial.println(F(" 2-4P-5N"));
242 Serial.println(F(" 3-6P-7N"));
243 Serial.println(F(" 4-1P-0N"));
244 Serial.println(F(" 5-3P-2N"));
245 Serial.println(F(" 6-5P_4N"));
246 Serial.println(F(" 7-7P-6N"));
247 Serial.println(F(" 8-ALL Even_P-Odd_N"));
248 Serial.println(F(" m-Main Menu"));
249 break;
250
251 case LTC2373_RANGE_DIFF_BIPOLAR:
252 Serial.println("");
253 Serial.println("");
254 Serial.println(F(" Differential Bipolar mode, -Vref to +Vref:"));
255 Serial.println(F(" 0-0P-1N"));
256 Serial.println(F(" 1-2P-3N"));
257 Serial.println(F(" 2-4P-5N"));
258 Serial.println(F(" 3-6P-7N"));
259 Serial.println(F(" 4-1P-0N"));
260 Serial.println(F(" 5-3P-2N"));
261 Serial.println(F(" 6-5P_4N"));
262 Serial.println(F(" 7-7P-6N"));
263 Serial.println(F(" 8-ALL"));
264 Serial.println(F(" m-Main Menu"));
265 break;
266
267 default:
268 Serial.println(" Invalid Option");
269 break;
270 }
271
272 Serial.println();
273 Serial.print(F(" Enter a Command: "));
274 user_command = read_int(); // Read the single command
275 if (user_command == 'm')
276 return;
277
278 switch (user_command)
279 {
280 case 0:
281 ;
282 break;
283 case 1:
284 ;
285 break;
286 case 2:
287 ;
288 break;
289 case 3:
290 ;
291 break;
292 case 4:
293 ;
294 break;
295 case 5:
296 ;
297 break;
298 case 6:
299 ;
300 break;
301 case 7:
302 ;
303 break;
304 case 8:
305 ;
306 break;
307 default:
308 {
309 Serial.println(" Invalid Option");
310 return;
311 }
312 break;
313 }
314
315 Serial.println(user_command);
316
317 switch (single_ended)
318 {
319 case 0: //differential mode
320 if (user_command == 8) //read all 8 channels
321 {
322 for (i = 0; i <= 7; i++) // Read all channels in differential mode
323 {
324 adc_command = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_DIFF[(i) % 8], LTC2373_range_select, LTC2373_gain_compression);
325 LTC2373_read(LTC2373_CS, adc_command, &adc_code);
326 delay(100);
327 LTC2373_read(LTC2373_CS, 0, &adc_code);
328
329 display_code = adc_code >> (32 - LTC2373_bits);
330 if (LTC2373_bits == 16) //grab the leftmost 16 bits
331 display_code = display_code & 0xFFFF;
332 else //grab the leftmost 18 bits
333 display_code = display_code & 0x3FFFF;
334
335 print_user_command(i);
336 Serial.print(F(" Received ADC Code: 0x"));
337 Serial.println(display_code, HEX);
338
339 // Convert the received code to voltage
340 adc_voltage = LTC2373_code_to_voltage(adc_command, adc_code, LTC2373_vref);
341 Serial.print(F(" Equivalent voltage: "));
342 Serial.print(adc_voltage, 4);
343 Serial.println(F("V"));
344 Serial.println();
345 }
346 }
347 else //read 1 channel
348 {
349 i = user_command;
350 adc_command = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_DIFF[i], LTC2373_range_select, LTC2373_gain_compression);
351 LTC2373_read(LTC2373_CS, adc_command, &adc_code); // Throws out last reading
352 delay(100);
353 LTC2373_read(LTC2373_CS, 0, &adc_code);
354
355 display_code = adc_code >> (32 - LTC2373_bits);
356 if (LTC2373_bits == 16) //grab the leftmost 16 bits
357 display_code = display_code & 0xFFFF;
358 else //grab the leftmost 18 bits
359 display_code = display_code & 0x3FFFF;
360
361 print_user_command(i);
362 Serial.print(F(" Received ADC Code: 0x"));
363 Serial.println(display_code, HEX);
364
365 // Convert the received code to voltage
366 adc_voltage = LTC2373_code_to_voltage(adc_command, adc_code, LTC2373_vref);
367 Serial.print(F(" Equivalent voltage: "));
368 Serial.print(adc_voltage, 4);
369 Serial.println(F("V"));
370 Serial.println();
371 }
372 break;
373
374 case 1: //single-ended mode
375 if (user_command == 8) //read all 8 channels
376 {
377 for (i = 0; i <= 7; i++) // Read all channels in single-ended mode
378 {
379 adc_command = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_SINGLE_ENDED[(i) % 8], LTC2373_range_select, LTC2373_gain_compression);
380 LTC2373_read(LTC2373_CS, adc_command, &adc_code); // Program sequencer once
381 delay(100);
382 LTC2373_read(LTC2373_CS, 0, &adc_code); //read adc
383
384 display_code = adc_code >> (32 - LTC2373_bits);
385 if (LTC2373_bits == 16) //grab the leftmost 16 bits
386 display_code = display_code & 0xFFFF;
387 else //grab the leftmost 18 bits
388 display_code = display_code & 0x3FFFF;
389
390 Serial.print(F(" CH"));
391 Serial.print(i);
392 Serial.print(F(" Received ADC Code: 0x"));
393 Serial.println(display_code, HEX);
394
395 // Convert the received code to voltage
396 adc_voltage = LTC2373_code_to_voltage(adc_command, adc_code, LTC2373_vref);
397 Serial.print(F(" Equivalent voltage: "));
398 Serial.print(adc_voltage, 4);
399 Serial.println(F("V"));
400 Serial.println();
401 }
402 }
403
404 else //read 1 channel
405 {
406 i = user_command;
407 adc_command = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_SINGLE_ENDED[i], LTC2373_range_select, LTC2373_gain_compression);
408 LTC2373_read(LTC2373_CS, adc_command, &adc_code); // Program sequencer once
409 delay(100);
410 LTC2373_read(LTC2373_CS, 0, &adc_code); //read adc
411
412 display_code = adc_code >> (32 - LTC2373_bits);
413 if (LTC2373_bits == 16) //grab the leftmost 16 bits
414 display_code = display_code & 0xFFFF;
415 else //grab the leftmost 18 bits
416 display_code = display_code & 0x3FFFF;
417
418 Serial.print(F(" CH"));
419 Serial.print(i);
420 Serial.print(F(" Received ADC Code: 0x"));
421 Serial.println(display_code, HEX);
422
423 // Convert the received code to voltage
424 adc_voltage = LTC2373_code_to_voltage(adc_command, adc_code, LTC2373_vref);
425 Serial.print(F(" Equivalent voltage: "));
426 Serial.print(adc_voltage, 4);
427 Serial.println(F("V"));
428 Serial.println();
429 }
430 break;
431 }
432 }
433 }
434
435
436 //! Program the sequencer
437 //! @return void
438 void menu_2_program_sequencer()
439 {
440 uint8_t temp_bits = 0;
441
442 Serial.println();
443 Serial.println(F("*****************************************************************************************"));
444 Serial.println(F("* This routine demonstrates how to program the sequencer. *"));
445 Serial.println(F("* *"));
446 Serial.println(F("* A specific set of four configurations will be programmed: *"));
447 Serial.println(F("* A single-ended unipolar voltage on AIN1+ *"));
448 Serial.println(F("* A differential unipolar voltage on AIN1+/AIN1-, which feeds the ADC differentially *"));
449 Serial.println(F("* A single-ended bipolar voltage on AIN3, which feeds the ADC differentially *"));
450 Serial.println(F("* A differential bipolar voltage on AIN4+/AIN4- *"));
451 Serial.println(F("* *"));
452 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator. *"));
453 Serial.println(F("* *"));
454 Serial.println(F("*****************************************************************************************"));
455
456 //Form a four byte object to hold four bytes of dummy data
457 LT_union_int32_4bytes adc_configuration; //instantiate the union
458
459 adc_configuration.LT_byte[0] = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_SINGLE_ENDED[0], LTC2373_RANGE_UNIPOLAR, LTC2373_NO_COMPRESSION);
460 adc_configuration.LT_byte[1] = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_DIFF[4], LTC2373_RANGE_DIFF_UNIPOLAR, LTC2373_NO_COMPRESSION);
461 adc_configuration.LT_byte[2] = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_DIFF[6], LTC2373_RANGE_DIFF_BIPOLAR, LTC2373_NO_COMPRESSION);
462 adc_configuration.LT_byte[3] = LTC2373_build_command(LTC2373_SEQUENCER_BIT, COMMAND_DIFF[3], LTC2373_RANGE_DIFF_BIPOLAR, LTC2373_NO_COMPRESSION);
463
464 LTC2373_configure(LTC2373_CS, adc_configuration.LT_uint32); // Program sequencer once
465
466 Serial.println(F(" Write Codes: "));
467 Serial.print(F(" Register C3 adc config code: "));
468 Serial.println(adc_configuration.LT_byte[0] & 0x7F, BIN);
469 Serial.print(F(" Register C2 adc config code: "));
470 Serial.println(adc_configuration.LT_byte[1] & 0x7F, BIN);
471 Serial.print(F(" Register C1 adc config code: "));
472 Serial.println(adc_configuration.LT_byte[2] & 0x7F, BIN);
473 Serial.print(F(" Register C0 adc config code: "));
474 Serial.println(adc_configuration.LT_byte[3] & 0x7F, BIN);
475 Serial.println("");
476 }
477
478
479 //! Program the sequencer
480 //! @return void
481 void menu_3_read_sequencer()
482 {
483 uint8_t i, mode;
484
485 for (i = 0; i < 4; i++)
486 {
487 LTC2373_read(LTC2373_CS, 0, &adc_code); //Read the data
488
489 display_code = adc_code >> (32 - LTC2373_bits);
490 if (LTC2373_bits == 16) //grab the leftmost 16 bits
491 display_code = display_code & 0xFFFF;
492 else //grab the leftmost 18 bits
493 display_code = display_code & 0x3FFFF;
494
495 adc_command = (adc_code >> 6) & 0x7F;
496
497 Serial.print(F(" Register C"));
498 Serial.println(i);
499 mode = (0x06 & adc_command) >> 1;
500
501 switch (mode)
502 {
503 case (0):
504 Serial.println(F(" Unipolar, 0 to Vref"));
505 break;
506 case (1):
507 Serial.println(F(" Bipolar, -Vref/2 to +Vref/2"));
508 break;
509 case (2):
510 Serial.println(F(" Differential unipolar, 0 to Vref"));
511 break;
512 case (3):
513 Serial.println(F(" Differential bipolar, -Vref to +Vref"));
514 break;
515 }
516
517 Serial.print(F(" Readback adc config: "));
518 Serial.println(adc_command, BIN);
519
520 Serial.print(F(" Received Code: 0x"));
521 Serial.println(display_code, HEX);
522
523 // Convert the received code to voltage
524 adc_voltage = LTC2373_code_to_voltage(adc_command, adc_code, LTC2373_vref);
525
526 Serial.print(F(" Equivalent voltage: "));
527 Serial.print(adc_voltage, 4);
528 Serial.println(F("V"));
529 Serial.println("");
530 Serial.println("");
531 }
532 }
533
534
535 //! Select number of bits
536 //! @return void
537 void menu_4_select_bits()
538 {
539 uint8_t user_command;
540
541 Serial.println();
542 if (LTC2373_bits == 16)
543 Serial.println(F(" 16 bits selected"));
544 else
545 Serial.println(F(" 18 bits selected"));
546
547 Serial.println(F(" 16 = 2373-16"));
548 Serial.println(F(" 18 = 2373-18"));
549 Serial.println(F(""));
550 Serial.print(F(" Enter a Command, based upon the resolution of the part under test: "));
551
552 user_command = read_int(); // Read user input
553 Serial.println(user_command); // Prints the user command to com port
554 switch (user_command)
555 {
556 case 16:
557 LTC2373_bits = 16;
558 break;
559 case 18:
560 LTC2373_bits = 18;
561 break;
562 default:
563 {
564 Serial.println(" Invalid Option");
565 return;
566 }
567 break;
568 }
569 }
570
571
572 //! Select range
573 //! @return void
574 void menu_5_select_range()
575 {
576 uint8_t user_command;
577
578 Serial.println(F(" 0 = Unipolar, 0 to Vref"));
579 Serial.println(F(" 1 = Bipolar, -Vref/2 to +Vref/2"));
580 Serial.println(F(" 2 = Differential unipolar, 0 to Vref"));
581 Serial.println(F(" 3 = Differential bipolar, -Vref to +Vref"));
582 Serial.println(F(""));
583 Serial.print(F(" Enter a Command: "));
584 user_command = read_int(); // Read user input for range select
585 Serial.println(user_command);
586
587 switch (user_command)
588 {
589 case 0:
590 Serial.println(F(" Unipolar input range selected; set JP9 to 'GND' position"));
591 LTC2373_range_select = LTC2373_RANGE_UNIPOLAR;
592 break;
593 case 1:
594 Serial.println(F(" Bipolar input range selected; set JP9 to 'CM' position"));
595 LTC2373_range_select = LTC2373_RANGE_BIPOLAR;
596 break;
597 case 2:
598 Serial.println(F(" Differential Unipolar input range selected"));
599 Serial.println(F(" Note that this range operates only for the following configurations:"));
600 Serial.println(F(" CH 0P-1N, with AIN1+ connected to GND"));
601 Serial.println(F(" CH 1P-0N, with AIN1- connected to GND"));
602 LTC2373_range_select = LTC2373_RANGE_DIFF_UNIPOLAR;
603 break;
604 case 3:
605 Serial.println(F(" Differential Bipolar input range selected"));
606 LTC2373_range_select = LTC2373_RANGE_DIFF_BIPOLAR;
607 break;
608 default:
609 {
610 Serial.println(" Invalid Option");
611 return;
612 }
613 break;
614 }
615 }
616
617
618 //! Select gain compression
619 //! @return void
620 void menu_6_select_gain_compression()
621 {
622 uint8_t user_command;
623 Serial.println();
624 if (LTC2373_gain_compression == 0)
625 Serial.println(F(" No gain compression enabled"));
626 else
627 Serial.println(F(" Gain compression enabled"));
628
629 Serial.println(F(" 0 = No Gain Compression"));
630 Serial.println(F(" 1 = Gain Compression"));
631 Serial.println(F(""));
632 Serial.print(F(" Enter a Command: "));
633
634 user_command = read_int(); // Read user input
635 Serial.println(user_command); // Prints the user command to com port
636 switch (user_command)
637 {
638 case 0:
639 LTC2373_gain_compression = 0;
640 break;
641 case 1:
642 LTC2373_gain_compression = 1;
643 break;
644 default:
645 {
646 Serial.println(" Invalid Option");
647 return;
648 }
649 break;
650 }
651 }
652
653
654 //! Prints the title block when program first starts.
655 void print_title()
656 {
657 Serial.println();
658 Serial.println(F("*****************************************************************"));
659 Serial.println(F("* DC2071A Demonstration Program *"));
660 Serial.println(F("* *"));
661 Serial.println(F("* This program demonstrates how to receive data *"));
662 Serial.println(F("* from the LTC2373-16/18 ADC. *"));
663 Serial.println(F("* *"));
664 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
665 Serial.println(F("* *"));
666 Serial.println(F("*****************************************************************"));
667 }
668
669
670 //! Prints main menu.
671 void print_prompt()
672 {
673 Serial.println("");
674 Serial.println(F(" 1-Read ADC Input"));
675 Serial.println(F(" 2-Program the Sequencer"));
676 Serial.println(F(" 3-Read the Sequencer"));
677 Serial.println(F(" 4-Select Number of Bits (Default is 18 bits)"));
678 Serial.println(F(" 5-Select Range (Default is Single-Ended Unipolar Range)"));
679 Serial.println(F(" 6-Select Gain Compression (Default is No Gain Compression)\n"));
680 Serial.println(F(""));
681 Serial.print(F(" Enter a command: "));
682 }
683
684
685 //! Display selected differential channels. Displaying single-ended channels is
686 //! straightforward; not so with differential because the inputs can take either polarity.
687 void print_user_command(uint8_t menu)
688 {
689 switch (menu)
690 {
691 case 0:
692 Serial.print(F(" CH 0P-1N"));
693 break;
694 case 1:
695 Serial.print(F(" CH 2P-3N"));
696 break;
697 case 2:
698 Serial.print(F(" CH 4P-5N"));
699 break;
700 case 3:
701 Serial.print(F(" CH 6P-7N"));
702 break;
703 case 4:
704 Serial.print(F(" CH 1P-0N"));
705 break;
706 case 5:
707 Serial.print(F(" CH 3P-2N"));
708 break;
709 case 6:
710 Serial.print(F(" CH 5P-4N"));
711 break;
712 case 7:
713 Serial.print(F(" CH 7P-6N"));
714 break;
715 }
716 }
717
LTC2373_build_command
uint8_t LTC2373_build_command(uint8_t sequencer_bit, uint8_t ch_designate, uint8_t range_select, uint8_t gain_compression)
Definition: LTC2373.cpp:79
COMMAND_SINGLE_ENDED
const uint8_t COMMAND_SINGLE_ENDED[8]
Lookup table to build the command for single-ended mode, input with respect to GND.
Definition: DC2071AA.ino:124
LTC2373_CH5_4
#define LTC2373_CH5_4
Definition: LTC2373.h:110
adc_command
static uint8_t adc_command
Definition: DC2071AA.ino:111
i2c_write_byte
int8_t i2c_write_byte(uint8_t address, uint8_t value)
Write "value" byte to device at "address".
Definition: LT_I2C.cpp:109
LT_union_int32_4bytes::LT_byte
uint8_t LT_byte[4]
4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer ...
Definition: Linduino.h:112
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC2071AA.ino:671
LTC2373_configure
void LTC2373_configure(uint8_t cs, uint32_t adc_configure)
Configures the LTC2373.
Definition: LTC2373.cpp:114
LTC2373_CH7_6
#define LTC2373_CH7_6
Definition: LTC2373.h:113
LTC2373_RANGE_DIFF_BIPOLAR
#define LTC2373_RANGE_DIFF_BIPOLAR
Definition: LTC2373.h:122
print_user_command
static void print_user_command(uint8_t menu)
Display selected differential channels.
Definition: DC2071AA.ino:687
LTC2373.h
LTC2373: 16/18-bit 1Msps 8 channel SAR ADC LTC2372: 16/18-bit 500ksps 8 channel SAR ADC LTC2374: 16 b...
COMMAND_DIFF
const uint8_t COMMAND_DIFF[8]
Lookup table to build the command for differential mode.
Definition: DC2071AA.ino:129
menu_4_select_bits
static void menu_4_select_bits()
Select number of bits.
Definition: DC2071AA.ino:537
LTC2373_CH6_7
#define LTC2373_CH6_7
Definition: LTC2373.h:112
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC2373_SEQUENCER_BIT
#define LTC2373_SEQUENCER_BIT
Definition: LTC2373.h:89
loop
static void loop()
Repeats Linduino loop.
Definition: DC2071AA.ino:147
LT_union_int32_4bytes::LT_uint32
uint32_t LT_uint32
32-bit unsigned integer to be converted to four bytes
Definition: Linduino.h:111
LTC2373_CH2_3
#define LTC2373_CH2_3
Definition: LTC2373.h:106
LTC2373_RANGE_BIPOLAR
#define LTC2373_RANGE_BIPOLAR
Definition: LTC2373.h:120
LTC2373_CH3_2
#define LTC2373_CH3_2
Definition: LTC2373.h:107
menu_3_read_sequencer
static void menu_3_read_sequencer()
Program the sequencer.
Definition: DC2071AA.ino:481
adc_voltage
static float adc_voltage
Definition: DC2071AA.ino:115
setup
static void setup()
Initialize Linduino.
Definition: DC2071AA.ino:135
LTC2373_CH1_0
#define LTC2373_CH1_0
Definition: LTC2373.h:104
LTC2373_RANGE_UNIPOLAR
#define LTC2373_RANGE_UNIPOLAR
Definition: LTC2373.h:119
LTC2373_vref
static float LTC2373_vref
Definition: DC2071AA.ino:116
QuikEval_EEPROM.h
QuikEval EEPROM Library.
LTC2373_CH4
#define LTC2373_CH4
Definition: LTC2373.h:98
quikeval_SPI_init
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
LTC2373_read
void LTC2373_read(uint8_t cs, uint8_t adc_command, uint32_t *ptr_adc_code)
Reads the LTC2373 and returns 32-bit data.
Definition: LTC2373.cpp:89
LTC2373_CS
#define LTC2373_CS
Define the SPI CS pin.
Definition: LTC2373.h:84
LTC2373_CH1
#define LTC2373_CH1
Definition: LTC2373.h:95
LTC2373_CH0_1
#define LTC2373_CH0_1
Definition: LTC2373.h:103
I2C_COMMAND
#define I2C_COMMAND
Definition: LTC2373.h:88
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LTC2373_CH3
#define LTC2373_CH3
Definition: LTC2373.h:97
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC2071AA.ino:655
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC2373_bits
static uint8_t LTC2373_bits
Default set for 18 bits.
Definition: DC2071AA.ino:119
menu_6_select_gain_compression
static void menu_6_select_gain_compression()
Select gain compression.
Definition: DC2071AA.ino:620
LTC2373_RANGE_DIFF_UNIPOLAR
#define LTC2373_RANGE_DIFF_UNIPOLAR
Definition: LTC2373.h:121
LTC2373_CH2
#define LTC2373_CH2
Definition: LTC2373.h:96
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
LTC2373_range_select
static uint8_t LTC2373_range_select
Default set for single-ended unipolar mode.
Definition: DC2071AA.ino:117
display_code
static int32_t display_code
Definition: DC2071AA.ino:114
LTC2373_NO_COMPRESSION
#define LTC2373_NO_COMPRESSION
Definition: LTC2373.h:125
LTC2373_gain_compression
static uint8_t LTC2373_gain_compression
Default set for no compression mode.
Definition: DC2071AA.ino:118
LT_union_int32_4bytes
This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer) four uint...
Definition: Linduino.h:108
LTC2373_CH5
#define LTC2373_CH5
Definition: LTC2373.h:99
user_command
static uint8_t user_command
Definition: DC2071AA.ino:112
menu_2_program_sequencer
static void menu_2_program_sequencer()
Program the sequencer.
Definition: DC2071AA.ino:438
menu_5_select_range
static void menu_5_select_range()
Select range.
Definition: DC2071AA.ino:574
LTC2373_CH7
#define LTC2373_CH7
Definition: LTC2373.h:101
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
i
static int i
Definition: DC2430A.ino:184
LTC2373_code_to_voltage
float LTC2373_code_to_voltage(uint8_t adc_command, uint32_t adc_code, float vref)
Calculates the LTC2373 input voltage given the binary data and lsb weight.
Definition: LTC2373.cpp:134
LTC2373_sequencer_bit
static uint8_t LTC2373_sequencer_bit
Definition: DC2071AA.ino:120
LTC2373_CH4_5
#define LTC2373_CH4_5
Definition: LTC2373.h:109
menu_1_read_adc
static void menu_1_read_adc()
Read channels in single-ended mode.
Definition: DC2071AA.ino:190
I2C_ADDRESS
#define I2C_ADDRESS
Definition: LTC2373.h:87
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113
LTC2373_CH6
#define LTC2373_CH6
Definition: LTC2373.h:100
LTC2373_CH0
#define LTC2373_CH0
Definition: LTC2373.h:94