How to measure/read the capacitve value of a button?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am developing an application for a touchpad where I use capacitive buttons in conjunction with the MIDI protocol to play some music notes. I would like to change the "velocity" parameter inside the library. This change must correspond to the pressure applied to the capacitive sensor touch. For example when you are playing the piano and you press the key harder. I'm not sure what function to use to do this. The parameter should vary with the variation of capacitance at the finger touch on the capacitive sensor. Any suggestions?

0 Likes
1 Solution
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

The idea of Cypress CapSense is to measure the parasitic capacitance of the sensor and converts it into a number. We call that number as raw counts. Based on the value of raw counts the parasitic capacitance can be estimated. So in your case in order to detect the pressure you should convert the pressure to capacitance. For that we recommend you to use a flexible dielectric so that when touched with more force the effective distance between the finger and overlay decreases and the raw counts increases. In this way you can detect pressure using CapSense. So please go through the PSoC 4 capSense design guide to design the application with a flexible overlay.

http://www.cypress.com/file/46081/download

Thanks and Regards

Ganesh

View solution in original post

0 Likes
2 Replies
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

The idea of Cypress CapSense is to measure the parasitic capacitance of the sensor and converts it into a number. We call that number as raw counts. Based on the value of raw counts the parasitic capacitance can be estimated. So in your case in order to detect the pressure you should convert the pressure to capacitance. For that we recommend you to use a flexible dielectric so that when touched with more force the effective distance between the finger and overlay decreases and the raw counts increases. In this way you can detect pressure using CapSense. So please go through the PSoC 4 capSense design guide to design the application with a flexible overlay.

http://www.cypress.com/file/46081/download

Thanks and Regards

Ganesh

0 Likes

digging into an old thread, but I am just beginning with a similar task and thinking how best to do it using capsense, and I am sure I won't be the last! :).

Ganesh's solution above looks good and I'll experiment with it soon.

However, one important distinction I'd like to make is that velocity in MIDI is not really the pressure of the finger on the piano key. It is really the speed at which the key is hit (although certainly there will be a difference in pressure as a result). On a conventional MIDI keyboard, velocity is measured by having the key press trigger two switches in succession. By measuring the time interval between the two switches going high (or maybe low), you know how fast the piano key is moving.

Some keyboards have pressure sensors under the keys to make a separate measurement of how hard you are pushing down on the key. In MIDI, this is handled in two different ways:

  1. If the pressure sensor runs the width of the keyboard, then its output is typically mapped to channel pressure (sometimes called aftertouch), which is a parameter that applies across all the notes in that MIDI channel (meaning that, if you press hard on one key after hitting it, that action will affect all notes being played, not just that particular one. This is often mapped to introduce some vibrato or a swell in volume, but that is a convention rather than a strict part of the MIDI standard)
  2. Some more expensive keyboards have what is called polyphonic aftertouch (sometimes called poly pressure, note pressure etc.) by having a separate pressure sensor underneath each individual key. polyphonic aftertouch  is treated as part of an individual note event so it applies only to the key being pressed

Although getting a single raw count of parasitic capacitance using a flexible dielectric should give you a reasonable measurement of how hard someone is hitting the 'key' on your capacitive keyboard, it would be cooler if we can quickly compare the difference in capacitance between a number of successive samples from the sensor.

Then you could, like a physical keyboard, have a separate measurement for the speed at which you hit the key and how hard you continue to press down on that key afterward.

It would be necessary to experiment with the polling rate to see how fast it needs to be. We are very sensitive to time delays in sound, as it is part of how we locate where sounds come from and how we notice reflected sound from walls etc. to tell us about our environment (sound can go about 34cm in just one millisecond).

So, I'm re-opening this question for suggestions about the best way to make these rapid comparisons in a way that is quick enough to be musically meaningful without swamping ourselves with too much data.

0 Likes