element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • 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
Cypress Kits
  • Products
  • Dev Tools
  • Cypress Kits
  • More
  • Cancel
Cypress Kits
Forum PSoC 4 Pioneer Kit Community Project#013 – CapSense Button and LED Control with Bridge Control Panel
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Cypress Kits requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 8 replies
  • Subscribers 15 subscribers
  • Views 392 views
  • Users 0 members are here
  • 100projects
Related

PSoC 4 Pioneer Kit Community Project#013 – CapSense Button and LED Control with Bridge Control Panel

cy.wbz
cy.wbz over 8 years ago

Hello!


This example provides users the ability to read out system status and to transmit values to control their end design. The example illustrates this through a simple CapSense button and an LED. Very often when developing a system you will want to monitor when actions are being taken and then transmit data to the system to initiate a state or control. In this example we read out button touches and display that value to our Bridge Control Panel bar chart. We can then send data to the Pioneer board to flip an LED on or off.

 

Forum Post Attachments:

 

At the bottom of this post we are including the following items:

  • Example Project Zip File
  • Bridge Control Panel Files
  • Zip File of Images
    • Project Schematic
    • Component Configurations

 

Components Used:

 

The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:

  • CapSense
  • I2C
  • CyPin

 

The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.

 

Firmware Description:

 

 

The main.c firmware is included in the example project. Please review the commented sections for more details.


The firmware of this project is straight forward. We can either receive and/or transmit up data from our system. In one use case we can read out the state of the CapSense button (is it pressed is it not pressed). In the second use case we send a value to the PSoC and we either turn on or turn off the LED.

 

As part of this example we include the IIC and INI files for the Bridge Control Panel. The IIC files can be opened in the Bridge Control Panel and include the command examples. The INI file covers the variable settings. The variable settings are used by the read action and the charting window.

 

The Bridge Control Panel is installed with the PSoC Programmer installation.

 

You will need to make sure you have the Pioneer Kit plugged in to the PC before using the Bridge Control Panel. Simply connect to the Kit in the port window. It will be listed as a 'KitProg'. The I2C protocol will be selected automatically.

 

Load the IIC and INI files. You can load the IIC files by selecting the open file button and navigating to the files included in this post. Next click the variable settings button or navigate to Chart>Variable Settigns. Click the load button and select the INI file included in this post. Select OK to return to the Bridge Control Panel window.

 

 

First we'll work with the write command in the editor window. You will see we use the following symbol to comment out the read command ';'. Make sure your cursor is placed on the write command line. The Bridge Control Panel uses the cursor to determine the command to send. The first command we'll send is:

 

w 8 01 p

 

To send the command click the Send button. This command sends a write command to the PSoC 4 using I2C address 8 and sending value 01. This will turn the LED off. Simply change the 01 to 00 and send the command again. You will see the LED turn on.

 

Next comment out the write command and decomment the read command using the ';' character. You will see that in our read command we use the '@key1' variable. This variable was defined in our INI file and associates the value received to that variable.

 

r 8 @key1 p

 

Again make sure the cursor is placed on the read command line. We can either send this command once using the Send button or we can continuously repeat this command using the Repeat button. By hitting the Repeat button this will enable us to chart the values received in real time. Click the Repeat button and you should see a stream of data in the output window. Click on the Chart tab while the data is Repeating. Then touch the CapSense button P1.1 to see the chart update with the button status.

 

If you happen to have the Line Plot option simply change that to the Bar Graph option. This selection is at the bottom right of the charting window.

 


 

Simply click the Stop button to end the Repeat data collection.


The chart is only displaying the 00 or 01 value. The chart can display values of more than 1. For example if you want to chart or plot the current value being read by the ADC the BCP chart will handle that. To think of it that sounds like a great example

 

There are many more options in the Bridge Control Panel so take some time to review the help guide.

 

Hardware Connections:

 

There are no hardware connections for this example.

 

Test Your Project:

 

Once the kit is programmed with the example project then the user will be able to launch the Bridge Control Panel to read out the CapSense state or control the LED.

 

I hope this example can help you out in your design.

 

Best,

Matt

Attachments:
5873.Project Images.zip
CapSenseButton_I2C.zip
Bridge Control Panel Files.zip
  • Reply
  • Cancel
  • Cancel
  • DAB
    DAB over 8 years ago

    Another great example.

     

    I really like this series.

     

    Keep up the good work.

    DAB

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago

    Thank you for the great examples.

     

    I'm a beginer of the PSOC,and I have some questions about this example.

     

    1.In the main.c,we first define the "uint8 rdBuf[1]",then use the "rdBuf[0]".Is rdBuf[1] a array include rdBuf[0] and rdBuf[1]?

     

    2.In the line 80 of main.c,why do we use  I2C_I2CSlaveClearrdBuf() function in a I2C write operation to make next read operation starting with index 0?Is it a must?

       And what will happen if I don't clear the read buffer pointer after the master read operation in line 88 of main.c?

     

    Best regards!

     

    Aimar.Zhao

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • cy.wbz
    cy.wbz over 8 years ago in reply to Former Member

    Aimar,

     

    uin8 rdBuf[1] defines an array of one value. That first value is rdBuf[0]. Take a look at example #15 in this series. The Proximity example uses arrays of longer than 1 value. In this case since the project was an array of one value it could have been assigned to a variable. An array was defined if you want to add more buttons to store the 1 byte values.

     

    By calling the I2CSlaveClearReadBuf API you are resetting the read pointer to the begging of the read buffer. This means that the next time the Master (PSoC 5LP device) reads from the I2C buffer it starts at the begining of that buffer. Doing this resets the index to the beginning of your array. If the array was longer then you would need this. Since it is only one value long it's not as applicable. If you want to see more on this topic go to the schematic view of the project and right click on the I2C component and select open Datasheet. There's a good explaination of this on page 24-25.

     

    I hope this helps!

     

    Best,

    Matt

     

    Matt

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • amitajit8
    amitajit8 over 6 years ago

    Hello all,

         I was trying to configure 5 segments of on-board slider to 5 individual buttons, but couldn't do that. So searched for CapSense buttons & LED control n found this project, but couldn't get it to my purpose. Can  anyone guide me doing that?

    5 separate buttons (using on-board 5 slider segments) tuning to 5 LED's.

    Please guide me on this.

    Thanks & Regards-

    Amit

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • clem57
    clem57 over 6 years ago in reply to amitajit8

    Cap sense measures changes in levels of current and cannot work with buttons.

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • amitajit8
    amitajit8 over 6 years ago in reply to clem57

    Dear Clem, you can have buttons with CapSense because when you bring your finger near it, its capacitance changes & in turn the c/n level as well.

    I seek guidance in firmware for configuring the buttons, like general API's used & there explanation, the flow of the control in the firmware; likewise. so anyone can help, please be kind.

    thanks

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 6 years ago in reply to amitajit8

    Is this the configuration you are looking for:

     

    ?

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • amitajit8
    amitajit8 over 6 years ago in reply to Jan Cumps

    Hello Jan,

    that's the configuration I am talking about.

    I wish to have on board slider segments to be configured as Buttons, (any count 2, 3 or all 5);

    For that I need some sample codes to proceed. Actually I'm not getting the coding environment with PSoC 4 as I'm new to it.

    Your guidelines could help a lot.

    Waiting for positives to come out.

    Thanks & Regards-

    Amit

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
Element14

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 © 2022 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube