<?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 5 CapSense Linear Slider with and without Tuner</title><link>https://community.element14.com/challenges-projects/design-challenges/smarter-life/w/documents/16725/psoc4-smarter-life-challenge---das-project-example-5-capsense-linear-slider-with-and-without-tuner</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>PSoC4 Smarter Life Challenge - DAS Project :Example 5 CapSense Linear Slider with and without Tuner</title><link>https://community.element14.com/challenges-projects/design-challenges/smarter-life/w/documents/16725/psoc4-smarter-life-challenge---das-project-example-5-capsense-linear-slider-with-and-without-tuner</link><pubDate>Wed, 17 Dec 2014 03:55:17 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1003e1fc-be7d-4204-a420-9db806b1db1c</guid><dc:creator>bose</dc:creator><comments>https://community.element14.com/challenges-projects/design-challenges/smarter-life/w/documents/16725/psoc4-smarter-life-challenge---das-project-example-5-capsense-linear-slider-with-and-without-tuner#comments</comments><description>Current Revision posted to Documents by bose on 12/17/2014 3:55:17 AM&lt;br /&gt;
&lt;p style="margin:0;"&gt;This example shows two ways to have CapSense Linear Sliders in the Cypress PSoC4 Pioneer Kit.&lt;/p&gt;&lt;p style="margin:0;"&gt;The RGB LED color Red and Green are used to demonstrate the operation with help of mixing them as one slides the finger across the Linear slider.&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/620x282/__key/communityserver-wikis-components-files/00-00-00-01-96/4118.contentimage_5F00_45824.png"&gt;&lt;img alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/96/4118.contentimage_45824.png-620x282.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=ncgybJFM7WzJtvIkpOcEP%2FavntYCwq0al0vjEfAUcyE%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=XOrmfvwhdtciq6wh/4w1Sw==" style="max-height: 282px;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/620x347/__key/communityserver-wikis-components-files/00-00-00-01-96/2055.contentimage_5F00_45825.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/96/2055.contentimage_45825.png-620x347.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=zgoGi%2Fi61vGW3lFVZ8wmJk0tnGDpFVC22e4nz5ticyE%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=lwdFLdbChHL9AWgmMTnjlw==" style="max-height: 347px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;Automatic Self Calibrating - Smart Sense&lt;/h2&gt;&lt;p style="margin:0;"&gt;The first part of the this example deals with the use of the Capsense CSD module to perform the detection with auto calibration and sense patterns.&lt;/p&gt;&lt;p style="margin:0;"&gt;In this case the SCB based I2C module is not required.&lt;/p&gt;&lt;p style="margin:0;"&gt;Here are the configuration for the CapSense module { &lt;strong&gt;CapSense CSD [v1.11]&lt;/strong&gt; } to have the automatic mode:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/4174.contentimage_5F00_45826.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/96/4174.contentimage_45826.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=zlRpMHN4xpIE01GCfRhC9ext69UfJZf%2ByKVTArAryXk%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=4ZgWXnilCIHACn/O+IZ6jA==" 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/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/0602.contentimage_5F00_45827.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/96/0602.contentimage_45827.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=bMv9nXphS3KdvWoj6huGwB8EehhOowbOaPhiCppHh7E%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=LubwPvB3A22NlJ4xo6STKw==" 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/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/6558.contentimage_5F00_45828.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/96/6558.contentimage_45828.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=WRa85%2BEUh8igak7n7%2BCYMMdIvPu47A%2FqvkpSmBoh1DQ%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=OK51RCVV5tHciMiaMN5uaQ==" 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/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/0285.contentimage_5F00_45829.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/96/0285.contentimage_45829.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=iodZkAZQ7n3rgK%2FDh%2Bo9oRaPMoQLUZ3LhFQtHioBNAg%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=S/VZ9nF/drdbOA+vwvdexg==" style="max-height: 465px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;Here is the PWM module Configuration:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/620x653/__key/communityserver-wikis-components-files/00-00-00-01-96/7142.contentimage_5F00_45830.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/96/7142.contentimage_45830.png-620x653.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=3S4YYwPWufa0BY40vm3ANDmcLRFqEb9eqIm7A4yDbIQ%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=phwQbL+sZCXGgJMnUf0UVQ==" style="max-height: 653px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;In this case we are using the Smart Sense feature of the CSD module. The Linear slider has 5 sense pads and is divided into 127 divisions.&lt;/p&gt;&lt;p style="margin:0;"&gt;The Input filter used here is the Stand IIR filter for high frequency noise filtering. These setting have been adapted from the system example of CapSense CSD PSoC4.&lt;/p&gt;&lt;p style="margin:0;"&gt;However without much of details one can easily realize this example thanks to Cypress PSoC Creator and handy component Library based API generation.&lt;/p&gt;&lt;p style="margin:0;"&gt;Here is the code to achieve the LED color mixing in Smart Sense mode.&lt;/p&gt;&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;project.h&amp;gt;
uint16 old,pos;
int main()
{
     // Enable Global Interrupts need for internal processing of the CapSense module
     CyGlobalIntEnable;
     // Start the PWM module
     PWM_1_Start();
     // Initialize the CSD module
     CapSense_1_Start();
     // Clear the Sensor baselines to begin the auto calibration cycle
     CapSense_1_InitializeAllBaselines();
     while(1)
     {
          // Enable the Sensor Auto calibration
          CapSense_1_UpdateEnabledBaselines();
          // Scan the Linear Slider
          CapSense_1_ScanEnabledWidgets();
          // Wait till the operation completes
          while(CapSense_1_IsBusy() != 0);
          // Get the Present Values for the Linear Slider output
          pos = CapSense_1_GetCentroidPos(CapSense_1_LINEARSLIDER0__LS);
          // Check for errors and nullyfy non detection events
          if(pos == 0x0FFFFu)
          {
             pos = 0u;
          }
          // Check of the Value changed
          if( old != pos)
          {
               old = pos;
               // Update the LED outputs
               if(pos != 0)
                   PWM_1_WriteCompare(pos&amp;lt;&amp;lt;9);
          }  
     }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="display:none;"&gt;&lt;/div&gt;&lt;p style="margin:0;"&gt;This program would alter the PWM duty cycle with respect to the Linear slider value. This intern would light up the corresponding LED color brighter.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;h2&gt;Tuner Calibrated CSD&lt;/h2&gt;&lt;p style="margin:0;"&gt;There might be a need to also calibrate the internal algorithm and threshold values of the CSD module, in order to have better detection and accuracy in a given product scenario. For this the CSD Tuner is used.&lt;/p&gt;&lt;p style="margin:0;"&gt;The CSD Tuner uses the system I2C to communicate the calibration values. For this we would need to slave I2C module to interface. The PSoC 5 on the Pioneer kit would act as the I2C Tuner host to control the CSD on the PSoC 4.&lt;/p&gt;&lt;p style="margin:0;"&gt;Here are the settings for the I2C Slave module{ &lt;strong&gt;EZI2C Slave (SCB mode) [v1.10]&lt;/strong&gt; } :&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/515x418/__key/communityserver-wikis-components-files/00-00-00-01-96/0361.contentimage_5F00_45831.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/96/0361.contentimage_45831.png-515x418.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=TdN530gYm0Tp5%2BfDtKRGLh%2FWRZR4dwlMeeVu2kxv9r0%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=2IXmYLeIAdbOxXR0dyiSxw==" style="max-height: 418px;max-width: 515px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;In order to have the Tuner enable we would need to change the settings for the CapSense CSD module also:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/7217.contentimage_5F00_45832.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/96/7217.contentimage_45832.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=AZyD8Q1RAyBDAwpySa%2FP8kJnU1mSDP6jR9NgdnKR5io%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=lXDrxEaL0GN8RVvdIPrfqw==" 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/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/2450.contentimage_5F00_45833.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/96/2450.contentimage_45833.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=SXdFmmXhVBPyXWCb4tJk5g2Q8uAeQA54gI2No00RjA0%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=JbMUyL5kNNHEFryxDN6w0Q==" 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/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/4186.contentimage_5F00_45834.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/96/4186.contentimage_45834.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=mK2bTXDb1pt6USNu2tKtQXuCiFzjrezHW9DbdhrSh1E%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=tFrtxkVAsA4UQ72UIb/b1A==" 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/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/2043.contentimage_5F00_45835.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/96/2043.contentimage_45835.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=oDc%2B3Y9cOQs7YbgnqplxZE1329O5Hbhk1J0qiwk3kLU%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=CLJG1/QB2YEueFDAE28Mpw==" 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/620x465/__key/communityserver-wikis-components-files/00-00-00-01-96/0880.contentimage_5F00_45836.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/96/0880.contentimage_45836.png-620x465.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=68cILk1jlepsgRAQm6Swvot5Fb%2Bu05NJjnFv6pADBfo%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=Z8Nb/mC8Tb5Cjnza/yhQRg==" style="max-height: 465px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;The rest of the configuration remains the same for the PWM module.&lt;/p&gt;&lt;p style="margin:0;"&gt;Now the code from the earlier automatic mode changes in order to support the Slave I2C communications and the calibration by the tuner.&lt;/p&gt;&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;project.h&amp;gt;
uint16 old,pos;
int main()
{
     // Enable Global Interrupts need for internal processing of the CapSense module
     CyGlobalIntEnable;
     // Start the PWM module
     PWM_1_Start();
     // Initialize the CSD Tuner module
     CapSense_1_TunerStart();;
     while(1)
     {
          // Process Communications to the Tuner UI
          CapSense_1_TunerComm();
          // Get the Present Values for the Linear Slider output
          pos = CapSense_1_GetCentroidPos(CapSense_1_LINEARSLIDER0__LS);
          // Check for errors and nullyfy non detection events
          if(pos == 0x0FFFFu)
          {
             pos = 0u;
          }
          // Check of the Value changed
          if( old != pos)
          {
               old = pos;
               // Update the LED outputs
               if(pos != 0)
                   PWM_1_WriteCompare(pos&amp;lt;&amp;lt;9);
          }   
     }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="display:none;"&gt;&lt;/div&gt;&lt;p style="margin:0;"&gt;Once to the code is build and loaded one needs to start the Tuner utility. To do so &lt;strong&gt;&lt;em&gt;&amp;#39;Right click&amp;#39;&lt;/em&gt;&lt;/strong&gt; on the CapSense CSD module and Start the Tuner:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/407x470/__key/communityserver-wikis-components-files/00-00-00-01-96/8304.contentimage_5F00_45837.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/96/8304.contentimage_45837.png-407x470.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=nesH%2Bjsa3xf8JnSIkB7qu6MBJVcKHk%2FEpwJnkDgApj0%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=PXTHRXpEQzsSxwBUB+PhXA==" style="max-height: 470px;max-width: 407px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;In the tuner window click on the Configuration button:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/620x458/__key/communityserver-wikis-components-files/00-00-00-01-96/2746.contentimage_5F00_45838.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/96/2746.contentimage_45838.png-620x458.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=yVNTLGMpraVif1MN3qKW%2Bjm%2B2g8UTX68lwqceW6lnUk%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=PHGwavn0jNfLTLgJjveEJA==" style="max-height: 458px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;The add the following configuration and Press &amp;#39;ok&amp;#39; to confirm:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/575x400/__key/communityserver-wikis-components-files/00-00-00-01-96/0602.contentimage_5F00_45839.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/96/0602.contentimage_45839.png-575x400.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=AWf%2FDzGEU2zYRJ5rilSs%2FCC9gdUqgGdnyk1SM6FRjjI%3D&amp;amp;se=2026-08-24T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=dXFk6dPxfiehA2ZBLOXPGA==" style="max-height: 400px;max-width: 575px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;Finally click on the Start button the enable the communications.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;There are many features in the CSD Tuner that help to calibrate and configure the CSD module as needed for a specific use case.&lt;/p&gt;&lt;p style="margin:0;"&gt;Also since the levels of the touch are visible as analog and graphs one can perform adjustment in the Noise and Finger threshold to avoid false detection.&lt;/p&gt;&lt;p style="margin:0;"&gt;Although one needs to re-configure the CSD to perform the calibration, this ensure better sensitivity in the specific application scenarios when the CapSense items is packaged into the systems. &lt;/p&gt;&lt;p style="margin:0;"&gt;For example the CapSense button pad can be under the Glass or fiber window on a system then it would need special configuration to have reliable operation. This is where the tuner would be really helpful.&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>