| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC1813A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1813A Demonstration Board.
3 LTC2364-16: 16-Bit, 250Ksps ADC.
4 LTC2364-18: 18-Bit, 250Ksps ADC.
5 LTC2367-16: 16-Bit, 500Ksps ADC
6 LTC2367-18: 18-Bit, 500Ksps ADC
7 LTC2368-16: 16-Bit, 1Msps ADC
8 LTC2368-18: 18-Bit, 1Msps ADC
9 LTC2369-18: 18-Bit, 1.6Msps ADC
10 LTC2370-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 DC1813A.
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
38 http://www.linear.com/product/LTC2364-16
39 http://www.linear.com/product/LTC2364-18
40 http://www.linear.com/product/LTC2367-16
41 http://www.linear.com/product/LTC2367-18
42 http://www.linear.com/product/LTC2368-16
43 http://www.linear.com/product/LTC2368-18
44 http://www.linear.com/product/LTC2369-18
45 http://www.linear.com/product/LTC2370-16
46
47 http://www.linear.com/product/LTC2364-16#demoboards
48 http://www.linear.com/product/LTC2364-18#demoboards
49 http://www.linear.com/product/LTC2367-16#demoboards
50 http://www.linear.com/product/LTC2367-18#demoboards
51 http://www.linear.com/product/LTC2368-16#demoboards
52 http://www.linear.com/product/LTC2368-18#demoboards
53 http://www.linear.com/product/LTC2369-18#demoboards
54 http://www.linear.com/product/LTC2370-16#demoboards
55
56
57 Copyright 2018(c) Analog Devices, Inc.
58
59 All rights reserved.
60
61 Redistribution and use in source and binary forms, with or without
62 modification, are permitted provided that the following conditions are met:
63 - Redistributions of source code must retain the above copyright
64 notice, this list of conditions and the following disclaimer.
65 - Redistributions in binary form must reproduce the above copyright
66 notice, this list of conditions and the following disclaimer in
67 the documentation and/or other materials provided with the
68 distribution.
69 - Neither the name of Analog Devices, Inc. nor the names of its
70 contributors may be used to endorse or promote products derived
71 from this software without specific prior written permission.
72 - The use of this software may or may not infringe the patent rights
73 of one or more patent holders. This license does not release you
74 from the requirement that you obtain separate licenses from these
75 patent holders to use this software.
76 - Use of the software either in source or binary form, must be run
77 on or directly connected to an Analog Devices Inc. component.
78
79 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
80 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
81 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
82 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
83 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
84 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
85 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
86 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
87 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
88 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89 */
90
91 /*! @file
92 @ingroup LTC2370
93 */
94
95 #include <Arduino.h>
96 #include <stdint.h>
97 #include "Linduino.h"
98 #include "LT_SPI.h"
99 #include "UserInterface.h"
100 #include "LT_I2C.h"
101 #include "QuikEval_EEPROM.h"
102 #include "LTC2370.h"
103 #include <SPI.h>
104 #include <Wire.h>
105
106 // Function Declaration
107 void print_title(); // Print the title block
108 void print_prompt(); // Prompt the user for an input command
109 void print_user_command(uint8_t menu); // Display selected differential channels
110
111 void menu_1_read_input();
112 void menu_2_select_bits();
113
114 // Global variables
115 static uint8_t LTC2370_bits = 18; //!< Default set for 18 bits
116 float LTC2370_vref = 5;
117
118
119 //! Initialize Linduino
120 void setup()
121 {
122 uint32_t adc_code;
123 quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
124 quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
125 quikeval_SPI_connect(); // Connect SPI to main data port
126 Serial.begin(115200); // Initialize the serial port to the PC
127 print_title();
128 print_prompt();
129 }
130
131
132 //! Repeats Linduino loop
133 void loop()
134 {
135 uint16_t user_command;
136 {
137 if (Serial.available())
138 {
139 user_command = read_int(); // Read the user command
140 if (user_command != 'm')
141 Serial.println(user_command); // Prints the user command to com port
142 switch (user_command)
143 {
144 case 1:
145 menu_1_read_input();
146 break;
147 case 2:
148 menu_2_select_bits();
149 break;
150 default:
151 Serial.println("Invalid Option");
152 break;
153 }
154 Serial.println();
155 print_prompt();
156 }
157 }
158 }
159
160 // Function Definitions
161 //! Read channel
162 //! @return void
163 void menu_1_read_input()
164 {
165 uint8_t user_command;
166 uint32_t adc_code; // The LTC2370 code
167 uint32_t display_code;
168 float adc_voltage; // The LTC2370 voltage
169
170 // Read and display a selected channel
171 LTC2370_read(LTC2370_CS, &adc_code); //discard the first reading
172 delay(100);
173 LTC2370_read(LTC2370_CS, &adc_code);
174
175 display_code = adc_code >> (32 - LTC2370_bits);
176 if (LTC2370_bits == 16)
177 display_code = display_code & 0xFFFF;
178 else
179 display_code = display_code & 0x3FFFF;
180
181 Serial.print(F(" Received Code: b"));
182 Serial.println(display_code, BIN);
183
184 // Convert the received code to voltage
185 adc_voltage = LTC2370_code_to_voltage(adc_code, LTC2370_vref);
186
187 Serial.print(F(" Equivalent voltage: "));
188 Serial.print(adc_voltage, 4);
189 Serial.println(F("V"));
190 }
191
192
193 //! Select number of bits
194 //! @return void
195 void menu_2_select_bits()
196 {
197 uint8_t user_command;
198
199 Serial.println(F(" 16 = 23XX-16"));
200 Serial.println(F(" 18 = 23XX-18"));
201 Serial.println(F(" Enter a Command, based upon the resolution of the part under test: "));
202
203 user_command = read_int(); // Read user input
204 Serial.println(user_command); // Prints the user command to com port
205 switch (user_command)
206 {
207 case 16:
208 LTC2370_bits = 16;
209 Serial.println(F(" 16 bits selected"));
210 break;
211 case 18:
212 LTC2370_bits = 18;
213 Serial.println(F(" 18 bits selected"));
214 break;
215 default:
216 {
217 Serial.println(" Invalid Option");
218 return;
219 }
220 break;
221 }
222 }
223
224
225 //! Prints the title block when program first starts.
226 void print_title()
227 {
228 Serial.println();
229 Serial.println(F("*****************************************************************"));
230 Serial.println(F("* DC1813A Demonstration Program *"));
231 Serial.println(F("* *"));
232 Serial.println(F("* This program demonstrates how to receive data *"));
233 Serial.println(F("* from the following ADCs: *"));
234 Serial.println(F("* LTC2364-16 *"));
235 Serial.println(F("* LTC2364-18 *"));
236 Serial.println(F("* LTC2367-16 *"));
237 Serial.println(F("* LTC2367-18 *"));
238 Serial.println(F("* LTC2368-16 *"));
239 Serial.println(F("* LTC2368-18 *"));
240 Serial.println(F("* LTC2369-18 *"));
241 Serial.println(F("* LTC2370-16 *"));
242 Serial.println(F("* *"));
243 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
244 Serial.println(F("* *"));
245 Serial.println(F("*****************************************************************"));
246 }
247
248
249 //! Prints main menu.
250 void print_prompt()
251 {
252 Serial.println(F("*************************"));
253 Serial.println(F("1-Read ADC Input"));
254 Serial.println(F("2-Select Number of bits (Default is 18 bits)\n"));
255 Serial.print(F("Enter a command:"));
256 }
257
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC1813A.ino:226
LTC2370_CS
#define LTC2370_CS
Define the SPI CS pin.
Definition: LTC2370.h:100
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
LTC2370_read
void LTC2370_read(uint8_t cs, uint32_t *ptr_adc_code)
Reads the LTC2370 and returns 32-bit data in offset binary format.
Definition: LTC2370.cpp:97
setup
static void setup()
Initialize Linduino.
Definition: DC1813A.ino:120
Linduino.h
Header File for Linduino Libraries and Demo Code.
menu_1_read_input
static void menu_1_read_input()
Read channel.
Definition: DC1813A.ino:163
print_user_command
static void print_user_command(uint8_t menu)
adc_voltage
static float adc_voltage
Definition: DC2071AA.ino:115
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC1813A.ino:250
LTC2370.h
LTC2364-16: 16-Bit, 250Ksps ADC.
LTC2370_code_to_voltage
float LTC2370_code_to_voltage(uint32_t adc_code, float vref)
Calculates the LTC2370 input voltage given the binary data and lsb weight.
Definition: LTC2370.cpp:119
LTC2370_vref
static float LTC2370_vref
Definition: DC1813A.ino:116
QuikEval_EEPROM.h
QuikEval EEPROM Library.
menu_2_select_bits
static void menu_2_select_bits()
Select number of bits.
Definition: DC1813A.ino:195
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: DC1813A.ino:133
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
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
display_code
static int32_t display_code
Definition: DC2071AA.ino:114
LTC2370_bits
static uint8_t LTC2370_bits
Default set for 18 bits.
Definition: DC1813A.ino:115
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113