Modular Library - Three Group Example for Atmel START QTouch Library

Last modified by Microchip on 2023/11/09 08:55

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.

Reference Materials

Microchip Studio

Project Files

SAM D20 Xplained Pro Evaluation Kit

QT1 Xplained Pro Extension Kit

Three Configurations

Picture of the SAM D20 Xplained Pro and QT1 Xplained Pro boards with the three touch zones (configurations) highlighted

Back to Top

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.
Moduletouch_set1touch_set2touch_set3
AcquisitionDEF_SENSOR_TYPE_1DEF_SENSOR_TYPE_2DEF_SENSOR_TYPE_3
AcquisitionDEF_PTC_CAL_OPTION_1DEF_PTC_CAL_OPTION_2DEF_PTC_CAL_OPTION_3
AcquisitionDEF_PTC_INTERRUPT_PRIORITY_1DEF_PTC_INTERRUPT_PRIORITY_2DEF_PTC_INTERRUPT_PRIORITY_3
AcquisitionDEF_PTC_TAU_TARGET_1DEF_PTC_TAU_TARGET_2DEF_PTC_TAU_TARGET_3
AcquisitionDEF_PTC_CAL_AUTO_TUNE_1DEF_PTC_CAL_AUTO_TUNE_2DEF_PTC_CAL_AUTO_TUNE_3
AcquisitionDEF_SEL_FREQ_INIT_1DEF_SEL_FREQ_INIT_2DEF_SEL_FREQ_INIT_3
AcquisitionDEF_NUM_CHANNELS_1DEF_NUM_CHANNELS_2DEF_NUM_CHANNELS_3
AcquisitionNODE_x_PARAMS_1NODE_x_PARAMS_2NODE_x_PARAMS_3
KeyDEF_NUM_SENSORS_1DEF_NUM_SENSORS_2DEF_NUM_SENSORS_3
KeyKEY_x_PARAMS_1KEY_x_PARAMS_2KEY_x_PARAMS_3
KeyDEF_TOUCH_DET_INT_1DEF_TOUCH_DET_INT_2DEF_TOUCH_DET_INT_3
KeyDEF_ANTI_TCH_DET_INT_1DEF_ANTI_TCH_DET_INT_2DEF_ANTI_TCH_DET_INT_1
KeyDEF_ANTI_TCH_RECAL_THRSHLD_1DEF_ANTI_TCH_RECAL_THRSHLD_2DEF_ANTI_TCH_RECAL_THRSHLD_3
KeyDEF_TCH_DRIFT_RATE_1DEF_TCH_DRIFT_RATE_2DEF_TCH_DRIFT_RATE_3
KeyDEF_ANTI_TCH_DRIFT_RATE_1DEF_ANTI_TCH_DRIFT_RATE_2DEF_ANTI_TCH_DRIFT_RATE_3
KeyDEF_DRIFT_HOLD_TIME_1DEF_DRIFT_HOLD_TIME_2DEF_DRIFT_HOLD_TIME_3
KeyDEF_REBURST_MODE_1DEF_REBURST_MODE_2DEF_REBURST_MODE_3
KeyDEF_MAX_ON_DURATION_1DEF_MAX_ON_DURATION_2DEF_MAX_ON_DURATION_3
Frequency Hop autotuneNUM_FREQ_STEPS_1NUM_FREQ_STEPS_2NUM_FREQ_STEPS_3
Frequency Hop autotuneDEF_MEDIAN_FILTER_FREQUENCIES_1DEF_MEDIAN_FILTER_FREQUENCIES_2DEF_MEDIAN_FILTER_FREQUENCIES_3
Frequency Hop autotuneDEF_FREQ_AUTOTUNE_ENABLE_1DEF_FREQ_AUTOTUNE_ENABLE_2DEF_FREQ_AUTOTUNE_ENABLE_3
Frequency Hop autotuneFREQ_AUTOTUNE_MAX_VARIANCE_1FREQ_AUTOTUNE_MAX_VARIANCE_2FREQ_AUTOTUNE_MAX_VARIANCE_3
Frequency Hop autotuneFREQ_AUTOTUNE_COUNT_IN_1FREQ_AUTOTUNE_COUNT_IN_2FREQ_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.
Moduletouch_set1touch_set2touch_set3
Acquisitionptc_qtlib_acq_gen1ptc_qtlib_acq_gen2ptc_qtlib_acq_gen3
Acquisitionptc_qtlib_node_stat1ptc_qtlib_node_stat2ptc_qtlib_node_stat3
Acquisitionptc_seq_node_cfg1ptc_seq_node_cfg2ptc_seq_node_cfg3
Acquisitionqtlib_acq_set1qtlib_acq_set2qtlib_acq_set3
Keyqtlib_key_grp_config_set1qtlib_key_grp_config_set2qtlib_key_grp_config_set3
Keyqtlib_key_grp_data_set1qtlib_key_grp_data_set2qtlib_key_grp_data_set3
Keyqtlib_key_data_set1qtlib_key_data_set2qtlib_key_data_set3
Keyqtlib_key_configs_set1qtlib_key_configs_set2qtlib_key_configs_set3
Keyqtlib_key_set1qtlib_key_set2qtlib_key_set3
Frequency Hop autotuneqtm_freq_hop_autotune_config1qtm_freq_hop_autotune_config2qtm_freq_hop_autotune_config3
Frequency Hop autotuneqtm_freq_hop_autotune_data1qtm_freq_hop_autotune_data2qtm_freq_hop_autotune_data3
Frequency Hop autotuneqtm_freq_hop_autotune_control1qtm_freq_hop_autotune_control2qtm_freq_hop_autotune_control3

Back to Top

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).

Back to Top