adc26  2.1.0.0
Main Page

ADC 26 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Sep 2024.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

  • adc26_start_conversion This function starts a single-shot conversion for the selected MUX channel and gain level (full-scale range).
    err_t adc26_start_conversion ( adc26_t *ctx, uint8_t mux, uint8_t pga );
  • adc26_get_alert_pin This function returns the ALERT (data ready) pin logic state.
    uint8_t adc26_get_alert_pin ( adc26_t *ctx );
  • adc26_read_voltage This function reads the RAW ADC measurement and converts it to a voltage level.
    err_t adc26_read_voltage ( adc26_t *ctx, float *voltage );

Example Description

This example demonstrates the use of ADC 26 click board by reading and

displaying the voltage levels from IN0-IN1 differential and IN2-IN3 single-ended analog input channels.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
adc26_cfg_t adc26_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
adc26_cfg_setup( &adc26_cfg );
ADC26_MAP_MIKROBUS( adc26_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == adc26_init( &adc26, &adc26_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ADC26_ERROR == adc26_default_cfg ( &adc26 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Reads the voltage levels from IN0-IN1 differential (+/- 2.048V) and

IN2-IN3 single-ended (+/- 4.096V) analog input channels and displays the results on the USB UART once per second approximately.

void application_task ( void )
{
float voltage = 0;
{
while ( adc26_get_alert_pin ( &adc26 ) ); // Waits for a data ready indication
if ( ADC26_OK == adc26_read_voltage ( &adc26, &voltage ) )
{
log_printf ( &logger, " Voltage between IN0[P] and IN1[N]: %.3f V\r\n", voltage );
}
}
{
while ( adc26_get_alert_pin ( &adc26 ) ); // Waits for a data ready indication
if ( ADC26_OK == adc26_read_voltage ( &adc26, &voltage ) )
{
log_printf ( &logger, " Voltage between IN2 and GND: %.3f V\r\n", voltage );
}
}
{
while ( adc26_get_alert_pin ( &adc26 ) ); // Waits for a data ready indication
if ( ADC26_OK == adc26_read_voltage ( &adc26, &voltage ) )
{
log_printf ( &logger, " Voltage between IN3 and GND: %.3f V\r\n\n", voltage );
}
}
Delay_ms ( 1000 );
}

Note

Do not apply more than VCC + 0.3 V to the analog inputs of the device.

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

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.


ADC26_MAP_MIKROBUS
#define ADC26_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: adc26.h:202
ADC26_MUX_P_AIN2_N_GND
#define ADC26_MUX_P_AIN2_N_GND
Definition: adc26.h:149
adc26_t
ADC 26 Click context object.
Definition: adc26.h:215
adc26_get_alert_pin
uint8_t adc26_get_alert_pin(adc26_t *ctx)
ADC 26 get alert pin function.
application_task
void application_task(void)
Definition: main.c:70
ADC26_ERROR
@ ADC26_ERROR
Definition: adc26.h:250
adc26_cfg_t
ADC 26 Click configuration object.
Definition: adc26.h:232
ADC26_PGA_4_096V
#define ADC26_PGA_4_096V
Definition: adc26.h:160
ADC26_MUX_P_AIN0_N_AIN1
#define ADC26_MUX_P_AIN0_N_AIN1
ADC 26 MUX setting.
Definition: adc26.h:143
ADC26_PGA_2_048V
#define ADC26_PGA_2_048V
Definition: adc26.h:159
adc26_start_conversion
err_t adc26_start_conversion(adc26_t *ctx, uint8_t mux, uint8_t pga)
ADC 26 start conversion function.
adc26_cfg_setup
void adc26_cfg_setup(adc26_cfg_t *cfg)
ADC 26 configuration object setup function.
ADC26_OK
@ ADC26_OK
Definition: adc26.h:249
application_init
void application_init(void)
Definition: main.c:34
adc26_init
err_t adc26_init(adc26_t *ctx, adc26_cfg_t *cfg)
ADC 26 initialization function.
adc26_read_voltage
err_t adc26_read_voltage(adc26_t *ctx, float *voltage)
ADC 26 read voltage function.
ADC26_MUX_P_AIN3_N_GND
#define ADC26_MUX_P_AIN3_N_GND
Definition: adc26.h:150
adc26_default_cfg
err_t adc26_default_cfg(adc26_t *ctx)
ADC 26 default configuration function.