TOP Contributors

  1. MIKROE (2660 codes)
  2. Alcides Ramos (356 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (137009 times)
  2. FAT32 Library (70133 times)
  3. Network Ethernet Library (56028 times)
  4. USB Device Library (46350 times)
  5. Network WiFi Library (41966 times)
  6. FT800 Library (41291 times)
  7. GSM click (29055 times)
  8. mikroSDK (26489 times)
  9. PID Library (26452 times)
  10. microSD click (25413 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

ADAC 2 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.7

mikroSDK Library: 2.0.0.0

Category: ADC-DAC

Downloaded: 70 times

Not followed.

License: MIT license  

ADAC 2 Click is a compact add-on board providing the ADC/DAC combo solution. This board features the MAX22000, a 24-bit ADC, an 18-bit DAC, and an analog front-end (AFE) from Analog Devices. It allows users to create a software-configurable (SPI interface) input/output that supports all standard industrial analog interfaces: -10V to +10V analog input or output, -20mA to +20mA analog input or output, as well as an RTD or thermocouple input for temperature measurement.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "ADAC 2 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "ADAC 2 click" changes.

Do you want to report abuse regarding "ADAC 2 click".

  • Information
  • Comments (0)

mikroSDK Library Blog


ADAC 2 click

ADAC 2 Click is a compact add-on board providing the ADC/DAC combo solution. This board features the MAX22000, a 24-bit ADC, an 18-bit DAC, and an analog front-end (AFE) from Analog Devices. It allows users to create a software-configurable (SPI interface) input/output that supports all standard industrial analog interfaces: -10V to +10V analog input or output, -20mA to +20mA analog input or output, as well as an RTD or thermocouple input for temperature measurement.

adac2_click.png

click Product page


Click library

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

Software Support

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

Standard key functions :

  • adac2_cfg_setup Config Object Initialization function.

    void adac2_cfg_setup ( adac2_cfg_t *cfg );
  • adac2_init Initialization function.

    err_t adac2_init ( adac2_t *ctx, adac2_cfg_t *cfg );
  • adac2_default_cfg Click Default Configuration function.

    err_t adac2_default_cfg ( adac2_t *ctx );

Example key functions :

  • adac2_set_active_ain_channel This function sets the active analog input channel.

    err_t adac2_set_active_ain_channel ( adac2_t *ctx, uint8_t channel );
  • adac2_read_voltage This function reads RAW ADC value of previous conversion and converts it to voltage.

    err_t adac2_read_voltage ( adac2_t *ctx, float fsr, float *voltage );
  • adac2_write_dac This function sets the analog output by writing to the AO_DATA_WR register.

    err_t adac2_write_dac ( adac2_t *ctx, int32_t dac );

Example Description

This example demonstrates the use of ADAC 2 click board by setting the DAC output (CIO) and reading the ADC results from a single-ended channel (AI4) and from a differential channel (AI5+, AI6-) as well as toggling all GPIO pins.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration which enables DAC voltage output, sets the analog input mode to single-ended for AI4 and differential (AI5+, AI6-), and enables all GPIOs as output.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    adac2_cfg_t adac2_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.
    adac2_cfg_setup( &adac2_cfg );
    ADAC2_MAP_MIKROBUS( adac2_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == adac2_init( &adac2, &adac2_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( ADAC2_ERROR == adac2_default_cfg ( &adac2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Reads the ADC results from a single-ended (AI4) and a differential (AI5+, AI6-) channels, then sets the raw DAC output increasing the value by 10000 after each iteration, and toggles all GPIO pins. The results will be displayed on the USB UART approximately once per second.

void application_task ( void )
{
    float voltage;
    if ( ADAC2_OK == adac2_set_active_ain_channel ( &adac2, ADAC2_CH_AI4_SINGLE_ENDED ) )
    {
        adac2_start_conversion ( &adac2, ADAC2_DATA_RATE_450_SPS );
        // Waits for the availability of the conversion result
        while ( adac2_get_rdy_pin ( &adac2 ) );
        adac2_stop_conversion ( &adac2 );
        if ( ADAC2_OK == adac2_read_voltage ( &adac2, ADAC2_FULL_SCALE_RANGE_12p5V, &voltage ) )
        {
            log_printf ( &logger, " Channel AI4 single-ended: %.2f V\r\n", voltage );
        }
    }
    if ( ADAC2_OK == adac2_set_active_ain_channel ( &adac2, ADAC2_CH_AI5_AI6_DIFFERENTIAL_25V ) )
    {
        adac2_start_conversion ( &adac2, ADAC2_DATA_RATE_450_SPS );
        // Waits for the availability of the conversion result
        while ( adac2_get_rdy_pin ( &adac2 ) );
        adac2_stop_conversion ( &adac2 );
        if ( ADAC2_OK == adac2_read_voltage ( &adac2, ADAC2_FULL_SCALE_RANGE_25V, &voltage ) )
        {
            log_printf ( &logger, " Channel AI5-AI6 differential: %.2f V\r\n", voltage );
        }
    }

    static int32_t dac = ADAC2_DAC_MIN_VALUE;
    if ( ADAC2_OK == adac2_write_dac ( &adac2, dac ) )
    {
        log_printf ( &logger, " DAC: %ld\r\n", dac );
        dac += 5000;
        if ( dac > ADAC2_DAC_MAX_VALUE )
        {
            dac = ADAC2_DAC_MIN_VALUE;
        }
    }

    uint32_t gpio_data;
    if ( ADAC2_OK == adac2_read_register ( &adac2, ADAC2_REG_GEN_GPIO_CTRL, &gpio_data ) )
    {
        gpio_data ^= ADAC2_GPIO_ALL_MASK;
        if ( ADAC2_OK == adac2_write_register ( &adac2, ADAC2_REG_GEN_GPIO_CTRL, gpio_data ) )
        {
            log_printf ( &logger, " GPIO: 0x%.2X\r\n\n", ( uint16_t ) ( gpio_data & ADAC2_GPIO_ALL_MASK ) );
        }
    }
    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.ADAC2

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.


ALSO FROM THIS AUTHOR

DIGI POT 2 click

10

DIGI POT 2 click is a mikroBUS add-on board with a single channel digital potentiometer TPL0501 with 256 wiper positions. The IC has 100 kilo Ohms end-to-end resistance, with ±20% tolerance. The board features two pairs of screw terminals for interfacing with the IC DIGI POT 2 click communicates with the target MCU through the mikroBUS SPI.

[Learn More]

OBDII click

0

OBDII click offers a unique opportunity to tap into the car diagnostic systems. It features the STN1110 Multiprotocol OBD to UART Interface, developed by the ScanTool technologies. This click can be used for the communication with the Electronic Control Unit (ECU) of a vehicle, via several different OBD II diagnostic protocols such as CAN, K LINE, L LINE and J1850. The STN1110 IC is used to process requests sent by the MCU via the UART interface and return back the responses from the ECU network nodes.

[Learn More]

H-Bridge 10 click

0

H-Bridge 10 Click is a compact add-on board containing H-bridge outputs that let you control a DC motor to go backward or forward. This board features the MP6523, a triple, half-bridge, DMOS, output driver with integrated power MOSFETs that can drive up to three different loads from Monolithic Power Systems (MPS). The MP6523 is rated for an operating voltage range from 7V to 28V. It is SPI-configurable and has various diagnostic functions. Complete protection features include short-circuit protection (SCP), under-voltage protection (UVP), and thermal shutdown, alongside an onboard power supply existence-check circuit. This Click board™ is suitable as a multiple brushed DC motor driver for driving various loads in automotive and industrial applications, and more.

[Learn More]