<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>PSoC4 Smarter Life Challenge - DAS Project :Example 6 Arbitary Metal object CapSense</title><link>https://community.element14.com/products/devtools/psoc4pioneerkit/w/documents/16280/psoc4-smarter-life-challenge---das-project-example-6-arbitary-metal-object-capsense</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>PSoC4 Smarter Life Challenge - DAS Project :Example 6 Arbitary Metal object CapSense</title><link>https://community.element14.com/products/devtools/psoc4pioneerkit/w/documents/16280/psoc4-smarter-life-challenge---das-project-example-6-arbitary-metal-object-capsense</link><pubDate>Sat, 16 Nov 2013 05:42:01 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:b9ad8855-1cc5-4e58-a269-a5ddeffa6017</guid><dc:creator>bose</dc:creator><comments>https://community.element14.com/products/devtools/psoc4pioneerkit/w/documents/16280/psoc4-smarter-life-challenge---das-project-example-6-arbitary-metal-object-capsense#comments</comments><description>Current Revision posted to Documents by bose on 11/16/2013 5:42:01 AM&lt;br /&gt;
&lt;p style="margin:0;"&gt;This example demonstrates how any metal target can be converted into the CapSense target using Cypress PSoC 4 Pioneer Kit.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;For metal target an old lock has been used. The PSoC4 enters deeps sleep for 2seconds and is woken up by the Watchdog timer.&lt;/p&gt;&lt;p style="margin:0;"&gt;After wake up it perform a capacitive sensing scan on the metal target and then goes back to sleep.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Here is the Application Schematics:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/323x230/__key/communityserver-wikis-components-files/00-00-00-01-62/2068.contentimage_5F00_28375.png"&gt;&lt;img alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/62/2068.contentimage_28375.png-323x229.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=MB2MkMb7V66SAmhSYKpNANqxyPC2XjHGmv3bOp2pCaM%3D&amp;amp;se=2026-08-18T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=ydC8Odt/6dOhPoIXSQgXXg==" style="max-height: 229px;max-width: 323px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/526x312/__key/communityserver-wikis-components-files/00-00-00-01-62/0815.contentimage_5F00_28376.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/62/0815.contentimage_28376.png-526x312.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=z4UkAlhc6ZD4spRE%2F%2FfDJBS4fvwdzIyIC1aEX%2FTLP3c%3D&amp;amp;se=2026-08-18T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=Du/KDKqegXomJVbfJ7pGcA==" style="max-height: 312px;max-width: 526px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;The CapSense module { &lt;strong&gt;CapSense CSD [v1.11]&lt;/strong&gt; } needs to be configured as follows:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/642x482/__key/communityserver-wikis-components-files/00-00-00-01-62/7762.contentimage_5F00_28377.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/62/7762.contentimage_28377.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=wCK8%2B%2Fsfo6otXFL%2F0PLpBLzYOvmoaBqKk605L0KZpuU%3D&amp;amp;se=2026-08-18T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=L//qzNY37Tc2BkMcnd4aKA==" style="max-height: 465px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/642x482/__key/communityserver-wikis-components-files/00-00-00-01-62/5126.contentimage_5F00_28378.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/62/5126.contentimage_28378.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=oX0iAwg95zJaJtFyZcyAIdnFVSRrbDs5PjiyQRdtWt0%3D&amp;amp;se=2026-08-18T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=MORN66LscIBPeGimqaqxcw==" style="max-height: 465px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/642x482/__key/communityserver-wikis-components-files/00-00-00-01-62/1884.contentimage_5F00_28379.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/62/1884.contentimage_28379.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=f56En6zFhBCDMdVH5yeGOIBtd%2BmJY0qnL2hV6SINCyU%3D&amp;amp;se=2026-08-18T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=yc9TFIaWHuh1Beylm3oPvw==" style="max-height: 465px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/642x482/__key/communityserver-wikis-components-files/00-00-00-01-62/1300.contentimage_5F00_28380.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/62/1300.contentimage_28380.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=RBIetjvWk3chZIUWrgss9u2ayOqV2LQu8AS25w79HYc%3D&amp;amp;se=2026-08-18T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=nzmaTa+E6xs5AFq9MNr2RQ==" style="max-height: 465px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;And the Digital output pin that is used to drive the LED is configured as follows:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/552x413/__key/communityserver-wikis-components-files/00-00-00-01-62/7245.contentimage_5F00_28381.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/62/7245.contentimage_28381.png-552x413.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=PaRbapsIEakenzChkQD6OjB6xYPXYzd6dEfODBHLQTY%3D&amp;amp;se=2026-08-18T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=cLLBNgzNws96Uk4SB4/44w==" style="max-height: 413px;max-width: 552px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;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.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Here is the source code for this example:&lt;/p&gt;&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;project.h&amp;gt;
#include &amp;lt;cyPm.h&amp;gt; // 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
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="display:none;"&gt;&lt;/div&gt;&lt;p style="margin:0;"&gt;After building and loading this program the Blue color in the RGB Led would be lit up when the metal object is touched.&lt;/p&gt;&lt;p style="margin:0;"&gt;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.&lt;/p&gt;&lt;p style="margin:0;"&gt;Here is a short video demonstrating the operation and current consumption for this example.&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span id="37dc9a5f_027c_411d_9274_ad10f901c5f3"&gt;&lt;span&gt;&lt;a href="https://players.brightcove.net/1362235890001/NkxiVJdjx_default/index.html?videoId=2826436351001"&gt;players.brightcove.net/.../index.html&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: psoc4, examples, smarter, das_project, smarter_life&lt;/div&gt;
</description></item></channel></rss>