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