We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2024-10-31
Package Version: 2.1.0.13
mikroSDK Library: 2.0.0.0
Category: ADC
Downloaded: 206 times
Not followed.
License: MIT license
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.
Do you want to subscribe in order to receive notifications regarding "ADC 12 Click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "ADC 12 Click" changes.
Do you want to report abuse regarding "ADC 12 Click".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
4518_adc_12_click.zip [475.98KB] | mikroC AI for ARM GCC for ARM Clang for ARM mikroC AI for PIC mikroC AI for PIC32 XC32 GCC for RISC-V Clang for RISC-V mikroC AI for AVR mikroC AI for dsPIC XC16 |
|
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.
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.
This library contains API for ADC12 Click driver.
adc12_cfg_setup
Config Object Initialization function.
void adc12_cfg_setup ( adc12_cfg_t *cfg );
adc12_init
Initialization function.
ADC12_RETVAL adc12_init ( adc12_t *ctx, adc12_cfg_t *cfg );
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 );
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 );
adc12_set_sd_mode
This function sets the input mode.
void adc12_set_sd_mode ( adc12_t *ctx, uint8_t sd_mode );
This example demonstrates the use of ADC 12 Click board.
The demo application is composed of two sections :
Initializes the driver and sets the input and power-down modes.
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
adc12_cfg_t adc12_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.
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 ( ; ; );
}
adc12_set_sd_mode ( &adc12, ADC12_CMD_SD_SINGLE_END );
adc12_set_pd_mode( &adc12, ADC12_CMD_PD_IRON_ADON );
log_info( &logger, " 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;
adc12_read_raw_data ( &adc12, ADC12_SINGLE_END_CH0, &raw_adc );
adc12_read_voltage ( &adc12, ADC12_SINGLE_END_CH0, ADC12_INTERNAL_VREF, &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 );
}
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:
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.