adc18  2.0.0.0
Main Page

ADC 18 Click

ADC 18 Click is a compact add-on board that contains a high-performance data converter. This board features the MAX22005, an SPI-configurable twelve-channel 24-bit analog-to-digital converter (ADC) from Analog Devices.

Click Product page


Click library

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

Software Support

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

Standard key functions :

Example key functions :

  • adc18_set_active_channel This function sets the active channel.
    err_t adc18_set_active_channel ( adc18_t *ctx, uint8_t channel );
  • adc18_start_conversion This function starts the conversion with the selected data rate.
    err_t adc18_start_conversion ( adc18_t *ctx, uint8_t data_rate );
  • adc18_read_voltage This function reads RAW ADC value of previous conversion and converts it to voltage.
    err_t adc18_read_voltage ( adc18_t *ctx, float *voltage );

Example Description

This example demonstrates the use of ADC 18 Click board by reading the voltage from 12 analog input single-ended channels.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger, and performs the Click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
adc18_cfg_t adc18_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
adc18_cfg_setup( &adc18_cfg );
ADC18_MAP_MIKROBUS( adc18_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == adc18_init( &adc18, &adc18_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ADC18_ERROR == adc18_default_cfg ( &adc18 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Reads and displays the voltage from 12 analog input single-ended channels on the USB UART approximately once per second.

void application_task ( void )
{
static uint8_t channel = ADC18_CH_AI1_SINGLE_ENDED;
if ( ADC18_OK == adc18_set_active_channel ( &adc18, channel ) )
{
// Waits for the availability of the conversion result
while ( adc18_get_rdy_pin ( &adc18 ) );
float voltage;
if ( ADC18_OK == adc18_read_voltage ( &adc18, &voltage ) )
{
log_printf ( &logger, "Channel AI%u: %.2f V\r\n", channel + 1, voltage );
if ( ++channel > ADC18_CH_AI12_SINGLE_ENDED )
{
log_printf ( &logger, "\r\n" );
Delay_ms ( 1000 );
}
}
}
}

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

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.


adc18_init
err_t adc18_init(adc18_t *ctx, adc18_cfg_t *cfg)
ADC 18 initialization function.
application_task
void application_task(void)
Definition: main.c:65
ADC18_CH_AI1_SINGLE_ENDED
#define ADC18_CH_AI1_SINGLE_ENDED
ADC 18 channel selection values.
Definition: adc18.h:161
adc18_set_active_channel
err_t adc18_set_active_channel(adc18_t *ctx, uint8_t channel)
ADC 18 set active channel function.
adc18_cfg_setup
void adc18_cfg_setup(adc18_cfg_t *cfg)
ADC 18 configuration object setup function.
adc18_cfg_t
ADC 18 Click configuration object.
Definition: adc18.h:262
adc18_stop_conversion
err_t adc18_stop_conversion(adc18_t *ctx)
ADC 18 stop conversion function.
ADC18_CH_AI12_SINGLE_ENDED
#define ADC18_CH_AI12_SINGLE_ENDED
Definition: adc18.h:172
adc18_read_voltage
err_t adc18_read_voltage(adc18_t *ctx, float *voltage)
ADC 18 read voltage function.
application_init
void application_init(void)
Definition: main.c:29
ADC18_MAP_MIKROBUS
#define ADC18_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: adc18.h:223
ADC18_DATA_RATE_225_SPS
#define ADC18_DATA_RATE_225_SPS
Definition: adc18.h:136
adc18_t
ADC 18 Click context object.
Definition: adc18.h:240
adc18_start_conversion
err_t adc18_start_conversion(adc18_t *ctx, uint8_t data_rate)
ADC 18 start conversion function.
ADC18_ERROR
@ ADC18_ERROR
Definition: adc18.h:288
adc18_get_rdy_pin
uint8_t adc18_get_rdy_pin(adc18_t *ctx)
ADC 18 get rdy pin function.
adc18_default_cfg
err_t adc18_default_cfg(adc18_t *ctx)
ADC 18 default configuration function.
ADC18_OK
@ ADC18_OK
Definition: adc18.h:287