| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC24XX_general_test.ino
Go to the documentation of this file.
1 /*!
2
3 Copyright 2018(c) Analog Devices, Inc.
4
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
14 distribution.
15 - Neither the name of Analog Devices, Inc. nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
18 - The use of this software may or may not infringe the patent rights
19 of one or more patent holders. This license does not release you
20 from the requirement that you obtain separate licenses from these
21 patent holders to use this software.
22 - Use of the software either in source or binary form, must be run
23 on or directly connected to an Analog Devices Inc. component.
24
25 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
26 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
27 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
29 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
31 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 /*! @file
38 @ingroup LTC24XX_general
39 */
40
41 #include <stdint.h>
42 #include <Arduino.h>
43 #include "Linduino.h"
44 #include "UserInterface.h"
45 #include <SPI.h>
46 #include "LT_SPI.h"
47
48
49 #include "LTC24XX_general.h"
50 #include "LTC2668.h"
51
52 #include "USE_WIRE.h"
53 #ifdef USEWIRE
54 #include "LT_I2C_Wire.h"
55 #include "QuikEval_EEPROM_Wire.h"
56 #else
57 #include "LT_I2C.h"
58 #include "QuikEval_EEPROM.h"
59 #endif
60
61 #define CS QUIKEVAL_CS //!< The chip select
62
63 #define LTC2668_CS_ADDR 0 //!< Decoder address for the LTC2668 chip select
64 #define LTC2439_CS_ADDR 1 //!< Decoder address for the LTC2439 chip select
65 #define LTC2418_CS_ADDR 2 //!< Decoder address for the LTC2418 chip select
66 #define LTC2449_CS_ADDR 3 //!< Decoder address for the LTC2449 chip select
67 #define LTC2494_CS_ADDR 4 //!< Decoder address for the LTC2494 chip select
68 #define LTC2498_CS_ADDR 5 //!< Decoder address for the LTC2498 chip select
69 #define LTC2496_CS_ADDR 6 //!< Decoder address for the LTC2496 chip select
70 #define LTC2412_CS_ADDR 7 //!< Decoder address for the LTC2412 chip select
71 #define LTC2436_CS_ADDR 8 //!< Decoder address for the LTC2436 chip select
72 #define LTC2400_CS_ADDR 9 //!< Decoder address for the LTC2400 chip select
73 #define LTC2420_CS_ADDR 10 //!< Decoder address for the LTC2420 chip select
74
75
76 //! @name I2C Addresses
77 // ADDRESS CA2 CA1 CA0
78 #define LTC2495_ADDR 0b0010100 // LOW LOW LOW
79 #define LTC2497_ADDR 0b0100110 // LOW HIGH LOW
80 #define LTC2499_ADDR 0b1010110 // HIGH LOW LOW
81 //! @}
82
83 #define TEST_LTC2439
84 #define TEST_LTC2418
85 #define TEST_LTC2449
86 #define TEST_LTC2494
87 #define TEST_LTC2496
88 #define TEST_LTC2498
89
90 #define TEST_LTC2495
91 #define TEST_LTC2497
92 #define TEST_LTC2499
93
94 #define TEST_LTC2436
95 #define TEST_LTC2412
96
97 #define TEST_LTC2400
98 #define TEST_LTC2420
99
100
101 // Constants
102
103 //! Lookup table to build the command for single-ended mode
104 const uint8_t SINGLE_ENDED_CONFIG_ARRAY[16] = {LTC24XX_MULTI_CH_CH0, LTC24XX_MULTI_CH_CH1, LTC24XX_MULTI_CH_CH2, LTC24XX_MULTI_CH_CH3,
105 LTC24XX_MULTI_CH_CH4, LTC24XX_MULTI_CH_CH5, LTC24XX_MULTI_CH_CH6, LTC24XX_MULTI_CH_CH7,
106 LTC24XX_MULTI_CH_CH8, LTC24XX_MULTI_CH_CH9, LTC24XX_MULTI_CH_CH10, LTC24XX_MULTI_CH_CH11,
107 LTC24XX_MULTI_CH_CH12, LTC24XX_MULTI_CH_CH13, LTC24XX_MULTI_CH_CH14, LTC24XX_MULTI_CH_CH15
108 }; //!< Builds the command for single-ended mode
109
110 //! Lookup table to build the command for differential mode
111 const uint8_t DIFF_CONFIG_ARRAY[16] = {LTC24XX_MULTI_CH_P0_N1, LTC24XX_MULTI_CH_P2_N3, LTC24XX_MULTI_CH_P4_N5, LTC24XX_MULTI_CH_P6_N7,
112 LTC24XX_MULTI_CH_P8_N9, LTC24XX_MULTI_CH_P10_N11, LTC24XX_MULTI_CH_P12_N13, LTC24XX_MULTI_CH_P14_N15,
113 LTC24XX_MULTI_CH_P1_N0, LTC24XX_MULTI_CH_P3_N2, LTC24XX_MULTI_CH_P5_N4, LTC24XX_MULTI_CH_P7_N6,
114 LTC24XX_MULTI_CH_P9_N8, LTC24XX_MULTI_CH_P11_N10, LTC24XX_MULTI_CH_P13_N12, LTC24XX_MULTI_CH_P15_N14
115 }; //!< Build the command for differential mode
116
117
118 //! Lookup table to build the OSR command
119 const uint8_t OSR_CONFIG_ARRAY[16] = {LTC24XX_MULTI_CH_OSR_32768, LTC24XX_MULTI_CH_OSR_16384, LTC24XX_MULTI_CH_OSR_8192,
120 LTC24XX_MULTI_CH_OSR_4096, LTC24XX_MULTI_CH_OSR_2048, LTC24XX_MULTI_CH_OSR_1024, LTC24XX_MULTI_CH_OSR_512, LTC24XX_MULTI_CH_OSR_256,
121 LTC24XX_MULTI_CH_OSR_128, LTC24XX_MULTI_CH_OSR_64, LTC24XX_MULTI_CH_OSR_32768, LTC24XX_MULTI_CH_OSR_32768,
122 LTC24XX_MULTI_CH_OSR_32768, LTC24XX_MULTI_CH_OSR_32768, LTC24XX_MULTI_CH_OSR_32768, LTC24XX_MULTI_CH_OSR_32768
123 }; //!< Build the command for different OSR modes
124
125 // Prototypes
126 void set_CS_decoder(uint8_t CS_addr);
127 void print_all(float *se_results, float *diff_results);
128 void test_LTC2400(float vref, uint16_t eoc_timeout);
129 void test_LTC2412(float vref, uint16_t eoc_timeout);
130 void test_LTC2418(float vref, uint16_t eoc_timeout);
131 void test_LTC2420(float vref, uint16_t eoc_timeout);
132 void test_LTC2436(float vref, uint16_t eoc_timeout);
133 void test_LTC2439(float vref, uint16_t eoc_timeout);
134 void test_LTC2449(float vref, uint16_t eoc_timeout);
135 void test_LTC2494(float vref, uint16_t eoc_timeout);
136 void test_LTC2495(float vref, uint16_t eoc_timeout);
137 void test_LTC2496(float vref, uint16_t eoc_timeout);
138 void test_LTC2497(float vref, uint16_t eoc_timeout);
139 void test_LTC2498(float vref, uint16_t eoc_timeout);
140 void test_LTC2499(float vref, uint16_t eoc_timeout);
141 void test_all(float vref, uint16_t eoc_timeout);
142
143
144 // Globals
145 char demo_name[] = "DCXXXX"; //!< Demo Board Name stored in QuikEval EEPROM
146
147 //! Initialize Linduino
148 void setup()
149 {
150 Serial.begin(115200); // Initialize the serial port to the PC
151 Serial.println(F("LTC24XX Test Suite\n"));
152 delay(200);
153
154 quikeval_I2C_init(); // Enable the I2C port
155 quikeval_I2C_connect(); // Connect I2C to main data port
156 quikeval_SPI_init(); // Configure the spi port for 4volts SCK
157 quikeval_SPI_connect(); // Connect SPI to main data port
158
159 pinMode(2, OUTPUT); // Set up the CS# decoder address lines
160 pinMode(3, OUTPUT);
161 pinMode(4, OUTPUT);
162 pinMode(5, OUTPUT);
163 discover_demo_board(demo_name);
164
165
166 } // End of setup()
167
168 //! Repeats Linduino loop
169 void loop()
170 {
171 static float LTC24XX_vref = 5.0;
172 static uint16_t EOC_timout = 250;
173
174 // Uses the last two digits of the LTC number for uniqueness
175 uint16_t demo_board_product_name_key = *(uint16_t *)(demo_board.product_name + 5);
176
177 switch (demo_board_product_name_key)
178 {
179 case 0x3030:
180 // LTC2400
181 test_LTC2400(LTC24XX_vref, EOC_timout);
182 break;
183 case 0x3231:
184 // LTC2412
185 test_LTC2412(LTC24XX_vref, EOC_timout);
186 break;
187 case 0x3831:
188 // LTC2418
189 test_LTC2418(LTC24XX_vref, EOC_timout);
190 break;
191 case 0x3933:
192 // LTC2439
193 test_LTC2439(LTC24XX_vref, EOC_timout);
194 break;
195 case 0x3934:
196 // LTC2449
197 test_LTC2449(LTC24XX_vref, EOC_timout);
198 break;
199 case 0x3439:
200 // LTC2494
201 test_LTC2494(LTC24XX_vref, EOC_timout);
202 break;
203 case 0x3539:
204 // LTC2495
205 test_LTC2495(LTC24XX_vref, EOC_timout);
206 break;
207 case 0x3639:
208 // LTC2496
209 test_LTC2496(LTC24XX_vref, EOC_timout);
210 break;
211 case 0x3739:
212 // LTC2497
213 test_LTC2497(LTC24XX_vref, EOC_timout);
214 break;
215 case 0x3839:
216 // LTC2498
217 test_LTC2498(LTC24XX_vref, EOC_timout);
218 break;
219 case 0x3939:
220 // LTC2499
221 test_LTC2499(LTC24XX_vref, EOC_timout);
222 break;
223 default:
224 // Test all
225 Serial.println(F("\nTEST ALL\n"));
226 test_all(LTC24XX_vref, EOC_timout);
227 break;
228 }
229 delay(500);
230 }
231
232 //! Displays the the data in the arrays
233 void print_all(float *se_results, float *diff_results)
234 {
235 uint8_t i;
236 Serial.println(F("\nSingle Ended Results..."));
237 for (i=0; i<=15; i++)
238 {
239 Serial.print(F("CH "));
240 Serial.print(i);
241 Serial.print(F(": "));
242 Serial.print(se_results[i], 8);
243 if (!((i+1)%4)) Serial.println();
244 else Serial.print(F(" "));
245 }
246
247 Serial.println(F("\nDifferential Results..."));
248 for (i=0; i<=7; i++)
249 {
250 Serial.print(F("CH "));
251 Serial.print(i*2);
252 Serial.print(F("-"));
253 Serial.print((i*2) + 1);
254 Serial.print(F(": "));
255 Serial.print(diff_results[i], 8);
256 if (!((i+1)%4)) Serial.println();
257 else Serial.print(F(" "));
258 }
259 }
260
261 // Brute force.
262 void set_CS_decoder(uint8_t CS_addr)
263 {
264 if (CS_addr & 0b00000001)
265 {
266 digitalWrite(2, HIGH);
267 }
268 else
269 {
270 digitalWrite(2, LOW);
271 }
272 if (CS_addr & 0b00000010)
273 {
274 digitalWrite(3, HIGH);
275 }
276 else
277 {
278 digitalWrite(3, LOW);
279 }
280 if (CS_addr & 0b00000100)
281 {
282 digitalWrite(4, HIGH);
283 }
284 else
285 {
286 digitalWrite(4, LOW);
287 }
288 if (CS_addr & 0b00001000)
289 {
290 digitalWrite(5, HIGH);
291 }
292 else
293 {
294 digitalWrite(5, LOW);
295 }
296 }
297
298 //! Reads the LTC2400 and displays the results
299 void test_LTC2400(float vref, uint16_t eoc_timeout)
300 {
301 float voltage = 0.0;
302 int32_t adc_code = 0;
303 int i;
304
305 quikeval_SPI_connect(); // Connect SPI to main data port
306 set_CS_decoder(LTC2400_CS_ADDR); // Set the decoder for the LTC2400 chip select
307
308 Serial.println(F("\nTesting LTC2400 with a 32 bit read using LTC24XX_SPI_32bit_data..."));
309
310 LTC24XX_EOC_timeout(CS, eoc_timeout); // First flush power-on conversion that probably happened before
311 LTC24XX_SPI_32bit_data(CS, &adc_code); // the DAC output was set
312
313 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
314 LTC24XX_SPI_32bit_data(CS, &adc_code); // Read the ADC
315 voltage = LTC24XX_SE_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
316
317 // Display results
318 Serial.print(F(" Formatted LTC2400 ADC code: 0x"));
319 Serial.println(adc_code, HEX);
320 Serial.print(F(" Voltage:"));
321 Serial.print(voltage, 8);
322 Serial.println(F(" V"));
323 }
324
325 //! Reads the LTC2412 and displays the results
326 void test_LTC2412(float vref, uint16_t eoc_timeout)
327 {
328 float voltage = 0.0;
329 int32_t adc_code = 0;
330 uint8_t channel;
331 int i;
332
333 quikeval_SPI_connect(); // Connect SPI to main data port
334 set_CS_decoder(LTC2412_CS_ADDR); // Set the decoder for the LTC2412 chip select
335
336 Serial.println(F("\nTesting LTC2412 with a 32 bit read..."));
337
338 LTC24XX_EOC_timeout(CS, eoc_timeout); // First flush power-on conversion that probably happened before
339 LTC24XX_SPI_2ch_ping_pong_32bit_data(CS, &channel, &adc_code); // the DAC output was set
340
341 for (i=0; i <= 1; ++i)
342 {
343 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
344 LTC24XX_SPI_2ch_ping_pong_32bit_data(CS, &channel, &adc_code); // Read the ADC and channel
345 voltage = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
346
347 // Display results
348 Serial.print(F(" Formatted LTC2412 ADC code CH"));
349 Serial.print(channel);
350 Serial.print(F(": 0x"));
351 Serial.println(adc_code, HEX);
352 Serial.print(F(" Voltage: "));
353 Serial.print(voltage, 8);
354 Serial.println(F(" V"));
355 }
356 }
357
358 //! Reads the LTC2418 and displays the results
359 void test_LTC2418(float vref, uint16_t eoc_timeout)
360 {
361 float se_results[16], diff_results[16];
362 int32_t adc_code = 0;
363 uint8_t i;
364
365 quikeval_SPI_connect(); // Connect SPI to main data port
366 set_CS_decoder(LTC2418_CS_ADDR); // Set the decoder for the LTC2418 chip select
367
368 Serial.println(F("\nTesting LTC2418, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_32bit_data() function"));
369 Serial.println(F("Reading Single-Ended channels..."));
370
371 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
372 LTC24XX_SPI_8bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code); // Prime with CH0
373
374 for (i=0; i <= 15; i++)
375 {
376 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
377 LTC24XX_SPI_8bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
378 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
379 }
380
381 Serial.println(F("Reading out all Differential channels..."));
382
383 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
384 LTC24XX_SPI_8bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[0], &adc_code); // Prime with CH_P0_N1
385
386 for (i=0; i <= 7; i++)
387 {
388 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
389 LTC24XX_SPI_8bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
390 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
391 }
392
393 print_all(se_results, diff_results); // Display results
394 }
395
396 //! Reads the LTC2420 and displays the results
397 void test_LTC2420(float vref, uint16_t eoc_timeout)
398 {
399 float voltage = 0.0;
400 int32_t adc_code = 0;
401 uint8_t i;
402
403 quikeval_SPI_connect(); // Connect SPI to main data port
404 set_CS_decoder(LTC2420_CS_ADDR); // Set the decoder for the LTC2420 chip select
405
406 Serial.println(F("\nTesting LTC2420 with a 24 bit read using LTC24XX_SPI_24bit_data..."));
407
408 LTC24XX_EOC_timeout(CS, eoc_timeout); // First flush power-on conversion that probably happened before
409 LTC24XX_SPI_24bit_data(CS, &adc_code); // the DAC output was set
410
411 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
412 LTC24XX_SPI_24bit_data(CS, &adc_code); // Read the ADC
413 voltage = LTC24XX_SE_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
414
415 // Display results
416 Serial.print(F(" Formatted LTC2412 ADC code: "));
417 Serial.println(adc_code, HEX);
418 Serial.print(F(" Voltage: "));
419 Serial.print(voltage, 8);
420 Serial.println(F(" V"));
421 }
422
423 //! Reads the LTC2436 and displays the results
424 void test_LTC2436(float vref, uint16_t eoc_timeout)
425 {
426 float voltage = 0.0;
427 int32_t adc_code = 0;
428 uint8_t channel;
429 uint8_t i;
430
431 quikeval_SPI_connect(); // Connect SPI to main data port
432 set_CS_decoder(LTC2436_CS_ADDR); // Set the decoder for the LTC2436 chip select
433
434 Serial.println(F("\nTesting LTC2436 with a 24 bit read..."));
435
436 LTC24XX_EOC_timeout(CS, eoc_timeout); // First flush power-on conversion that probably happened before
437 LTC24XX_SPI_2ch_ping_pong_32bit_data(CS, &channel, &adc_code); // the DAC output was set
438
439 for (i=0; i <= 1; ++i)
440 {
441 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
442 LTC24XX_SPI_2ch_ping_pong_24bit_data(CS, &channel, &adc_code); // Read the ADC and channel
443 voltage = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
444
445 // Display results
446 Serial.print(F(" Formatted LTC2436 ADC code CH"));
447 Serial.print(channel);
448 Serial.print(F(": 0x"));
449 Serial.println(adc_code, HEX);
450 Serial.print(F(" Voltage: "));
451 Serial.print(voltage, 8);
452 Serial.println(F(" V"));
453 }
454 }
455
456 //! Reads the LTC2439 and displays the results
457 void test_LTC2439(float vref, uint16_t eoc_timeout)
458 {
459 float se_results[16], diff_results[16];
460 int32_t adc_code = 0;
461 uint8_t i;
462
463 quikeval_SPI_connect(); // Connect SPI to main data port
464 set_CS_decoder(LTC2439_CS_ADDR); // Set the decoder for the LTC2439 chip select
465
466 Serial.println(F("\nTesting LTC2439, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_24bit_data() function"));
467 Serial.println(F("Reading out all Single-Ended channels..."));
468
469 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
470 LTC24XX_SPI_8bit_command_24bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code); // Prime with CH0
471
472 for (i=0; i<=15; i++)
473 {
474 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
475 LTC24XX_SPI_8bit_command_24bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
476 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
477 }
478
479 Serial.println(F("Reading out all Differential channels..."));
480
481 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
482 LTC24XX_SPI_8bit_command_24bit_data(CS, DIFF_CONFIG_ARRAY[0], &adc_code); // Prime with CH_P0_N1
483
484 for (i=0; i<=7; i++)
485 {
486 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
487 LTC24XX_SPI_8bit_command_24bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
488 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
489 }
490
491 print_all(se_results, diff_results); // Display results
492 }
493
494 //! Reads the LTC2449 and displays the results
495 void test_LTC2449(float vref, uint16_t eoc_timeout)
496 {
497 float se_results[16], diff_results[16];
498 int32_t adc_code = 0;
499 uint8_t i;
500
501 quikeval_SPI_connect(); // Connect SPI to main data port
502 set_CS_decoder(LTC2449_CS_ADDR); // Set the decoder for the LTC2449 chip select
503
504 Serial.println(F("\nTesting LTC2449, 24 bit ADC with a 24 bit output word using LTC24XX_SPI_16bit_command_32bit_data() function"));
505 Serial.println(F("Reading out all Single-Ended channels..."));
506
507 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
508 LTC24XX_SPI_16bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], OSR_CONFIG_ARRAY[0], &adc_code); // Prime with CH0
509
510 for (i=0; i<=15; i++)
511 {
512 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
513 LTC24XX_SPI_16bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], OSR_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
514 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
515 }
516
517 Serial.println(F("Reading out all Differential channels..."));
518
519 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
520 LTC24XX_SPI_16bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[0], OSR_CONFIG_ARRAY[0], &adc_code); // Prime with CH_P0_N1
521
522 for (i=0; i<=7; i++)
523 {
524 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
525 LTC24XX_SPI_16bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], OSR_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
526 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
527 }
528
529 print_all(se_results, diff_results); // Display results
530 }
531
532 //! Reads the LTC2494 and displays the results
533 void test_LTC2494(float vref, uint16_t eoc_timeout)
534 {
535 float se_results[16], diff_results[16];
536 int32_t adc_code = 0;
537 uint8_t i;
538
539 quikeval_SPI_connect(); // Connect SPI to main data port
540 set_CS_decoder(LTC2494_CS_ADDR); // Set the decoder for the LTC2494 chip select
541
542 Serial.println(F("\nTesting LTC2494, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_24bit_data() function"));
543 Serial.println(F("Reading out all Single-Ended channels..."));
544
545 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
546 LTC24XX_SPI_8bit_command_24bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code); // Prime with CH0
547
548 for (i=0; i<=15; i++)
549 {
550 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
551 LTC24XX_SPI_8bit_command_24bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
552 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
553 }
554
555 Serial.println(F("Reading out all Differential channels..."));
556
557 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
558 LTC24XX_SPI_8bit_command_24bit_data(CS, DIFF_CONFIG_ARRAY[0], &adc_code); // Prime with CH_P0_N1
559
560 for (i=0; i<=7; i++)
561 {
562 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
563 LTC24XX_SPI_8bit_command_24bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
564 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
565 }
566
567 print_all(se_results, diff_results); // Display results
568 }
569
570 //! Reads the LTC2495 and displays the results
571 void test_LTC2495(float vref, uint16_t eoc_timeout)
572 {
573 int32_t adc_code = 0;
574 int8_t ack, i;
575 float se_results[16], diff_results[16];
576
577 quikeval_I2C_connect(); // Connect I2C to main data port
578
579 Serial.println(F("\nTesting LTC2495, 24 bit output using LTC24XX_I2C_16bit_command_32bit_data..."));
580 Serial.println(F("Reading out all Single-Ended channels..."));
581
582 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2495_ADDR, SINGLE_ENDED_CONFIG_ARRAY[0], 0, &adc_code, eoc_timeout); // Prime with CH0
583
584 for (i=0; i <= 15; i++)
585 {
586 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2495_ADDR, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], 0, &adc_code, eoc_timeout); // Read the ADC
587 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
588 }
589
590 Serial.println(F("Reading out all Differential channels..."));
591
592 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2495_ADDR, DIFF_CONFIG_ARRAY[0], 0, &adc_code, eoc_timeout); // Prime with CH_P0_N1
593 for (i=0; i <= 7; i++)
594 {
595 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2495_ADDR, DIFF_CONFIG_ARRAY[(i+1)%16], 0, &adc_code, eoc_timeout); // Read the ADC
596 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
597 }
598
599 if (!ack)
600 print_all(se_results, diff_results); // Display results
601 else
602 Serial.println(F("LTC2497 Nacked, check address."));
603 }
604
605 //! Reads the LTC2496 and displays the results
606 void test_LTC2496(float vref, uint16_t eoc_timeout)
607 {
608 float se_results[16], diff_results[16];
609 int32_t adc_code = 0;
610 uint8_t i;
611
612 quikeval_SPI_connect(); // Connect SPI to main data port
613 set_CS_decoder(LTC2496_CS_ADDR); // Set the decoder for the LTC2496 chip select
614
615 Serial.println(F("\nTesting LTC2496, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_32bit_data() function"));
616 Serial.println(F("Reading out all Single-Ended channels..."));
617
618 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
619 LTC24XX_SPI_8bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code); // Prime with CH0
620
621 for (i=0; i<=15; i++)
622 {
623 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
624 LTC24XX_SPI_8bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
625 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
626 }
627
628 Serial.println(F("Reading out all Differential channels..."));
629
630 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
631 LTC24XX_SPI_8bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[0], &adc_code); // Prime with CH_P0_N1
632
633 for (i=0; i<=7; i++)
634 {
635 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
636 LTC24XX_SPI_8bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code); // Read the ADC
637 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
638 }
639
640 print_all(se_results, diff_results); // Display results
641 }
642
643 //! Reads the LTC2497 and displays the results
644 void test_LTC2497(float vref, uint16_t eoc_timeout)
645 {
646 int32_t adc_code = 0;
647 int8_t ack, i;
648 float se_results[16], diff_results[16];
649
650 quikeval_I2C_connect(); // Connect I2C to main data port
651
652 Serial.println(F("\nTesting LTC2497, 16 bit output using LTC24XX_I2C_8bit_command_24bit_data..."));
653 Serial.println(F("Reading out all Single-Ended channels..."));
654
655 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code, eoc_timeout); // Prime with CH0
656
657 for (i=0; i <= 15; i++)
658 {
659 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code, eoc_timeout); // Read the ADC
660 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
661 }
662
663 Serial.println(F("Reading out all Differential channels..."));
664
665 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, DIFF_CONFIG_ARRAY[0], &adc_code, eoc_timeout); // Prime with CH_P0_N1
666
667 for (i=0; i <= 7; i++)
668 {
669 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code, eoc_timeout); // Read the ADC
670 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
671 }
672
673 if (!ack)
674 print_all(se_results, diff_results); // Display results
675 else
676 Serial.println(F("LTC2497 Nacked, check address."));
677 }
678
679 //! Reads the LTC2498 and displays the results
680 void test_LTC2498(float vref, uint16_t eoc_timeout)
681 {
682 float se_results[16], diff_results[16];
683 int32_t adc_code = 0;
684 uint8_t i;
685
686 quikeval_SPI_connect(); // Connect SPI to main data port
687 set_CS_decoder(LTC2498_CS_ADDR); // Set the decoder for the LTC2498 chip select
688
689 Serial.println(F("\nTesting LTC2498, 32 bit output using LTC24XX_SPI_16bit_command_32bit_data..."));
690
691 Serial.println(F("Reading out all Single-Ended channels..."));
692 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
693 LTC24XX_SPI_16bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], 0, &adc_code); // Prime with CH0
694 for (i=0; i<=15; i++)
695 {
696 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
697 LTC24XX_SPI_16bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], 0, &adc_code); // Read the ADC
698 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
699 }
700
701 Serial.println(F("Reading out all Differential channels..."));
702 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
703 LTC24XX_SPI_16bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[0], 0, &adc_code); //Prime with CH_P0_N1
704 for (i=0; i<=7; i++)
705 {
706 LTC24XX_EOC_timeout(CS, eoc_timeout); // Wait for end of conversion
707 LTC24XX_SPI_16bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], 0, &adc_code); // Read the ADC
708 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
709 }
710
711 print_all(se_results, diff_results); // Display results
712 }
713
714 //! Reads the LTC2499 and displays the results
715 void test_LTC2499(float vref, uint16_t eoc_timeout)
716 {
717 int32_t adc_code = 0;
718 int8_t ack, i;
719 float se_results[16], diff_results[16];
720
721 quikeval_I2C_connect(); // Connect I2C to main data port
722
723 Serial.println(F("\nTesting LTC2499, 24 bit output using LTC24XX_I2C_16bit_command_32bit_data..."));
724 Serial.println(F("Reading out all Single-Ended channels..."));
725
726 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2499_ADDR, SINGLE_ENDED_CONFIG_ARRAY[0], 0, &adc_code, eoc_timeout); // Prime with CH0
727
728 for (i=0; i <= 15; i++)
729 {
730 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2499_ADDR, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], 0, &adc_code, eoc_timeout); // Read the ADC
731 se_results[i%16] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
732 }
733
734 Serial.println(F("Reading out all Differential channels..."));
735
736 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2499_ADDR, DIFF_CONFIG_ARRAY[0], 0, &adc_code, eoc_timeout); // Prime with CH_P0_N1
737
738 for (i=0; i <= 7; i++)
739 {
740 ack = LTC24XX_I2C_16bit_command_32bit_data(LTC2499_ADDR, DIFF_CONFIG_ARRAY[(i+1)%16], 0, &adc_code, eoc_timeout); // Read the ADC
741 diff_results[i%8] = LTC24XX_diff_code_to_voltage(adc_code, vref); // Convert ADC code to voltage
742 }
743
744 if (!ack)
745 print_all(se_results, diff_results); // Display results
746 else
747 Serial.println(F("LTC2497 Nacked, check address."));
748 }
749
750 //! Sets the LTC6998, reads all the ADCs, and displays the results
751 void test_all(float vref, uint16_t eoc_timeout)
752 {
753 uint8_t i;
754 int32_t adc_code = 0;
755 float voltage;
756
757 // Write a ramp of voltages
758 set_CS_decoder(LTC2668_CS_ADDR); // And point to the LTC2668 first...
759 quikeval_SPI_connect(); // Connect SPI to main data port
760 for (i=0; i <= 15; ++i)
761 {
762 LTC2668_write(LTC2668_CS,LTC2668_CMD_WRITE_N_UPDATE_N, i, (i + 1) * 1312);
763 }
764
765 // Read all the ADCs
766 test_LTC2400(vref, eoc_timeout);
767 test_LTC2412(vref, eoc_timeout);
768 test_LTC2418(vref, eoc_timeout);
769 test_LTC2420(vref, eoc_timeout);
770 test_LTC2436(vref, eoc_timeout);
771 test_LTC2439(vref, eoc_timeout);
772 test_LTC2449(vref, eoc_timeout);
773 test_LTC2494(vref, eoc_timeout);
774 test_LTC2495(vref, eoc_timeout);
775 test_LTC2496(vref, eoc_timeout);
776 test_LTC2497(vref, eoc_timeout);
777 test_LTC2498(vref, eoc_timeout);
778 test_LTC2499(vref, eoc_timeout);
779
780 delay(150);
781
782 Serial.println(F("Done!"));
783 while (1) {}
784 }
785
786 /*** main() ********************************************************************
787 Main program initializes microcontroller registers, checks to see if calibration
788 mode is selected, reads calibration constants from nonvolatile memory.
789 Main loop reads ADC input and PTAT voltage, calculates temperatures and voltages,
790 then sends this information to the display.
791 *******************************************************************************/
792 /*
793 void loop()
794 {
795 // Write a ramp of voltages
796 set_CS_decoder(LTC2668_CS_ADDR); // And point to the LTC2668 first...
797 quikeval_SPI_connect(); // Connect SPI to main data port
798 for(i=0; i <= 15; ++i)
799 {
800 LTC2668_write(LTC2668_CS,LTC2668_CMD_WRITE_N_UPDATE_N, i, (i + 1) * 1312);
801 }
802
803 // Uncomment the following lines to test code to voltage function:
804 // Serial.print("Testing - Voltage is ");
805 // voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
806 // Serial.println(voltage, 6);
807
808 #ifdef TEST_LTC2400 // LTC24XX_SPI_32bit_data
809
810 quikeval_SPI_connect(); // Connect SPI to main data port
811 set_CS_decoder(LTC2400_CS_ADDR);
812 Serial.println("\nTesting LTC2400 with a 32 bit read using LTC24XX_SPI_32bit_data...");
813
814 LTC24XX_EOC_timeout(CS, 250); // First flush power-on conversion that probably happened before
815 LTC24XX_SPI_32bit_data(CS, &adc_code); // the DAC output was set
816
817 LTC24XX_EOC_timeout(CS, 250); // First flush power-on conversion that probably happened before
818 LTC24XX_SPI_32bit_data(CS, &adc_code); // the DAC output was set
819
820 Serial.print("Got formatted code ");
821 Serial.print(adc_code, HEX);
822 Serial.print(", Which is a voltage of ");
823 voltage = LTC24XX_SE_code_to_voltage(adc_code, LTC24XX_vref);
824 Serial.println(voltage, 8);
825
826 #endif // TEST_LTC2400
827
828
829 #ifdef TEST_LTC2418
830 set_CS_decoder(LTC2418_CS_ADDR); //LTC24XX_SPI_8bit_command_32bit_data
831
832 quikeval_SPI_connect(); // Connect SPI to main data port
833 Serial.println("\nTesting LTC2418, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_32bit_data() function");
834
835 Serial.println("Reading out all Single-Ended channels...");
836 LTC24XX_EOC_timeout(CS, 250);
837 LTC24XX_SPI_8bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code); //Prime with CH0
838 for(i=0; i<=15; i++)
839 {
840 LTC24XX_EOC_timeout(CS, 250);
841 LTC24XX_SPI_8bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code);
842 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
843 se_results[i%16] = voltage;
844 }
845
846 Serial.println("Reading out all Differential channels...");
847 LTC24XX_EOC_timeout(CS, 250);
848 LTC24XX_SPI_8bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[0], &adc_code); //Prime with CH_P0_N1
849 for(i=0; i<=7; i++)
850 {
851 LTC24XX_EOC_timeout(CS, 250);
852 LTC24XX_SPI_8bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code);
853 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
854 diff_results[i%8] = voltage;
855 }
856
857 print_all();
858
859 #endif // TEST_LTC2418
860
861
862 #ifdef TEST_LTC2498 //LTC24XX_SPI_16bit_command_32bit_data
863
864 set_CS_decoder(LTC2498_CS_ADDR);
865
866 quikeval_SPI_connect(); // Connect SPI to main data port
867 Serial.println("\nTesting LTC2498, 32 bit output using LTC24XX_SPI_16bit_command_32bit_data...");
868
869 Serial.println("Reading out all Single-Ended channels...");
870 LTC24XX_EOC_timeout(CS, 250);
871 LTC24XX_SPI_16bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], 0, &adc_code); //Prime with CH0
872 for(i=0; i<=15; i++)
873 {
874 LTC24XX_EOC_timeout(CS, 250);
875 LTC24XX_SPI_16bit_command_32bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], 0, &adc_code);
876 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
877 se_results[i%16] = voltage;
878 }
879
880 Serial.println("Reading out all Differential channels...");
881 LTC24XX_EOC_timeout(CS, 250);
882 LTC24XX_SPI_16bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[0], 0, &adc_code); //Prime with CH_P0_N1
883 for(i=0; i<=7; i++)
884 {
885 LTC24XX_EOC_timeout(CS, 250);
886 LTC24XX_SPI_16bit_command_32bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], 0, &adc_code);
887 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
888 diff_results[i%8] = voltage;
889 }
890
891 print_all();
892
893 #endif // TEST_LTC2498
894
895 #ifdef TEST_LTC2439 //LTC24XX_SPI_8bit_command_24bit_data
896 set_CS_decoder(LTC2439_CS_ADDR);
897
898 quikeval_SPI_connect(); // Connect SPI to main data port
899 Serial.println("\nTesting LTC2439, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_24bit_data() function");
900
901 Serial.println("Reading out all Single-Ended channels...");
902 LTC24XX_EOC_timeout(CS, 250);
903 LTC24XX_SPI_8bit_command_24bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code); //Prime with CH0
904 for(i=0; i<=15; i++)
905 {
906 LTC24XX_EOC_timeout(CS, 250);
907 LTC24XX_SPI_8bit_command_24bit_data(CS, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code);
908 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
909 se_results[i%16] = voltage;
910 }
911
912 Serial.println("Reading out all Differential channels...");
913 LTC24XX_EOC_timeout(CS, 250);
914 LTC24XX_SPI_8bit_command_24bit_data(CS, DIFF_CONFIG_ARRAY[0], &adc_code); //Prime with CH_P0_N1
915 for(i=0; i<=7; i++)
916 {
917 LTC24XX_EOC_timeout(CS, 250);
918 LTC24XX_SPI_8bit_command_24bit_data(CS, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code);
919 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
920 diff_results[i%8] = voltage;
921 }
922
923 print_all();
924 #endif // TEST_LTC2439
925
926 #ifdef TEST_LTC2420 // LTC24XX_SPI_32bit_data
927
928 quikeval_SPI_connect(); // Connect SPI to main data port
929 set_CS_decoder(LTC2420_CS_ADDR);
930 Serial.println("\nTesting LTC2420 with a 24 bit read using LTC24XX_SPI_24bit_data...");
931
932 LTC24XX_EOC_timeout(CS, 250); // First flush power-on conversion that probably happened before
933 LTC24XX_SPI_24bit_data(CS, &adc_code); // the DAC output was set
934
935 LTC24XX_EOC_timeout(CS, 250); // First flush power-on conversion that probably happened before
936 LTC24XX_SPI_24bit_data(CS, &adc_code); // the DAC output was set
937
938 Serial.print("Got formatted code "); Serial.print(adc_code, HEX);
939 Serial.print(", Which is a voltage of ");
940 voltage = LTC24XX_SE_code_to_voltage(adc_code, LTC24XX_vref);
941 Serial.println(voltage, 8);
942
943 #endif // TEST_LTC2420
944
945 #ifdef TEST_LTC2497
946 quikeval_I2C_connect();
947
948 Serial.println("\nTesting LTC2497, 24 bit output using LTC24XX_I2C_8bit_command_24bit_data...");
949 Serial.println("Reading out all Single-Ended channels...");
950
951 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, SINGLE_ENDED_CONFIG_ARRAY[0], &adc_code, 150); //Prime with CH0
952 for(i=0; i<=15; i++)
953 {
954 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, SINGLE_ENDED_CONFIG_ARRAY[(i+1)%16], &adc_code, 150);
955 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
956 se_results[i%16] = voltage;
957 }
958
959 Serial.println("Reading out all Differential channels...");
960
961 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, DIFF_CONFIG_ARRAY[0], &adc_code, 150); //Prime with CH_P0_N1
962 for(i=0; i<=7; i++)
963 {
964 LTC24XX_EOC_timeout(CS, 250);
965 ack = LTC24XX_I2C_8bit_command_24bit_data(LTC2497_ADDR, DIFF_CONFIG_ARRAY[(i+1)%16], &adc_code, 150);
966 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
967 diff_results[i%8] = voltage;
968 }
969
970 if(!ack)
971 print_all();
972 else
973 Serial.println("LTC2497 Nacked, check address.");}
974
975 #endif // TEST_LTC2497
976
977 #ifdef TEST_LTC2499
978 //int8_t LTC24XX_I2C_16bit_command_32bit_data(uint8_t i2c_address,uint8_t adc_command_high,
979 // uint8_t adc_command_low,int32_t *adc_code,uint16_t eoc_timeout)
980
981
982 #endif // TEST_LTC2499
983
984
985
986 #ifdef TEST_LTC2436
987 quikeval_SPI_connect(); // Connect SPI to main data port
988 set_CS_decoder(LTC2436_CS_ADDR);
989 Serial.println("\nTesting LTC2436 with a 24 bit read...");
990
991 LTC24XX_EOC_timeout(CS, 250); // First flush power-on conversion that probably happened before
992 LTC24XX_SPI_2ch_ping_pong_32bit_data(CS, &channel, &adc_code); // the DAC output was set
993
994 for(i=0; i<=1; ++i)
995 {
996 LTC24XX_EOC_timeout(CS, 250);
997 LTC24XX_SPI_2ch_ping_pong_24bit_data(CS, &channel, &adc_code);
998 Serial.print("Got formatted code "); Serial.print(adc_code, HEX);
999 Serial.print("From Channel "); Serial.print(channel);
1000 Serial.print(", Which is a voltage of ");
1001 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
1002 Serial.println(voltage, 8);
1003 }
1004
1005 #endif // TEST_LTC2436
1006
1007 #ifdef TEST_LTC2412
1008 quikeval_SPI_connect(); // Connect SPI to main data port
1009 set_CS_decoder(LTC2412_CS_ADDR);
1010 Serial.println("\nTesting LTC2412 with a 32 bit read...");
1011
1012 LTC24XX_EOC_timeout(CS, 250); // First flush power-on conversion that probably happened before
1013 LTC24XX_SPI_2ch_ping_pong_32bit_data(CS, &channel, &adc_code); // the DAC output was set
1014
1015 for(i=0; i<=1; ++i)
1016 {
1017 LTC24XX_EOC_timeout(CS, 250);
1018 LTC24XX_SPI_2ch_ping_pong_32bit_data(CS, &channel, &adc_code);
1019 Serial.print("Got formatted code "); Serial.print(adc_code, HEX);
1020 Serial.print("From Channel "); Serial.print(channel);
1021 Serial.print(", Which is a voltage of ");
1022 voltage = LTC24XX_diff_code_to_voltage(adc_code, LTC24XX_vref);
1023 Serial.println(voltage, 8);
1024 }
1025
1026 #endif // TEST_LTC2412
1027
1028 delay(150);
1029
1030 Serial.println("Done!");
1031 while(1){}
1032
1033 }
1034 */
demo_board
struct demo_board_type demo_board
Instantiate demo board structure.
Definition: QuikEval_EEPROM.cpp:71
LTC24XX_MULTI_CH_OSR_32768
#define LTC24XX_MULTI_CH_OSR_32768
Definition: LTC24XX_general.h:251
LTC24XX_MULTI_CH_CH3
#define LTC24XX_MULTI_CH_CH3
Definition: LTC24XX_general.h:185
test_LTC2420
static void test_LTC2420(float vref, uint16_t eoc_timeout)
Reads the LTC2420 and displays the results.
Definition: LTC24XX_general_test.ino:397
LTC2412_CS_ADDR
#define LTC2412_CS_ADDR
Decoder address for the LTC2412 chip select.
Definition: LTC24XX_general_test.ino:70
LTC24XX_SPI_32bit_data
void LTC24XX_SPI_32bit_data(uint8_t cs, int32_t *adc_code)
Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
Definition: LTC24XX_general.cpp:103
LTC24XX_MULTI_CH_CH14
#define LTC24XX_MULTI_CH_CH14
Definition: LTC24XX_general.h:196
LTC24XX_MULTI_CH_OSR_8192
#define LTC24XX_MULTI_CH_OSR_8192
Definition: LTC24XX_general.h:249
test_LTC2418
static void test_LTC2418(float vref, uint16_t eoc_timeout)
Reads the LTC2418 and displays the results.
Definition: LTC24XX_general_test.ino:359
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: LTC24XX_general_test.ino:145
QuikEval_EEPROM_Wire.h
QuikEval EEPROM Library.
LTC24XX_MULTI_CH_CH8
#define LTC24XX_MULTI_CH_CH8
Definition: LTC24XX_general.h:190
LTC24XX_MULTI_CH_CH15
#define LTC24XX_MULTI_CH_CH15
Definition: LTC24XX_general.h:197
USE_WIRE.h
LTC24XX_MULTI_CH_CH13
#define LTC24XX_MULTI_CH_CH13
Definition: LTC24XX_general.h:195
LTC24XX_MULTI_CH_CH1
#define LTC24XX_MULTI_CH_CH1
Definition: LTC24XX_general.h:183
LTC24XX_MULTI_CH_OSR_256
#define LTC24XX_MULTI_CH_OSR_256
Definition: LTC24XX_general.h:244
test_LTC2497
static void test_LTC2497(float vref, uint16_t eoc_timeout)
Reads the LTC2497 and displays the results.
Definition: LTC24XX_general_test.ino:644
LTC24XX_MULTI_CH_CH6
#define LTC24XX_MULTI_CH_CH6
Definition: LTC24XX_general.h:188
LTC24XX_MULTI_CH_P13_N12
#define LTC24XX_MULTI_CH_P13_N12
Definition: LTC24XX_general.h:225
LTC24XX_MULTI_CH_OSR_1024
#define LTC24XX_MULTI_CH_OSR_1024
Definition: LTC24XX_general.h:246
LTC2494_CS_ADDR
#define LTC2494_CS_ADDR
Decoder address for the LTC2494 chip select.
Definition: LTC24XX_general_test.ino:67
LTC24XX_MULTI_CH_P1_N0
#define LTC24XX_MULTI_CH_P1_N0
Definition: LTC24XX_general.h:207
LTC2436_CS_ADDR
#define LTC2436_CS_ADDR
Decoder address for the LTC2436 chip select.
Definition: LTC24XX_general_test.ino:71
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC2449_CS_ADDR
#define LTC2449_CS_ADDR
Decoder address for the LTC2449 chip select.
Definition: LTC24XX_general_test.ino:66
LTC2420_CS_ADDR
#define LTC2420_CS_ADDR
Decoder address for the LTC2420 chip select.
Definition: LTC24XX_general_test.ino:73
LTC2499_ADDR
#define LTC2499_ADDR
Definition: LTC24XX_general_test.ino:80
LTC24XX_EOC_timeout
int8_t LTC24XX_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
Definition: LTC24XX_general.cpp:82
LTC24XX_SPI_8bit_command_24bit_data
void LTC24XX_SPI_8bit_command_24bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit output word...
Definition: LTC24XX_general.cpp:195
LTC24XX_MULTI_CH_CH5
#define LTC24XX_MULTI_CH_CH5
Definition: LTC24XX_general.h:187
print_all
static void print_all(float *se_results, float *diff_results)
Displays the the data in the arrays.
Definition: LTC24XX_general_test.ino:233
channel
static uint8_t channel
LTC2305 Channel selection.
Definition: DC1444A.ino:127
LTC24XX_MULTI_CH_P4_N5
#define LTC24XX_MULTI_CH_P4_N5
Definition: LTC24XX_general.h:212
LTC24XX_MULTI_CH_CH0
#define LTC24XX_MULTI_CH_CH0
Definition: LTC24XX_general.h:182
LTC2418_CS_ADDR
#define LTC2418_CS_ADDR
Decoder address for the LTC2418 chip select.
Definition: LTC24XX_general_test.ino:65
LTC2668_write
int8_t LTC2668_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2668.
Definition: LTC2668.cpp:70
LTC24XX_MULTI_CH_CH11
#define LTC24XX_MULTI_CH_CH11
Definition: LTC24XX_general.h:193
LTC24XX_I2C_8bit_command_24bit_data
int8_t LTC24XX_I2C_8bit_command_24bit_data(uint8_t i2c_address, uint8_t adc_command, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit result.
Definition: LTC24XX_general.cpp:268
LTC2498_CS_ADDR
#define LTC2498_CS_ADDR
Decoder address for the LTC2498 chip select.
Definition: LTC24XX_general_test.ino:68
test_LTC2496
static void test_LTC2496(float vref, uint16_t eoc_timeout)
Reads the LTC2496 and displays the results.
Definition: LTC24XX_general_test.ino:606
LTC24XX_SPI_8bit_command_32bit_data
void LTC24XX_SPI_8bit_command_32bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 32 bit result.
Definition: LTC24XX_general.cpp:118
test_LTC2495
static void test_LTC2495(float vref, uint16_t eoc_timeout)
Reads the LTC2495 and displays the results.
Definition: LTC24XX_general_test.ino:571
LTC24XX_general.h
LTC24XX General Library: Functions and defines for all SINC4 Delta Sigma ADCs.
LTC24XX_MULTI_CH_P9_N8
#define LTC24XX_MULTI_CH_P9_N8
Definition: LTC24XX_general.h:219
LTC24XX_MULTI_CH_P14_N15
#define LTC24XX_MULTI_CH_P14_N15
Definition: LTC24XX_general.h:227
LTC24XX_SPI_16bit_command_32bit_data
void LTC24XX_SPI_16bit_command_32bit_data(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 32 bit result.
Definition: LTC24XX_general.cpp:136
LTC24XX_MULTI_CH_OSR_64
#define LTC24XX_MULTI_CH_OSR_64
Definition: LTC24XX_general.h:242
CS
#define CS
The chip select.
Definition: LTC24XX_general_test.ino:61
LTC24XX_MULTI_CH_CH2
#define LTC24XX_MULTI_CH_CH2
Definition: LTC24XX_general.h:184
LTC2497_ADDR
#define LTC2497_ADDR
Definition: LTC24XX_general_test.ino:79
LTC2668_CS_ADDR
#define LTC2668_CS_ADDR
Decoder address for the LTC2668 chip select.
Definition: LTC24XX_general_test.ino:63
test_LTC2498
static void test_LTC2498(float vref, uint16_t eoc_timeout)
Reads the LTC2498 and displays the results.
Definition: LTC24XX_general_test.ino:680
eoc_timeout
static uint16_t eoc_timeout
timeout in ms
Definition: LTC2492_Panel_Meter.ino:135
LTC2496_CS_ADDR
#define LTC2496_CS_ADDR
Decoder address for the LTC2496 chip select.
Definition: LTC24XX_general_test.ino:69
LTC2668.h
LTC2668: 16-Channel SPI 16-/12-Bit +/-10V Vout SoftSpan DACs with 10ppm/C Max Reference.
LT_I2C_Wire.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC24XX_MULTI_CH_P3_N2
#define LTC24XX_MULTI_CH_P3_N2
Definition: LTC24XX_general.h:210
QuikEval_EEPROM.h
QuikEval EEPROM Library.
LTC24XX_I2C_16bit_command_32bit_data
int8_t LTC24XX_I2C_16bit_command_32bit_data(uint8_t i2c_address, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 32 bit result.
Definition: LTC24XX_general.cpp:350
LTC24XX_MULTI_CH_OSR_4096
#define LTC24XX_MULTI_CH_OSR_4096
Definition: LTC24XX_general.h:248
LTC24XX_MULTI_CH_P2_N3
#define LTC24XX_MULTI_CH_P2_N3
Definition: LTC24XX_general.h:209
LTC24XX_MULTI_CH_OSR_16384
#define LTC24XX_MULTI_CH_OSR_16384
Definition: LTC24XX_general.h:250
LTC24XX_MULTI_CH_OSR_128
#define LTC24XX_MULTI_CH_OSR_128
Definition: LTC24XX_general.h:243
test_LTC2400
static void test_LTC2400(float vref, uint16_t eoc_timeout)
Reads the LTC2400 and displays the results.
Definition: LTC24XX_general_test.ino:299
setup
static void setup()
Initialize Linduino.
Definition: LTC24XX_general_test.ino:148
quikeval_SPI_init
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
test_LTC2499
static void test_LTC2499(float vref, uint16_t eoc_timeout)
Reads the LTC2499 and displays the results.
Definition: LTC24XX_general_test.ino:715
test_LTC2494
static void test_LTC2494(float vref, uint16_t eoc_timeout)
Reads the LTC2494 and displays the results.
Definition: LTC24XX_general_test.ino:533
discover_demo_board
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
Definition: QuikEval_EEPROM.cpp:141
SINGLE_ENDED_CONFIG_ARRAY
const uint8_t SINGLE_ENDED_CONFIG_ARRAY[16]
Lookup table to build the command for single-ended mode.
Definition: LTC24XX_general_test.ino:104
LTC24XX_MULTI_CH_P10_N11
#define LTC24XX_MULTI_CH_P10_N11
Definition: LTC24XX_general.h:221
LTC24XX_MULTI_CH_CH12
#define LTC24XX_MULTI_CH_CH12
Definition: LTC24XX_general.h:194
test_LTC2412
static void test_LTC2412(float vref, uint16_t eoc_timeout)
Reads the LTC2412 and displays the results.
Definition: LTC24XX_general_test.ino:326
LTC24XX_MULTI_CH_OSR_512
#define LTC24XX_MULTI_CH_OSR_512
Definition: LTC24XX_general.h:245
LTC24XX_SPI_2ch_ping_pong_24bit_data
void LTC24XX_SPI_2ch_ping_pong_24bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel pa...
Definition: LTC24XX_general.cpp:239
LTC24XX_MULTI_CH_P12_N13
#define LTC24XX_MULTI_CH_P12_N13
Definition: LTC24XX_general.h:224
LTC2439_CS_ADDR
#define LTC2439_CS_ADDR
Decoder address for the LTC2439 chip select.
Definition: LTC24XX_general_test.ino:64
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
loop
static void loop()
Repeats Linduino loop.
Definition: LTC24XX_general_test.ino:169
LTC24XX_MULTI_CH_CH7
#define LTC24XX_MULTI_CH_CH7
Definition: LTC24XX_general.h:189
LTC24XX_MULTI_CH_P5_N4
#define LTC24XX_MULTI_CH_P5_N4
Definition: LTC24XX_general.h:213
LTC2495_ADDR
#define LTC2495_ADDR
Definition: LTC24XX_general_test.ino:78
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC24XX_MULTI_CH_P8_N9
#define LTC24XX_MULTI_CH_P8_N9
Definition: LTC24XX_general.h:218
LTC24XX_MULTI_CH_P7_N6
#define LTC24XX_MULTI_CH_P7_N6
Definition: LTC24XX_general.h:216
LTC24XX_diff_code_to_voltage
float LTC24XX_diff_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an ADC code, given the reference voltage. ...
Definition: LTC24XX_general.cpp:389
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
test_LTC2436
static void test_LTC2436(float vref, uint16_t eoc_timeout)
Reads the LTC2436 and displays the results.
Definition: LTC24XX_general_test.ino:424
LTC24XX_MULTI_CH_CH10
#define LTC24XX_MULTI_CH_CH10
Definition: LTC24XX_general.h:192
LTC2668_CMD_WRITE_N_UPDATE_N
#define LTC2668_CMD_WRITE_N_UPDATE_N
Write to input register n, update (power-up)
Definition: LTC2668.h:98
EOC_timout
static uint16_t EOC_timout
Definition: LTC2442_Datalogger.ino:97
LTC24XX_MULTI_CH_CH9
#define LTC24XX_MULTI_CH_CH9
Definition: LTC24XX_general.h:191
demo_board_type::product_name
char product_name[15]
LTC Product (LTC2654-L16)
Definition: QuikEval_EEPROM.h:70
LTC24XX_MULTI_CH_P15_N14
#define LTC24XX_MULTI_CH_P15_N14
Definition: LTC24XX_general.h:228
test_LTC2449
static void test_LTC2449(float vref, uint16_t eoc_timeout)
Reads the LTC2449 and displays the results.
Definition: LTC24XX_general_test.ino:495
LTC24XX_SPI_2ch_ping_pong_32bit_data
void LTC24XX_SPI_2ch_ping_pong_32bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel pa...
Definition: LTC24XX_general.cpp:155
test_LTC2439
static void test_LTC2439(float vref, uint16_t eoc_timeout)
Reads the LTC2439 and displays the results.
Definition: LTC24XX_general_test.ino:457
OSR_CONFIG_ARRAY
const uint8_t OSR_CONFIG_ARRAY[16]
Lookup table to build the OSR command.
Definition: LTC24XX_general_test.ino:119
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
quikeval_I2C_connect
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
i
static int i
Definition: DC2430A.ino:184
LTC2400_CS_ADDR
#define LTC2400_CS_ADDR
Decoder address for the LTC2400 chip select.
Definition: LTC24XX_general_test.ino:72
voltage
static float voltage
Definition: DC2289AA.ino:71
LTC24XX_MULTI_CH_P11_N10
#define LTC24XX_MULTI_CH_P11_N10
Definition: LTC24XX_general.h:222
LTC24XX_MULTI_CH_OSR_2048
#define LTC24XX_MULTI_CH_OSR_2048
Definition: LTC24XX_general.h:247
LTC24XX_SE_code_to_voltage
float LTC24XX_SE_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an ADC code, given the reference voltage. ...
Definition: LTC24XX_general.cpp:375
LTC24XX_SPI_24bit_data
void LTC24XX_SPI_24bit_data(uint8_t cs, int32_t *adc_code)
Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
Definition: LTC24XX_general.cpp:176
vref
float vref
Definition: LTC2492_Thermocouple_Meter.ino:129
LTC24XX_MULTI_CH_P0_N1
#define LTC24XX_MULTI_CH_P0_N1
Definition: LTC24XX_general.h:206
DIFF_CONFIG_ARRAY
const uint8_t DIFF_CONFIG_ARRAY[16]
Lookup table to build the command for differential mode.
Definition: LTC24XX_general_test.ino:111
LTC24XX_MULTI_CH_CH4
#define LTC24XX_MULTI_CH_CH4
Definition: LTC24XX_general.h:186
test_all
static void test_all(float vref, uint16_t eoc_timeout)
Sets the LTC6998, reads all the ADCs, and displays the results.
Definition: LTC24XX_general_test.ino:751
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113
LTC24XX_MULTI_CH_P6_N7
#define LTC24XX_MULTI_CH_P6_N7
Definition: LTC24XX_general.h:215
LTC2668_CS
#define LTC2668_CS
Define the SPI CS pin.
Definition: LTC2668.h:90
set_CS_decoder
static void set_CS_decoder(uint8_t CS_addr)
Definition: LTC24XX_general_test.ino:262