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.7
mikroSDK Library: 2.0.0.0
Category: ADC-DAC
Downloaded: 104 times
Not followed.
License: MIT license
ADAC 3 Click is a compact add-on board representing the ADC/DAC combo solution. This board features the PCF8591, a low-power 8-bit CMOS data acquisition device with four analog inputs, one analog output, and a serial I2C interface from NXP Semiconductors. The PCF8591 includes analog input multiplexing, an on-chip track and hold function and 8-bit analog-to-digital conversion alongside an 8-bit digital-to-analog conversion. In addition, the user is given the option to select the PCF8591 reference voltage value, choosing between 2,048 and 4,096V.
Do you want to subscribe in order to receive notifications regarding "ADAC 3 Click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "ADAC 3 Click" changes.
Do you want to report abuse regarding "ADAC 3 Click".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
4983_adac_3_click.zip [488.19KB] | 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 |
|
ADAC 3 Click is a compact add-on board representing the ADC/DAC combo solution. This board features the PCF8591, a low-power 8-bit CMOS data acquisition device with four analog inputs, one analog output, and a serial I2C interface from NXP Semiconductors. The PCF8591 includes analog input multiplexing, an on-chip track and hold function and 8-bit analog-to-digital conversion alongside an 8-bit digital-to-analog conversion. In addition, the user is given the option to select the PCF8591 reference voltage value, choosing between 2,048 and 4,096V.
We provide a library for the ADAC 3 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 ADAC 3 Click driver.
adac3_cfg_setup
Config Object Initialization function.
void adac3_cfg_setup ( adac3_cfg_t *cfg );
adac3_init
Initialization function.
err_t adac3_init ( adac3_t *ctx, adac3_cfg_t *cfg );
adac3_default_cfg
Click Default Configuration function.
err_t adac3_default_cfg ( adac3_t *ctx );
adac3_write_control
This function writes a control byte by using I2C serial interface.
err_t adac3_write_control ( adac3_t *ctx, uint8_t control );
adac3_write_dac
This function writes a DAC byte by using I2C serial interface.
err_t adac3_write_dac ( adac3_t *ctx, uint8_t dac );
adac3_read_adc
This function reads the AD conversion byte by using I2C serial interface.
err_t adac3_read_adc ( adac3_t *ctx, uint8_t *adc );
This example demonstrates the use of ADAC 3 Click board by setting the DAC output and reading the ADC results from 2 single-ended channels (AIN0, AIN1) and from a differential channel (AIN2+, AIN3-).
The demo application is composed of two sections :
Initializes the driver and performs the Click default configuration which enables DAC output, sets the analog input mode to single-ended (AIN0, AIN1) and differential (AIN2+, AIN3-), and enables the auto increment mode.
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
adac3_cfg_t adac3_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.
adac3_cfg_setup( &adac3_cfg );
ADAC3_MAP_MIKROBUS( adac3_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == adac3_init( &adac3, &adac3_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ADAC3_ERROR == adac3_default_cfg ( &adac3 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
Sets the DAC output increasing the value by 1 after each iteration, and reads the ADC results from 2 single-ended and 1 differential channels, and displays the results on the USB UART every 100ms approximately.
void application_task ( void )
{
static uint8_t dac = 0;
uint8_t ain0, ain1, ain2_ain3_diff;
if ( ADAC3_OK == adac3_write_dac ( &adac3, dac ) )
{
log_printf ( &logger, " DAC : %u mV\r\n",
( uint16_t ) ( ( ADAC3_VREF_2048mV / ADAC3_RESOLUTION ) * dac++ ) );
}
if ( ADAC3_OK == adac3_read_adc ( &adac3, &ain0 ) )
{
log_printf ( &logger, " AIN0+: %u mV\r\n",
( uint16_t ) ( ( ADAC3_VREF_2048mV / ADAC3_RESOLUTION ) * ain0 ) );
}
if ( ADAC3_OK == adac3_read_adc ( &adac3, &ain1 ) )
{
log_printf ( &logger, " AIN1+: %u mV\r\n",
( uint16_t ) ( ( ADAC3_VREF_2048mV / ADAC3_RESOLUTION ) * ain1 ) );
}
if ( ADAC3_OK == adac3_read_adc ( &adac3, &ain2_ain3_diff ) )
{
log_printf ( &logger, " AIN2+ - AIN3-: %d mV\r\n\n",
( int16_t ) ( ( ADAC3_VREF_2048mV / ADAC3_RESOLUTION ) * ( int8_t ) ain2_ain3_diff ) );
}
Delay_ms ( 100 );
}
Inputs should be connected to GND when not in use.
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.