element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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
Smarter Life
  • Challenges & Projects
  • Design Challenges
  • Smarter Life
  • More
  • Cancel
Smarter Life
Documents PSoC4 Smarter Life Challenge - DAS Project :Example 5 CapSense Linear Slider with and without Tuner
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: bose
  • Date Created: 7 Nov 2013 1:18 AM Date Created
  • Last Updated Last Updated: 17 Dec 2014 3:55 AM
  • Views 543 views
  • Likes 1 like
  • Comments 0 comments
Related
Recommended

PSoC4 Smarter Life Challenge - DAS Project :Example 5 CapSense Linear Slider with and without Tuner

This example shows two ways to have CapSense Linear Sliders in the Cypress PSoC4 Pioneer Kit.

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.

 

Here is the Application Schematics:

image

image

Automatic Self Calibrating - Smart Sense

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.

In this case the SCB based I2C module is not required.

Here are the configuration for the CapSense module { CapSense CSD [v1.11] } to have the automatic mode:

image

image

image

image

Here is the PWM module Configuration:

image

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.

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.

However without much of details one can easily realize this example thanks to Cypress PSoC Creator and handy component Library based API generation.

Here is the code to achieve the LED color mixing in Smart Sense mode.

#include <project.h>
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<<9);
          }  
     }
}

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.

 

Tuner Calibrated CSD

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.

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.

Here are the settings for the I2C Slave module{ EZI2C Slave (SCB mode) [v1.10] } :

image

In order to have the Tuner enable we would need to change the settings for the CapSense CSD module also:

image

image

image

image

image

The rest of the configuration remains the same for the PWM module.

Now the code from the earlier automatic mode changes in order to support the Slave I2C communications and the calibration by the tuner.

#include <project.h>
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<<9);
          }   
     }
}

Once to the code is build and loaded one needs to start the Tuner utility. To do so 'Right click' on the CapSense CSD module and Start the Tuner:

image

In the tuner window click on the Configuration button:

image

The add the following configuration and Press 'ok' to confirm:

image

Finally click on the Start button the enable the communications.

 

There are many features in the CSD Tuner that help to calibrate and configure the CSD module as needed for a specific use case.

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.

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.

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.

  • psoc4
  • examples
  • smarter
  • das_project
  • smarter_life
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
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