TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139245 times)
  2. FAT32 Library (71743 times)
  3. Network Ethernet Library (57115 times)
  4. USB Device Library (47428 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28073 times)
  9. PID Library (26885 times)
  10. microSD click (26198 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

ADC 20 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.8

mikroSDK Library: 2.0.0.0

Category: ADC

Downloaded: 129 times

Not followed.

License: MIT license  

ADC 20 Click is a compact add-on board with a high-performance data converter. This board features the TLA2518, an SPI-configurable eight-channel 12-bit successive approximation register analog-to-digital converter (SAR ADC) from Texas Instruments. The TLA2518 has an internal oscillator for the ADC conversion and supports averaging multiple data samples with a single conversion start. Also, the built-in programmable averaging filters help reduce noise from the analog inputs and reduce the number of data samples required to be read by the host MCU. All eight channels can be used as analog inputs, with the addition that the four channels can be used as digital inputs or digital outputs.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "ADC 20 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "ADC 20 Click" changes.

Do you want to report abuse regarding "ADC 20 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


ADC 20 Click

ADC 20 Click is a compact add-on board with a high-performance data converter. This board features the TLA2518, an SPI-configurable eight-channel 12-bit successive approximation register analog-to-digital converter (SAR ADC) from Texas Instruments. The TLA2518 has an internal oscillator for the ADC conversion and supports averaging multiple data samples with a single conversion start. Also, the built-in programmable averaging filters help reduce noise from the analog inputs and reduce the number of data samples required to be read by the host MCU. All eight channels can be used as analog inputs, with the addition that the four channels can be used as digital inputs or digital outputs.

adc20_click.png

Click Product page


Click library

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

Software Support

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

Standard key functions :

  • adc20_cfg_setup Config Object Initialization function.

    void adc20_cfg_setup ( adc20_cfg_t *cfg );
  • adc20_init Initialization function.

    err_t adc20_init ( adc20_t *ctx, adc20_cfg_t *cfg );
  • adc20_default_cfg Click Default Configuration function.

    err_t adc20_default_cfg ( adc20_t *ctx );

Example key functions :

  • adc20_read_data This function reads two bytes of data by using SPI serial interface.

    err_t adc20_read_data ( adc20_t *ctx, uint16_t *data_out );
  • adc20_set_gpo_value This function sets the gpo value for the selected channels.

    err_t adc20_set_gpo_value ( adc20_t *ctx, uint8_t ch_mask, uint8_t value );
  • adc20_read_gpio_value This function reads the gpio pins value.

    err_t adc20_read_gpio_value ( adc20_t *ctx, uint8_t *gpio_value );

Example Description

This example demonstrates the use of ADC 20 Click board by displaying the state of 8 channels configured as analog inputs (CH2-CH5), digital inputs (CH0-CH1) and digital outputs (CH6-CH7).

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    adc20_cfg_t adc20_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.
    adc20_cfg_setup( &adc20_cfg );
    ADC20_MAP_MIKROBUS( adc20_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == adc20_init( &adc20, &adc20_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( ADC20_ERROR == adc20_default_cfg ( &adc20 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Starts the auto sequence mode, reads the 12bit ADC value from analog input channels (CH2-CH5) and displays the values converted to voltage on the USB UART. After that, stops auto sequence mode and toggles the state of digital output pins (CH6-CH7), then reads and displays the state of all GPIO pins.

void application_task ( void )
{
    adc20_start_auto_sequence ( &adc20 );
    for ( uint8_t ch_id = ADC20_CHANNEL_ID_2; ch_id <= ADC20_CHANNEL_ID_5; ch_id++ )
    {
        uint16_t adc_data = 0;
        if ( ADC20_OK == adc20_read_data ( &adc20, &adc_data ) )
        {
            float voltage = ( float ) ( adc_data >> ADC20_ADC_OFFSET ) / ADC20_RES_12BIT * ADC20_VREF_3V3;
            log_printf ( &logger, " AIN%u: %.2f V\r\n", ( adc_data & ADC20_CHANNEL_ID_MASK ), voltage );
        }
    }
    adc20_stop_auto_sequence ( &adc20 );
    static uint8_t out_logic_state = ADC20_GPIO_VALUE_LOW;
    if ( ADC20_OK == adc20_set_gpo_value ( &adc20, ( ADC20_CHANNEL_6 | ADC20_CHANNEL_7 ), out_logic_state ) )
    {
        uint8_t gpio_value = 0;
        if ( ADC20_OK == adc20_read_gpio_value ( &adc20, &gpio_value ) )
        {
            log_printf ( &logger, " GPIO state: 0x%.2X\r\n", gpio_value );
        }
    }
    out_logic_state = !out_logic_state;
    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.ADC20

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

Thermo 22 Click

0

Thermo 22 Click is a compact add-on board that provides an accurate temperature measurement. This board features the TMP75C, a high-precision digital temperature sensor from Texas Instruments. The TMP75C houses an integrated digital temperature sensor with a 12-bit analog-to-digital converter (ADC), a reference circuit, and serial interface logic functions in one package. Characterized by its high accuracy (up to ±0.25°C typical) and high resolution of 0.0625°C, this temperature sensor provides temperature data to the host controller with a configurable I2C interface. This Click board™ is appropriate for thermal management and protection of various consumer, industrial, and environmental applications.

[Learn More]

4G LTE-E Click

0

4G LTE Click is an LTE Cat 1 / 2G multimode cellular network solution, featuring the compact LARA-R2 series modem from u-blox. This module supports up to three LTE bands and GSM bands. It also features a full range of options for the high speed cellular networking and communication, such as the network indication, full embedded TCP/UDP stack, HTTP and HTTPS transfer protocols, IPv4/IPv6 dual-stack support, secondary antenna for the RX diversity, antenna detection, jamming signal detection, embedded TLS 1.2 protocol for the improved security and more. 4G LARA Click can achieve data rates up to 10.3 Mbps/5.2 Mbps (downlink/uplink).

[Learn More]

Charger 11 click

5

Charger 11 Click is a LiFePO4 (lithium iron phosphate) battery charger. This click can be used for Low-Cost LiFePO4 battery chargers, or Power Tools, toys, backup energy storage solutions, etc.

[Learn More]