Capsense Matrix keypad 2x2

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

cross mob
shilpasonone04
Level 1
Level 1
25 sign-ins 10 sign-ins 5 questions asked

I am working on 2x3 Cap Sense matrix keypad interfacing using PSOC4 ,

but i am facing difficulty in software section. Can anyone give suggestion on it.

0 Likes
1 Solution
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @shilpasonone04,

After scanning the sensors in the for loop, processing needs to be done. Can you include the CapSense_ProcessAllWidgets() function in the for loop and check for the functionality?

Also, when CapSense scan is initiated, the program must wait until the scan is complete. Use the below template, and test your application:

int main(void)
{
CyGlobalIntEnable;
CapSense_Start();
//<other code>

for(;;)
{
/* Place your application code here. */
if( !CapSense_IsBusy())
{
CapSense_ProcessAllWidgets();

//other implementations

CapSense_ScanAllWidgets();
}
}
}

 

Regards,
Nikhil

View solution in original post

0 Likes
7 Replies
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @shilpasonone04,

Refer to the CE224821 – PSoC 4 CapSense Touchpad with Gestures code example to get a better understanding of how to develop a trackpad application.

Regards,
Nikhil

0 Likes
shilpasonone04
Level 1
Level 1
25 sign-ins 10 sign-ins 5 questions asked

Thank You for your response. I want to design 2*3 capsense buttons in matrix format. Is it possible? and so then is it working as a same  as simple switches in row and column format?

0 Likes
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @shilpasonone04,

Yes, you may change the number of rows and columns are per your requirement.

Do you want the matrix keys to be physically separated? If so, you may have to implement 6 separate capsense buttons. You need to place the sensors in the required geometry.

Regards,
Nikhil

0 Likes

I tried code for 2x2 capsense matrix but its not working. Please check code and suggest me .

/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include "project.h"
uint8 flag0 = 0;
uint8 flag1 = 0;
uint8 wrBuf;
uint32 userBuf;
uint8 matrixBuf;
uint8 rowBuf,clmnBuf,Sensor_id;
uint8 i2cReadBuffer[10];
uint8 byteCnt,i,wid_value,sense_value;
uint8 S0 =0;
uint8 S1 =0;
uint8 S2 =0;
uint8 S3 =0;
int main(void)
{
uint16 bIndex, sIndex;
CyGlobalIntEnable; /* Enable global interrupts. */
// Initialize CSD module.
CapSense_Start();
CapSense_SetupWidget(CapSense_MATRIX_BUTTONS_TOUCHED);
// Set finger thresholds according to parameter value

CapSense_InitializeAllBaselines();
// Reset baseline for each sensor

//Clear All LEDs
// ClearAllLEDs();

// SRegInfo.bSensorID = 0; //On reset store 0 as sensor id
I2C_1_I2CSlaveClearReadBuf();
I2C_1_I2CSlaveClearWriteBuf();
i2cReadBuffer[0]=00;
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
I2C_1_I2CSlaveInitWriteBuf((uint8 *) wrBuf, 10);

/* Start I2C Slave operation */
I2C_1_Start();
for(;;)
{
// Capsense_csd_scanSensor();
CapSense_ScanAllWidgets();

// Update sensor baseline
CapSense_UpdateAllBaselines();
// Update sensor baseline
matrixBuf = CapSense_IsSensorActive(wid_value,sense_value);
switch(matrixBuf)
{
case 00:
led1_Write(1);
break;
case 01:
led2_Write(1);
break;
case 03:
led3_Write(1);
break;
case 04:
led4_Write(1);
break;
}

}
}

/* [] END OF FILE */

 

0 Likes
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @shilpasonone04,

Can you share your project here so that it would be easy to debug the issue?

Regards,
Nikhil

0 Likes
lock attach
Attachments are accessible only for community members.
shilpasonone04
Level 1
Level 1
25 sign-ins 10 sign-ins 5 questions asked

Please check the attached project file.

0 Likes
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @shilpasonone04,

After scanning the sensors in the for loop, processing needs to be done. Can you include the CapSense_ProcessAllWidgets() function in the for loop and check for the functionality?

Also, when CapSense scan is initiated, the program must wait until the scan is complete. Use the below template, and test your application:

int main(void)
{
CyGlobalIntEnable;
CapSense_Start();
//<other code>

for(;;)
{
/* Place your application code here. */
if( !CapSense_IsBusy())
{
CapSense_ProcessAllWidgets();

//other implementations

CapSense_ScanAllWidgets();
}
}
}

 

Regards,
Nikhil

0 Likes