CE95284 - CapSense® CSD Design with PSoC® 3 and PSoC 5LP Objective This code example demonstrates the usage of the CapSense® CSD component in PSoC® 3 and PSoC 5LP. Overview This code example shows how to implement CapSense button sensors and linear slider using the CapSense CSD Component. In this code example, the CapSense CSD Component is configured to scan two CapSense button sensors and one linear slider with five segments. The CapSense button sensor on/off status is indicated using the LEDs and the finger position on the linear slider is indicated on a character LCD using a bar graph. This code example can be tested on PSoC development kits such as CY8CKIT-001, CY8CKIT-030, and CY8CKIT-050. PSoC Resources Cypress provides a wealth of data at www.cypress.com to help you to select the right PSoC device for your design, and quickly and effectively integrate the device into your design. For a comprehensive list of resources, see KBA86521, How to Design with PSoC 3, PSoC 4, and PSoC 5LP. The following is an abbreviated list for PSoC 1, PSoC 3, and PSoC 5LP resources: Overview: PSoC Portfolio and PSoC Roadmap Product Selectors: PSoC 1, PSoC 3, PSoC 4, or PSoC 5LP. In addition, PSoC Creator™ includes a device selection tool. Datasheets: Describe and provide electrical specifications for the PSoC 3 and PSoC 5LP device families. CapSense Design Guide: Learn how to design capacitive touch-sensing applications with the PSoC 3 and PSoC 5LP families of devices. Application Notes and Code Examples: Cover a broad range of topics, from basic to advanced level. Many of the application notes include code examples. Technical Reference Manuals (TRM): Provide detailed descriptions of the architecture and registers in each of the PSoC 3 and PSoC 5LP device families. Development Kits: o CY8CKIT-001 is a common development platform for all PSoC family devices. o CY8CKIT-030 and CY8CKIT-050 are designed for analog performance. They enable you to evaluate, develop, and prototype high-precision analog, low-power, and low-voltage applications powered by PSoC 3 and PSoC 5LP, respectively. The MiniProg3 device provides an interface for flash programming and debug. PSoC Creator PSoC Creator is a free Windows-based Integrated Design Environment (IDE). It enables concurrent hardware and firmware design of systems based on PSoC 3, PSoC 4, and PSoC 5LP; see Figure 1. With PSoC Creator, you can: 1. Drag and drop Components to build your hardware system design in the main design workspace 3. Configure Components using configuration tools 4. Explore the library of 100+ Components 2. Codesign your application firmware with the PSoC hardware 5. Review Component datasheets www.cypress.com Document No. 001-95284 Rev.** 1 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Figure 1. PSoC Creator Features Requirements Tool: PSoC Creator 3.0 SP2 See also Upgrade Information. Programming Language: C (DP8051 Keil 9.51, ARM GCC 4.7.3, and ARM MDK compilers) Associated Parts: All PSoC 3 and PSoC 5LP parts Related Hardware: CY8CKIT-001, CY8CKIT-030, and CY8CKIT-050 Design Figure 2 shows the PSoC Creator schematic design of the code example. The code example features the following: CapSense CSD Component to detect finger touches on the CapSense button sensor and finger position (centroid) on the linear slider. SmartSense™ auto-tuning method is used to automatically tune all the sensor tuning parameters The CapSense Component is configured for two CapSense button sensors and one linear slider with five segments The API resolution of the linear slider is set to 100 (0x64) A display Component (Character LCD or Pins driving LEDs) to show the status of CapSense sensors The Pins Component is used to drive the LEDs to indicate the on/off status of CapSense button sensors The Character LCD Component is used to display the finger position on the linear slider using a bar graph www.cypress.com Document No. 001-95284 Rev.** 2 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Figure 2. CapSense CSD Design with PSoC 3 and PSoC 5LP www.cypress.com Document No. 001-95284 Rev.** 3 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Design Considerations In the code example, the sensitivity parameter is set to the default value of ‘2’. To test the code example with an overlay on the sensor, the sensitivity parameter should be set such that touch is detected. Thicker overlays require low value of sensitivity setting. The sensitivity parameter for each sensor can be specified in the Scan Order tab of the CapSense CSD component, as shown in Figure 3. Figure 3. CapSense CSD Component Scan Order Tab Hardware Setup For the basic kit board setup, see the corresponding Kit User Guide. The code example can be tested on CY8CKIT-030 or CY8CKIT-050 without any hardware modification. To test the code example on CY8CKIT-001 follow these steps: 1. Set the LCD power jumper J12 to the ON position and leave the rest of the board at default configuration. 2. Connect pin P1[6] to LED1 and pin P1[7] to LED2 on the development board using jumper wires. 3. Ensure that the character LCD is connected to header P18 on the development board. Software Setup The code example works with CY8CKIT-030 without any modification. To test the code example with CY8CKIT-050, in PSoC Creator, click Project > Device Selector, select CY8C5868AXI-LP035, and click OK. www.cypress.com Document No. 001-95284 Rev.** 4 CapSense® CSD Design with PSoC® 3 and PSoC 5LP To test the code example with CY8CKIT-001 follow these steps: In PSoC Creator, click Project > Device Selector; select CY8C3866AXI-040 if you are using the PSoC 3 processor module or CY8C5868AXI-LP035 if you are using the PSoC 5 processor module and click OK. In the Pins tab of the Design-Wide Resources (.cydwr) file, reassign the sensor and LED pins by referring to Table 1. Table 1. Pin Assignment for CapSense CSD Design Project Port Pin Function CY8CKIT-030 CY8CKIT-050 CY8CKIT-001 (PSoC 3 Module) CY8CKIT-001 (PSoC 5 Module) CY8C3866AXI040 CY8C5868AXILP035 CY8C3866AXI040 CY8C5868AXILP035 Cmod_CH0 P6[4] P6[4] P2[7] P15[5] Button0_BTN P5[5] P5[5] P0[5] P0[5] Button1_BTN P5[6] P5[6] P0[6] P0[6] LinearSlider0_e0_LS P5[0] P5[0] P0[0] P0[0] LinearSlider0_e1_LS P5[1] P5[1] P0[1] P0[1] LinearSlider0_e2_LS P5[2] P5[2] P0[2] P0[2] LinearSlider0_e3_LS P5[3] P5[3] P0[3] P0[3] LinearSlider0_e4_LS P5[4] P5[4] P0[4] P0[4] LED1 P6[2] P6[2] P1[6] P1[6] LED2 P6[3] P6[3] P1[7] P1[7] Device Components Table 2 lists the PSoC Creator Components used in the code example, as well as the hardware resources used by each Component. Table 2. List of PSoC Creator Components Component Hardware Resources CapSense CSD 2 UDBs, 1 interrupt, 1 clock divider,1 IDAC, 1 comparator, 1 CapSense buffer, 1 AMUXBUS Character LCD 7 pins Pin 2 pins for LEDs Parameter Settings Figure 4 to Figure 7 show the parameter settings for each of the PSoC Creator Components used in the code example. Only the parameters that vary from the default are shown. www.cypress.com Document No. 001-95284 Rev.** 5 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Figure 4. CapSense CSD Component General Tab Settings Figure 5. CapSense CSD Component Widgets Config Tab Settings www.cypress.com Document No. 001-95284 Rev.** 6 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Figure 6. LCD Component General Tab Settings Figure 7. Digital Output Pin Pins Tab Settings www.cypress.com Document No. 001-95284 Rev.** 7 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Design-Wide Resources Figure 8 shows the pin assignments for the code example project with CY8CKIT-030 or CY8CKIT-050. No other design-wide resource needs to be changed from its default setting. Figure 8. Pin Assignments for PSoC 3 and PSoC 5LP Example Operation After you build and install the example in the appropriate kit, test the example by doing the following: Touch the CapSense buttons and verify that the LED turns ON. Slide your finger over the linear slider and verify that the Length of the bar graph in the character LCD varies with the finger position. Finger position on the linear slider is displayed on the character LCD. Upgrade Information This code example also works with PSoC Creator 3.1. To upgrade the code example to PSoC Creator 3.1, follow these steps: 1. Open the code example in PSoC Creator 3.1. 2. The Component Update Tool window (Figure 9) will pop up asking to update the components in the code example. Click Next > Finish. 3. In the Workspace/Project Achiever window (Figure 10), click Archive > OK to archive the files and update the components in the code example. www.cypress.com Document No. 001-95284 Rev.** 8 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Figure 9. PSoC Creator Component Update Tool Window Figure 10. PSoC Creator Workspace/Project Archiver Window www.cypress.com Document No. 001-95284 Rev.** 9 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Related Documents Table 3 lists all relevant application notes, code examples, knowledge base articles, device datasheets, and component datasheets. Table 3. Related Documents Application Notes AN54181 Getting Started with PSoC 3 In this application note, you will learn about the PSoC 3 architecture and how the 8051-based MCU subsystem works closely with PSoC's programmable digital and analog fabric. AN77759 Getting Started with PSoC 5LP In this application note you will learn about PSoC 5LP and PSoC Creator IDE. Design Guide Getting Started with CapSense This guide is an ideal starting point if you are new to capacitive touch sensing (CapSense). It is also useful for learning key design considerations and layout best practices to ensure design success. PSoC 3 and PSoC 5LP CapSense Design Guide This document provides design guidance for building CapSense applications with the PSoC 3 and PSoC 5LP family of devices. PSoC Creator Component Datasheets CapSense CSD Controls CapSense CSD block and detects change in capacitance in applications such as touch sense buttons, sliders, touchpad, and proximity detection. Character LCD (CharLCD) Contains a set of library routines that enable simple use of one, two, or four-line LCD modules, which follow the Hitachi 44780 standard 4-bit interface. Pins Controls interface with physical I/O port pins. Device Documentation PSoC 3 Datasheets PSoC 5LP Datasheets PSoC 3 Technical Reference Manuals PSoC 5LP Technical Reference Manuals Development Kit(DVK) Documentation PSoC 3 and PSoC 5LP Kits www.cypress.com Document No. 001-95284 Rev.** 10 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Document History Document Title: CapSense® CSD Design with PSoC® 3 and PSoC 5LP - CE95284 Document Number: 001-95284 Revision ECN ** 4646184 www.cypress.com Orig. of Change DCHE Submission Date 01/30/2015 Description of Change New code example. Document No. 001-95284 Rev.** 11 CapSense® CSD Design with PSoC® 3 and PSoC 5LP Worldwide Sales and Design Support Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find the office closest to you, visit us at Cypress Locations. PSoC® Solutions Products Automotive cypress.com/go/automotive psoc.cypress.com/solutions Clocks & Buffers cypress.com/go/clocks PSoC 1 |PSoC 3 | PSoC 4 |PSoC 5LP Interface cypress.com/go/interface Lighting & Power Control cypress.com/go/powerpsoc cypress.com/go/plc Memory cypress.com/go/memory PSoC cypress.com/go/psoc Touch Sensing cypress.com/go/touch USB Controllers cypress.com/go/usb Wireless/RF cypress.com/go/wireless Cypress Developer Community Community | Forums |Blogs | Video |Training Technical Support cypress.com/go/support PSoC and CapSense areregistered trademarks, and PSoC Creator and SmartSense are trademarks of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners. Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone Fax Website : 408-943-2600 : 408-943-4730 : www.cypress.com © Cypress Semiconductor Corporation, 2015. 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. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, 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 products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. This 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. www.cypress.com Document No. 001-95284 Rev.** 12