Sensor Parameters

Last modified by Microchip on 2026/04/07 08:45

Sensor parameters are critical parameters that define how and when capacitive touch measurements are performed in Microchip’s touch libraries. This section covers parameters that control touch measurement behaviors that are common to all the sensors.

Please refer to the "Sensor Application Programming Interfaces (APIs)" page for details on APIs.

Sensor Typedefs

mtouch_sensor_sample_t

 typedef uint16_t mtouch_sensor_sample_t;

Description: Defines the sensor sample reading minimum and maximum

Range:

#define MTOUCH_SENSOR_SAMPLE_MIN (0)
#define MTOUCH_SENSOR_SAMPLE_MAX (UINT16_MAX)

mtouch_sensor_mask_t

typedef uint8_t mtouch_sensor_mask_t;

Description: Defines the sensor mask minimum and maximum value

Range:

#define MTOUCH_SENSOR_MASK_MIN (0)
#define MTOUCH_SENSOR_MASK_MAX (UINT8_MAX)

mtouch_sensor_adcsample_t

typedef uint16_t mtouch_sensor_adcsample_t;

Description: Defines the sensor Analog-to-Digital Converter (ADC) sample minimum and maximum

Range: 

#define MTOUCH_SENSOR_ADCSAMPLE_MIN ((mtouch_sensor_adcsample_t)0)
#define MTOUCH_SENSOR_ADCSAMPLE_MAX ((mtouch_sensor_adcsample_t)4095)

mtouch_sensor_packetcounter_t

typedef uint16_t mtouch_sensor_packetcounter_t;

Description: Defines the sensor packet counter reading minimum and maximum

Range:

#define MTOUCH_SENSOR_PACKET_ADCSAMPLES ((mtouch_sensor_packetcounter_t)32)
#define MTOUCH_SENSOR_PACKETCOUNTER_MIN ((mtouch_sensor_packetcounter_t)0)
#define MTOUCH_SENSOR_PACKETCOUNTER_MAX ((mtouch_sensor_packetcounter_t)UINT16_MAX)

mtouch_sensor_packetsample_t

typedef uint16_t mtouch_sensor_packetsample_t;

Description: Defines the sensor packet sample reading minimum and maximum

Range:

#define MTOUCH_SENSOR_PACKETSAMPLE_MIN ((mtouch_sensor_packetsample_t)0)
#define MTOUCH_SENSOR_PACKETSAMPLE_MAX ((mtouch_sensor_packetsample_t)UINT16_MAX)

mtouch_sensor_delay_t

typedef uint8_t mtouch_sensor_delay_t;

Description: Alias for code readability and adapting to sensor-specific naming conventions

Range:

0 to 255

mtouch_sensor_addcap_t

typedef uint8_t mtouch_sensor_addcap_t;

Description: Capacitance limit

Range:

#define ADD_CAP_LIMIT (mtouch_sensor_addcap_t)31

mtouch_sensor_time_t

typedef uint8_t mtouch_sensor_time_t;

Description: Sensor time

#define MIN_PRECHARGE_TIME          ((mtouch_sensor_time_t)DELAY_CYCLE(1))
#define MIN_ACQ_TIME                ((mtouch_sensor_time_t)DELAY_CYCLE(1))
#define MAX_ACQ_TIME                ((mtouch_sensor_time_t)DELAY_CYCLE(x))
#define MAX_PRECHARGE_TIME          ((mtouch_sensor_time_t)DELAY_CYCLE(x))

X is based on the XTAL frequency.

Back to Top

Sensor Enum and Structures

mtouch_sensor_names

enum mtouch_sensor_names
{
Sensor_ANAx = 0,
...
};

Description: Displays the sensor names configured in the project

mtouch_sensor_error

enum mtouch_sensor_error
{
         MTOUCH_SENSOR_ERROR_none                  =  0,
         MTOUCH_SENSOR_ERROR_invalid_index         = -1,
         MTOUCH_SENSOR_ERROR_interrupt_notEnabled  = -2,
         MTOUCH_SENSOR_ERROR_invalid_calibrate     = -3,
         MTOUCH_SENSOR_ERROR_tooManyRetries        = -4,
         MTOUCH_SENSOR_ERROR_scanOverrun           = -5,
         MTOUCH_SENSOR_ERROR_interruptedScan       = -6
 };

Description: Lists the sensor error

 

mtouch_sensor_t

typedef struct
{
const  enum mtouch_sensor_names        sensor_name;
const  uint8_t                         adpch;
        mtouch_sensor_time_t            precharge_time;
        mtouch_sensor_time_t            acquisition_time;
        mtouch_sensor_packetcounter_t   oversampling;
        mtouch_sensor_addcap_t          addcap;
        mtouch_sensor_sample_t          rawSample;
       unsigned                        enabled:1;
       unsigned                        sampled:1;
       unsigned                        active:1;
       unsigned                        calibrated:1;
       unsigned                        acqTime_cal:1;
} mtouch_sensor_t;

Description: This structure lists down all the elements corresponding to sensors configured in the project

 

Back to Top