\mainpage Main Page
ADC 15 Click is a compact add-on board that contains a high-performance data converter. This board features the ADS131M02, a two-channel, simultaneously sampling, 24-bit, delta-sigma (ΔΣ), analog-to-digital converter from Texas Instruments. The ADC inputs can be independently configured via serial peripheral interface depending on the sensor input. A low noise, programmable gain amplifier (PGA) provides gains ranging from 1 to 128 to amplify low-level signals.
- Author : Luka Filipovic
- Date : Sep 2021.
- Type : SPI type
We provide a library for the ADC15 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.
This library contains API for ADC15 Click driver.
adc15_cfg_setup
Config Object Initialization function.
void adc15_cfg_setup ( adc15_cfg_t *cfg );
adc15_init
Initialization function.
err_t adc15_init ( adc15_t *ctx, adc15_cfg_t *cfg );
adc15_default_cfg
Click Default Configuration function.
err_t adc15_default_cfg ( adc15_t *ctx );
adc15_read_voltage
Get voltage value.
err_t adc15_read_voltage ( adc15_t *ctx, uint16_t *status, float *ch1_out, float *ch2_out );
adc15_set_gain
Set gain for channel.
err_t adc15_set_gain ( adc15_t *ctx, adc15_channel_t channel, adc15_gain_t gain );
adc15_set_word_len
Set word len.
err_t adc15_set_word_len ( adc15_t *ctx, adc15_word_t word_len );
This example showcases ability of the click board to read adc data from 2 different channels. It's also configuratable to read data in different output rate, resolutions( word/data len ), and gain.
The demo application is composed of two sections :
Initialization of communication modules (SPI, UART) and additional pins for control of the device. Sets default configuration, that sets gain of 1 for both channels(+/-1.2V range) and word/data length of 24bit. In the end reads device ID.
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
adc15_cfg_t adc15_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
adc15_cfg_setup( &adc15_cfg );
ADC15_MAP_MIKROBUS( adc15_cfg, MIKROBUS_1 );
err_t init_flag = adc15_init( &adc15, &adc15_cfg );
if ( SPI_MASTER_ERROR == init_flag )
{
log_error( &logger, " Communication Init. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
if ( adc15_default_cfg ( &adc15 ) )
{
log_error( &logger, " Default configuration. " );
for( ; ; );
}
uint16_t reg_val;
adc15_reg_read( &adc15, ADC15_REG_ID, ®_val );
log_printf( &logger, " > ID: 0x%.4X\r\n", reg_val );
log_info( &logger, " Application Task " );
Delay_ms( 1000 );
}
Waits for data ready signal and reads voltage value of both channels, and logs read status and channel voltage level.
void application_task ( void )
{
while ( adc15_data_ready( &adc15 ) );
float channel1 = 0;
float channel2 = 0;
uint16_t status = 0;
if ( !adc15_read_voltage( &adc15, &status, &channel1, &channel2 ) )
{
log_printf( &logger, " > Status: 0x%.4X\r\n", status );
log_printf( &logger, " > V ch1: %f\r\n", channel1 );
log_printf( &logger, " > V ch2: %f\r\n", channel2 );
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.ADC15
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. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.