adc12 2.0.0.0
Main Page

ADC 12 click

ADC 12 Click is a compact add-on board that contains a fully-featured, general-purpose analog-to-digital converter. This board features the ADS7828, a low-power 12-bit data acquisition device that features a serial I2C interface and an 8-channel multiplexer from Texas Instruments.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jun 2021.
  • Type : I2C type

Software Support

We provide a library for the ADC12 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 ADC12 Click driver.

Standard key functions :

  • adc12_cfg_setup Config Object Initialization function.
    void adc12_cfg_setup(adc12_cfg_t *cfg)
    ADC 12 configuration object setup function.
    ADC 12 Click configuration object.
    Definition adc12.h:190
  • adc12_init Initialization function.
    ADC12_RETVAL adc12_init ( adc12_t *ctx, adc12_cfg_t *cfg );
    err_t adc12_init(adc12_t *ctx, adc12_cfg_t *cfg)
    ADC 12 initialization function.
    ADC 12 Click context object.
    Definition adc12.h:171

Example key functions :

  • adc12_read_voltage This function reads the voltage in milivolts from the desired channel.
    err_t adc12_read_voltage ( adc12_t *ctx, uint8_t ch, uint16_t vref, float *data_out );
    err_t adc12_read_voltage(adc12_t *ctx, uint8_t ch, uint16_t vref, float *data_out)
    ADC 12 read voltage function.
  • adc12_read_raw_data This function reads raw 12-bit ADC data from the desired channel.
    err_t adc12_read_raw_data ( adc12_t *ctx, uint8_t ch, uint16_t *data_out );
    err_t adc12_read_raw_data(adc12_t *ctx, uint8_t ch, uint16_t *data_out)
    ADC 12 read raw ADC data function.
  • adc12_set_sd_mode This function sets the input mode.
    void adc12_set_sd_mode ( adc12_t *ctx, uint8_t sd_mode );
    void adc12_set_sd_mode(adc12_t *ctx, uint8_t sd_mode)
    ADC 12 set the Single-Ended/Differential Inputs function.

Example Description

‍This example demonstrates the use of ADC 12 click board.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and sets the input and power-down modes.

void application_init ( void )
{
log_cfg_t log_cfg;
adc12_cfg_t adc12_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
adc12_cfg_setup( &adc12_cfg );
ADC12_MAP_MIKROBUS( adc12_cfg, MIKROBUS_1 );
err_t init_flag = adc12_init( &adc12, &adc12_cfg );
if ( init_flag == I2C_MASTER_ERROR )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define ADC12_CMD_PD_IRON_ADON
Definition adc12.h:81
#define ADC12_CMD_SD_SINGLE_END
Definition adc12.h:75
#define ADC12_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition adc12.h:159
void adc12_set_pd_mode(adc12_t *ctx, uint8_t pd_mode)
ADC 12 set the Power-Down mode function.
void application_init(void)
Definition main.c:31

Application Task

‍Reads the RAW ADC data and converts it to voltage in milivolts and displays both values on the USB UART every second.

void application_task ( void )
{
uint16_t raw_adc;
float voltage;
log_printf( &logger, " RAW ADC: %u \r\n", raw_adc );
log_printf( &logger, " Voltage from Channel 0: %.2f mV \r\n", voltage );
log_printf( &logger, " ---------------------------\r\n" );
Delay_ms ( 1000 );
}
#define ADC12_SINGLE_END_CH0
ADC 12 Single-Ended channels selection.
Definition adc12.h:99
#define ADC12_INTERNAL_VREF
ADC 12 Internal Reference value.
Definition adc12.h:125
void application_task(void)
Definition main.c:67

Note

‍With internal reference voltage set the click measures up to 2500 mV.

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.ADC12

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.