PSoC Designer™, Programmable System-on-Chip™, PSoC Creator™, and SmartSense™ are trademarks and PSoC® and
CapSense® are registered trademarks of Cypress Semiconductor Corp. All other trademarks or registered trademarks
referenced herein are property of the respective corporations.
Source Code
Any Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected
by and subject to worldwide patent protection (United States and foreign), United States copyright laws and international
treaty provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use,
modify, create derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of
creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or
representation of this Source Code except as specified above is prohibited without the express written permission of
Cypress.
Disclaimer
CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described
herein. Cypress does not assume any liability arising out of the application or use of any product or circuit described herein.
Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure
may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support
systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against
all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
3.1.4 CapSense Data Viewing Tools ............................................................................................................... 18
3.2 User Module Overview ........................................................................................................................................ 18
3.3 CapSense User Module Global Arrays ................................................................................................................ 18
3.3.1 Raw Count .............................................................................................................................................. 19
3.3.4 Sensor State ........................................................................................................................................... 19
3.4 CSD User Module Configurations ........................................................................................................................ 20
3.4.1 CSD without Clock Prescaler .................................................................................................................. 20
3.4.2 CSD with Clock Prescaler ....................................................................................................................... 20
3.5 CSD User Module Parameters ............................................................................................................................ 20
3.6 CSD User Module High-Lev el Parame t ers .......................................................................................................... 21
3.6.9 High Level Parameter Recommendations .............................................................................................. 22
3.7 CSD User Module Low-Lev el Parame ter s ........................................................................................................... 23
3.7.4 Ref Value ................................................................................................................................................ 24
3.7.5 Prescaler Period ..................................................................................................................................... 24
3.7.6 Shield Electrode Out ............................................................................................................................... 24
3.8 CSDADC User Module Configurations ................................................................................................................ 24
3.8.1 CSDADC with PRS16 Clock Source....................................................................................................... 24
3.8.2 CSDADC with PRS8 Clock Source......................................................................................................... 24
3.8.3 CSDADC with PWM8 Clock Source ....................................................................................................... 25
3.8.4 CSDADC with VC2 Clock Source ........................................................................................................... 25
3.9 CSDADC User Module Parameters ..................................................................................................................... 25
3.10.4 Ref Value ................................................................................................................................................ 26
3.10.5 Prescaler Period ..................................................................................................................................... 26
3.10.6 Shield Electrode Out ............................................................................................................................... 26
4. CapSense Performance Tuning with User Modules ................................................................................................. 29
4.1 General Considerations ....................................................................................................................................... 29
4.1.1 Signal, Noise, and SNR .......................................................................................................................... 29
5.5 Power Consumption ............................................................................................................................................ 40
5.5.1 System Design Recommendations ......................................................................................................... 40
6. Water Tolerance ........................................................................................................................................................... 43
6.1 Shield Electrode and Guard Sensor .................................................................................................................... 43
8. Low Power Design Considerations ............................................................................................................................ 51
8.1 Additional Power Saving Techniques .................................................................................................................. 51
8.1.1 Set Drive Modes to Analog HI-Z ............................................................................................................. 51
8.1.2 Putting it All Together ............................................................................................................................. 52
9.4 Development Kits ................................................................................................................................................ 55
9.9 Design Support .................................................................................................................................................... 57
9.10 Document Revision History ................................................................................................................................. 57
This document gives design guidance for using capacitive touch sensing (CapSense®) functionality with the
CY8C21x34/B family of CapSense Plus Controllers. The following topics are covered in thi s guide:
Features of the CY8C21x34/B family of CapSense Plus Controllers
CapSense principl es of oper ati on
Introduction to CapSense design tools
In depth guide to tuning the CapSense touch sensing system for optimal performance
Advanced features such as water tolerance and proximity detection
Electrical and mechanical system design consid erations
Additional resources and support for designing CapSense into your system
1.2 Cypress CapSense Documentation Ecosystem
Figure 1-1and Table 1-1 summarize the Cypress CapSense documentation ecosystem. These resources allow
implementers to quickly access the information needed to successfully complete a CapSense product design.
Figure 1-1shows the typical flow of a product design cycle with capacitive sensing; the information in this guide is
most pertinent to the topics highlighted in green. Table 1-1includes links to the supporting documents for each of the
numbered tasks in Figure 1-1.
Cypress’s CY8C21x34/B is a low-power, high-perfor ma nce, progr a mm able CapSense controller family that features:
1.3.1 Advanced Touch Sensing Features
Programmable capacitive sensing elements
Supports a combination of CapSense buttons, sliders, and proximity sensors with CSD and CSDADC
capacitive sensing technology
SmartSense™ Auto-tuning (CY8C21x34B)
Contains an integrated API to implement buttons and sliders
Supports up to 24 capacitive buttons and 4 sliders
Supports proximity sensing up to 5 cm (with on-board PCB trace)
Water-tolerant performance with shield electrode
1.3.2 Device Features
High-performance, low-power M8C Harvard-architec tur e pro ces sor
M8C processor speeds up to 24 MHz
Flexible on-chip memory
Up to 8 KB of flash and 512 B of SRAM
Emulated EEPROM supported
Precision, progra mma ble cloc king
Internal main oscillator (IMO): 24/48 MHz ± 2.5%
Internal low-speed oscillator (ILO) at 32 kHz for watchdog and sleep
Enhanced general-purpose input/output (GPIO) features
Up to 28 general-purpose I/Os (GPIOs) with programmable pin configuration
25-mA sink current on all GPIOs
Internal resistive pull-up, HI-Z, open-drain, and strong drive modes on all GPIOs
CapSense is a touch-sensing technology that works by measuring the capacitance of each I/O pin on the CapSense
controller that has been designated as a sensor. As shown in Figure 2-1, the total capacitance on each of the sensor
pins can be modeled as equivalent lumped capacitors with values of C
Circuitry internal to the CY8C21x34/B device converts the magnitude of each C
post processing. The other components, namely Rb and C
circuitry.
Figure 2-1. CapSense Implementation in a CY8C21x34/B PSoC Device
, are used by the CapSense controller’s internal
MOD
through C
X,1
X
for a design with n sensors.
X,n
into a digital code that is stored for
As shown in Figure 2-2, each sensor I/O pin is connected to a sensor pad by traces, vias, or both as necessary. The
overlay is a nonconductive cover over the sensor pad that constitutes the product’s touch interface. When a f inger
comes into contact with the overlay, the conductivity and mass of the body effectively introduces a grounded
conductive plane parallel to the sensor pad. This is represented in Figure 2-2. This arrangement constitutes a pa r all e l
plate capacitor whose capacitance is given by Equation 1.
Figure 2-2. Cross Section of Typical CapSense PCB with the Sensor Being Activated by a Finger
Equation 1
Where:
CF = The capacitance affected by a finger in contact with the overlay over a sensor
ε
= Free space permittivity
0
= Dielectric constant (relative permittivity) of overlay
ε
r
A = Area of finger and sensor pad overlap
D = Overlay thickness
In addition to the parallel plate capacitance, a finger in contact with the overlay causes electric field fringing between
itself and other conductors in the immediate vicinity. The effect of these fringing fields is typically minor compared to
that of the parallel plate capacitor and can usually be ignored.
Even without a finger touching the overlay, the sensor I/O pin has some parasitic capacitance (C
). CP results f rom
P
the combination of the CapSense controller internal parasitics and electric field coupling between the sensor pad,
traces, and vias, and other conductors in the system such as ground plane, other traces, any metal in the product’s
chassis or enclosure, and so on. The CapSense controller measures the total capacitance (C
) connected to a
X
sensor pin.
When a finger is not touching a sensor:
Equation 2
When a finger is touching the sensor:
Equation 3
In general CP is an order of magnitude greater than CF. CP usually ranges from 6 pF to 15 pF, but in extreme cases
can be as high as 50 pF. CF usually ranges from 0.1 pF to 0.4 pF. The magnitude of C
is of critical importance when
P
tuning a CapSense system and will be discussed in CapSense Performance Tuning with User Modules.
CY8C21x34/B devices support several CapSense methods for converting sensor capacitance (CX) into a digi t al co de.
These are CapSense Sigma Delta (CSD), CSD with ADC (CSDADC), and SmartSense. These methods are
implemented in the form of PSoC Designer User Modules and are described in Section 3 of this design guide.
2.2.1 CapSense with Sigma Delta Modulator (CSD)
The CapSense Sigma-Delta (CSD) method in CY8C21x34/B devices incorporates CX into a switched-capacitor circuit
as shown in Figure 2-3. The sensor (C
underlapped switches Sw1 and Sw2, respectively. Sw1 and Sw2 are driven by a Precharge clock to generate a
current (I
) into the AMUX bus. The magnitude of I
SENSOR
Sigma-Delta converter samples AMUX bus voltage and generates a modulating bit stream that controls the constant
current source (I
sensor bleeds off the charge I
), which charges AMUX such that the average AMUX bus voltage is maintained at V
DAC
SENSOR
low-pass filter that attenuates Precharge switching transients at the Sigma-Delta converter input.
) is alternately connected to VDD and the Analog MUX (AMUX) bus by the
X
is directly proportional to the magnitude of CX. The
SENSOR
from the modulating capacitor (C
MOD
). C
in combination with Rbus forms a
MOD
Figure 2-3. CSD Block Diagram
REF
. The
In maintaining the average AMUX voltage at a steady state value (V
average bleed current (I
BLEED
) to I
by controlling the bit stream duty cycle. The Sigma-Delta converter stores
SENSOR
), the Sigma-Delta converter matches the
REF
the bit stream over the duration of a sensor scan and the accumulated result is a digital output value, known as raw
counts, that is directly proportional to C
state. Figure 2-4plots the CSD raw counts from a number of consecutive scans during which the sensor is touched
and then released by a finger. As explained in CapSense Fundamentals, the fing er touch caus es C
which in turn causes raw counts to increase proportionally. By comparing the shift in steady state raw count level
C
F,
. This raw count is interpreted by high-level algorithms to resolve sensor
x
to increase by
x
to a predetermined threshold, the high-level algorithms can determine whether the sensor is in an On (Touch) or Off
(No Touch) state.
The CSDADC CapSense method functions in an identical manner as CSD except that it is augmented with the ADC
functionality in addition to capacitance measurement.
2.2.2.1 ADC Features
Absolute and ratiometric ADC input modes with run-time mode switching, which allows you to easily scan
different sensor types
Single-slope ADC for absolute voltage input mode
Built-in calibration mechanism for the single-slope ADC
Integrating incremental ADC for ratiometric input mode
2.2.3 SmartSense™ Auto-tuning
Tuning the touch-sensing user interface is a critical step in ensuring proper system operation and a pleasant user
experience. The typical design flow entails tuning the sensor interface in the initial design phase, during system
integration, and finally production fine-tuning before the production ramp. Tuning is an iterative process and can be
time consuming. SmartSense Auto-tuning was developed to simplify the user interface development cycle. It is easy
to use and significantly reduces the design cycle time by eliminating the tuning process throughout the entire product
development cycle, from prototype to mass production. SmartSense tunes each CapSense sensor automatically at
power up and then monitors and maintains optimum sensor performance during run time. This technology adapts for
manufacturing variation in PCBs, overlays, and noise generators such as LCD inverters, AC line noise, and switchmode power supplies, and automatically tunes them out. SmartSense Auto-tuning requires between 2.1 KB -3.7 KB
of flash depending on configuration and 29B of RAM per sensor.
2.2.3.1 Process Variation
The SmartSense User Module (UM) for the CY8C21x34B is designed to work with sensor parasitic capacitance in the
range of 5 pF to 45 pF (typical sensor CP values are in the range of 10 pF to 20 pF). The sensitivity parameter for
each sensor is set automatically, based on the characteristics of that particular sensor. This improves the yield in
mass production, as consistent response is maintained from every sensor regardless of C
within the specified range of 5 to 41 pF. Parasitic capacitance of the individual sensors can vary due to PCB layout,
PCB manufacturing process variation, or with vendor-to-vendor PCB variation within a multisourced supply chain.
The sensitivity of a sensor depends on its parasitic capacitance; higher C
result in decreased finger touch signal amplitude. In some cases, the change in C
resulting in less than optimum sensor performance (either too sensitive or not sensitive enough) or, wor st case, a
nonoperational sensor. In either situation, you must retune the system, and in some cases requalify the UI
subsystem. SmartSense Auto-tuning solves these issues.
SmartSense based capacitive user interface Design Cycle
Firmware
Development
SmartSense Auto-tuning makes platform designs possible. Imagine the capacitive touch sensing multimedia keys in a
laptop computer; the spacing between the buttons depends on the size of the laptop and keyboard layout. In this
example, the wide-screen machine has larger spaces between the buttons than a standard-screen model. More
space between buttons means increased trace length between the sensor and the CapSense controller, which leads
to higher parasitic capacitance of the sensor. This means that the parasitic capacitance of the CapSense buttons can
be different in different models of the same platform design. Though the functionality of these buttons is the same for
all of the laptop models, the sensors must be tuned for each model. SmartSense enables you to do platform designs
using the recommended best practices shown in the PCB Layout in Getting Started with CapSense, knowing the
tuning will be done efficiently and automatically.
Figure 2-5. Design of Laptop Multimedia Keys for a 21-inchModel
Figure 2-6. Design of Laptop Multimedia Keys for a 15-inchModel with Identical Functionality and Button Size
2.2.3.2 Reduced Design Cycle Time
Usually the most time-consuming task for a capacitive sensor interface design is firmware development and sensor
tuning. With a typical touch-sensing controller, the sensor must be retuned when the same design is ported to
different models or when there are changes in the mechanical dimensions of the PCB or the sensor PCB layout. A
design with SmartSense solves these challenges because it needs less firmware development effort, no tuning, and
no retuning. This makes a typical design cycle much faster. Figure 2-7compares the design cycles of a t ypi c al t ouc h sensing controller and a SmartSense-based design.
Figure 2-7. Typical Capacitive Inter fa ce Design Cycle Comparison
Cypress offers a full line of hardware and software tools for developing your CapSense capacitive touch-sense
application. A basic development system for the CY8C21x34/B family includes the components discussed in this
chapter. See Resources for ordering information.
3.1.1 PSoC Designer™ and User Modules
Cypress’s exclusive integrated design environment, PSoC Designer, allows you to configure analog and digital
blocks, develop firmware, tune, and debug your design. Applications are developed in a drag-and-drop design
environment using a library of user modules. User modules are configured either through the Device Editor GUI or by
writing into specific registers with firmware. PSoC Designer comes with a built-in C compiler and an embedded
programmer. A pro compiler is available for complex designs.
CSD, CSDADC, and SmartSense User Modules implement capacitive touch sensors using switched-capacitor
circuitry, an analog multiplexer, a comparator, digital counting functions, and high-level software routines (APIs). User
modules for other analog and digital peripherals are available to implement additional functionality such as I
TX8, Timers, and PWMs.
Figure 3-1. PSoC Designer Device Editor
2
C, SPI,
3.1.1.1 Gett ing Started with CapSense User Modules
To create a new CY8C21x34/B project in PSoC Designer:
1. Create a new CY8C21x34/B PSoC Designer proje ct.
2. Select and place any user modules requiring dedicated pins (such as I
3. Select and place the CSD, CSDADC, or SmartSense User Module.
4. Right-click the user module to access the User Module wizard.
5. Set button sensor count, slider configuration, pin assignments, and associations.
6. Set pins and global user mod u le parame ter s .
7. Generate the application and switch to Application Editor.
8. Adapt sample code from U ser Module Datasheet: (CY8C21x34) to implement buttons or sliders.
3.1.2 Universal CapSense Controller Kit
The Universal CY3280-BK1CapSense Controller Kit features predefined control circuitry and plug-in hardware to
make prototyping and debugging easy. Programming and I2C-to-USB Bridge hardware are included for tuning and
data acquisition.
Many times during the CapSens e design process, you will want to monitor CapSense data (raw counts, baseline,
difference counts, and so on) for tuning and debugging purposes. There are two CapSense Data Viewing Tools,
MultiChart, and Bridge Control Panel. These tools are explained in more detail in the application note
AN2397 – CapSense Data Viewing Tools.
3.2 User Module Overview
Figure 3-3. User Module Block Diagram
User modules contain an entire CapSense system from physical sensing to data processing. The behavior of the user
module is defined using several parameters. These parameters affect different parts of the sensing system and can
be separated into low-level and high-level parameters that communicate with one another using global arrays.
Low-level parameters, such as the speed and resolutions for scanning sensors, define the behavior of the sensing
method at the physical layer, and relate to the conversion from capacitance to raw count. Low-level parameters are
unique to each type of sensing method and are described in CSDADC User Module Configurations, CSDADC Use r
Module Parameters, and SmartSense User Module Parameters.
High-level parameters, such as debounce counts and noise thresholds, define how the raw counts are processed to
produce information such as the sensor ON/OFF state and the estimated finger position on a slider. These
parameters are the same for all sensing methods and are described in CSD User Module High-Level Parameters.
3.3 CapSens e Us e r Module Global Arrays
Before learning CapSense User Module parameters, you must be familiar with certain global arrays used by the
CapSense system. These arrays should not be altered manually, but may be inspected for debugging purposes.