A simpler PSoC CapSense Proximity switch example

The built-in Capsense example of the CY8KIT-043 PSOC 4200M is a bit complex. So I searched their tutorials for simpler ones and found a very good one but it was implemented on a different PSoC chip. I stole the DWR (design wide resources) and the code from there and used my specific bootloader to flash my chip.

Sketch (1).png
All it needs is a capsense module and a digital output pin with its H/W connections disabled. We’ll be driving it directly from the code

Then mapped the pins as follows:
Sketch (1).png

The code is as follows:

#include "project.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
CapSense_1_Start();
CapSense_1_EnableWidget(CapSense_1_PROXIMITYSENSOR0__PROX); 
CapSense_1_InitializeAllBaselines(); /* To take care of stray capacitances*/
CapSense_1_ScanEnabledWidgets();

for(;;)
{
/* Place your application code here. */
if (CapSense_1_IsBusy()==0)
{
LED_Write(CapSense_1_CheckIsWidgetActive(CapSense_1_PROXIMITYSENSOR0__PROX));
CapSense_1_UpdateEnabledBaselines();
CapSense_1_ScanEnabledWidgets();

}

}
}

 

 

IMG_20180529_013509_HDR.jpg
The setup worked fine with this small loop!

 

The next thing to try is testing the same with many CSD (CapSense Devices) to turn on multiple LEDs.

As per the datasheet most of the general pins support CSD.

Update:

It worked perfectly. One CSD module was enough for all the proximity detectors. I only added digital outputs in each case and assigned them different pin numbers and above all made the necessary modifications in the code.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s