multiple touch button related issue, 1 button continously active

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.
admin_hun_main
Level 1
Level 1
10 sign-ins 5 replies posted 5 sign-ins

hi,

SO I tested my hardware with Capsense P4 one Button code. it was working, now I have to modify it for 3 buttons, so from the forum, I have modified the code as follow, 

so here is my code:

 

/* ========================================
 *
 * 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"


/* Refresh interval in milliseconds for fast scan mode */
#define LOOP_TIME_FASTSCANMODE          (30u)

/* Refresh interval in milliseconds for slow scan mode */
#define LOOP_TIME_SLOWSCANMODE          (100u)

#define MILLI_SEC_TO_MICRO_SEC          (1000u)

#if (!CY_IP_SRSSV2)
    /* ILO frequency for PSoC 4 S-Series device */
    #define ILO_CLOCK_FACTOR            (40u)
#else
    /* ILO frequency for PSoC 4 device */
    #define ILO_CLOCK_FACTOR            (32u)
#endif

/* Refresh rate control parameters */    
#define WDT_TIMEOUT_FAST_SCAN           (ILO_CLOCK_FACTOR * LOOP_TIME_FASTSCANMODE)   
#define WDT_TIMEOUT_SLOW_SCAN           (ILO_CLOCK_FACTOR * LOOP_TIME_SLOWSCANMODE)

/* Macro to enable WDT */
#define ENABLE_WDT                      (0x01u)

/* Macro to disable/enable tuner to update sensor parameters - 0: disable 1: enable */
#define TUNER_UPDATE_ENABLE             (0u)

/* This timeout is for changing the refresh interval from fast to slow rate
*  The timeout value is WDT_TIMEOUT_FAST_SCAN * SCANMODE_TIMEOUT_VALUE
*/
#define SCANMODE_TIMEOUT_VALUE          (150u)  

/* Reset value of softCounter */    
#define RESET                           (0u)

/* Boolean constants */
#define TRUE                            (1u)
#define FALSE                           (0u)

/* Finite state machine states for device operating states */
typedef enum
{
    SENSOR_SCAN = 0x01u, /* Sensor is scanned in this state */
    WAIT_FOR_SCAN_COMPLETE = 0x02u, /* CPU is put to sleep in this state */
    PROCESS_DATA = 0x03u, /* Sensor data is processed */
    SLEEP = 0x04u /* Device is put to deep sleep */
} DEVICE_STATE;


/* Firmware implements two refresh rates for reducing average power consumption */
typedef enum
{
    SLOW_SCAN_MODE = 0u,
    FAST_SCAN_MODE = 1u
} SCAN_MODE;
/*      Variable to hold the current device state 
    *  State machine starts with sensor scan state after power-up
    */
DEVICE_STATE currentState = SENSOR_SCAN; 

/* This variable is used to indicate the current power mode */
SCAN_MODE deviceScanMode = FAST_SCAN_MODE;

/* Variable to store interrupt state */
uint32 interruptState = 0u;
/* This variable is used to implement a software counter. If the value 
    *  of this counter is greater than SCANMODE_TIMEOUT_VALUE, it indicates that the button sensor 
    *  was inactive for more than 3s. 
    */
uint16 softCounter = RESET;

/* Compensated Watchdog match value in fast scan mode */
uint32 wdtMatchValFastMode = 0u;

/* Compensated Watchdog match value in slow scan mode */
uint32 wdtMatchValSlowMode = 0u;

/* Variable to check the WDT interrupt state */
volatile uint8 wdtInterruptOccured = FALSE;

/* Contains watchdog match value to generate period interrupt */
volatile uint32 watchdogMatchValue = WDT_TIMEOUT_FAST_SCAN;



/* API to prepare the device for deep sleep */
void EnterDeepSleepLowPowerMode(void);

/* API to configure the WDT timer for controlling scan intervals */
void WDT_Start(void);

/* API to get WDT matchvalue to generate precise scan intervals */
void CalibrateWdtMatchValue(void);

void scan_process();


int main(void)
{
    
    /* Enable global interrupts for CapSense operation */
    CyGlobalIntEnable;
    
    /* Initialize the LED pin as digital output, initially off */

    Green_LED_Write( 0 );
    Green_LED_1_Write( 0 );
    Green_LED_2_Write( 0 );
    
  
#if TUNER_UPDATE_ENABLE    
    /* Start EZI2C block */
    EZI2C_Start();
    
    /* Set up communication data buffer to CapSense data structure to 
     * expose to I2C master at primary slave address request        
     */
    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),\
                         (uint8 *)&CapSense_dsRam);
#endif
    /* Start CapSense block - Initializes CapSense data structure and 
     * performs first scan of all widgets/sensors to set up sensors
     * baselines 
     */
    CapSense_Start();

    /* Configure button sensor parameters and connect it to AMUXBUS */
    CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);
    /* Watchdog is used to control the loop time in this project and watchdog
    *  is set to generate interrupt at every LOOP_TIME_FASTSCANMODE in fast scan mode  
    *  and at LOOP_TIME_SLOWSCANMODE in slow scan mode
    */
    WDT_Start();
    for(;;)
    {
        /* Place your application code here. */
        scan_process();
    }
}


void scan_process()
{
    /* Switch between sensor-scan -> wait-for-scan -> process -> sleep states */
        switch(currentState)
        {
            case SENSOR_SCAN:
                /* Initiate new scan only if the CapSense hardware is idle */
                if(CapSense_NOT_BUSY == CapSense_IsBusy())
                {
                    /* Update CapSense parameters set via CapSense tuner before the 
                    *  beginning of CapSense scan. This check if required if we are using 
                    *  CapSense Extension (Ext) APIs in the project.
                    */
                    #if (TUNER_UPDATE_ENABLE)
                        if(CapSense_STATUS_RESTART_DONE == CapSense_RunTuner())
                        {
                            /* Set up sensor */
                            //CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);
                            //CapSense_CSDSetupWidgetExt(CapSense_BUTTON1_WDGT_ID, CapSense_BUTTON1_SNS0_ID);
                            CapSense_CSDSetupWidgetExt(CapSense_BUTTON2_WDGT_ID, CapSense_BUTTON2_SNS0_ID);
                        }
                    #endif
                    
                    /* Scan widget configured by CSDSetupWidgetExt API */
                    CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);
                    CapSense_CSDScanExt();
                    while(CapSense_IsBusy());
                    
                    CapSense_CSDSetupWidgetExt(CapSense_BUTTON1_WDGT_ID, CapSense_BUTTON1_SNS0_ID);
                    CapSense_CSDScanExt();
                    while(CapSense_IsBusy());
                    
                    CapSense_CSDSetupWidgetExt(CapSense_BUTTON2_WDGT_ID, CapSense_BUTTON2_SNS0_ID);
                    CapSense_CSDScanExt();
                    
                    /* Put CPU to sleep while sensor scanning is in progress */
                    currentState = WAIT_FOR_SCAN_COMPLETE;       
                }
                break;

            case WAIT_FOR_SCAN_COMPLETE:
                /* Device is in CPU Sleep until CapSense scanning is complete or
                *  device is woken-up by either CapSense interrupt or I2C interrupt 
                */
                /* Disable interrupts, so that ISR is not serviced while
                *  checking for CapSense scan status.
                */
                interruptState = CyEnterCriticalSection();
                
                /* Check if CapSense scanning is complete */
                if(CapSense_NOT_BUSY != CapSense_IsBusy())
                {
                    /* If CapSense scanning is in progress, put CPU to sleep */
                    CySysPmSleep();
                }
                /* If CapSense scanning is complete, process the CapSense data */
                else
                {
                    currentState = PROCESS_DATA;
                }
                /* Enable interrupts for servicing ISR */
                CyExitCriticalSection(interruptState);
                break;
            
            case PROCESS_DATA:
                
                /* Set next state to SLEEP */
                currentState = SLEEP;
                
                /* process button widget */
                /*CapSense_ProcessWidget(CapSense_BUTTON0_WDGT_ID);
                CapSense_ProcessWidget(CapSense_BUTTON1_WDGT_ID);
                CapSense_ProcessWidget(CapSense_BUTTON2_WDGT_ID);*/
                CapSense_ProcessAllWidgets();
                if(deviceScanMode == FAST_SCAN_MODE)
                {  
                    /* If button is active, reset software counter */
                   if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
                    {
                        // Reset the software counter if any button is active. *  /
                        softCounter = RESET;
                        // led 1 ON
                        Green_LED_Write( 1 );
                    }else if(CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)){
                        // Reset the software counter if any button is active. 
                        softCounter = RESET;
                        // LED 2 ON
                        Green_LED_2_Write( 1 );
                    }else if(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)){
                        // Reset the software counter if any button is active. 
                        softCounter = RESET;
                        // LED 0 ON
                        Green_LED_1_Write( 1 );
                    }
                    else
                    {
                        /* Increment the software counter every LOOP_TIME_FASTSCANMODE if button 
                        *  touch is not detected. 
                        */
                        softCounter++;  
                        // reset led
                        Green_LED_Write( 0 );
                        Green_LED_1_Write( 0 );
                        Green_LED_2_Write( 0 );
                        /* If finger is not on sensor for SCANMODE_TIMEOUT_VALUE, switch off the 
                        *  LEDs and switch mode to slow scan mode to reduce power consumption 
                        */
                        if(softCounter >= SCANMODE_TIMEOUT_VALUE)
                        {   
                            /* Watchdog is configured to generate interrupt at LOOP_TIME_SLOWSCANMODE */
                            watchdogMatchValue = wdtMatchValSlowMode;
                            
                            #if(CY_IP_SRSSV2)
                                /* Configure Match value */
                                CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, watchdogMatchValue);
                            #endif
        
                            /* Set mode to slow scan mode to scan sensors at LOOP_TIME_SLOWSCANMODE */
                            deviceScanMode = SLOW_SCAN_MODE;
                        }
                    }
                }
                /* If deviceScanMode is SLOW_SCAN_MODE, perform the following tasks */   
                else
                {                    
                    /* If button is active, switch to active mode */
                   /* if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID) ||
                        CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID) ||
                        CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)
                        )*/
                    if (CapSense_IsAnyWidgetActive())
                    {   
                       /* If sensor is active in slow-scan mode, skip sleep
                        *  and perform sensor scan
                        */
                        currentState = SENSOR_SCAN;
                        
                        /* Set watchdog match value to fast scan mode */
                        watchdogMatchValue = wdtMatchValFastMode;      
                        
                        #if(CY_IP_SRSSV2)
                            /* Configure Match value */
                            CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, watchdogMatchValue);
                        #endif
                        
                        /* Change the device mode to fast scan mode to provide fast touch response */
                        deviceScanMode = FAST_SCAN_MODE; 
                    }                    
                }
                break;
                
            case SLEEP:
               /* Put the device to deep sleep after each CapSense scan */
                EnterDeepSleepLowPowerMode();
                
                /* Start scanning the sensors only if interrupt occurred due to WDT.
                   Interrupt can also occur due to I2C interrupt while tuner is running.
                   In such cases, sensor is not scanned until WDT interrupt has occurred
                */
                if(wdtInterruptOccured)
                {
                    /* Set state to scan sensor after device wakes up from sleep */
                    currentState = SENSOR_SCAN;
                    
                    wdtInterruptOccured = FALSE;  
                }
                break;
            default:
                /*******************************************************************
                 * Unknown power mode state. Unexpected situation.
                 ******************************************************************/
                CYASSERT(0);
                break;
        } // end switch
}


/*******************************************************************************
* Function Name: EnterDeepSleepLowPowerMode
********************************************************************************
* Summary:
*  Put the device to DeepSleep power mode. Reconfigures the Components for 
*  normal operation after wake-up. 
*
* Parameters:
*  void
*
* Return:
*  void
*
* Theory: Before going to deep sleep, the API checks for any
*         I2C activity and waits till the I2C transaction is complete before 
*         the device is put to deep sleep. 
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
void EnterDeepSleepLowPowerMode(void)
{
    /* EZI2C_Sleep routine should be called only after on-going I2C 
    *  transaction is complete
    *  Enter critical section to lock slave state 
    */
    interruptState = CyEnterCriticalSection();
#if TUNER_UPDATE_ENABLE    
      /* Check if I2C is busy. If so, skip deep sleep until I2C is free */
    if(!(EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY))
    {
        /* Configure slave to be wakeup source */
        EZI2C_Sleep();
        
        /* Enter DeepSleep. */
        CySysPmDeepSleep();	
       
        /* WDT or any I2C communication wakes up device from deep sleep. */

        /* Configure slave for active mode operation */
        EZI2C_Wakeup();
    }
#endif
    /* Enable interrupts */
    CyExitCriticalSection(interruptState);
}

/******************************************************************************
* Function Name: Timer_Interrupt
*******************************************************************************
*
* Summary:
*  Handles the Interrupt Service Routine for the WDT timer.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Theory: The interrupt is cleared on the ISR as watchdog in this project is 
*         used for timing maintenance only. Match value is updated to maintain 
*         the loop time. 
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
CY_ISR(Timer_Interrupt)
{
    #if (CY_IP_SRSSV2)    
        /* Clears interrupt request  */
        CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER0_INT);
    #else
        /* Clear the watchdog interrupt */
        CySysWdtClearInterrupt();    
        
        /* WDT match value is updated in order to obtain periodic interrupts */
        CySysWdtWriteMatch(CySysWdtReadMatch() + watchdogMatchValue); 
    #endif /* !CY_IP_SRSSV2 */
    
    /* Set to variable that indicates that WDT interrupt had triggered*/
    wdtInterruptOccured = TRUE;   
}

/******************************************************************************
* Function Name: WDT_Start
*******************************************************************************
*
* Summary:
*  Configures WDT.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Theory: This API unmasks the WDT interrupt to route the interrupt to CPU and 
*         configures the ISR.
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
void WDT_Start(void)
{   
    /* Setup ISR */
    WDT_Interrupt_StartEx(Timer_Interrupt);
    
    /* Get the actual match value required to generate a given delay */
    watchdogMatchValue = WDT_TIMEOUT_FAST_SCAN;
    CalibrateWdtMatchValue();
    wdtMatchValFastMode  = watchdogMatchValue;
    
    watchdogMatchValue = WDT_TIMEOUT_SLOW_SCAN;
    CalibrateWdtMatchValue();
    wdtMatchValSlowMode = watchdogMatchValue;
    
    #if (CY_IP_SRSSV2)    
        /* Configure Match value */
        CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, wdtMatchValFastMode);
        
        /* Set up WDT mode */
        CySysWdtSetMode(CY_SYS_WDT_COUNTER0, CY_SYS_WDT_MODE_INT);
        
        /* Automatically reset counter */
        CySysWdtSetClearOnMatch(CY_SYS_WDT_COUNTER0, ENABLE_WDT);
        CySysWdtResetCounters(CY_SYS_WDT_COUNTER0_RESET);
        
        /* Enable WDT */
        CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK);
    #else 
        /* WDT match value is updated in order to obtain periodic interrupts */
        CySysWdtWriteMatch(CySysWdtReadMatch() + watchdogMatchValue);
        
        /* Enable WDT interrupt */
        CySysWdtUnmaskInterrupt();
    #endif
}
/*******************************************************************************
* Function Name: CalibrateWdtMatchValue
********************************************************************************
* Summary: 
*  This function calibrates the match value of the Watchdog Timer 
*
* Parameter:
*  None
*
* Return:
*  void
*
* Theory: The ILO is calibrated using IMO to improve the accuracy of ILO.
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
void CalibrateWdtMatchValue()
{    
    /* Contains ILO Trimmed value */
    uint32 tempIloCounts = 0u;
    
    /* Desired delay in microseconds for ILO Trimming */
    uint32 desiredDelay = ((watchdogMatchValue / ILO_CLOCK_FACTOR) * MILLI_SEC_TO_MICRO_SEC);  
    
    /* Get the ILO compensated counts i.e. the actual counts for the desired ILO frequency 
    *  Trimming is done to improve ILO accuracy using IMO; ILO default accuracy is +/- 60% 
    */
    if(CYRET_SUCCESS == CySysClkIloCompensate(desiredDelay, &tempIloCounts))
    {    
        watchdogMatchValue = (uint32)tempIloCounts;
    }    
}
/* [] END OF FILE */

 

 

The problem that I am facing is, I have 3 buttons of which 2 are detected properly, that when I touch led is ON when release OFF, but for 1 button its continuously ON either touch or not, when I debugged I found that the program continuously goes in the below section,

 

else if(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)){
                        // Reset the software counter if any button is active. 
                        softCounter = RESET;
                        // LED 0 ON
                        Green_LED_1_Write( 1 );
                    }

 

 

for debugging purposes, I changed the button position in GPIO allocation, but the same result either of 1 button from 3 is continuously active. I don't think it is hardware-related, I am looking for help in this section, what could I be doing wrong?

Secondly, I read about the Guard sensor, what I have to do for implementing the guard sensor? 

 

Edit : added project as zip file

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

Hi @admin_hun_main,

  • You are mentioning that buttons work fine when you observe their activity in Tuner. I observe the same from the csv file too. You also mention that you have changed the pin assignments for the buttons and still observe one LED always glowing, whereas that is not the case with me:
    • Can you check if the LED is accidentally connected to VDD in your design? If so, that might be causing the LED to always glow.
    • If possible, try to change the GPIO driving the LED and observe the LED status.
    • Now, considering the fact that in the debug activity, the control always went to :
      else if(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)){​

      can you try manual tuning the sensors? You can refer 5.3 Manual tuning of PSoC™ 4 and PSoC™ 6 MCU CAPSENSE™ design guide for detailed steps.

  • I observe SmartSense enabled in the project. Are you retaining the same?

  • I observe sudden spikes in signal for Raw_Button2_Sns0. Is any conductive material entering the vicinity of the button? Are any sources present near the sensors which emit radiations? Avoid having conductive material or emissive sources near the CapSense system.
    Is the temperature in the vicinity of the CapSense system drastically changing?

  • I do not see information regarding your guard sensor implementation.
    • Are you using any of the Button0, Button1 or Button2 as a guard sensor?
    • I don't see guard sensor details in the zip file shared by you.

 

Regards,
Nikhil

View solution in original post

9 Replies
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @admin_hun_main,

Can you share the project as a zip file so that we can take a closer look?

Also, which kit/device are you using for your application?

Regards,
Nikhil

i have attached the project.


@ncbs wrote:

Hi @admin_hun_main,

Can you share the project as a zip file so that we can take a closer look?

Also, which kit/device are you using for your application?

Regards,
Nikhil


Its Custome hardware 

@ncbs any update ?

 

 

 

 

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

Hi @admin_hun_main,

I tested the project on CY8CKIT-149 without any changes in the firmware. The code works perfectly for me.

Whenever a button is pressed, the corresponding LED status gets changed. When the touch is withdrawn, the LED toggles back. This is obeyed by all the buttons. Could you re-program the device and check? 

 

Guard sensor:

A guard sensor is a copper trace that surrounds all the sensors on the PCB. A guard sensor is similar to a button sensor and is used to detect the presence of streaming liquids.

Figure 149 shows the typical placement of a guard sensor. The guard sensor is placed 1cm away from all the sensors so that false triggers are avoided. The guard sensor's thickness is recommended to be equal to 2mm. 

 

ncbs_0-1646827872232.png

 

Please refer to section 7.4.12.2 Layout guidelines for guard sensor in PSoC™ 4 and PSoC™ 6 MCU CAPSENSE™ design guide for more details regarding the implementation of guard sensor.

 

Regards,
Nikhil


@ncbs wrote:

Hi @admin_hun_main,

I tested the project on CY8CKIT-149 without any changes in the firmware. The code works perfectly for me.

Whenever a button is pressed, the corresponding LED status gets changed. When the touch is withdrawn, the LED toggles back. This is obeyed by all the buttons. Could you re-program the device and check? 

 

Guard sensor:

A guard sensor is a copper trace that surrounds all the sensors on the PCB. A guard sensor is similar to a button sensor and is used to detect the presence of streaming liquids.

Figure 149 shows the typical placement of a guard sensor. The guard sensor is placed 1cm away from all the sensors so that false triggers are avoided. The guard sensor's thickness is recommended to be equal to 2mm. 

 

ncbs_0-1646827872232.png

 

Please refer to section 7.4.12.2 Layout guidelines for guard sensor in PSoC™ 4 and PSoC™ 6 MCU CAPSENSE™ design guide for more details regarding the implementation of guard sensor.

 

Regards,
Nikhil


Hi @ncbs , 

 

I have checked many times reprogramming and I also created a new project for this. but its same result. And also I don't think its hardware related cos if I change the button position on IO pins it still occurs, and keeps shifting from button to button. 

what should I do in case to debug it for the root cause? what is the use of a Tuner cause I have checked with the tuner and all button seems to detect normal? does the cap sense tuner make any change in code?

also, I have made changes for the Guard sensor according to the document, but what are the changes I have to make in current for the Guard sensor to be effective?

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

Hi @ncbs ,

 

I am sharing the logfile from the cap sense tuner, is there anything you can understand from it. I think the button2 has a noise issues. 

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

Hi @admin_hun_main,

  • You are mentioning that buttons work fine when you observe their activity in Tuner. I observe the same from the csv file too. You also mention that you have changed the pin assignments for the buttons and still observe one LED always glowing, whereas that is not the case with me:
    • Can you check if the LED is accidentally connected to VDD in your design? If so, that might be causing the LED to always glow.
    • If possible, try to change the GPIO driving the LED and observe the LED status.
    • Now, considering the fact that in the debug activity, the control always went to :
      else if(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)){​

      can you try manual tuning the sensors? You can refer 5.3 Manual tuning of PSoC™ 4 and PSoC™ 6 MCU CAPSENSE™ design guide for detailed steps.

  • I observe SmartSense enabled in the project. Are you retaining the same?

  • I observe sudden spikes in signal for Raw_Button2_Sns0. Is any conductive material entering the vicinity of the button? Are any sources present near the sensors which emit radiations? Avoid having conductive material or emissive sources near the CapSense system.
    Is the temperature in the vicinity of the CapSense system drastically changing?

  • I do not see information regarding your guard sensor implementation.
    • Are you using any of the Button0, Button1 or Button2 as a guard sensor?
    • I don't see guard sensor details in the zip file shared by you.

 

Regards,
Nikhil

lock attach
Attachments are accessible only for community members.
  • Can you check if the LED is accidentally connected to VDD in your design? If so, that might be causing the LED to always glow.
    • No the led is properly connected to GPIO, I have a separate blink code.
  • can you try manual tuning the sensors? You can refer 5.3 Manual tuning of PSoC™ 4 and PSoC™ 6 MCU CAPSENSE™ design guide for detailed steps.
    • Actually, I was trying manual tuning but I am a bit clueless as to how to do it.
  • I observe SmartSense enabled in the project. Are you retaining the same?
    • Yes
  • I observe sudden spikes in signal for Raw_Button2_Sns0. Is any conductive material entering the vicinity of the button? Are any sources present near the sensors which emit radiations? Avoid having conductive material or emissive sources near the CapSense system.
    Is the temperature in the vicinity of the CapSense system drastically changing?
    • Actually Yes there is Capacitor and inductor near the button, as the Guard sensor ends it's in close vicinity, it's for Power supply from 12v to 5v. it's due to the space constraint. 

So actually got it working, it took a very much and turns out a big task, I tried tunning it with a cap sense tuner, it works now but sometimes it FAILS like it working you can see led glowing for all 3 buttons, but after some times it hangs like nothing happens even if you press a finger to the surface of the button. then after some time, it starts sensing the button. I didn't get the reason behind this, WDT is getting triggered but why it's getting hanged is clueless or where.

And sometimes if you touch (button0) then led corresponding to button1 is glowing. which I think is noise but after tunning i shouldn't be expecting any noise that's weird

 

  • I do not see information regarding your guard sensor implementation.
    • it's at different GPIO, I have enabled it in components but I was unsure of code as in how to implement it in code. I have attached an image, it's at PIN1.7. Maybe that time when I shared files I hadn't added that it's different than Button0/1/2, it's a different ring around the button. 

Also how to detect 2 buttons simultaneously, in. My code if press 2 button either of one is detected. 

 

@ncbs 

Also, how do I verify that cap sense tuner config are written to the project?

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

Hi @admin_hun_main 

> Can you share all the tuning parameters? It seems like this is a tuning issue.

> It would be recommended to have radiating elements such as inductors away from the sensors.

> I was pointing out to the layout of the guard. Ensure that the guard sensor is a loop surrounding all other sensors, with a thickness of 2mm and separation distance to shield  hatch at 1mm.

> When you change any parameter(s), you can click on the "To Project" to apply it to the project. To test the changes immediately on the device, click on "To Device".

ncbs_1-1650451376714.png

 

> instead of if...elseif...else block, use if statements. Your logic should be as follows:

/* If button is active, reset software counter */
if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
	// Reset the software counter if any button is active. *  /
	softCounter = RESET;
	// led 1 ON
	Green_LED_Write( 1 );
}
if(CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)){
	// Reset the software counter if any button is active. 
	softCounter = RESET;
	// LED 2 ON
	Green_LED_2_Write( 1 );
}
if(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)){
	// Reset the software counter if any button is active. 
	softCounter = RESET;
	// LED 0 ON
	Green_LED_1_Write( 1 );
}

Regards,
Nikhil

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

Hi @admin_hun_main,

To implement guard sensor in firmware, use the Button widget and assign a suitable pin to the same.

The status of the guard sensor must be used to proceed ahead with scanning other sensors. Other sensors must not be scanned when guard sensor is active. If otherwise, other sensors are scanned/normal application may run.

Regards,
Nikhil

0 Likes