Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC2094A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC2094AA Demonstration Board.
3 LTC2348-18: Octal, 18-Bit, 200ksps Differential ±10.24V Input SoftSpan ADC with Wide Input Common Mode Range.
4 
5 Linear Technology DC2094AD Demonstration Board.
6 LTC2348-16: Octal, 16-Bit, 200ksps Differential ±10.24V Input SoftSpan ADC with Wide Input Common Mode Range.
7 
8 Linear Technology DC2520AA Demonstration Board.
9 LTC2344-18: Quad, 18-Bit, 400ksps/ch Differential SoftSpan ADC with Wide Input Common Mode Range.
10 
11 Linear Technology DC2520AB Demonstration Board.
12 LTC2344-16: Quad, 16-Bit, 400ksps/ch Differential SoftSpan ADC with Wide Input Common Mode Range.
13 
14 Linear Technology DC2365AD Demonstration Board.
15 LTC2333-18: Buffered 8-Channel, 18-Bit, 800ksps Differential ±10.24V ADC with 30VP-P Common Mode Range.
16 
17 Linear Technology DC2365AH Demonstration Board.
18 LTC2333-16: Buffered 8-Channel, 16-Bit, 800ksps Differential ±10.24V ADC with 30VP-P Common Mode Range.
19 
20 Linear Technology DC2365AB Demonstration Board.
21 LTC2357-18: Buffered Quad, 18-Bit, 350ksps/Ch Differential ±10.24V ADC with 30VP-P Common Mode Range.
22 
23 Linear Technology DC2365AF Demonstration Board.
24 LTC2357-16: Buffered Quad, 16-Bit, 350ksps/Ch Differential ±10.24V ADC with 30VP-P Common Mode Range.
25 
26 Linear Technology DC2365AA Demonstration Board.
27 LTC2358-18: Buffered Octal, 18-Bit, 200ksps/Ch Differential ±10.24V ADC with 30VP-P Common Mode Range.
28 
29 Linear Technology DC2365AE Demonstration Board.
30 LTC2358-16: Buffered Octal, 16-Bit, 200ksps/Ch Differential ±10.24V ADC with 30VP-P Common Mode Range.
31 
32 Linear Technology DC2365AC Demonstration Board.
33 LTC2353-18: Buffered Dual, 18-Bit, 550ksps/Ch Differential ±10.24V ADC with 30VP-P Common Mode Range.
34 
35 Linear Technology DC2365AG Demonstration Board.
36 LTC2353-16: Buffered Dual, 16-Bit, 550ksps/Ch Differential ±10.24V ADC with 30VP-P Common Mode Range.
37 
38 
39 @verbatim
40 
41 NOTES
42  Setup:
43  Set the terminal baud rate to 115200 and select the newline terminator.
44  Ensure all jumpers on the demo board are installed in their default positions
45  as described in Demo Manual DC2094A. Apply +/- 16V to the indicated terminals.
46  Make sure the input range of channels are configured to measure according to
47  the input range required.
48 
49  This code can be used for all the Family supported parts by changing num_of_channels
50  and num_of_bits corresponding to each of those parts.
51 
52  Menu Entry 1: Display ADC Output Data and Calculated ADC input voltage
53 
54  Menu Entry 2: Change Configuration Settings
55 
56 @endverbatim
57 
58 http://www.linear.com/product/LTC2348-18
59 http://www.linear.com/product/LTC2348-16
60 http://www.linear.com/product/LTC2344-18
61 http://www.linear.com/product/LTC2344-16
62 http://www.linear.com/product/LTC2333-18
63 http://www.linear.com/product/LTC2333-16
64 http://www.linear.com/product/LTC2357-18
65 http://www.linear.com/product/LTC2357-16
66 http://www.linear.com/product/LTC2358-18
67 http://www.linear.com/product/LTC2358-16
68 http://www.linear.com/product/LTC2353-18
69 http://www.linear.com/product/LTC2353-16
70 
71 http://www.linear.com/product/LTC2348-18#demoboards
72 http://www.linear.com/product/LTC2348-16#demoboards
73 http://www.linear.com/product/LTC2344-18#demoboards
74 http://www.linear.com/product/LTC2344-16#demoboards
75 http://www.linear.com/product/LTC2333-18#demoboards
76 http://www.linear.com/product/LTC2333-16#demoboards
77 http://www.linear.com/product/LTC2357-18#demoboards
78 http://www.linear.com/product/LTC2357-16#demoboards
79 http://www.linear.com/product/LTC2358-18#demoboards
80 http://www.linear.com/product/LTC2358-16#demoboards
81 http://www.linear.com/product/LTC2353-18#demoboards
82 http://www.linear.com/product/LTC2353-16#demoboards
83 
84 
85 Copyright 2018(c) Analog Devices, Inc.
86 
87 All rights reserved.
88 
89 Redistribution and use in source and binary forms, with or without
90 modification, are permitted provided that the following conditions are met:
91  - Redistributions of source code must retain the above copyright
92  notice, this list of conditions and the following disclaimer.
93  - Redistributions in binary form must reproduce the above copyright
94  notice, this list of conditions and the following disclaimer in
95  the documentation and/or other materials provided with the
96  distribution.
97  - Neither the name of Analog Devices, Inc. nor the names of its
98  contributors may be used to endorse or promote products derived
99  from this software without specific prior written permission.
100  - The use of this software may or may not infringe the patent rights
101  of one or more patent holders. This license does not release you
102  from the requirement that you obtain separate licenses from these
103  patent holders to use this software.
104  - Use of the software either in source or binary form, must be run
105  on or directly connected to an Analog Devices Inc. component.
106 
107 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
108 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
109 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
110 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
111 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
112 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
113 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
114 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
115 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
116 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
117  */
118 
119 
120 /*! @file
121  @ingroup LTC23XX
122 */
123 
124 #include <Arduino.h>
125 #include "LT_I2C.h"
126 #include "LT_SPI.h"
127 #include "UserInterface.h"
128 #include "QuikEval_EEPROM.h"
129 #include "Linduino.h"
130 #include <Wire.h>
131 #include <stdint.h>
132 #include <SPI.h>
133 #include "LTC2348.h"
134 
135 // Global variable
136 static uint8_t demo_board_connected; //!< Set to 1 if the board is connected
139 
140 // LTC2348 specific values
141 uint8_t num_of_channels = 8; // Number of channels
142 uint8_t num_of_bits = 18;
143 
144 // Function declarations
145 void sneaker_port_init();
146 uint8_t discover_DC2094(char *demo_name);
147 void print_title();
148 void print_prompt();
149 void decode_values(uint32_t channel_data);
152 
153 //! Initialize Linduino
154 void setup()
155 {
156  char demo_name[] = "LTC2348-18"; //! Demo Board Name stored in QuikEval EEPROM
157  quikeval_I2C_init(); //! Initializes Linduino I2C port.
158  quikeval_SPI_init(); //! Initializes Linduino SPI port.
159 
160  Serial.begin(115200); //! Initialize the serial port to the PC
161  print_title();
162 
165  {
166  print_prompt();
167  }
168  sneaker_port_init(); //! Configure sneaker port to talk to the ADC
169  quikeval_SPI_connect(); //! Connects to main SPI port
170 }
171 
172 //! Repeats Linduino Loop
173 void loop()
174 {
175  int8_t user_command; // The user input command
176  uint8_t acknowledge = 0;
177  if (Serial.available()) // Check for user input
178  {
179  user_command = read_int(); // Read the user command
180  if (user_command != 'm')
181  Serial.println(user_command); // Prints the user command to com port
182  Serial.flush();
183  switch (user_command)
184  {
185  case 1:
187  break;
188  case 2:
190  break;
191  default:
192  Serial.println(F("Incorrect Option"));
193  }
194  if (acknowledge)
195  Serial.println(F("***** I2C ERROR *****"));
196  Serial.print(F("\n****************************** Press Enter to Continue ******************************\n"));
197  read_int();
198  print_prompt();
199  }
200 }
201 
202 //! Configure sneaker port to talk to the ADC
204 {
205  uint8_t value = 0;
207  delay(100);
208  value = value & 0x7F; // P7 = WRIN = 0
209  value = value | 0x04; // P2 = WRIN2 = 1
211  delay(100);
212 }
213 
214 //! Read the ID string from the EEPROM and determine if the correct board is connected.
215 //! Returns 1 if successful, 0 if not successful
217 {
218  Serial.print(F("\nChecking EEPROM contents..."));
220  ui_buffer[48] = 0;
221  Serial.println(ui_buffer);
222 
223  if (!strcmp(demo_board.product_name, demo_name))
224  {
225  Serial.print("Demo Board Name: ");
226  Serial.println(demo_board.name);
227  Serial.print("Product Name: ");
228  Serial.println(demo_board.product_name);
229  if (demo_board.option)
230  {
231  Serial.print("Demo Board Option: ");
232  Serial.println(demo_board.option);
233  }
234  Serial.println(F("Demo board connected"));
235  Serial.println(F("\n\n\t\t\t\tPress Enter to Continue..."));
236  read_int();
237  return 1;
238  }
239  else
240  {
241  Serial.print("Demo board ");
242  Serial.print(demo_name);
243  Serial.print(" not found, \nfound ");
244  Serial.print(demo_board.name);
245  Serial.println(" instead. \nConnect the correct demo board, then press the reset button.");
246  return 0;
247  }
248 }
249 
250 //! Prints the title block when program first starts.
252 {
253  Serial.print(F("\n*****************************************************************\n"));
254  Serial.print(F("* DC2094A Demonstration Program *\n"));
255  Serial.print(F("* *\n"));
256  Serial.print(F("* This program demonstrates how to send data and receive data *\n"));
257  Serial.print(F("* from the 18-bit ADC. *\n"));
258  Serial.print(F("* *\n"));
259  Serial.print(F("* *\n"));
260  Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
261  Serial.print(F("* *\n"));
262  Serial.print(F("*****************************************************************\n"));
263 }
264 
265 //! Prints main menu.
267 {
268  Serial.println(F("\n\n\n\t\t\t\tCONFIGURATION SETTINGS (Vref = 4.096V)\n"));
269  Serial.println(F("|Config Number| SS2 | SS1 | SS0 | ANALOG INPUT RANGE | DIGITAL COMPRESSION | RESULT BINARY FORMAT |"));
270  Serial.println(F("|-------------|-----------------|-------------------------|---------------------|----------------------|"));
271  Serial.println(F("| 0 | 0 | 0 | 0 | Disable Channel | N/A | All Zeros |"));
272  Serial.println(F("| 1 | 0 | 0 | 1 | 0 - 1.25 Vref | 1 | Straight Binary |"));
273  Serial.println(F("| 2 | 0 | 1 | 0 | -1.25 Vref - +1.25 Vref | 1/1.024 | Two's Complement |"));
274  Serial.println(F("| 3 | 0 | 1 | 1 | -1.25 Vref - +1.25 Vref | 1 | Two's Complement |"));
275  Serial.println(F("| 4 | 1 | 0 | 0 | 0 - 2.5 Vref | 1/1.024 | Straight Binary |"));
276  Serial.println(F("| 5 | 1 | 0 | 1 | 0 - 2.5 Vref | 1 | Straight Binary |"));
277  Serial.println(F("| 6 | 1 | 1 | 0 | -2.5 Vref - +2.5 Vref | 1/1.024 | Two's Complement |"));
278  Serial.println(F("| 7 | 1 | 1 | 1 | -2.5 Vref - +2.5 Vref | 1 | Two's Complement |"));
279 
280  Serial.print(F("\n\n\n\t\t\t\tOPTIONS\n"));
281  Serial.print(F("\n1 - Display ADC output\n"));
282  Serial.print(F("2 - Change configuration setting\n"));
283 
284  Serial.print(F("\nENTER A COMMAND: "));
285 }
286 
287 void decode_values(uint32_t channel_data)
288 {
289  uint8_t channel, config_number;
290  float voltage;
291  uint32_t code;
292 
293  channel = (channel_data & CHANNEL_NUMBER) >> 3;
294  config_number = channel_data & SOFTSPAN;
295  code = (channel_data & 0xFFFFC0) >> 6;
296  voltage = LTC23XX_voltage_calculator(code, config_number);
297 
298  Serial.print(F("\nChannel : "));
299  Serial.print(channel);
300  Serial.print(F("\t\tData : 0x"));
301  Serial.println(code, HEX);
302  Serial.print(F("Voltage : "));
303  Serial.print(voltage, 6);
304  Serial.print(F(" V"));
305  Serial.print(F("\tConfig Number: "));
306  Serial.println(config_number);
307 }
308 
309 //! Displays the ADC output and calculated voltage for all channels
311 {
312  uint8_t display_channels;
313  uint8_t Result[24];
314  uint8_t pos;
315  data.LT_uint32 = 0;
316 
317  Serial.print("\nEnter the number of channels to be displayed: ");
318  display_channels = read_int();
319  if (display_channels < 1)
320  display_channels = 1;
321  else if (display_channels > num_of_channels)
322  display_channels = num_of_channels;
323 
324  while (!Serial.available())
325  {
327  Serial.println(F("\n********************************************"));
328 
329  pos = 23;
330  for (int i = 0; i < display_channels; ++i)
331  {
332  data.LT_byte[2] = Result[pos--];
333  data.LT_byte[1] = Result[pos--];
334  data.LT_byte[0] = Result[pos--];
335 
337  }
338  }
339 }
340 
341 //! Function to change the configuration setting
343 {
344  uint32_t config_word = 0;
345  uint8_t num;
346  for (int i = 0; i < num_of_channels; ++i)
347  {
348  Serial.print(F("\nEnter configuration number for channel "));
349  Serial.print(i);
350  Serial.print(F(": "));
351  num = read_int();
352  if (num < 0)
353  num = 0;
354  else if (num > 7)
355  num = 7;
356  Serial.print(num);
357  LTC23XX_create_config_word(i, num, &config_word);
358  }
359  Serial.print("\nConfig word: 0x");
360  Serial.println(config_word, HEX);
361  configuration_bits.LT_uint32 = config_word;
362  Serial.print(F("\nCONFIGURATION CHANGED!"));
363 }
struct demo_board_type demo_board
Instantiate demo board structure.
char option
Demo Circuit option (A)
static uint8_t demo_board_connected
Set to 1 if the board is connected.
Definition: DC2094A.ino:136
unsigned char user_command
int8_t i2c_write_byte(uint8_t address, uint8_t value)
Write "value" byte to device at "address".
Definition: LT_I2C.cpp:109
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
char name[15]
Demo Circuit number (DC1678)
#define CHANNEL_NUMBER
Definition: LTC2348.h:113
static uint8_t num_of_bits
Definition: DC2094A.ino:142
Header File for Linduino Libraries and Demo Code.
uint32_t LT_uint32
32-bit unsigned integer to be converted to four bytes
Definition: Linduino.h:111
static uint8_t channel
LTC2305 Channel selection.
Definition: DC1444A.ino:127
#define SOFTSPAN
Definition: LTC2348.h:114
static void print_title()
Prints the title block when program first starts.
Definition: DC2094A.ino:251
void LTC23XX_create_config_word(uint8_t channel, uint8_t config_number, uint32_t *config_word)
Creates 24-bit configuration word for the 8 channels.
Definition: LTC2348.cpp:106
static uint8_t num_of_channels
Definition: DC2094A.ino:141
float LTC23XX_voltage_calculator(uint32_t data, uint8_t channel_configuration)
Calculates the voltage from ADC output data depending on the channel configuration.
Definition: LTC2348.cpp:142
static void menu1_display_adc_output()
Displays the ADC output and calculated voltage for all channels.
Definition: DC2094A.ino:310
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
static void print_prompt()
Prints main menu.
Definition: DC2094A.ino:266
static int16_t pos
static uint8_t discover_DC2094(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
Definition: DC2094A.ino:216
void LTC23XX_read(uint8_t cs_pin, uint32_t config_word, uint8_t data_array[24])
Transmits 24 bits (3 bytes) of configuration information and reads back 24 bytes of data (3 bytes/ 24...
Definition: LTC2348.cpp:115
static void menu2_change_softspan_range()
Function to change the configuration setting.
Definition: DC2094A.ino:342
QuikEval EEPROM Library.
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.
LTC2348-18: Octal, 18-Bit, 200ksps Differential ±10.24V Input SoftSpan ADC with Wide Input Common Mod...
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
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()
This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer) four uint...
Definition: Linduino.h:108
char product_name[15]
LTC Product (LTC2654-L16)
static void setup()
Initialize Linduino.
Definition: DC2094A.ino:154
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
static int i
Definition: DC2430A.ino:184
static void loop()
Repeats Linduino Loop.
Definition: DC2094A.ino:173
static float voltage
Definition: DC2289AA.ino:71
#define SNEAKER_PORT_I2C_ADDRESS
Definition: LTC2348.h:116
static void sneaker_port_init()
Configure sneaker port to talk to the ADC.
Definition: DC2094A.ino:203
#define QUIKEVAL_CS
QuikEval CS pin (SPI chip select on QuikEval connector pin 6) connects to Arduino SS pin...
Definition: Linduino.h:57
uint8_t read_quikeval_id_string(char *buffer)
Read the id string from the EEPROM, then parse the product name, demo board name, and demo board opti...
char ui_buffer[UI_BUFFER_SIZE]
int8_t i2c_read_byte(uint8_t address, uint8_t *value)
Read a byte, store in "value".
Definition: LT_I2C.cpp:93
static void decode_values(uint32_t channel_data)
Definition: DC2094A.ino:287
union LT_union_int32_4bytes configuration_bits
Definition: DC2094A.ino:137