How to change
Touch Button Sensitivity
on STM8S Discovery




Home Page
STM8 home page
STM8L home page


Suggested reading:
  • AN2927 RC acquisition principle for touch sensing applications
  • AN2869 Guidelines for designing touch sensing applications
  • TN0075 Touch sensing software library (TSSL) frequently asked and anticipated questions (FAAQs)
  • STM8 Touch Sensing Firmware Library - click here
  • Explanations about the use of the library documentation
  • Tutorial that explains how to start developing on STM8S - click here
  • Flow diagram for developing software in C on STM8 - click here

Preconditions:

Click here to get this SW Example ready to use
(STM8-Discovery-Touch-Sensitivity)




Topics:
Download Software
Update Software
Start to use Discover example
The parameters to be amended to change the sensitivity of the Touch Button are here
STM8 Touch Sensing Firmware Library V2.3.0 - click here





Download Software


First of all download the SW package concerning the Discovery STM8:
http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm8s-discovery_dev.zip
Once you download this package, unzip it and it will create the directory:
STM8S-Discovery_dev
Where will we find the following examples:





Update Software


CAUTION:
in the stm8s-discovery_dev.zip is included the old version of:
  • Touch Sensing Library Firmware V1.3.0
  • MCU Libraries
These versions are too old, now we proceed with their update.

Download the new STM8 Touch Sensing Firmware Library (V2.3.0) that you can get  from here:
Home Page:
ZIP Library:
see below



After downloading and unzipped the library, there is an executable file that must be launched for install the library.
The library will installed in the:
C:\Program Files\STMicroelectronics\STM8 Touch Sensing Library Package

In summary, now we are:
Software examples for STM8S Discovery, in my case is in the working directory:
C:\ESEMPI-SW\STM8-Examples\STM8S-Discovery_dev
The new Touch Sensing Library Firmware v2.3.0 and the new MCU libraries are in the directory:
C:\Program Files\STMicroelectronics\STM8 Touch Sensing Library Package

Let's go to the directory:
C:\Program Files\STMicroelectronics\STM8 Touch Sensing Library Package
and copy files circled in red (see below) in the working directory:
C:\ESEMPI-SW\STM8-Examples\STM8S-Discovery_dev



Now we go to the directory:
C:\Program Files\STMicroelectronics\STM8 Touch Sensing Library Package\Libraries\STM8_TouchSensing_Driver
and copy files circled in red (see below) in the working directory to the location:
C:\ESEMPI-SW\STM8-Examples\STM8S-Discovery_dev\Libraries\STM8_TouchSensing_Driver



Finally, now we go to the directory:
C:\Program Files\STMicroelectronics\STM8 Touch Sensing Library Package\Libraries\STM8S_StdPeriph_Driver
and copy files circled in red (see below) in the working directory to the location:
C:\ESEMPI-SW\STM8-Examples\STM8S-Discovery_dev\Libraries\STM8S_StdPeriph_Driver


At this point we have finished upgrading the:  STM8S-Discovery_dev
We can then start working on the project to change the parameters of the touch response.






Start to use Discover example



The project that we will use is:
DISCOVER
In my case the example is located in:
C:\ESEMPI-SW\STM8-Examples\STM8S-Discovery_dev\Project\Discover\STVD\Cosmic
see below



By default it is implemented Cosmic C Compiler version 16K Free  (C:\Program Files\COSMIC\CXSTM8_16K)
In my case I installed the Cosmic C Compiler 32K Free, for this reason is necessary click on the icon:
and then change the root path and set:
C:\Program Files\COSMIC\CXSTM8_32K
As shown below.



At this point you can compile the program to give:
0 Errors 0 Warning

Now you can enter debugging, but first we need to configure the emulator we want to use.

To do this, press the icon
and from the window that opens (see below) selected Swim ST-Link and then click Apply and OK.


Now that the development environment is set up we are going to change the parameters of the Touch Button.


The parameters to be amended to change the sensitivity of the Touch Button are:


SCKEY_DETECTTHRESHOLD_DEFAULT
Defines the default detection threshold value for the Single-channel keys. The key is determined "detected" if the Delta value is greater than this threshold.
This parameter can take a value between 1 to 127.
A Low value will result in a high sensitivity during the detection.
A High value will result in a low sensitivity during the detection.
Typical value: 15 (depends of hardware and desired feeling on the key)

SCKEY_ENDDETECTTHRESHOLD_DEFAULT
Defines the default end-detection threshold value for the Single-channel keys. The key is determined "not detected" if the Delta value is lower than this threshold.
This parameter can take a value between 1 to 127.
A Low value will result in a low sensitivity during the un-detection.
A High value will result in a high sensitivity during the un-detection.
Typical value: half of detection threshold (depends of hardware and desired feeling on the key)

SCKEY_RECALIBRATIONTHRESHOLD_DEFAULT
Defines the default (re)calibration threshold value for the Single-channel keys.
The key is (re)calibrated if the Delta value is lower than this threshold.
This parameter can take a value between -1 to -128.
A Low absolute value will result in a high sensitivity for the (re)calibration.
A High absolute value will result in a low sensitivity for the (re)calibration.
Typical value: minus end-detection threshold (depends of hardware and desired feeling on the key)

These parameters are in the file (line 299 and up to 305):
discover/Include FIles/stm8_tsl_rc_configuration.h
In my case I set the parameters as shown below (in bold):

// Thresholds
#define SCKEY_DETECTTHRESHOLD_DEFAULT          (2)                // 15 /**< Single channel key detection threshold (value from 1 to 127) */
#define SCKEY_ENDDETECTTHRESHOLD_DEFAULT       (1)           // 6  /**< Single channel key end detection threshold (value from 1 to 127) */
#define SCKEY_RECALIBRATIONTHRESHOLD_DEFAULT   (-2)     // -6 /**< Single channel key calibration threshold (value from -1 to -128) */
#define MCKEY_DETECTTHRESHOLD_DEFAULT          (30)             /**< Multi channel key detection threshold (value from 1 to 127) */
#define MCKEY_ENDDETECTTHRESHOLD_DEFAULT       (20)       /**< Multi channel key end detection threshold (value from 1 to 127) */
#define MCKEY_RECALIBRATIONTHRESHOLD_DEFAULT  (-20)  /**< Multi channel key calibration threshold (value from -1 to -128) */

With the above parameters I obtained a reading distance, with insulation made using post-it, of about 4 mm over the plastic insulation already present in your STM8S Discovery.
Then I finished the post-it and I could not go beyond with the test.





I recommend you read the documentation:

  •  

    After downloading the library and unzipped it, there is an executable file that must  be launched and taht installs the library:
    C:\Program Files\STMicroelectronics\STM8 Touch Sensing Library Package
    The file with explanations about the use of the library is circled in red below - stm8_tsl_um.chm



    The parameters I mentioned above are in Section 4.1, see below.










LINK:






Home Page
STM8 home page
STM8L home page