| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC1190A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1190A Demonstration Board.
3 LTC2360-12: 12-Bit, 100Ksps ADC.
4 LTC2361-12: 12-Bit, 250Ksps ADC.
5 LTC2362-12: 12-Bit, 500Ksps ADC
6 LTC2365-12: 12-Bit, 1Msps ADC
7 LTC2366-12: 12-Bit, 3Msps ADC
8
9 @verbatim
10
11 NOTES
12 Setup:
13 Set the terminal baud rate to 115200 and select the newline terminator. Equipment
14 required is a voltage source (preferably low-noise) and a precision voltmeter.
15 Ensure all jumpers on the demo board are installed in their default positions
16 from the factory. Refer to Demo Manual DC1190A.
17
18 How to test:
19 The voltage source should be connected to input AIN. Ensure the input is within its
20 specified absolute input voltage range. (It is easiest
21 to tie the voltage source negative terminal to COM.) Ensure the voltage
22 source is set within the range of 0V to +2.5V for low range, or within 0V to +3V
23 for high range.
24
25 USER INPUT DATA FORMAT:
26 decimal : 1024
27 hex : 0x400
28 octal : 02000 (leading 0 "zero")
29 binary : B10000000000
30 float : 1024.0
31
32 @endverbatim
33
34 http://www.linear.com/product/LTC2360-12
35 http://www.linear.com/product/LTC2361-12
36 http://www.linear.com/product/LTC2362-12
37 http://www.linear.com/product/LTC2365-12
38 http://www.linear.com/product/LTC2366-12
39
40 http://www.linear.com/product/LTC2360-12#demoboards
41 http://www.linear.com/product/LTC2361-12#demoboards
42 http://www.linear.com/product/LTC2362-12#demoboards
43 http://www.linear.com/product/LTC2365-12#demoboards
44 http://www.linear.com/product/LTC2366-12#demoboards
45
46
47 Copyright 2018(c) Analog Devices, Inc.
48
49 All rights reserved.
50
51 Redistribution and use in source and binary forms, with or without
52 modification, are permitted provided that the following conditions are met:
53 - Redistributions of source code must retain the above copyright
54 notice, this list of conditions and the following disclaimer.
55 - Redistributions in binary form must reproduce the above copyright
56 notice, this list of conditions and the following disclaimer in
57 the documentation and/or other materials provided with the
58 distribution.
59 - Neither the name of Analog Devices, Inc. nor the names of its
60 contributors may be used to endorse or promote products derived
61 from this software without specific prior written permission.
62 - The use of this software may or may not infringe the patent rights
63 of one or more patent holders. This license does not release you
64 from the requirement that you obtain separate licenses from these
65 patent holders to use this software.
66 - Use of the software either in source or binary form, must be run
67 on or directly connected to an Analog Devices Inc. component.
68
69 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
70 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
71 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
72 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
73 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
74 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
75 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
76 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
77 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
78 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79 */
80
81 /*! @file
82 @ingroup LTC2366
83 */
84
85 #include <Arduino.h>
86 #include <stdint.h>
87 #include "Linduino.h"
88 #include "LT_SPI.h"
89 #include "UserInterface.h"
90 #include "LT_I2C.h"
91 #include "QuikEval_EEPROM.h"
92 #include "LTC2366.h"
93 #include <SPI.h>
94 #include <Wire.h>
95
96 // Function Declaration
97 void print_title(); // Print the title block
98 void print_prompt(); // Prompt the user for an input command
99 void print_user_command(uint8_t menu); // Display selected differential channels
100
101 void menu_1_read_input();
102 void menu_2_select_vref();
103
104 // Global variables
105 static uint8_t LTC2366_bits = 12; //!< Default set for 12 bits
106 float LTC2366_vref = 2.5; //!< Default set for 2.5V with JP1 in the 2.5V position
107
108
109 //! Initialize Linduino
110 void setup()
111 {
112 uint32_t adc_code;
113 quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
114 quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
115 quikeval_SPI_connect(); // Connect SPI to main data port
116 Serial.begin(115200); // Initialize the serial port to the PC
117 print_title();
118 print_prompt();
119 quikeval_SPI_connect(); //Initialize for SPI
120 }
121
122
123 //! Repeats Linduino loop
124 void loop()
125 {
126 uint16_t user_command;
127 {
128 if (Serial.available())
129 {
130 user_command = read_int(); // Read the user command
131 if (user_command != 'm')
132 Serial.println(user_command); // Prints the user command to com port
133 switch (user_command)
134 {
135 case 1:
136 menu_1_read_input();
137 break;
138 default:
139 Serial.println(" Invalid Option");
140 break;
141 }
142 Serial.println();
143 print_prompt();
144 }
145 }
146 }
147
148
149 // Function Definitions
150 //! Read channel
151 //! @return void
152 void menu_1_read_input()
153 {
154 uint8_t user_command;
155 uint16_t adc_code =0; // The LTC2366 code
156 uint16_t display_code;
157 float adc_voltage; // The LTC2366 voltage
158
159 // Read and display a selected channel
160 LTC2366_read(LTC2366_CS, &adc_code); //discard the first reading
161 delay(100);
162 LTC2366_read(LTC2366_CS, &adc_code);
163
164 display_code = adc_code >> (16 - LTC2366_bits - 2); //the data is left justified to bit_13 of a 16 bit word
165 display_code = display_code & 0xFFF;
166
167 Serial.print(F(" Received Code: b"));
168 Serial.println(display_code, BIN);
169
170 // Convert the received code to voltage
171 adc_voltage = LTC2366_code_to_voltage(adc_code, LTC2366_vref);
172
173 Serial.print(F(" Equivalent voltage: "));
174 Serial.print(adc_voltage, 4);
175 Serial.println(F("V"));
176 Serial.println();
177 }
178
179
180
181 //! Prints the title block when program first starts.
182 void print_title()
183 {
184 Serial.println();
185 Serial.println(F("*****************************************************************"));
186 Serial.println(F("* DC1190A Demonstration Program *"));
187 Serial.println(F("* *"));
188 Serial.println(F("* This program demonstrates how to receive data *"));
189 Serial.println(F("* from the following ADCs: *"));
190 Serial.println(F("* LTC2360-12 *"));
191 Serial.println(F("* LTC2361-12 *"));
192 Serial.println(F("* LTC2362-12 *"));
193 Serial.println(F("* LTC2365-12 *"));
194 Serial.println(F("* LTC2366-12 *"));
195 Serial.println(F("* *"));
196 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
197 Serial.println(F("* *"));
198 Serial.println(F("*****************************************************************"));
199 }
200
201
202 //! Prints main menu.
203 void print_prompt()
204 {
205 Serial.println(F("*************************"));
206 Serial.println(F("1-Read ADC Input"));
207 Serial.print(F("Enter a command: "));
208 }
209
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
loop
static void loop()
Repeats Linduino loop.
Definition: DC1190A.ino:124
setup
static void setup()
Initialize Linduino.
Definition: DC1190A.ino:110
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC2366_bits
static uint8_t LTC2366_bits
Default set for 12 bits.
Definition: DC1190A.ino:105
menu_1_read_input
static void menu_1_read_input()
Read channel.
Definition: DC1190A.ino:152
LTC2366_vref
static float LTC2366_vref
Default set for 2.5V with JP1 in the 2.5V position.
Definition: DC1190A.ino:106
adc_voltage
static float adc_voltage
Definition: DC2071AA.ino:115
LTC2366.h
LTC2360-12: 12-Bit, 100Ksps ADC.
LTC2366_read
void LTC2366_read(uint8_t cs, uint16_t *ptr_adc_code)
Reads the LTC2366 and returns 32-bit data in offset binary format.
Definition: LTC2366.cpp:85
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC1190A.ino:203
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
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC1190A.ino:182
print_user_command
static void print_user_command(uint8_t menu)
LTC2366_CS
#define LTC2366_CS
Define the SPI CS pin.
Definition: LTC2366.h:88
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.
menu_2_select_vref
static void menu_2_select_vref()
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
LTC2366_code_to_voltage
float LTC2366_code_to_voltage(uint16_t adc_code, float vref)
Calculates the LTC2366 input voltage given the binary data and lsb weight.
Definition: LTC2366.cpp:97
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