| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC1796A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1796A 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 DC1796A.
21
22 How to test:
23 The voltage source should be connected to input AIN+/AIN-. Ensure the
24 input is within its 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 +4.096V.
27
28 USER INPUT DATA FORMAT:
29 decimal : 1024
30 hex : 0x400
31 octal : 02000 (leading 0 "zero")
32 binary : B10000000000
33 float : 1024.0
34
35 @endverbatim
36
37 http://www.linear.com/product/LTC2364-16
38 http://www.linear.com/product/LTC2364-18
39 http://www.linear.com/product/LTC2367-16
40 http://www.linear.com/product/LTC2367-18
41 http://www.linear.com/product/LTC2368-16
42 http://www.linear.com/product/LTC2368-18
43 http://www.linear.com/product/LTC2369-18
44 http://www.linear.com/product/LTC2370-16
45
46 http://www.linear.com/product/LTC2364-16#demoboards
47 http://www.linear.com/product/LTC2364-18#demoboards
48 http://www.linear.com/product/LTC2367-16#demoboards
49 http://www.linear.com/product/LTC2367-18#demoboards
50 http://www.linear.com/product/LTC2368-16#demoboards
51 http://www.linear.com/product/LTC2368-18#demoboards
52 http://www.linear.com/product/LTC2369-18#demoboards
53 http://www.linear.com/product/LTC2370-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 LTC2370
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 "LTC2370.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_bits();
112
113 // Global variables
114 static uint8_t LTC2370_bits = 18; //!< Default set for 18 bits
115 float LTC2370_vref = 4.096;
116
117
118 //! Initialize Linduino
119 void setup()
120 {
121 uint32_t adc_code;
122 quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
123 quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
124 quikeval_SPI_connect(); // Connect SPI to main data port
125 Serial.begin(115200); // Initialize the serial port to the PC
126 print_title();
127 print_prompt();
128 }
129
130
131 //! Repeats Linduino loop
132 void loop()
133 {
134 uint16_t user_command;
135 {
136 if (Serial.available())
137 {
138 user_command = read_int(); // Read the user command
139 if (user_command != 'm')
140 Serial.println(user_command); // Prints the user command to com port
141 switch (user_command)
142 {
143 case 1:
144 menu_1_read_input();
145 break;
146 case 2:
147 menu_2_select_bits();
148 break;
149 default:
150 Serial.println("Invalid Option");
151 break;
152 }
153 Serial.println();
154 print_prompt();
155 }
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 int32_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();
200 if (LTC2370_bits == 16)
201 Serial.println(F(" 16 bits selected"));
202 else
203 Serial.println(F(" 18 bits selected"));
204
205 Serial.println(F(" 16 = 2370-16"));
206 Serial.println(F(" 18 = 2370-18"));
207 Serial.print(F(" Enter a Command, based upon the resolution of the part under test: "));
208
209 user_command = read_int(); // Read user input
210 Serial.println(user_command); // Prints the user command to com port
211 switch (user_command)
212 {
213 case 16:
214 LTC2370_bits = 16;
215 Serial.println(F(" 16 bits selected"));
216 break;
217 case 18:
218 LTC2370_bits = 18;
219 Serial.println(F(" 18 bits selected"));
220 break;
221 default:
222 {
223 Serial.println(" Invalid Option");
224 return;
225 }
226 break;
227 }
228 }
229
230
231 //! Prints the title block when program first starts.
232 void print_title()
233 {
234 Serial.println();
235 Serial.println(F("*****************************************************************"));
236 Serial.println(F("* DC1796A Demonstration Program *"));
237 Serial.println(F("* *"));
238 Serial.println(F("* This program demonstrates how to receive data *"));
239 Serial.println(F("* from the following ADCs: *"));
240 Serial.println(F("* LTC2364-16 *"));
241 Serial.println(F("* LTC2364-18 *"));
242 Serial.println(F("* LTC2367-16 *"));
243 Serial.println(F("* LTC2367-18 *"));
244 Serial.println(F("* LTC2368-16 *"));
245 Serial.println(F("* LTC2368-18 *"));
246 Serial.println(F("* LTC2369-18 *"));
247 Serial.println(F("* LTC2370-16 *"));
248 Serial.println(F("* *"));
249 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
250 Serial.println(F("* *"));
251 Serial.println(F("*****************************************************************"));
252 }
253
254
255 //! Prints main menu.
256 void print_prompt()
257 {
258 Serial.println(F("*************************"));
259 Serial.println(F("1-Read ADC Input"));
260 Serial.println(F("2-Select Number of bits (Default is 18 bits)\n"));
261 Serial.print(F("Enter a command:"));
262 }
263
LTC2370_CS
#define LTC2370_CS
Define the SPI CS pin.
Definition: LTC2370.h:100
menu_1_read_input
static void menu_1_read_input()
Read channel.
Definition: DC1796A.ino:163
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: DC1796A.ino:119
loop
static void loop()
Repeats Linduino loop.
Definition: DC1796A.ino:132
menu_2_select_bits
static void menu_2_select_bits()
Select number of bits.
Definition: DC1796A.ino:195
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: DC1796A.ino:232
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC1796A.ino:256
adc_voltage
static float adc_voltage
Definition: DC2071AA.ino:115
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
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
LTC2370_bits
static uint8_t LTC2370_bits
Default set for 18 bits.
Definition: DC1796A.ino:114
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LTC2370_vref
static float LTC2370_vref
Definition: DC1796A.ino:115
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
print_user_command
static void print_user_command(uint8_t menu)
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
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113