Modular Library - Three Group Example

Introduction

The goal of this tutorial is to show you how to combine different touch configurations into a single project. As of now, this is not possible in START or Harmony 3. For example, combining a mutual-capacitance touchpad with self-capacitance buttons and a mutual-capacitance slider.

Apart from self-capacitance plus mutual-capacitance, it may not be possible to share the same drift rate, max-on-duration, frequency hop parameters, etc., due to different physical locations of the sensors, types of sensor construction, or custom application requirements. In such cases, multiple groups can be used, each having a different set of configurations.

Example Application

For ease of demonstration, all three projects in this exercise use mutual-capacitance buttons.

File Download
Installation
Instructions
Windows Linux Mac OSX
Project and Source Files

Boards Used

Three Configurations

project%20config.png

Procedure

Begin by creating three different projects and verify operation. Then combine as follows:

touch.h

  1. They must all share the same DEF_TOUCH_MEASUREMENT_PERIOD_MS.
  2. Label the parameters of each configuration by appending one, two, and three as needed.
  3. You can copy all three configurations to any one project.
Module touch_set1 touch_set2 touch_set3
Acquisition DEF_SENSOR_TYPE_1 DEF_SENSOR_TYPE_2 DEF_SENSOR_TYPE_3
Acquisition DEF_PTC_CAL_OPTION_1 DEF_PTC_CAL_OPTION_2 DEF_PTC_CAL_OPTION_3
Acquisition DEF_PTC_INTERRUPT_PRIORITY_1 DEF_PTC_INTERRUPT_PRIORITY_2 DEF_PTC_INTERRUPT_PRIORITY_3
Acquisition DEF_PTC_TAU_TARGET_1 DEF_PTC_TAU_TARGET_2 DEF_PTC_TAU_TARGET_3
Acquisition DEF_PTC_CAL_AUTO_TUNE_1 DEF_PTC_CAL_AUTO_TUNE_2 DEF_PTC_CAL_AUTO_TUNE_3
Acquisition DEF_SEL_FREQ_INIT_1 DEF_SEL_FREQ_INIT_2 DEF_SEL_FREQ_INIT_3
Acquisition DEF_NUM_CHANNELS_1 DEF_NUM_CHANNELS_2 DEF_NUM_CHANNELS_3
Acquisition NODE_x_PARAMS_1 NODE_x_PARAMS_2 NODE_x_PARAMS_3
Key DEF_NUM_SENSORS_1 DEF_NUM_SENSORS_2 DEF_NUM_SENSORS_3
Key KEY_x_PARAMS_1 KEY_x_PARAMS_2 KEY_x_PARAMS_3
Key DEF_TOUCH_DET_INT_1 DEF_TOUCH_DET_INT_2 DEF_TOUCH_DET_INT_3
Key DEF_ANTI_TCH_DET_INT_1 DEF_ANTI_TCH_DET_INT_2 DEF_ANTI_TCH_DET_INT_1
Key DEF_ANTI_TCH_RECAL_THRSHLD_1 DEF_ANTI_TCH_RECAL_THRSHLD_2 DEF_ANTI_TCH_RECAL_THRSHLD_3
Key DEF_TCH_DRIFT_RATE_1 DEF_TCH_DRIFT_RATE_2 DEF_TCH_DRIFT_RATE_3
Key DEF_ANTI_TCH_DRIFT_RATE_1 DEF_ANTI_TCH_DRIFT_RATE_2 DEF_ANTI_TCH_DRIFT_RATE_3
Key DEF_DRIFT_HOLD_TIME_1 DEF_DRIFT_HOLD_TIME_2 DEF_DRIFT_HOLD_TIME_3
Key DEF_REBURST_MODE_1 DEF_REBURST_MODE_2 DEF_REBURST_MODE_3
Key DEF_MAX_ON_DURATION_1 DEF_MAX_ON_DURATION_2 DEF_MAX_ON_DURATION_3
Frequency Hop autotune NUM_FREQ_STEPS_1 NUM_FREQ_STEPS_2 NUM_FREQ_STEPS_3
Frequency Hop autotune DEF_MEDIAN_FILTER_FREQUENCIES_1 DEF_MEDIAN_FILTER_FREQUENCIES_2 DEF_MEDIAN_FILTER_FREQUENCIES_3
Frequency Hop autotune DEF_FREQ_AUTOTUNE_ENABLE_1 DEF_FREQ_AUTOTUNE_ENABLE_2 DEF_FREQ_AUTOTUNE_ENABLE_3
Frequency Hop autotune FREQ_AUTOTUNE_MAX_VARIANCE_1 FREQ_AUTOTUNE_MAX_VARIANCE_2 FREQ_AUTOTUNE_MAX_VARIANCE_3
Frequency Hop autotune FREQ_AUTOTUNE_COUNT_IN_1 FREQ_AUTOTUNE_COUNT_IN_2 FREQ_AUTOTUNE_COUNT_IN_3

touch.c

  1. Define a global variable acq_set used for sequencing the three configurations.
  2. Configuration one, two, and three arrays and structures are declared.
  3. touch_sensors_config: all configurations are initialized.
  4. qtm_measure_complete_callback: configuration sequencing takes place with the acquisition index acq_set.
  5. touch_process: execution of the three configurations.
Module touch_set1 touch_set2 touch_set3
Acquisition ptc_qtlib_acq_gen1 ptc_qtlib_acq_gen2 ptc_qtlib_acq_gen3
Acquisition ptc_qtlib_node_stat1 ptc_qtlib_node_stat2 ptc_qtlib_node_stat3
Acquisition ptc_seq_node_cfg1 ptc_seq_node_cfg2 ptc_seq_node_cfg3
Acquisition qtlib_acq_set1 qtlib_acq_set2 qtlib_acq_set3
Key qtlib_key_grp_config_set1 qtlib_key_grp_config_set2 qtlib_key_grp_config_set3
Key qtlib_key_grp_data_set1 qtlib_key_grp_data_set2 qtlib_key_grp_data_set3
Key qtlib_key_data_set1 qtlib_key_data_set2 qtlib_key_data_set3
Key qtlib_key_configs_set1 qtlib_key_configs_set2 qtlib_key_configs_set3
Key qtlib_key_set1 qtlib_key_set2 qtlib_key_set3
Frequency Hop autotune qtm_freq_hop_autotune_config1 qtm_freq_hop_autotune_config2 qtm_freq_hop_autotune_config3
Frequency Hop autotune qtm_freq_hop_autotune_data1 qtm_freq_hop_autotune_data2 qtm_freq_hop_autotune_data3
Frequency Hop autotune qtm_freq_hop_autotune_control1 qtm_freq_hop_autotune_control2 qtm_freq_hop_autotune_control3

Example Project Configuration

Compiler Configuration

  • Release – Production code without project debugging and Data Visualizer
  • Debug – Project debugging without Data Visualizer
  • DataVisualizer – Both project debugging and Data Visualizer enabled

Data Visualizer Flag

  • Flag to enable DEF_TOUCH_DATA_STREAMER_ENABLE is removed from the touch.h file and defined in the project configuration (Project/Properties/Toolchain/AVR/GNU C Compiler/Symbols for Data Visualizer Configuration).
© 2020 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.