Using CapSense_CSD_P4 with button

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I'm attempting to use the CapSense_CSD_P4 to enable a proximity sensor. I downloaded and ran the example project and all goes well. If I try to add a simple button everything breaks. 

   

The proximity sensor reads fine until you press the button, which then causes the proximity sensor to read its max value 255 indefinitaly. 

   

Attached is an example project. All I did was take the example proj from Cypress and add a debouncer with pin. So if you run it with a proximity attached and a button here is what happens: 

   

1. Code loads fine

   

2. As you move your hand closer to proxmity sensor red LED on pioneer board changes intensity (working fine)

   

3. If you press the button the led goes to full bright 

   

4. Proximity sensor no longers works. Code is in some type of deadlock. 

0 Likes
13 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Max clock for the debouncer is 200Hz.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

So are you  using a CY8CKIT-042 Ble kit? Looking at your program I found that your pin selections where incorrect for the example.  I have made the changes along with the clock change that Bob Marlowe  gave you.  I am also using PSOC Creator 4.0

0 Likes
Anonymous
Not applicable

That's correct, I'm using the  CY8CKIT-042 Ble Pioneer kit. So I opened your project but was met with the attached errors. So to fix it I changed the clock to 200kHz instead of 200Hz. 

   

   

However, using your project with the updated pins the program is still deadlocking the same as before. Any other ideas? I can try to record a video and upload if that will help .

   

0 Likes
Anonymous
Not applicable

After a little more debugging it seems that whenever I press the button, this line is always returning true...

   

/* Check if proximity sensor is active - thresholds are dynamically calculated during run-time
                proximityActive variable will have a non-zero value if Proximity was active */
proximityActive = CapSense_CheckIsSensorActive(PROXIMITY_SENSOR_INDEX);

0 Likes
Anonymous
Not applicable

Just found something else that may help. I'm using one of these push buttons. 

   
        
  1. Now, when I move my hand closer to the proximity sensor the LED intensity goes up and down. 
  2.     
  3. When I press the button, the LED intensity goes full bright and now the proximity does nothing.
  4.     
  5. Now, if I hold down the button, the proximity sensor works (aka step 1 is possible)
  6.     
  7. If I let go of the button I get stuck in step 2.
  8.    
   

It seems like something is getting stuck high? or low? and not going back after the button is released...but I have no idea what that would be.

   

Which to be honest I have no idea why pressing the button changes the LED state at all, it's not connected to it any way. 

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Can I ask why you are using a Debouncer component? The CapSense has Debounce.  Also why are you not using a CapSense button? Can you send a block diagram of your circuit so I can better understand what you are trying to do.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Are you using the Switch to wake up the device from Sleep mode?

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

I have two input methods: capsesense proximity and push button. I was using the debouncer to handle the push button. I'm not using the switch to do anything at the moment. When the switch is selected it simply triggers the ISR, that's it. 

   

I'm attaching a file of the board (ignore the other wires and the second push button, I'm only using the first) and also a file of a video so you can see what's happening. 

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I can't see the complete board  in your picture so I am not able to determine what pins you are using.  Also I have no information on how your switch is connected.  I have tried it on my  board using a wire to connect P0.5 to ground  to simulate a switch and I don't see you issue.  I do have some issues with it latching up at random times but I think this is due to the wire picking up stray signals.  I am sending you an updated program. I have a frequency divider to bring down the clock for the Debouncer component.

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

Here is a terrible block diagram with my pinouts. 

0 Likes
Anonymous
Not applicable

Trying your example project I'm getting the same weird functionality. I'm not sure why pressing the button is having any effect on the proximity readings...still trying to debug through it. 

   

If worse comes to worse, and I admit defeat, I'll just switch to polling the button rather than relying on an ISR. Not ideal but it'll work I guess 😞 

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

You don't need to have a voltages on your switch just ground. You can select a pull up resistor on P0.5 That way all your switch needs is a ground connection. One other thing use Volatile for your interrupt variable. 

   

0 Likes
Yuva
Moderator
Moderator
Moderator
250 replies posted 250 sign-ins 100 solutions authored

Hi,

   

 

   

Can you check the capsense data (rawcount, baseline, signal) using the tuner example project and share your observations? Also one more point to be noted is that your sensor setup is not rigid and move when touched which can cause huge variation in the capacitance resulting increase in rawcount more than noise threshold configured which causes stuck-up situation. You may check the manual tuning section available in the CapSense Design Guide to get more details.

   

 

   

Thanks,

   

Yuva.

0 Likes