TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 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 (137111 times)
  2. FAT32 Library (70239 times)
  3. Network Ethernet Library (56129 times)
  4. USB Device Library (46437 times)
  5. Network WiFi Library (42080 times)
  6. FT800 Library (41394 times)
  7. GSM click (29118 times)
  8. mikroSDK (26566 times)
  9. PID Library (26503 times)
  10. microSD click (25488 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

CDC click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.4

mikroSDK Library: 2.0.0.0

Category: Measurements

Downloaded: 28 times

Not followed.

License: MIT license  

CDC Click is a compact add-on board that allows your application do a conversion of capacitance to a digital format. This board features the PCAP04, a capacitance-to-digital converter (CDC) from ScioSense. It also includes an integrated digital signal processor (DSP) for on-chip data post-processing. The converter has high flexibility and allows you to convert grounded capacitors and floating capacitors to a digital format. It has up to 50KHz sampling rate in up to 20-bit resolution.

No Abuse Reported

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

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

Do you want to report abuse regarding "CDC click".

  • Information
  • Comments (0)

mikroSDK Library Blog


CDC click

CDC Click is a compact add-on board that allows your application do a conversion of capacitance to a digital format. This board features the PCAP04, a capacitance-to-digital converter (CDC) from ScioSense. It also includes an integrated digital signal processor (DSP) for on-chip data post-processing. The converter has high flexibility and allows you to convert grounded capacitors and floating capacitors to a digital format. It has up to 50KHz sampling rate in up to 20-bit resolution.

cdc_click.png

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Oct 2023.
  • Type : I2C/SPI type

Software Support

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

Standard key functions :

  • cdc_cfg_setup Config Object Initialization function.

    void cdc_cfg_setup ( cdc_cfg_t *cfg );
  • cdc_init Initialization function.

    err_t cdc_init ( cdc_t *ctx, cdc_cfg_t *cfg );
  • cdc_default_cfg Click Default Configuration function.

    err_t cdc_default_cfg ( cdc_t *ctx );

Example key functions :

  • cdc_write_config This function writes configuration data starting from the selected config address.

    err_t cdc_write_config ( cdc_t *ctx, uint8_t address, const uint8_t *data_in, uint8_t len );
  • cdc_send_opcode This function sends a desired opcode command byte.

    err_t cdc_send_opcode ( cdc_t *ctx, uint8_t opcode );
  • cdc_read_results This function reads all results and status registers.

    err_t cdc_read_results ( cdc_t *ctx, cdc_results_t *results );

Example Description

This example demonstrates the use of CDC click board by reading capacitance measurements from C3/C2 and C5/C4 ports calculated from pure capacitance ratio between those ports and port C1/C0 which is used as external C reference.

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. */
    cdc_cfg_t cdc_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.
    cdc_cfg_setup( &cdc_cfg );
    CDC_MAP_MIKROBUS( cdc_cfg, MIKROBUS_1 );
    err_t init_flag = cdc_init( &cdc, &cdc_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( CDC_ERROR == cdc_default_cfg ( &cdc ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Starts measurement and reads the results. The results data is displayed on the USB UART.

void application_task ( void )
{
    cdc_results_t results;
    cdc_send_opcode ( &cdc, CDC_OPCODE_CDC_START );
    Delay_ms ( 200 );
    if ( CDC_OK == cdc_read_results ( &cdc, &results ) )
    {
        log_printf ( &logger, " C1/C0: %.1f pF\r\n", 
                     results.res_0 * CDC_REF - CDC_INT_CAP_PF );
        log_printf ( &logger, " C3/C2: %.1f pF\r\n", 
                     results.res_1 * CDC_REF - CDC_INT_CAP_PF );
        log_printf ( &logger, " C5/C4: %.1f pF\r\n\n", 
                     results.res_2 * CDC_REF - CDC_INT_CAP_PF );
        Delay_ms ( 1000 );
    }
}

Note

For better accuracy and higher measurement range, add 200pF external capacitor between C1/C0 ports and set it below as CDC_EXT_CAP_C1_C0_PF macro before running the application. This way you will be able to measure capacitance in range from 1 to 2000pF.

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

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

RS232 3 click

0

RS232 3 Click is a compact add-on board representing a universal usable RS232 transceiver. This board features the SP3221E, a low-power RS232 transceiver from MaxLinear. The SP3221E uses an internal high-efficiency, charge-pump power supply and is compliant with EIA/TIA-232-F standards when powered by any of the mikroBUS™ power rails. The AUTO ON-LINE® feature allows the SP3221E to automatically Wake-Up from a Shutdown state when an RS232 cable is connected and a peripheral device is turned on. When not connected or not in use, the SP3221E will automatically shut down, drawing less supply current.

[Learn More]

IR Sense 3 click

5

IR Sense 3 Click is the infrared sensor Click board, designed to be used for the short range IR sensing applications. Unlike other pyroelectric sensors, it is able to sense environmental heat changes up to 1m, even through the glass.

[Learn More]

Temp-Hum 12 click

5

Temp-Hum 12 click is a smart environmental temperature and humidity sensor Click board, packed with features which allow easy and simple integration into any design that requires accurate and reliable humidity and temperature measurements.

[Learn More]