proximity sensor signals

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

cross mob
KyCl_4704321
Level 1
Level 1

i am working on a project that uses a capsense proximity sensor. i am wanting to use the sensor as both a proximity sensor and a touch sensor. i was hoping someone could show me maybe some example code on how i could do this.

thanks,

kyle

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi KyCl_4704321​,

The proximity widget has a parameter called "Touch Threshold" which can be used to check if the proximity widget is touched or not. If the diff counts is greater than touch threshold + hysteresis, then touch event is detected. If diff counts is greater the proximity threshold + hysteresis, then proximity event is detected, For proper operation, proximity threshold should be less than touch threshold.

Use CapSense_IsProximitySensorActive() to differentiate between proximity event and touch event.

Refer CapSense component datasheet for details.

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
7 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi KyCl_4704321​,

The proximity widget has a parameter called "Touch Threshold" which can be used to check if the proximity widget is touched or not. If the diff counts is greater than touch threshold + hysteresis, then touch event is detected. If diff counts is greater the proximity threshold + hysteresis, then proximity event is detected, For proper operation, proximity threshold should be less than touch threshold.

Use CapSense_IsProximitySensorActive() to differentiate between proximity event and touch event.

Refer CapSense component datasheet for details.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

so if i use the command CapSense_IsProximitySensorActive() i would just be checkoing if bit 0 is high from the value the sensor returns? but its still unclear what i do about the touch ive tried looking through the capsense component data sheet but i cant seem to find this. could you help point me to the right section maybe?

0 Likes

Hi KyCl_4704321​,

I'm assuming that you are using PSoC 4 device for your application with the latest CapSense component version for your design. Please correct if my assumption is wrong.

CapSense_IsProximitySensorActive() returns a 32 bit unsigned integer.

bit[0] - Indicates that a proximity is detected. Diff Counts is greater than Proximity threshold + Hysteresis

bit[1] - Indicates that a touch is detected. Diff Counts is greater than Touch threshold + Hysteresis

Please refer Pg no 69 in the CapSense component datasheet.

https://www.cypress.com/file/492461/download

Please let us know if you have questions.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

above i attached a snapshot of my code. so would this be the right implimentation of this? that when a touch is sensed it would go into the SIngleLedMultiColor routine?

and if that is not working is that because my device is not properly tuned?

Thanks,

Kyle

0 Likes

Capture.PNG

0 Likes

Capture.PNGi notice another issue i have is that when i run the tuner i get no signals. i can clearly see in the sensor data graph that the raw counts change with the proximity of my hand , but the sensor signal graph and the status graph are unchanging.

0 Likes

Hi KyCl_4704321​,

Looks like the rawcounts are saturating (15 bits -> 2^15). This is a tuning/ calibration issue.

1. Can you ensure the auto-calibration is turned ON?

2. Did you check the return of CapSense_Start() and check if it returns pass (if auto calib is enabled)

3. Did you set Fsw by following the 10 RC rule?

Question: above i attached a snapshot of my code. so would this be the right implementation of this? that when a touch is sensed it would go into the SIngleLedMultiColor routine?

--> No, this is incorrect. You should check the return of this function CapSense_IsProximitySensorActive(). See example code below:

uint32_t proxReturn = 0;

...

...

...

proxReturn = CapSense_IsProximitySensorActive(CapSense_PROX_WIDGET_ID, CapSense_PROX_SENSOR_ID);

if((proxReturn & 0x1) != 0) //Check bit 0 is set or clear

{

     /* Proximity is detected  */

}

if((proxReturn & 0x2) != 0) //Check bit 1 is set or clear

{

     /* Touch is detected  */

}

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes