7 Replies Latest reply on Sep 4, 2020 10:39 AM by BragadeeshV_41

    proximity sensor signals

    KyCl_4704321

      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

        • 1. Re: proximity sensor signals
          BragadeeshV_41

          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

          • 2. Re: proximity sensor signals
            KyCl_4704321

            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?

            • 3. Re: proximity sensor signals
              BragadeeshV_41

              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

              • 4. Re: proximity sensor signals
                KyCl_4704321

                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

                • 6. Re: proximity sensor signals
                  KyCl_4704321

                  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.

                  • 7. Re: proximity sensor signals
                    BragadeeshV_41

                    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