element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Cypress Kits
  • Products
  • Dev Tools
  • Cypress Kits
  • More
  • Cancel
Cypress Kits
Documents PSoC4 Smarter Life Challenge - DAS Project :Example 6 Arbitary Metal object CapSense
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Cypress Kits requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: bose
  • Date Created: 16 Nov 2013 5:18 AM Date Created
  • Last Updated Last Updated: 16 Nov 2013 5:42 AM
  • Views 731 views
  • Likes 1 like
  • Comments 2 comments
Related
Recommended

PSoC4 Smarter Life Challenge - DAS Project :Example 6 Arbitary Metal object CapSense

This example demonstrates how any metal target can be converted into the CapSense target using Cypress PSoC 4 Pioneer Kit.

 

For metal target an old lock has been used. The PSoC4 enters deeps sleep for 2seconds and is woken up by the Watchdog timer.

After wake up it perform a capacitive sensing scan on the metal target and then goes back to sleep.

 

Here is the Application Schematics:

image

image

The CapSense module { CapSense CSD [v1.11] } needs to be configured as follows:

image

image

image

image

And the Digital output pin that is used to drive the LED is configured as follows:

image

In this case the CSD module is used without a tuner like the earlier Non-Tuner example. The CSD performs the scan after each wake-up and unless there is a detection the LED is turned off.

 

Here is the source code for this example:

#include <project.h>
#include <cyPm.h> // Used for Deep Sleep mode entry
uint8 val; // Used to obtain the CapSense value for the button - which is Arbitrary Metal target
CY_ISR(Wakee) // ISR to handle the wakeup from DeepSleep
{
     CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER0_INT);
     CyIntClearPending(9);
}
int main()
{
     CyIntSetVector(9, Wakee); // Setup the WDT Isr
     CyIntEnable(9);
     Pin_LED_Write(1);     // Set the Default LED state as OFF

     CyGlobalIntEnable; // Enable the Interrupts

     CapSense_1_Start(); //Initialize CapSense Module
     CapSense_1_InitializeAllBaselines();

     // WDT Configuration
     CySysWdtWriteMode(CY_SYS_WDT_COUNTER0,CY_SYS_WDT_MODE_INT_RESET); // Counter 0 with Reset in case 3times the interrupt is not serviced
     CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0,0x2FFF);               // Delay for wake-up from Deep Sleep
     CySysWdtWriteClearOnMatch(CY_SYS_WDT_COUNTER0, 1u);          // Auto Clear the Timer
     CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK); //Enable the WDT
     CySysWdtLock(); // Lock WDT registers

     for(;;)
    {
            // Enable the Sensor Autocalibration
            CapSense_1_UpdateEnabledBaselines();
            // Begin Scanning the Linear Sider
            CapSense_1_ScanEnabledWidgets();
            // Wait for Scanning to Complete
            while(CapSense_1_IsBusy() != 0);

            // Obtain the Detection Value
            val = CapSense_1_CheckIsWidgetActive(CapSense_1_BUTTON0__BTN);
            if(val == 1)
            {
                Pin_LED_Write(0); // Turn On the LED if there was detection
            }
            else
            {
                Pin_LED_Write(1); //Else Turn OFf by default
            }
            CySysPmDeepSleep(); // Enter Sleep to be woken up by the WDT interrupt
    }
}

After building and loading this program the Blue color in the RGB Led would be lit up when the metal object is touched.

An important thing to note is that the code generated by using IIR filter for the CapSense would be high. It would better if by tuning the Threshold and Noise coefficients and use a simpler jitter or averaging filter instead for this type of CapSense detection.

Here is a short video demonstrating the operation and current consumption for this example.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • psoc4
  • examples
  • smarter
  • das_project
  • smarter_life
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
Parents
  • DAB
    DAB over 11 years ago

    Good blog on the CapSense control option.

     

    DAB


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • DAB
    DAB over 11 years ago

    Good blog on the CapSense control option.

     

    DAB


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube