adc19 2.0.0.0
Main Page

ADC 19 click

‍ADC 19 Click is a compact add-on board that contains a high-performance data converter. This board features the ADC122S101, a low-power two-channel CMOS 12-bit analog-to-digital converter from Texas Instruments. This SPI configurable analog-to-digital converter (ADC) is fully specified over a sample rate range of 500ksps to 1Msps, offering high reliability and performance. The converter is based on a successive-approximation register architecture with an internal track-and-hold circuit configurable to accept one or two input signals at its input channels.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Mar 2022.
  • Type : SPI type

Software Support

We provide a library for the ADC 19 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for ADC 19 Click driver.

Standard key functions :

  • adc19_cfg_setup Config Object Initialization function.
    void adc19_cfg_setup(adc19_cfg_t *cfg)
    ADC 19 configuration object setup function.
    ADC 19 Click configuration object.
    Definition adc19.h:141
  • adc19_init Initialization function.
    err_t adc19_init ( adc19_t *ctx, adc19_cfg_t *cfg );
    err_t adc19_init(adc19_t *ctx, adc19_cfg_t *cfg)
    ADC 19 initialization function.
    ADC 19 Click context object.
    Definition adc19.h:126

Example key functions :

  • adc19_set_vref This function sets the voltage reference value that will be used for voltage calculation.
    void adc19_set_vref ( adc19_t *ctx, float vref );
    void adc19_set_vref(adc19_t *ctx, float vref)
    ADC 19 set vref function.
  • adc19_set_input_channel This function sets the selected input channel active by modifying the control register.
    err_t adc19_set_input_channel ( adc19_t *ctx, uint8_t input_ch );
    err_t adc19_set_input_channel(adc19_t *ctx, uint8_t input_ch)
    ADC 19 set input channel function.
  • adc19_get_voltage This function reads the voltage from the previously selected channel by using SPI serial interface.
    err_t adc19_get_voltage ( adc19_t *ctx, float *voltage );
    err_t adc19_get_voltage(adc19_t *ctx, float *voltage)
    ADC 19 get voltage function.

Example Description

‍This example demonstrates the use of ADC 19 click board by reading the voltage from the two analog input channels.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and logger and sets the ADC voltage reference.

void application_init ( void )
{
log_cfg_t log_cfg;
adc19_cfg_t adc19_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
adc19_cfg_setup( &adc19_cfg );
ADC19_MAP_MIKROBUS( adc19_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == adc19_init( &adc19, &adc19_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define ADC19_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition adc19.h:112
#define ADC19_VREF_3V3
Definition adc19.h:82
void application_init(void)
Definition main.c:29

Application Task

‍Reads and displays the voltage from the two analog input channels on the USB UART approximately every 500ms.

void application_task ( void )
{
float voltage;
{
if ( ADC19_OK == adc19_get_voltage ( &adc19, &voltage ) )
{
log_printf ( &logger, " IN1 : %.3f V \r\n", voltage );
}
}
{
if ( ADC19_OK == adc19_get_voltage ( &adc19, &voltage ) )
{
log_printf ( &logger, " IN2 : %.3f V \r\n\n", voltage );
}
}
Delay_ms ( 500 );
}
@ ADC19_OK
Definition adc19.h:161
#define ADC19_INPUT_CHANNEL_2
Definition adc19.h:75
#define ADC19_INPUT_CHANNEL_1
ADC 19 input channel selection.
Definition adc19.h:74
void application_task(void)
Definition main.c:61

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.ADC19

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.