TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 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 (139565 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57255 times)
  4. USB Device Library (47615 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42563 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26933 times)
  10. microSD click (26309 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

LDC Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.15

mikroSDK Library: 2.0.0.0

Category: Inductance

Downloaded: 195 times

Not followed.

License: MIT license  

LDC Click is a compact add-on board that measures inductance change which a conductive target causes when it moves into the inductor's AC magnetic field.

No Abuse Reported

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

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

Do you want to report abuse regarding "LDC Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


LDC Click

LDC Click is a compact add-on board that measures inductance change which a conductive target causes when it moves into the inductor's AC magnetic field.

ldc_click.png

Click Product page


Click library

  • Author : Luka Filipovic
  • Date : Jul 2021.
  • Type : I2C type

Software Support

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

Standard key functions :

  • ldc_cfg_setup Config Object Initialization function.

    void ldc_cfg_setup ( ldc_cfg_t *cfg );
  • ldc_init Initialization function.

    err_t ldc_init ( ldc_t *ctx, ldc_cfg_t *cfg );
  • ldc_default_cfg Click Default Configuration function.

    err_t ldc_default_cfg ( ldc_t *ctx );

Example key functions :

  • ldc_get_interrupt Get interrupt pin status.

    uint8_t ldc_get_interrupt ( ldc_t *ctx );
  • ldc_get_frequency Get frequency value calculated for specific channel.

    err_t ldc_get_frequency ( ldc_t *ctx, uint8_t channel, uint16_t divider, float *frequency );
  • ldc_calculate_inductance Calculate inductance relative to frequency.

    float ldc_calculate_inductance ( float frequency );

Example Description

This example showcases abillity of the device to detect metal objects. It configures device for reading data from channel 0, checks if ID's are OK and reads data when interrupt is asserted and logs result.

The demo application is composed of two sections :

Application Init

Initialization of communication modules (I2C, UART) and additional pins. Then configures the device for reading data from channel 0, and checks if device ID's are correctly read, and read the currently set divider.


void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    ldc_cfg_t ldc_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.
    ldc_cfg_setup( &ldc_cfg );
    LDC_MAP_MIKROBUS( ldc_cfg, MIKROBUS_1 );
    err_t init_flag = ldc_init( &ldc, &ldc_cfg );
    if ( I2C_MASTER_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }

    if ( ldc_default_cfg ( &ldc ) < 0 )
    {
        log_error( &logger, " Default configuration. " );
        for ( ; ; );
    }

    uint16_t temp_data = 0;
    ldc_generic_read( &ldc, LDC_REG_MANUFACTURER_ID, &temp_data );
    log_printf( &logger, "> Manufacturer ID: 0x%.4X\r\n", temp_data );
    if ( LDC_MANUFACTURER_ID != temp_data )
    {
        log_error( &logger, " Manufacturer ID. " );
        for ( ; ; );
    }

    ldc_generic_read( &ldc, LDC_REG_DEVICE_ID, &temp_data );
    log_printf( &logger, "> Device ID 0x%.4X\r\n", temp_data );
    if ( LDC_DEVICE_ID != temp_data )
    {
        log_error( &logger, " Device ID. " );
        for ( ; ; );
    }

    ldc_generic_read( &ldc, LDC_REG_CLOCK_DIVIDERS_CH0, &temp_data );
    divider = temp_data & 0x3FF;

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

Application Task

Checks if interrupt pin is asserted, if so reads data from channel 0. Calculates and returns the frequency of the sensor. If the frequency is greater than 0, then it calculates the inductance of the sensor. It will log error and error values if it occurred.


void application_task ( void ) 
{
    if ( !ldc_get_interrupt( &ldc ) )
    {
        float frequency = 0.0;
        float inductance = 0.0;
        uint16_t status = 0;
        ldc_generic_read( &ldc, LDC_REG_STATUS, &status );
        if ( status & LDC_STATUS_DRDY )
        {
            err_t ret_val = ldc_get_frequency( &ldc, LDC_REG_DATA_CH0, divider, &frequency );
            if ( !ret_val )
            {
                log_printf( &logger, "> Freq[MHz]: %.3f\r\n", frequency );
                if ( frequency > 0 )
                {
                    inductance = ldc_calculate_inductance( frequency );
                }
                log_printf( &logger, "> L[uH]: %.3f\r\n", inductance );
                log_printf( &logger, "> ************************\r\n" );

                Delay_ms ( 500 );
            }
            else
            {
                log_error( &logger, " Reading data: %ld", ret_val );
            }
        }
    }
}

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.LDC

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

GNSS 15 Click

0

GNSS 15 Click is a compact add-on board for advanced automotive navigation and tracking applications. This board features the TESEO-VIC3DA, an automotive GNSS dead-reckoning module from STMicroelectronics. This module combines a 6-axis IMU with multi-constellation satellite reception, offering exceptional accuracy and dead-reckoning capabilities. It stands out for its rapid time-to-first-fix and the ability to receive firmware updates for enhanced performance. Designed for flexibility, it supports both UART and I2C communications, includes pins for precise odometer readings, and features an SMA antenna connector for superior signal quality.

[Learn More]

MICRF RX 2 Click

0

MICRF RX 2 Click is a compact add-on board for high-sensitivity applications, including remote keyless entry, tire pressure monitoring systems, and remote actuation systems. This board features the MICRF219A, an ASK/OOK 433MHz receiver with Auto-Poll and RSSI from Microchip to offer top-notch RF performance. This super-heterodyne, image-reject RF receiver provides a -110dBm sensitivity at 1kbps and a 0.1% Bit Error Rate (BER), supporting adjustable demodulator filter bandwidths for bit rates up to 20kbps.

[Learn More]

Boost click

2

Boost click carries Microchip’s MIC2606, a 2MHz, PWM DC/DC boost switching regulator available in a 2mm x 2mm MLF package. The input voltage can be set to 5V from mikroBUS or in range 7-20V from an external DC source connected to VIN screw terminal. The output voltage can be set up to 38V.

[Learn More]