4 Replies Latest reply on Jun 25, 2018 5:00 AM by brvi

    CE210291_CapSense_P4_One_Button01 modify to multiple Buttons / Sense?

    user_1_2651671

      Hello,

       

      I am using a capsense Evalkit (4045) with example Code CE210291.

      That Programm is adjusted for a One Button/Sense with low power consumption.

       

      Now I'm trying to modify that programm to work with 8..9 Buttons. I have configure "Capsense" with 7 additional buttons.
      Unfortunately still only one Button is detected.

       

      I think I need to add additional code in the main.c, but I am not sure how much I need to change? Maybe it need only one line of code?

      I think I have to modify follow line, but I am not sure - maybe somebody can confirm/ give some correction, advice?:

       

      line 176

      /* Configure button sensor parameters and connect it to AMUXBUS */

          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);

      CapSense_CSDSetupWidgetExt(CapSense_BUTTON3_WDGT_ID, CapSense_BUTTON3_SNS0_ID);

      etc....

       

      line 243              

      /* process button widget */

      CapSense_ProcessWidget(CapSense_BUTTON0_WDGT_ID);

      CapSense_ProcessWidget(CapSense_BUTTON1_WDGT_ID);

      CapSense_ProcessWidget(CapSense_BUTTON2_WDGT_ID);

      CapSense_ProcessWidget(CapSense_BUTTON3_WDGT_ID);

      etc...

       

      line 248 ... line 300

                      /* If button is active, reset software counter */

                          if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID) ||  CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID) || etc....)

                          {

                              /* Reset the software counter if any button is active. */

                              softCounter = RESET;

                          }

                          else

      ...

      ..

      /* If button is active, switch to active mode */

                          if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID) ||  CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID) || etc....)

                          { 

                             /* If sensor is active in slow-scan mode, skip sleep

                              *  and perform sensor scan

                              */

       

       

      thank you

        • 1. Re: CE210291_CapSense_P4_One_Button01 modify to multiple Buttons / Sense?
          brvi

          Hi,

           

          You have given the “ CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);" and so on in initialization.

           

          CSDSetupWidgetExt can connect only one sensor at a time to the AMUX bus. This may be the reason why the tuner had sensed the last button which was setup using CSDSetUpWidgetExt().

           

          Try the following code snippet. This should work.

           

          int main()

          {   

          -

          -

          -

          /* Don’t setup the widgets here */

           

            for(;;)

              {

          switch(currentState)

          {

          case SENSOR_SCAN:

           

                          if(CapSense_NOT_BUSY == CapSense_IsBusy())

          {

           

                              #if (TUNER_UPDATE_ENABLE)

          if(CapSense_STATUS_RESTART_DONE == CapSense_RunTuner())

          {

          /* Set up sensor */

          CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID)

           

                                  }

          #endif

          /*Setup the widgets here*/

          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());

          -

          -

          -

            while(CapSense_IsBusy());

          CapSense_CSDSetupWidgetExt(CapSense_BUTTON8_WDGT_ID, CapSense_BUTTON8_SNS0_ID);

          CapSense_CSDScanExt();

           

          currentState = WAIT_FOR_SCAN_COMPLETE;     

          }

          break;

           

          case WAIT_FOR_SCAN_COMPLETE:

          -

          -

          -

                        break;

          case PROCESS_DATA:

           

            currentState = SLEEP;

           

          CapSense_ProcessWidget(CapSense_BUTTON0_WDGT_ID);

          CapSense_ProcessWidget(CapSense_BUTTON1_WDGT_ID);

          -

          -

          CapSense_ProcessWidget(CapSense_BUTTON7_WDGT_ID);

          -

          if(deviceScanMode == FAST_SCAN_MODE)

          {

          if (CapSense_IsAnyWidgetActive())

          {

          softCounter = RESET;

          }

           

          else

          {

            if (CapSense_IsAnyWidgetActive())

            currentState = SENSOR_SCAN;

           

            watchdogMatchValue = wdtMatchValFastMode;     

                                 

                #if(CY_IP_SRSSV2)

           

                  CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, watchdogMatchValue);

          #endif

           

              deviceScanMode = FAST_SCAN_MODE;

                }

            }

          break;

            -

          -

          -

          }   

           

          I have also attached the project. You can also refer to it.

           

          Regards,

          Bragadeesh

          • 2. Re: CE210291_CapSense_P4_One_Button01 modify to multiple Buttons / Sense?
            user_1_2651671

            thank you very much for that great support, I will try it tomorrow and give a feedback.

            EDIT: it works :-D !

            • 3. Re: CE210291_CapSense_P4_One_Button01 modify to multiple Buttons / Sense?
              user_1_2651671

              I measured the power consumption directly at the power inputs (Pin 21, 39,40) from CY8C4045AZI-S413 on my Evakit. The current consumption is around 4mA with above programm example (Launch Tuner not active). I have removed L3 and L4 to disconnect the Bluetooth chip from the power supply.

               

              I am little bit surprised about te high current consumption, because for example the CY8CMBR3116 (fix programmed device) only consume 1.1mA. According my Infos the CY8CMBR3116 is based on the PSoC 4000, typ: CY8C4014LQI-422

               

              So what could be the root cause? What are your experience?

               

              thank you

              • 4. Re: CE210291_CapSense_P4_One_Button01 modify to multiple Buttons / Sense?
                brvi

                Hi,

                 

                There are a lot of parameters based on which the power consumption is measured.

                 

                Power consumption varies with the button diameter, overlay thickness, no. of buttons used, trace length and the application.

                 

                In case you need to reduce the power consumed, refer to the following document on PSoC 4 Low-Power CapSense Design (AN210998).

                http://www.cypress.com/file/230796/download

                 

                Regards,

                Bragadeesh

                1 of 1 people found this helpful