CY8C21x34/B CapSense® Design Guide Doc. No 001-66271 Rev. *B Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone (USA): 1.800.541.4736 Phone (Intnl): 408.943.2600 http://www.cypress.
Copyrights Copyrights © Cypress Semiconductor Corporation, 2010–2011. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights.
Contents 1. Introduction.................................................................................................................................................................... 7 1.1 1.2 1.3 1.4 2. CapSense Technology ................................................................................................................................................ 11 2.1 2.2 3. Abstract ............................................................................................................
3.6.6 Debounce ............................................................................................................................................... 22 3.6.7 Negative Noise Threshold ...................................................................................................................... 22 3.6.8 Low Baseline Reset ................................................................................................................................ 22 3.6.
.1 5.2 5.3 5.4 5.5 5.6 5.7 6. Water Tolerance........................................................................................................................................................... 43 6.1 6.2 7. 7.2 Types of Proximity Sensors ................................................................................................................................. 49 7.1.1 Button ................................................................................................................
Website ............................................................................................................................................................... 55 Datasheet ............................................................................................................................................................ 55 Technical Reference Manual ...............................................................................................................................
1. Introduction 1.1 Abstract ® This document gives design guidance for using capacitive touch sensing (CapSense ) functionality with the CY8C21x34/B family of CapSense Plus Controllers.
Figure 1-1. Typical CapSense Product Design Flow 1. Specify system requirements and characteristics 2. CapSense device selection based on needed functionality Design for CapSense 3. Mechanical Design 4. Schematic capture and PCB layout 5. PSoC Designer project creation 6. Firmware development = Topics covered in this document 7. CapSense configuration and tuning Preproduction build (prototype) 8.
1.3 CY8C21x34/B CapSense Plus Family Features Cypress’s CY8C21x34/B is a low-power, high-performance, programmable CapSense controller family that features: 1.3.
1.4 Document Conventions Convention Usage Courier New Displays file locations, user entered text, and source code: C:\ ...cd\icc\ Italics Displays file names and reference documentation: Read about the sourcefile.hex file in the PSoC Designer User Guide.
2. CapSense Technology 2.1 CapSense Fundamentals 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 CX,1 through CX,n for a design with n sensors.
Figure 2-2.
2.2 CapSense Methods in CY8C21x34/B CY8C21x34/B devices support several CapSense methods for converting sensor capacitance (CX) into a digital code. 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.
Figure 2-4. CSD Raw Counts during a Finger Touch 2.2.2 CSD with ADC Functionality (CSDADC) 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.
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.
3. CapSense Design Tools 3.1 Overview of CapSense Design Tools 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.
7. Generate the application and switch to Application Editor. 8. Adapt sample code from User Module Datasheet: (CY8C21x34) to implement buttons or sliders. 3.1.2 Universal CapSense Controller Kit The Universal CY3280-BK1 CapSense Controller Kit features predefined control circuitry and plug-in hardware to 2 make prototyping and debugging easy. Programming and I C-to-USB Bridge hardware are included for tuning and data acquisition. Figure 3-2.
3.1.3 Universal CapSense Controller Module Board Cypress’s module boards feature a variety of sensors, LEDs, and interfaces to meet your application’s needs. CY3280-BSM Simple Button Module CY3280-BMM Matrix Button Module CY3280-SLM Linear Slider Module CY3280-SRM Radial Slider Module CY3280-BBM Universal CapSense Prototyping Module 3.1.
Figure 3-4. Raw Count, Baseline, Difference Count, and Sensor State Raw Count Difference Count (Signal) 3.3.1 Raw Count The hardware circuit in the CapSense controller measures the sensor capacitance. It stores the result in a digital form called raw count upon calling the user module API UMname_ScanSensor(), where UMname can be CSD, CSDADC, or SmartSense. The raw count of a sensor is proportional to its sensor capacitance. Raw count increases as the sensor capacitance value increases.
Sensor states are updated by the user module API UMname_bIsAnySensorActive() 3.4 CSD User Module Configurations The CSD User Module has two selectable clock configurations. These configurations use different signal sources for the switched-capacitor circuit on the front end of the CSD, as shown in Figure 2-3 on page 13. You should select the clock configuration when you first place the CSD User Module in your PSoC Designer project.
3.6 CSD User Module High-Level Parameters 3.6.1 Finger Threshold The Finger Threshold parameter is used by the user module to judge the active/inactive state of a sensor. If the Difference Count value of a sensor is greater than the Finger Threshold value, the sensor is judged as active. This definition assumes that Hysteresis is set to zero and Debounce is set to 1. Possible values are 5 to 255. 3.6.
Figure 3-6. Sensor State Versus Difference Count with Hysteresis Set to Zero Equation 4 3.6.6 Debounce The Debounce parameter prevents spikes in raw counts from changing the sensor state from OFF to ON. For the sensor state to transition from OFF to ON, the Difference Count value must remain greater than the Finger Threshold value plus the hysteresis level for the number of samples specified. Possible values are 1 to 255. A setting of 1 provides no debouncing. 3.6.
Negative Noise Threshold: Set equal to Noise Threshold Low Baseline Reset: Set to 10 3.7 CSD User Module Low-Level Parameters The CSD User Module has several low-level parameters in addition to the high-level parameters. These parameters are specific to the CSD sensing method and determine how raw count data is acquired from the sensor. 3.7.1 Scanning Speed This parameter sets the sensor scanning speed.
3.7.3 Reference A voltage reference to the input of the comparator is required for the proper operation of CSD. Possible values are: VBG: Internal voltage reference of 1.3 V derived from a fixed bandgap reference. ASE11: Internal variable voltage reference derived from a PWM. AnalogColumn_InputSelect_1: External voltage reference such as a resistor divider network or externally filtered PWM/PRSPWM signal.
Because it needs a lower switching frequency, you should use configuration when operating in an environment with high CP, The relationship between CP and switching frequency is discussed in CapSense Performance Tuning with User Modules. 3.8.3 CSDADC with PWM8 Clock Source In this configuration, IMO is divided by an adjustable prescaler divider and used for the switched capacitor circuit on the front end of the CSD.
3.10.3 Reference A voltage reference to the input of the comparator is required for the proper operation of CSD. Possible values are: VBG: Internal voltage reference of 1.3 V derived from a fixed band-gap reference. ASE11: Internal variable voltage reference derived from a PWM. AnalogColumn_InputSelect_1: External voltage reference such as a resistor divider network or externally filtered PWM/PRSPWM signal.
3.11 SmartSense User Module Parameters Figure 3-8. PSoC Designer SmartSense Parameters High-Level Low-Level Low-Level High-Level Low-Level 3.12 Low-Level Parameters 3.12.1 Shield Electrode Out A shield electrode is used to reduce parasitic capacitance. The shield electrode signal can be routed to one of the free digital row buses (Row_0_Output_1 – Row_0_Output_3). Each row output can then be routed to one of the allowed pins. Set the Row LUT Function to A. 3.12.
3.12.6 Finger Threshold This parameter is applicable only when threshold setting mode is set to Manual mode. It is recommended that you set this value to 80 percent of the sensor signal stored in the SmartSense_baSnSSignal[] array. This array can be easily 2 monitored using I C or UART communication protocols. 28 Document No. 001-66271 Rev.
4. CapSense Performance Tuning with User Modules Optimal user module parameter settings depend on board layout, button dimensions, overlay material, and application requirements. These factors are discussed in Design Considerations. Tuning is the process of identifying the optimal parameter settings for robust and reliable sensor operation. 4.1 General Considerations 4.1.1 Signal, Noise, and SNR A well-tuned CapSense system reliably discriminates between ON and OFF sensor states.
4.1.1.2 CapSense Noise CapSense noise is the peak-to-peak variation in sensor response when a finger is not present, as shown in Figure 4-2. In this example, the output waveform without a finger is bounded by a minimum of 5912 counts and a maximum of 5938 counts. Because the noise is the difference between the minimum and the maximum values of this waveform, Noise = 5938 – 5912 = 26 counts. Figure 4-2. Example of CapSense Noise 4.1.1.3 CapSense SNR CapSense SNR is the simple ratio of signal and noise.
Figure 4-3. Charge/Discharge Waveforms Vs Tsmin >= 10*Rx*Cx Vdd Rx Vx Vs Vref Vx Cx 5*Rx*Cx 5*Rx*Cx t Vdd Vref t Make sure to set the charge/discharge rate to a level that is compatible with this RC time constant. The rule of thumb is to allow a period of 5RC for each transition, with two transitions per period (one charge, one discharge).
4.2 Tuning the CSD and CSDADC User Modules Figure 4-4. Tuning CSD and CSDADC User Modules 32 Document No. 001-66271 Rev.
4.2.1 Set Up Hardware and Software for Tuning Before starting the tuning process, certain hardware and software tools are required. They are listed in the Overview of CapSense Design Tools. Tuning requires monitoring the raw counts, baseline, and difference counts of the 2 sensors through a communication interface. A code example that uses an I C communication protocol to communicate with the PC can be downloaded here. After downloading the example project: 1. Open the code example using PSoC Designer.
raw count value in a no touch condition. Increasing Rb also decreases the maximum capacitance value that can be measured by the CapSense sensor. Figure 4-5. CSD Measurement Range RawCount Measurement Range with Rb 1 RawCount Measurement Range with Rb2 > Rb1 2n-1 2n-1 Difference count Difference count 70% (2n-1) 20% (2n-1) Cxmax2 Cxmax1 Change in Cx due to finger touch Cx Cx Change in Cx due to finger touch Consider the two raw count measurement range graphs in Figure 4-5.
Under Global Settings in the CapSense wizard, assign one sensor under the category "Button". Select the modulation Capacitor and Feedback resistor pin as well. Set the threshold setting mode as manual, and disable the Median and IIR filters. Ensure that in the board, the Rb value is 15 K and the Cmod is 10 nF. Under the Sensor Settings tab in CapSense wizard, set "Sensitivity Level" to Low and "Finger Threshold" to 96. 4.
Figure 4-7. Monitoring the Sensor Signal baSnsSignal Now open the CapSense wizard, and under the Sensor Settings tab set the finger threshold to the calculated value (it is 100 for the example as shown in Figure 4-7). 7. 36 The SmartSense sensor tuning process is completed with the previous step. However, there could be scenarios where the SNR achieved in Step 5 is below 5:1, for example, when using a thicker overlay.
5. Design Considerations When designing capacitive touch sense technology into your application, it is crucial to keep in mind that the CapSense device exists within a larger framework. Careful attention to every level of detail from PCB layout to user interface to end-use operating environment will lead to robust and reliable system performance. For more in-depth information, see Getting Started with CapSense. 5.
5.2 ESD Protection Robust ESD tolerance is a natural byproduct of careful system design. By considering how contact discharge will occur in your end product, particularly in your user interface, it is possible to withstand an 18-kV discharge event without incurring any damage to the CapSense controller. CapSense controller pins can withstand a direct 2-kV event. In most cases, the overlay material provides sufficient ESD protection for the controller pins.
The recommended series resistance for communication lines, such as I C, and SPI is 330 Ω. 2 Trace Length: Minimize trace length whenever possible. Current Loop Area: Minimize the return path for current. Provide hatched ground instead of solid fill within 1 cm of the sensors and traces to reduce the impact of parasitic capacitance. RF Source Location: Partition systems with noise sources such as LCD inverters and switched-mode power supplies (SMPS) to keep them separated from CapSense inputs.
Table 5-4 shows the RAM and flash requirements for different software filters. The amount of flash required for each filter type depends on the performance of the compiler. The requirements listed here are for both the ImageCraft compiler and the ImageCraft Pro compiler Table 5-4.
The average power consumed by the device can be calculated as follows: Equation 12 Where: VDD = supply voltage IAVE = average current An Excel-based average power consumption calculator is available. Click here to download the calculator. 5.5.3 Response Time versus Power Consumption As illustrated in Equation 12, the average power consumption can be reduced by decreasing IAVE or VDD. IAVE may be decreased by increasing sleep time.
5.6 Pin Assignments An effective method to reduce interaction between CapSense sensor traces and communication and non-CapSense traces is to isolate each by port assignment. Figure 5-2 shows a basic version of this isolation for a 32-pin QFN package. Because each function is isolated, the CapSense controller is oriented such that there is no crossing of communication, LED, and sensing traces. Figure 5-2.
6. Water Tolerance Some CapSense capacitive touch-sensing applications require reliable operation in the presence of water. White goods, automotive applications, and industrial applications are examples of systems that must perform in environments that include water, ice, and humidity changes. For such applications, shield electrodes and guard sensors can provide robust touch sensing. 6.1 Shield Electrode and Guard Sensor Figure 6-1.
Figure 6-2. Capacitance Measurement with Water Drop CWD – Capacitance between the water drop and shield electrode The purpose of the shield electrode is to set up an electric field around the touch sensors that helps attenuate the effects of water. The shield electrode works by mirroring the voltage of the touch sensor on the shield. Follow these guidelines to ensure proper shield operation: Schematic Layout Firmware Development 6.1.1.
Figure 6-3. Schematic View of Digital Interconnect 5. Select Row_0_Output_2_Drive_0 and select GlobalOutEven_2 as shown in Figure 6-4. Figure 6-4. Schematic View of Output Select 6. Click on GlobalOutEven_2 and select P0{2] in the Pin option as shown in the following figure. ® CY8C21x34/B CapSense Design Guide Document No. 001-66271 Rev.
6.1.2 Guard Sensor Figure 6-5. PCB with Shield and Guard Sensor PCB Shield Electrode Guard Sensor Sensor Pads 46 Document No. 001-66271 Rev.
A guard sensor is a copper trace, as shown in Figure 6-5, that surrounds all the sensors on the PCB, which is used to detect the presence of a continuous water stream. When a water stream is present on the sensing surface, a largecapacitance CST is added to the system, as shown in Figure 6-6. This capacitance may be several times larger than CWD.
Figure 6-7. Flow Chart to Implement the Guard Sensor Start of main function Initialize CapSense block and other blocks Scan all sensors including Guard sensor Update baseline of all sensors Is Guard Sensor ON? Yes Turn off all the sensors No Guard sensor counter elapsed? No Yes Report sensor status normally End of main function 6.
7. Proximity Sensing Proximity sensors detect the presence of a hand or other conductive object before it makes contact with the capacitive touch surface. Imagine a hand stretched out to operate a car audio system in the dark. Proximity detection enables the system to light up with the approach of a finger. For example, the buttons of an audio system will glow with its backlight LEDs when the user's hand is near. 7.1 Types of Proximity Sensors 7.1.
7.2 Design Recommendations Using a shield electrode effectively extends the detection distance of the proximity sensor. This is particularly helpful when the proximity sensor must operate in the presence of metal. A wire sensor increases the beneficial effect of the shield electrode because it can be located farther from the shield electrode. Avoid large, solid ground-fill areas inside the proximity sensor, because this decreases the sensitivity.
8. Low Power Design Considerations Power consumption is an important aspect of microcontroller designs. Among the several techniques to reduce the average current used by the CapSense controller, sleep mode is the most popular. The CapSense controller uses sleep mode when it is not required to perform any function, similar to a cell phone backlight dimming after an idle period. This is done to reduce the average current consumed by the device, a necessity of all battery applications.
8.1.2 Putting it All Together The following code is a sample of a typical sleep preparation sequence for a 28-pin part. In this sequence, interrupts are disabled, the analog circuitry is turned off, all drive modes are set to Analog HI-Z, and interrupts are re-enabled.
8.2 Post Wakeup Execution Sequence If the CapSense controller is awakened through a reset, then execution starts at the beginning of the boot code. If the CapSense controller is awakened by an interrupt service routine, the first instruction to execute is the one immediately following the sleep instruction. This is because the instruction immediately following the sleep instruction is prefetched before the CapSense controller is fully asleep.
Figure 8-1. Sleep Timer User Module Block Diagram 54 Document No. 001-66271 Rev.
9. Resources 9.1 Website The Cypress CapSense Controllers website gives access to all of the reference material discussed in this section. The CY8C21x34/B web page has a variety of technical resources for the CapSense CY8C21x34/B family of devices. 9.2 Datasheet The datasheet for the CapSense CY8C21x34/B family of devices is available at www.cypress.com. CY8C21234, CY8C21334, CY8C21434, CY8C21534, CY8C21634 CY8C21234B, CY8C21334B, CY8C21434B, CY8C21534B, CY8C21634B 9.
9.4.2.3 Linear Slider Module Board The CY3280-SLM Linear Slider Module consists of five CapSense buttons, one linear slider (with ten sensors), and five LEDs. This module connects to any CY3280 Universal CapSense Controller Board. 9.4.2.4 Radial Slider Module Board The CY3280-SRM Radial Slider Module consists of four CapSense buttons, one radial slider (with ten sensors), and four LEDs. This module connects to any CY3280 Universal CapSense Controller Board. 9.4.2.
CMPPRG User Module Example Receive String using CYRF6936 and CY8C27643 CapSense Sigma Delta (CSD) with LED Backlight Fading on CY8C21x34 CSD with SPIS on CY8C21x34 9.9 Design Support Cypress has many design support channels to ensure the success of your CapSense solutions. Knowledge Base Articles –Browse technical articles by product family or perform a search on various CapSense topics.