Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Articles

Mutual Capacitance Calculation of a CapSense Sensor Through Firmware - KBA222425

chaitanyav_41
Employee

Mutual Capacitance Calculation of a CapSense Sensor Through Firmware - KBA222425

Version: **

Translation - Japanese: ファームウェアによるCapSenseセンサーの相互容量計算 - KBA222425 - Community Translated (JA)

Question:

How do you calculate the mutual capacitance of a CapSense sensor, through firmware in CapSense Component version 3.0 or above?

Answer:

Raw counts are a direct measure of the mutual capacitance (Cm). The raw counts obtained can be used to calculate the mutual capacitance of sensor, by following these steps:

1. Start the CapSense Component; scan and process all the CapSense widgets

2. Calculate the maximum counts using the frequency of the modulator clock, number of sub conversions, and frequency of the transmitter clock.

Max_count =

( Modulator_clock_frequency * Number_of_sub_conversions )

Transmitter_clock_frequency

3. Calculate the hardware raw counts using the max counts (obtained in step 1) and raw counts processed by the CapSense Component.

Raw_count_hardware = Max_count – Raw_count

4. Calculate the mutual capacitance using the max counts (from step 1), hardware raw counts (from step 2), IDAC current, frequency, and amplitude of the transmitter clock signal.

Raw_count_hardware =

( 2 * Max_count * Mutual_capacitance * Transmitter_voltage * Transmitter_clock_frequency )

IDAC_current

include "project.h"

#define TRANSMITTER_VOLTAGE (5u) /* unit - voltage */

#define IDAC_GAIN (300u) /* unit – nano Amperes/bit */

int main(void)

{

     

    CyGlobalIntEnable; /* Enable global interrupts. */

 

    uint32 raw_count, modulator_clock_divider, sense_clock_divider, sub_conversions, IDAC_code, hardware_raw_count, max_count, mutual_capacitance;

    /* Start the CapSense component */

    CapSense_Start();

    /* Scan all the CapSense widgets */

    CapSense_ScanAllWidgets();

     

      for(;;)

      {

        /* Check if CapSense scan is completed*/

        if (!CapSense_IsBusy())

        {

            /* Process all the CapSense widgets */

CapSense_ProcessAllWidgets();

           

            /* Calculation of max counts for button 0*/

           

            /* API to get the value of modulator clock divider = HF_CLK_FREQ / MOD_CLK_FREQ */

CapSense_GetParam (CapSense_MOD_CSX_CLK_PARAM_ID , &modulator_clock_divider);

           

            /* API to get the value of sense clock divider = MOD_CLK_FREQ / SNS_CLK_FREQ */

CapSense_GetParam (CapSense_BUTTON0_SNS_CLK_PARAM_ID, &sense_clock_divider);

            /* API to get the number of sub conversions */

            CapSense_GetParam (CapSense_BUTTON0_RESOLUTION_PARAM_ID , &sub_conversions);

            max_count = sense_clock_divider * sub_conversions ;

            /* Calculation of hardware raw counts for button 0 */

            /* API to get the value of raw counts */

            CapSense_GetParam (CapSense_BUTTON0_RX0_RAW0_PARAM_ID , &raw_count);

hardware_raw_count = max_count-raw_count ;

            /* Calculation of mutual capacitance for button 0 */

            /* API to get the IDAC code */

CapSense_GetParam (CapSense_BUTTON0_RX0_IDAC_COMP0_PARAM_ID , &IDAC_code);

mutual_capacitance = (hardware_raw_count * IDAC_code * IDAC_GAIN * sense_clock_divider * modulator_clock_divider) / (2 * max_count * TRANSMITTER_VOLTAGE * CYDEV_BCLK__HFCLK__MHZ);

                       

            /* Scan all the CapSense widgets*/                   

CapSense_ScanAllWidgets();

        }

      }

}

The mutual capacitance is expected to be in the range of thousands of femto farads under the following conditions:

    HF_clock_fequency = 48 MHz

    Modulator_clock_frequency = 48 MHz

    Sense_clock_frequency = 300 kHz

    Transmitter_voltage = 5 V

    IDAC_gain = 300 nA/ bit

    IDAC code= 32

    Number_of_sub_conversions = 100

    Modulator_clock_divider = 1

    Sense clock divider = 160

     Max_count =

(48 * 100* 160 )

1 * 48

= 16000

As an example, if the raw counts obtained are 6200, then

    Raw_count_hardware = 16000 – 6200= 9800

     Mutual_capacitance =

(9800*300*20*160)

( 2*16000*5*48 )

= 1225 fF

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎Jan 03, 2018 10:25 PM
Updated by:
 
Contributors