LTC1856 - 8-Channel, ±10V Input 16-Bit, 100ksps ADC Converter with Shutdown

Features

  • Single 5V Supply
  • Sample Rate: 100ksps
  • 8-Channel Multiplexer with ±30V Protection
  • ±10V Bipolar Input Range
      Single Ended or Differential
  • ±3LSB INL for the LTC1856,
    ±1.5LSB INL for the LTC1855,
    ±1LSB INL for the LTC1854
  • Power Dissipation: 40mW (Typ)
  • SPI/MICROWIRETM Compatible Serial I/O
  • Power Shutdown: Nap and Sleep
  • SINAD: 87dB (LTC1856)
  • Operates with Internal or External Reference
  • Internal Synchronized Clock
  • 28-Pin SSOP Package

Typical Application

LTC1856 Typical Application
LTC1856 Typical Application

Description

The LTC1854/LTC1855/LTC1856 are 8-channel, low power, 12-/14-/16-bit, 100ksps, analog-to-digital converters (ADCs). These ADCs operate from a single 5V supply and the 8-channel multiplexer can be programmed for single-ended inputs, pairs of differential inputs, or combinations of both. In addition, all channels are fault protected to ±30V. A fault condition on any channel will not affect the conversion result of the selected channel.

An onboard precision reference minimizes external components. Power dissipation is 40mW at 100ksps and lower in two power shutdown modes (27.5mW in Nap mode and 40mW in Sleep mode.) DC specifications include ±3LSB INL for the LTC1856, ±1.5LSB INL for the LTC1855 and ±1LSB for the LTC1854.

The internal clock is trimmed for 5ms maximum conversion time and the sampling rate is guaranteed at 100ksps. A separate convert start input and data ready signal (BUSY) ease connections to FIFOs, DSPs and microprocessors.

Packaging

CAD Symbols and Footprints: The downloadable Zip file below contains the schematic symbol and PCB footprints.

For complete and up to date package information and drawings, please refer to our packaging page

Part Number Package Code Temp Package
Drawing
RoHS
LTC1856CG#PBF SSOP-28 G C 05-08-1640 (G28) Yes
LTC1856CG#TRPBF SSOP-28 G C 05-08-1640 (G28) Yes
LTC1856IG#PBF SSOP-28 G I 05-08-1640 (G28) Yes
LTC1856IG#TRPBF SSOP-28 G I 05-08-1640 (G28) Yes


LTC1856 Package Drawing

Order Info

  • Part numbers ending in PBF are lead free. Solder plated terminal finish (SnPb) versions are non-standard and special terms and conditions and pricing applies if available. Please contact LTC marketing for information.
  • Part numbers containing TR or TRM are shipped in tape and reel or 500 unit mini tape and reel, respectively
  • Please refer to our general ordering information or the product datasheet for more details

Package Variations and Pricing

Part Number Package Temp Price
(1-99)
Price
(1k)*
RoHS
LTC1856CG#PBF SSOP-28 C $18.96 $12.95 Yes
LTC1856CG#TRPBF SSOP-28 C $13.00 Yes
LTC1856IG#PBF SSOP-28 I $22.76 $15.54 Yes
LTC1856IG#TRPBF SSOP-28 I $15.60 Yes
Buy NowRequest Samples
* The USA list pricing shown is for BUDGETARY USE ONLY, shown in United States dollars (FOB USA per unit for the stated volume), and is subject to change. International prices may differ due to local duties, taxes, fees and exchange rates. For volume-specific price or delivery quotes, please contact your local Linear Technology sales office or authorized distributor.

Demo Boards

Linear Technology offers many demo boards free of charge to qualified customers. Contact your local sales office or distributor to inquire about a demo board. Certain demo boards are also available for sale via credit card on this website. Demo boards are for evaluation purposes only. It remains the customer’s responsibility to verify proper and reliable operation in the actual end application.

Part Number Description Price Documentation
DC682A LTC1859CG Demo Board | 8-Channel, 16-Bit, 100ksps SoftSpan ADC (req DC2026) $50.00
Buy Now

Companion Boards

Part Number Description Price Documentation
DC2026C Linduino One Isolated USB Demo Board: An Arduino- and QuikEval-Compatible Code Development Platform $75.00
Buy Now
Click here to view our complete list of demo boards

Applications

  • Industrial Process Control
  • Multiplexed Data Acquisition Systems
  • High Speed Data Acquisition for PCs
  • Digital Signal Processing

Product Notifications

Please login to your MyLinear account for notifications of datasheet updates, new document releases and LTspice model announcements for your favorite products. If you do not have a MyLinear account you may Sign Up Now.

Forgot your password? Click here.
Need help? Email mylinear@linear.com with questions and comments.

Design Tools

Linduino

Linduino is an Arduino compatible platform for developing and distributing firmware libraries and code for SPI and I²C-compatible integrated circuits. The Linduino One board interfaces to more than 300 QuikEval demonstration cards, supporting a variety of product types including analog-to-digital converters (ADCs)digital-to-analog converters (DACs)power monitors, and more. Firmware libraries for individual devices are written in C and designed to be portable to a wide variety of processors and microcontrollers. Each library has a demonstration program that can be uploaded to the Linduino One platform to allow the circuit and software to be quickly and easily verified.

Click here for more information on Linduino

Code

Linduino is Linear Technology's Arduino compatible system for developing and distributing firmware libraries and example code for Linear Technology’s integrated circuits. The code below can be downloaded or copied and pasted into your project. Please visit the Linduino Home Page for demo board, manual and setup information.

This part is Code Supported: There is example code available for this part. The code below may rely on other drivers available in the full library.

Download LTC1856 - Linduino Header File

/*!
LTC1856: 16-bit 8-channel 100ksps ADC

@verbatim

The LTC1857/1858/LTC1856 are pin-compatible, 8-channel 12-/14-/16-bit A/D converters 
with serial I/O, and an internal reference. The ADCs typically draw only 1.3mA 
from a single 5V supply. The 8-channel input multiplexer can be configured for 
either single-ended or differential inputs and unipolar or bipolar conversions 
(or combinations thereof). The automatic nap and sleep modes benefit power 
sensitive applications. 

The LTC1856's DC performance is outstanding with a +/-2LSB INL specification and 
no missing codes over temperature. The signal-to-noise ratio (SNR) for the 
LTC1856 is typically 89dB, with the internal reference. 

SPI DATA FORMAT (MSB First):

            Byte #1                           Byte #2
Data Out :  D15 D14 D13 D12 D11 D10  D9  D8    D7  D6  D5  D4  D3  D2  D1  D0
Data In  :  SD  OS  S1  S0  UNI GAIN NAP SLP   X   X   X   X   X   X   X   X

SD   : Single/Differential Bit
OS   : ODD/Sign Bit
Sx   : Address Select Bit
UNI  : Unipolar/Bipolar Bit
GAIN : Input Span Bit
NAP  : Nap Mode Bit
SLP  : Sleep Mode Bit
Dx   : Data Bits
X    : Don't care


Example Code:

Read Channel 0 in Single-Ended Unipolar mode when input is with respect to GND

    adc_command = LTC1856_CH0 | LTC1856_UNIPOLAR_MODE | LTC1856_LOW_GAIN_MODE | LTC1856_NORMAL_MODE;     // Single-ended, CH0, unipolar, low gain, normal mode.
    LTC1856_read(LTC1856_CS, adc_command, &adc_code);   // Throws out last reading
    LTC1856_read(LTC1856_CS, adc_command, &adc_code);   // Obtains the current reading and stores to adc_code variable

    // Convert adc_code to voltage
    adc_voltage = LTC1856_unipolar_code_to_voltage(adc_code, LTC1856_lsb, LTC1856_offset_unipolar_code);

@endverbatim

http://www.linear.com/product/LTC1856

http://www.linear.com/product/LTC1856#demoboards

REVISION HISTORY
$Revision: 1807 $
$Date: 2013-07-29 13:06:06 -0700 (Mon, 29 Jul 2013) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

/*! @file
    @ingroup LTC1856
    Header for LTC1856: 16-bit 8-channel 100ksps ADC
*/

#ifndef LTC1856_H
#define LTC1856_H

#include <SPI.h>

//! Define the SPI CS pin
#ifndef LTC1856_CS
#define LTC1856_CS QUIKEVAL_CS
#endif

//! @name LTC1856 Single-Ended Channel Addresses
//! @{
// Single-Ended Channel Address
#define LTC1856_CH0             0x80
#define LTC1856_CH1             0xC0
#define LTC1856_CH2             0x90
#define LTC1856_CH3             0xD0
#define LTC1856_CH4             0xA0
#define LTC1856_CH5             0xE0
#define LTC1856_CH6             0xB0
#define LTC1856_CH7             0xF0
//!@}

//! @name LTC1856 Differential Channel Addresses
//! @{
// Differential Channel Address
#define LTC1856_P0_N1           0x00
#define LTC1856_P1_N0           0x40

#define LTC1856_P2_N3           0x10
#define LTC1856_P3_N2           0x50

#define LTC1856_P4_N5           0x20
#define LTC1856_P5_N4           0x60

#define LTC1856_P6_N7           0x30
#define LTC1856_P7_N6           0x70
//!@}

//! @name LTC1856 Sleep/Nap config bits
//! @{
// Sleep Mode Command
#define LTC1856_SLEEP_MODE      0x01
#define LTC1856_NORMAL_MODE     0x00
// Nap Mode Command
#define LTC1856_NAP_MODE   	  0x02
//!@}

// Single-Ended Mode Command
#define LTC1856_SINGLE_ENDED_MODE   0x01
#define LTC1856_DIFFERENTIAL_MODE  0x00

/*
  Example command
  adc_command = LTC1856_CH0 | LTC1856_NORMAL_MODE;     // Single-ended, CH0, normal mode.
 */


//! Builds the ADC command and returns an 8 bit command
//! @return  8 bit command
uint8_t LTC1856_build_command(uint8_t ch_designate
			);


//! Reads the ADC and returns 16-bit data
//! @return void
void LTC1856_read(uint8_t cs,           //!< Chip Select Pin 
                  uint8_t adc_command,  //!< Channel address, config bits ORed together
                  uint16_t *adc_code    //!< Returns code read from ADC (from previous conversion)
                 );


//! Calculates the LTC1856 input's unipolar voltage given the binary data and lsb weight.
//! @return Floating point voltage
float LTC1856_code_to_voltage(uint16_t adc_code,                   //!< Raw ADC code
                                       float vref	//!< 
                                      );

#endif  //  LTC1856_H

Download LTC1856 - Linduino.CPP File

/*!
LTC1856: 16-Bit 8-Channel 200ksps ADC

@verbatim

The LTC1863/LTC1856 are pin-compatible, 8-channel 12-/16-bit A/D converters with 
serial I/O, and an internal reference. The ADCs typically draw only 1.3mA from a 
single 5V supply. The 8-channel input multiplexer can be configured for either 
single-ended or differential inputs and unipolar or bipolar conversions (or 
combinations thereof). The automatic nap and sleep modes benefit power sensitive 
applications. 

The LTC1856's DC performance is outstanding with a +/-2LSB INL specification and 
no missing codes over temperature. The signal-to-noise ratio (SNR) for the 
LTC1856 is typically 89dB, with the internal reference. 

@endverbatim

http://www.linear.com/product/LTC1856

http://www.linear.com/product/LTC1856#demoboards

REVISION HISTORY
$Revision: 1785 $
$Date: 2013-07-25 08:47:24 -0700 (Thu, 25 Jul 2013) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

//! @defgroup LTC1856 LTC1856: 16-Bit 8-Channel 200ksps ADC

/*! @file
    @ingroup LTC1856
    Library for LTC1856: 16-Bit 8-Channel 200ksps ADC
*/

#include <Arduino.h>
#include <stdint.h>
#include "Linduino.h"
#include "LT_SPI.h"
#include "LTC1856.h"
#include <SPI.h>


// Builds the ADC command
uint8_t LTC1856_build_command(uint8_t ch_designate)
{
  uint8_t adc_command;
  adc_command = ch_designate;
  return (adc_command);
}


// Reads the ADC  and returns 16-bit data
void LTC1856_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
{
  spi_transfer_word(cs, (uint16_t)(adc_command<<8), adc_code);
}


// Calculates the LTC1856 input voltage given the data, vref, bits, and unipolar/bipolar status.
float LTC1856_code_to_voltage(uint16_t adc_code, float vref)
{
  float voltage;
  float sign = 1;

  if ((adc_code & 0x8000) == 0x8000)	//adc code is < 0
  {
	adc_code = (adc_code ^ 0xFFFF)+1;                                    //! Convert ADC code from two's complement to binary
    sign = -1;
  }

  voltage = sign*(float)adc_code;
  voltage = voltage / (pow(2,15)-1);    //! 2) This calculates the input as a fraction of the reference voltage (dimensionless)
  voltage = voltage * vref;           //! 3) Multiply fraction by Vref to get the actual voltage at the input (in volts)

  return(voltage);
}

Download LTC1859 - DC682A Linduino .INO File

/*!
Linear Technology DC682A Demonstration Board.
LTC1859: 16-Bit, 8-Channel 100ksps SAR ADC with SPI Interface.

@verbatim

NOTES
  Setup:
   Set the terminal baud rate to 115200 and select the newline terminator.
   Equipment required is a precision voltage source (null box) and a precision voltmeter (to monitor voltage source).
   No external power supply is required.
   Ensure JP1 is installed in the default position from the factory.

  How to test Single-Ended mode:
   Bipolar Mode:
     The voltage source should be connected to the channel under test. The negative lead of the voltage source
     must be connected to the GND pin in order to provide a ground-referenced voltage. Ensure voltage is within the
     range of -5V to +5V for low range mode, and -10V to +10V for high range mode.

   Unipolar Mode:
     The voltage source should be connected to the channel under test. The negative lead of the voltage source
     must be connected to the GND pin in order to provide a ground-referenced voltage. Ensure voltage is within the
     range of 0 to +5V for low range mode, and 0 to +10V for high range mode.

  How to test Differential Mode:
   Bipolar Mode:
     The voltage source should be connected with positive and negative leads to paired channels. The negative lead of the voltage source
     must also be connected to the GND pin in order to provide a ground-referenced voltage. Ensure the differential voltage is within the
     range of -5V to +5V for low range mode, and -10V to +10V for high range mode. Swapping input voltages results in a reversed polarity reading.

   Unipolar Mode:
     The voltage source should be connected with positive and negative leads to paired channels. The negative lead of the voltage source
     must also be connected to the GND pin in order to provide a ground-referenced voltage. Ensure the differential voltage is within the
     range of 0V to +5V for low range mode, and 0V to +10V for high range mode. Swapping input voltages results in a reversed polarity reading.

USER INPUT DATA FORMAT:
 decimal : 1024
 hex     : 0x400
 octal   : 02000  (leading 0 "zero")
 binary  : B10000000000
 float   : 1024.0

@endverbatim

http://www.linear.com/product/LTC1859

http://www.linear.com/product/LTC1859#demoboards

REVISION HISTORY
$Revision: 1792 $
$Date: 2013-08-9 13:58:53 -0700 (Thu, 25 Jul 2013) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

/*! @file
    @ingroup LTC1859
*/

#include <Arduino.h>
#include <stdint.h>
#include "Linduino.h"
#include "LT_SPI.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "LTC1859.h"
#include <SPI.h>
#include <Wire.h>

// Function Declaration
void print_title();                                     // Print the title block
void print_prompt();                                    // Prompt the user for an input command
uint8_t print_user_command_differential();             // Display selected differential channels
uint8_t print_user_command_single_ended();             // Display selected single ended channels
void print_channel_selection(uint8_t menu);

void menu_1_read_input();                             // Read channels
void menu_2_select_single_ended_differential();       // Sets LTC1859 to Single-Ended or Differential
void menu_3_select_uni_bipolar();                       // Sets LTC1859 to Bipolar or Unipolar
void menu_4_select_range();                       // Sets LTC1859 to high or low input range
void menu_5_sleep();                                  

// Global variables
static uint8_t uni_bipolar = LTC1859_UNIPOLAR_MODE;    //!< Default set for unipolar mode
static uint8_t single_ended_differential = LTC1859_SINGLE_ENDED_MODE;    //!< LTC1859 Unipolar or Bipolar mode selection
static uint8_t range_low_high = LTC1859_HIGH_RANGE_MODE;   //!< Default set for high range mode
static float LTC1859_bits = 16;                      //!< Resolution (16 bits)
static float LTC1859_vref = 10; 

// Constants
//! Lookup table to build the command for single-ended mode, input with respect to GND
const uint8_t BUILD_COMMAND_SINGLE_ENDED[8] = {LTC1859_CH0, LTC1859_CH1, LTC1859_CH2, LTC1859_CH3,
    LTC1859_CH4, LTC1859_CH5, LTC1859_CH6, LTC1859_CH7
                                              }; //!< Builds the command for single-ended mode, input with respect to GND

//! Lookup table to build the command for differential mode with the selected uni/bipolar mode
const uint8_t BUILD_COMMAND_DIFF[8] = {LTC1859_P0_N1, LTC1859_P2_N3, LTC1859_P4_N5, LTC1859_P6_N7,
                                       LTC1859_P1_N0, LTC1859_P3_N2, LTC1859_P5_N4, LTC1859_P7_N6
                                      }; //!< Build the command for differential mode


//! Initialize Linduino
void setup()
{
  uint16_t adc_code; 
  
  quikeval_SPI_init();           // Configure the spi port for 4MHz SCK
  quikeval_SPI_connect();        // Connect SPI to main data port
  Serial.begin(115200);          // Initialize the serial port to the PC
  print_title();
  print_prompt();
}

//! Repeats Linduino loop
void loop()
{
  uint16_t user_command;

  if (Serial.available())             // Check for user input
  {
      user_command = read_int();        // Read the user command
      if (user_command != 'm')
        Serial.println(user_command);   // Prints the user command to com port
      Serial.flush();
      switch (user_command)
      {
        case 1:
          menu_1_read_input();
          break;
        case 2:
          menu_2_select_single_ended_differential();
          break;
        case 3:
          menu_3_select_uni_bipolar();
          break;
        case 4:
          menu_4_select_range();
          break;
        case 5:
          menu_5_sleep();
          break;
        default:
          Serial.println(F("Invalid Option"));
          break;
      }
      Serial.println();
      Serial.println(F("*************************"));
      print_prompt();
  }
}


// Function Definitions
//! Prints the title block when program first starts.
void print_title()
{
  Serial.println();
  Serial.println(F("*****************************************************************"));
  Serial.println(F("* DC682A Demonstration Program                                  *"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("* This program demonstrates how to send data and receive data   *"));
  Serial.println(F("* from the LTC1859 16-bit ADC.                                  *"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("*****************************************************************"));
}


//! Prints main menu.
void print_prompt()
{
  Serial.println(F("1-Read ADC Input "));
  Serial.println(F("2-Select Single-Ended / Differential measurement (default is Single_Ended)"));
  Serial.println(F("3-Select Unipolar / Bipolar measurement (default is Unipolar)"));
  Serial.println(F("4-Set Input Range (default is High Range)"));
  Serial.println(F("5-Select Sleep Mode"));
  Serial.println();
  Serial.print(F("Enter a command:  "));
}


//! Display selected differential channels. Displaying single-ended channels is
//! straightforward; not so with differential because the inputs can take either polarity.
uint8_t print_user_command_differential()
{
  uint8_t user_command;

  Serial.println(F("*************************"));
  Serial.println(F("  0 = 0P-1N"));
  Serial.println(F("  1 = 2P-3N"));
  Serial.println(F("  2 = 4P-5N"));
  Serial.println(F("  3 = 6P-7N"));
  Serial.println(F("  4 = 1P-0N"));
  Serial.println(F("  5 = 3P-2N"));
  Serial.println(F("  6 = 5P_4N"));
  Serial.println(F("  7 = 7P = 6N"));
  Serial.println(F("  8 = ALL Even_P-Odd_N"));
  Serial.println(F("  m = Main Menu"));
  Serial.println();
  Serial.print(F("  Enter a Command: "));
    
  user_command = read_int();  // Read the menu command    
  Serial.println(user_command);
  if (user_command == 'm')
    return(0);
    
  switch (user_command)  //check for invalid selection
  {
    case 0:
      Serial.println(F("  0P-1N selected"));
      break;
    case 1:
      Serial.println(F("  2P-3N selected"));
      break;
    case 2:
      Serial.println(F("  4P-5N selected"));
      break;
    case 3:
      Serial.println(F("  6P-7N selected"));
      break;
    case 4:
      Serial.println(F("  1P-0N selected"));
      break;
    case 5:
      Serial.println(F("  3P-2N selected"));
      break;
    case 6:
      Serial.println(F("  5P-4N selected"));
      break;
    case 7:
      Serial.println(F("  7P-6N selected"));
      break;
    case 8:
      Serial.println(F("  ALL Even_P-Odd_N selected"));
      break;
    default:
      Serial.println(F("  Invalid Option"));
      break;
   }
  return(user_command);
}


//! Display selected differential channels. Displaying single-ended channels is
//! straightforward; not so with differential because the inputs can take either polarity.
void print_channel_selection(uint8_t menu)
{
  switch (menu)
  {
    case 0:
      Serial.print(F(" 0P-1N:"));
      break;
    case 1:
      Serial.print(F(" 2P-3N:"));
      break;
    case 2:
      Serial.print(F(" 4P-5N:"));
      break;
    case 3:
      Serial.print(F(" 6P-7N:"));
      break;
    case 4:
      Serial.print(F(" 1P-0N:"));
      break;
    case 5:
      Serial.print(F(" 3P-2N:"));
      break;
    case 6:
      Serial.print(F(" 5P-4N:"));
      break;
    case 7:
      Serial.print(F(" 7P-6N:"));
      break;
  }
}


//! Display selected single-ended channel.
uint8_t print_user_command_single_ended()
{
  uint8_t user_command;
  
  Serial.println(F("*************************"));                         
  Serial.println(F("  0 = CH0"));
  Serial.println(F("  1 = CH1"));
  Serial.println(F("  2 = CH2"));
  Serial.println(F("  3 = CH3"));
  Serial.println(F("  4 = CH4"));
  Serial.println(F("  5 = CH5"));
  Serial.println(F("  6 = CH6"));
  Serial.println(F("  7 = CH7"));
  Serial.println(F("  8 = ALL"));
  Serial.println(F("  m = Main Menu"));
  Serial.println();
  Serial.print(F("  Enter a Command: "));

  user_command = read_int();  // Read the single-ended menu command
  Serial.println(user_command);
  if (user_command == 'm')
    return(0);
      
  switch (user_command)  //check for invalid selection
  {
    case 0:
      Serial.println(F("  CH0 selected"));
      break;
    case 1:
      Serial.println(F("  CH1 selected"));
      break;
    case 2:
      Serial.println(F("  CH2 selected"));
      break;
    case 3:
      Serial.println(F("  CH3 selected"));
      break;
    case 4:
      Serial.println(F("  CH4 selected"));
      break;
    case 5:
      Serial.println(F("  CH5 selected"));
      break;
    case 6:
      Serial.println(F("  CH6 selected"));
      break;
    case 7:
      Serial.println(F("  CH7 selected"));
      break;
    case 8:
      Serial.println(F("  All selected"));
      break;
    default:
      Serial.println(F("  Invalid Option"));
      break;
   }

  return(user_command);
}


//! Read channels
//! @return 1 if successful, 0 if not
void menu_1_read_input()
{
  uint8_t user_command;
  uint16_t adc_command;         // The LTC1859 command byte    
  uint16_t adc_code = 0;    // The LTC1859 code
  uint8_t x, y, startcount, endcount;
  float adc_voltage;
  
  if (uni_bipolar == LTC1859_UNIPOLAR_MODE)
  {
    if (single_ended_differential == LTC1859_SINGLE_ENDED_MODE)
    {
    Serial.println(F("  Read Input in Single-Ended, Unipolar mode:"));
    Serial.println(F("  Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
    user_command = print_user_command_single_ended();
    }
    else
    {
    Serial.println(F("  Read Input in Differential, Unipolar mode:"));
    Serial.println(F("  Note that in Unipolar mode, input voltages less than zero are reported as 0.0V"));
    user_command = print_user_command_differential();
    }    
  }
  else
  {
    if (single_ended_differential == LTC1859_SINGLE_ENDED_MODE)
    {
    Serial.println(F("  Read Input in Single-Ended, Bipolar mode:"));
    user_command = print_user_command_single_ended();
    }
    else
    {
    Serial.println(F("  Read Input in Differential, Bipolar mode:"));
    user_command = print_user_command_differential();
    }    
  }

  if (user_command == 8)  //read all channels
  {
    startcount = 0;
    endcount = 7;
  }
  else 
  {
    startcount = user_command;
    endcount = user_command;
  }
   
  if(single_ended_differential == LTC1859_SINGLE_ENDED_MODE)  //read single-ended
  {
      adc_command = BUILD_COMMAND_SINGLE_ENDED[0] | uni_bipolar | range_low_high;
      LTC1859_read(LTC1859_CS, adc_command, &adc_code);     // Throws out last reading and starts CH0 conversion
      for (x = startcount; x <= endcount; x++)
      {
            adc_command = BUILD_COMMAND_SINGLE_ENDED[x % 8] | uni_bipolar | range_low_high; // Send channel config for the NEXT conversion to take place
            LTC1859_read(LTC1859_CS, adc_command, &adc_code);   // Read previous channel conversion (x-1) and start next one (x)
            LTC1859_read(LTC1859_CS, adc_command, &adc_code);   // Read previous channel conversion (x-1) and start next one (x)
            Serial.print(F("  Received Code: b"));
            Serial.println(adc_code, BIN);
            
            adc_voltage = LTC1859_code_to_voltage(adc_code, LTC1859_vref, range_low_high, uni_bipolar);
            Serial.print(F("  Voltage read on "));
            Serial.print(F("Ch"));
            Serial.print(x);
            Serial.print(F(": "));
            Serial.print(adc_voltage, 4);
            Serial.println(F("V"));
            Serial.println();
      }
  }

  else  //read differential
  {
      adc_command = BUILD_COMMAND_DIFF[0] | uni_bipolar | range_low_high;
      LTC1859_read(LTC1859_CS, adc_command, &adc_code);     // Throws out last reading and starts CH0 conversion
      for (x = startcount; x <= endcount; x++)
      {
            adc_command = BUILD_COMMAND_DIFF[x % 8] | uni_bipolar | range_low_high; // Send channel config for the NEXT conversion to take place
            LTC1859_read(LTC1859_CS, adc_command, &adc_code);   // Read previous channel conversion (x-1) and start next one (x)
            LTC1859_read(LTC1859_CS, adc_command, &adc_code);   // Read previous channel conversion (x-1) and start next one (x)
            Serial.print(F("  Received Code: b"));
            Serial.println(adc_code,BIN);

            adc_voltage = LTC1859_code_to_voltage(adc_code, LTC1859_vref, range_low_high, uni_bipolar);
            Serial.print(F("  Voltage read between Chs "));
            print_channel_selection(x + y);
            Serial.print(adc_voltage, 4);
            Serial.println(F("V"));
            Serial.println();
      }
  }
}


//! Sets LTC1859 to Single-Ended or Differential
void menu_2_select_single_ended_differential()
{
  uint8_t user_command;

  Serial.println(F("\n  0 = Single-Ended"));
  Serial.println(F("  1 = Differential"));
  Serial.print(F("  Enter a Command: "));

  user_command = read_int();    // Read user input for uni_bipolar 
  Serial.println(user_command);
  switch (user_command)
      {
        case 0:
          Serial.println(F("  Single-Ended mode selected"));
          single_ended_differential = LTC1859_SINGLE_ENDED_MODE;
        break;
        case 1:
          Serial.println(F("  Differential mode selected"));
          single_ended_differential = LTC1859_DIFFERENTIAL_MODE;
          break; 
        default:
        {
          Serial.println("  Invalid Option");
          return;
        }
          break;
      }    
}


//! Select unipolar (0-REFCOMP) or bipolar (+/- 0.5 x REFCOMP) mode
//! @return void
void menu_3_select_uni_bipolar()
{
  uint8_t user_command;
  
  Serial.println(F("\n  0 = Unipolar"));
  Serial.println(F("  1 = Bipolar"));
  Serial.print(F("  Enter a Command: "));

  user_command = read_int();    // Read user input for uni_bipolar 
  Serial.println(user_command);
  switch (user_command)
      {
        case 0:
          Serial.println(F("  Unipolar mode selected"));
          uni_bipolar = LTC1859_UNIPOLAR_MODE;
        break;
        case 1:
          Serial.println(F("  Bipolar mode selected"));
          uni_bipolar = LTC1859_BIPOLAR_MODE;
          break; 
        default:
          Serial.println("  Invalid Option");
          return;
          break;
      }    
}


//! Select low range or high range mode
//! @return void
void menu_4_select_range()
{
  uint8_t user_command;
  
  Serial.println(F("\n  0 = High Range"));
  Serial.println(F("  1 = Low Range"));
  Serial.print(F("  Enter a Command: "));
  user_command = read_int();    // Read user input for range select
  Serial.println(user_command);

  switch (user_command)
    {
        case 0:
          Serial.println(F("  High Range selected"));
          range_low_high = LTC1859_HIGH_RANGE_MODE;
          break;
        case 1:
          Serial.println(F("  Low Range selected"));
          range_low_high = LTC1859_LOW_RANGE_MODE;
          break;
        default:
        {
          Serial.println("  Invalid Option");
          return;
        }
          break;
    }
   }


//! Put LTC1859 to sleep (low power)
//! @return void
void menu_5_sleep()
{
  // Sleep Mode
  uint16_t user_command;
  uint16_t adc_code = 0;                                        // The LTC1859 code
  LTC1859_read(LTC1859_CS, LTC1859_SLEEP_MODE, &adc_code);      // Build ADC command for sleep mode
  Serial.println();
  Serial.print(F("  ADC Command: B"));
  Serial.println(LTC1859_SLEEP_MODE, BIN);
  Serial.println(F("  LTC1859 Is Now In Sleep Mode"));
  Serial.println(F("  Enter RETURN to exit Sleep Mode"));
  user_command = read_int();
  LTC1859_read(LTC1859_CS, LTC1859_NORMAL_MODE, &adc_code); // Exit Sleep Mode
}

Technical Support