Unlock infinite possibilities with our inductance-to-digital marvel, which effortlessly converts inductance values into digital data, making it a vital component for real-time monitoring, quality control, and system automation
A
A
Hardware Overview
How does it work?
LDC Click is based on the LDC1312-Q1, two-channel, 12-bit inductance to digital converters (LDCs) for inductive sensing solutions from Texas Instruments. This Click board™ is easy to use, requiring only the sensor frequency within 1kHz and 10MHz to begin sensing. It measures the oscillation frequency of an LC resonator and outputs a digital value proportional to frequency. Inductive sensing offers better performance, reliability, and flexibility than competitive technologies at lower cost and power. This board is ideal for exact short-range measurements of conductive targets' position, motion, or composition. Conductive objects in contact with an AC electromagnetic (EM) field will induce field changes that can be detected using a sensor such
as an inductor. Conveniently, an inductor and a capacitor are used to construct an LC resonator, also known as an LC tank, to produce an EM field. In the case of an LC tank, the effect of the field disturbance is an apparent shift in the inductance of the sensor, which can be observed as a shift in the resonant frequency - using this principle, the LDC1312-Q1 works. LDC Click communicates with MCU using the standard I2C 2-Wire interface with a maximum clock frequency of 400kHz. In addition to I2C communication, two GPIO pins connected to the mikroBUS™ socket pins are also used. The SD pin routed to the RST pin of the mikroBUS™ socket, is used to place the LDC1312-Q1 in Shutdown mode, saving current, while the INT pin may be configured as an interrupt
to notify the host MCU of changes in system status. Besides, it also allows the choice of the least significant bit of its I2C slave address by positioning the SMD jumper labeled ADDR SEL to an appropriate position marked as 1 and 0. It also can connect additional external LC sensors, allowing you to replace the provided onboard sensor and solder your own at places marked with COIL1 and COIL2. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any
circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.
Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
2048
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for LDC Click driver.
Key functions:
ldc_get_interrupt
- Get interrupt pin statusldc_get_frequency
- Get frequency value calculated for specific channelldc_calculate_inductance
- Calculate inductance relative to frequency
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief LDC Click example
*
* # Description
* This example showcases the ability of the device to detect
* metal objects. It configures a device for reading data from
* channel 0, checks if ID's are OK and reads data when interrupting
* 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.
*
* ## 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.
*
* @author Luka Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "ldc.h"
#include "math.h"
static ldc_t ldc;
static log_t logger;
uint16_t 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 " );
}
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 );
}
}
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END