PSoC 4 Capsense for measuring capacitance

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Dirk_6716
Level 2
Level 2
10 sign-ins 10 replies posted 10 questions asked

Hello, 

I want to use a PSoC 4 device to continuously measure the raw capacitance of a two terminal capacitive sensor. The examples I found seem to detect changes in capacitance beyond a certain threshold, rather than measuring and outputting the raw capacitance value across two terminals. How would I do this? Are there any examples to follow?

Thanks!

0 Likes
1 Solution
PandaS
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 5 likes given

Hi @Dirk_6716 ,

But for measuring the Capacitance of the sensor, to be specific Parasitic Capacitance - You can use BIST APIs.

To know more about, how to implement BIST in firmware you can refer to the following CapSense Button Tuning example.

https://github.com/Infineon/mtb-example-psoc4-capsense-csd-button-tuning

If you go through the readme, you will find a place which demonstrates Cp measurement using BIST.

PandaS_0-1658385217726.png

Where in measure_sensor_cp() function has the following implementation in the code:

PandaS_0-1658385629643.png

So you can call Cy_CapSense_MeasureCapacitanceSensor() to fetch the Cp value but make sure you have:

  1. Enabled Manual Tuning in Basics Tab of CapSense Configurator.
  2.  Enabled self test library in the Advanced Tab of CapSense Configurator. 

Kindly follow the steps provided in the readme for detailed explanation and feel free to contact us for further queries.

Thanks and regards

Sobhit

 

View solution in original post

0 Likes
2 Replies
PandaS
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 5 likes given

Hi @Dirk_6716 ,

You can also get the raw count values by using Cy_CapSense_GetParam() API. 

This function gets the value of the specified parameter by the paramId argument. The paramId for each register of cy_capsense_tuner is available in the cycfg_capsense.h file as CY_CAPSENSE_<ParameterName>_PARAM_ID. The paramId is a special enumerated value generated by the CAPSENSE™ Configurator. 

Syntax - 

cy_capsense_status_t Cy_CapSense_GetParam ( uint32_t  paramId,
    uint32_t *  value,
    const void *  ptrTuner,
    const cy_stc_capsense_context_t  context 
  )

 

Parameters

paramId Specifies the ID of parameter to get its value. A macro for the parameter ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<ParameterName>_PARAM_ID.
value The pointer to a variable to be updated with the obtained value.
ptrTuner The pointer to the cy_capsense_tuner variable of cy_stc_capsense_tuner_t. The cy_capsense_tuner is declared in CAPSENSE™ Configurator generated files:
  • cycfg_capsense.c/h
context

The pointer to the CAPSENSE™ context structure cy_stc_capsense_context_t.

 

Look at the image below taken from the CapSense configuration header file. 

PandaS_0-1658373634136.png

The return value would be : Return status of the operation. If CY_CAPSENSE_STATUS_SUCCESS is not received, either paramId is invalid or ptrTuner is null.

 

 

0 Likes
PandaS
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 5 likes given

Hi @Dirk_6716 ,

But for measuring the Capacitance of the sensor, to be specific Parasitic Capacitance - You can use BIST APIs.

To know more about, how to implement BIST in firmware you can refer to the following CapSense Button Tuning example.

https://github.com/Infineon/mtb-example-psoc4-capsense-csd-button-tuning

If you go through the readme, you will find a place which demonstrates Cp measurement using BIST.

PandaS_0-1658385217726.png

Where in measure_sensor_cp() function has the following implementation in the code:

PandaS_0-1658385629643.png

So you can call Cy_CapSense_MeasureCapacitanceSensor() to fetch the Cp value but make sure you have:

  1. Enabled Manual Tuning in Basics Tab of CapSense Configurator.
  2.  Enabled self test library in the Advanced Tab of CapSense Configurator. 

Kindly follow the steps provided in the readme for detailed explanation and feel free to contact us for further queries.

Thanks and regards

Sobhit

 

0 Likes