Raw capacitance data reading. CapSense_GetSensorCapacitance()

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

cross mob
Anonymous
Not applicable

We are trying to read raw capacitance data using a PSoc series 4000 (proto kit CY8CKIT-145-40XX).

Reading the manuals (!!!) it is documented a low level reading function named:

CapSense_GetSensorCapacitance()

however when compiling code using this function, the function is not found.

Is there anybody who kindly can help us to solve this issue: either by suggesting how to call the function or by suggesting any other "low level" reading function?

We need to read raw capacitance data ("analog" capacitance measurements).

Thank you in advance for any support on this topic.

Giorgio Cannata

0 Likes
1 Solution
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

You should check the BIST(build in self test) checkbox in CapSense component configuration GUI and then compile the project.  This API is not generated by default by component, until you enable the BIST option.

View solution in original post

0 Likes
4 Replies
BrHu_1305671
Level 1
Level 1
Welcome! First question asked First reply posted

My comments below are with respect to the newer CapSense v5.0 component.  This matters because that component uses the newer API (which you probably want if  you are just starting out).   The new API uses a Get and SetParam interface.

Here is a snippet of code I use to read the sensors raw capacitance signal

// read the sensor raw capacitance

uint32 tmpUint32;

CapSense_GetParam(CapSense_LLS_SNS0_RAW0_PARAM_ID,&tmpUint32);

gCurrentCapacitance = (uint16)(tmpUint32 & 0xFFFF);

There are lots of params you can get and set and they are documented in the datasheet in the High Level API section.  For example here is a snippet of my code to get/set the idac's.   I use the EZI2C interface on my board and keep shadow copies to know when things changed, hence the extra code.  The params interface uses Uint32 even though not all params are that big (something to keep in mind).

// update the IDAC values if the registers changed via I2C interface

            tmpUint8 = gReg->IDAC;

            if(gIDACShadow != tmpUint8 )

            {

                tmpUint32 = (uint32)tmpUint8;

                gIDACShadow = tmpUint8;

                cystatusRet = CapSense_SetParam(CapSense_LLS_IDAC_MOD0_PARAM_ID, tmpUint32);

                //CapSense_Start();

                cystatusRet = CapSense_GetParam(CapSense_LLS_IDAC_MOD0_PARAM_ID, &tmpUint32);

                gReg->IDAC = gIDACShadow = (uint8)(tmpUint32 & 0xFF);

            }

            tmpUint8 = gReg->CompIDAC;

            if(gCompgIDACShadow != tmpUint8 )

            {

                tmpUint32 = (uint32)tmpUint8;

                gCompgIDACShadow = tmpUint8;

                cystatusRet = CapSense_SetParam(CapSense_LLS_SNS0_IDAC_COMP0_PARAM_ID, tmpUint32);

                //CapSense_Start();

                cystatusRet = CapSense_GetParam(CapSense_LLS_SNS0_IDAC_COMP0_PARAM_ID, &tmpUint32);

                gReg->CompIDAC = gCompgIDACShadow = (uint8)(tmpUint32 & 0xFF);

            }

Now in the Low Level API I discovered some useful stuff like reading the capacitance in pF and reading the PSoC voltage.  Having the capacitance in pF is pretty handy for experimenting and messing around.

Important: to get these library calls you have to "enable self-test library" under the CapSense Advanced tab.  This is not documented well or at all and took me forever to figure out.

// Bits [7..0] are the capacitance (in pF) of the CSD electrode

                uint32 sensorCap = CapSense_GetSensorCapacitance(CapSense_LLS_WDGT_ID, CapSense_LLS_SNS0_ID);

                if( (sensorCap & CapSense_TST_BAD_PARAM) == 0 ) gReg->sensorCapacitance = (uint8)(sensorCap & 0xFF);

                gReg->sensorVdda = CapSense_GetVdda();  // value is in mV;

                CapSense_Start(); // this is needed to get the raw capacitance working again after sensorCapacitance call (455 uS)

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thank you for the valuable hints.

Giorgio

0 Likes
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

You should check the BIST(build in self test) checkbox in CapSense component configuration GUI and then compile the project.  This API is not generated by default by component, until you enable the BIST option.

0 Likes
Anonymous
Not applicable

Thank you very much indeed for the suggestion

Giorgio

Prof. Giorgio Cannata

Automatic Control

DIBRIS – Universita’ di Genova

Via Opera Pia 13, 16145 Genova

Tel: +39 010 3532223

Skype: giorgio.cannata.unige

Fax: +39 010 3532154

email: <mailto:giorgio.cannata@unige.it> giorgio.cannata@unige.it

0 Likes