Powerful projected capacitive controller for precise and adaptive touch interactions in any environment
A
A
Hardware Overview
How does it work?
Touchpad 5 Click is based on the IQS550, a projected capacitive touch and proximity trackpad/touchscreen controller from Azoteq. The IQS550 offers high-sensitivity proximity wake-up and contact detection (touch) through many I2C-controllable sensor lines. Its advanced on-chip signal processing capabilities provide stable high performance with high sensitivity. Also, multiple filters are implemented to detect and suppress noise, track slow varying environmental conditions, and avoid the effects of possible drift. The IQS550 controller is very flexible, providing numerous outputs such as proximity, touch, snap, touch strength, area, and actual finger position, all in one solution. On Click boards™ front side, a clearly defined field represents a touchpad area. This area is a matrix of conductive electrodes on the PCB, electrically isolated from each other, arranged as rows and columns
of X and Y in a dimension of 29x23mm. An electrode consists of multiple diamond-shaped elements connected to the next with a conductive neck. The controller uses the principle of projected capacitance charge transfer on the trackpad. When a conductive object such as a human finger approaches the sense pad, it will decrease the detected capacitance. Thresholds are applied to the sensor data to identify proximity and touch deviation areas. The contours of the touch areas are then translated to Cartesian position coordinates that are continuously monitored to recognize gestures. A user can access all the data layers – the raw sensor data, the sensor proximity/touch status data, the XY coordinates, and the gesture outputs. Touchpad 5 Click communicates with MCU using the standard I2C 2-Wire interface with a maximum clock frequency of 400kHz, fully adjustable
through software registers. An additional ready signal, routed on the INT pin of the mikroBUS™ socket, is added, which indicates when the communication window is available with new data for optimal response. Thus, it is optimal for the response rate to use the INT pin as a communication trigger. Alongside this pin, this Click board™ has a Reset feature routed to the RST pin on the mikroBUS™ socket, which with a low logic level, puts the module into a Reset state, and with a high level, operates the module normally. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
Nucleo-64 with STM32F091RC MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin
headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is
provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M0
MCU Memory (KB)
256
Silicon Vendor
STMicroelectronics
Pin count
64
RAM (Bytes)
32768
You complete me!
Accessories
Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for Touchpad 5 Click driver.
Key functions:
touchpad5_get_touch
This function get touch XY data.touchpad5_get_status
This function get status proximity, touch, or snap data.touchpad5_wait_ready
This function waits for the communication window to be available.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* @file main.c
* @brief TouchPad5 Click example
*
* # Description
* This example demonstrates the use of Touchpad 5 click board by utilizing the touchpad XY
* and snap functionalities.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and USB UART logging and displays the device version information
* such as product number, project number, major/minor release number, hardware ID, hardware
* revision and bootloader status.
*
* ## Application Task
* Task busy waits for the touchpad controller ready bit using polling operation. When the
* communication window is available, the snap functionality is being checked, as well as
* XY touchpad data. Based on the user's touch sensibility and duration, one of the two
* features is being determined and logged over UART terminal. Snap (click) corresponds to
* the shorter and lighter 'click' gesture, while the touch is detected as longer and
* stronger 'swipe' gesture.
*
* @note This example relies on the IQS5xx-A000 firmware of the touch-pad controller.
*
* @author Stefan Popovic
*
*/
#include "board.h"
#include "log.h"
#include "touchpad5.h"
// Snap buffer size
#define SNAP_BUFFER_SIZE ( 8 )
// Number of read channels for snap status
#define SNAP_NUMBER_OF_CHANNELS ( 8 )
// Snap detection condition
#define SNAP_MAX_NO_CONSECUTIVE_SAMPLES ( 3 )
// Touchpad strength threshold for XY touch detection
#define TOUCH_STRENGTH_THRESHOLD ( 30 )
static touchpad5_t touchpad5;
static log_t logger;
static touchpad5_touch_t touch_data;
static touchpad5_ver_info_t ver_info;
// Bootloader status ( 0xA5 - present, 0xEE - not present )
static uint8_t bl_status = 0;
// Snap (click) support buffer and variables
static uint16_t snap_buffer[ SNAP_BUFFER_SIZE ] = { 0 };
static uint16_t snap_reference = 0;
static uint8_t snap_idx = 0;
static uint8_t tmp_count = 0;
static uint8_t snap_calc_no_samples = 0;
static uint16_t tmp_reference = 0;
static uint8_t snap_max_no_samples = SNAP_MAX_NO_CONSECUTIVE_SAMPLES;
static uint16_t snap_reg_data[ 2 * SNAP_NUMBER_OF_CHANNELS ] = { 0 };
/**
* @brief TouchPad 5 snap sample getter.
* @details This function gets the snap sample value as the averaged value of the predefined number of channels.
* @param[in] ctx : Click context object.
* See #touchpad5_t object definition for detailed explanation.
* @param[out] snap_data : Pointer to the memory location of the buffer where data is stored.
* @return true - Success,
* false - Error.
*
* @note Snap functionality must be enabled in control settings byte second byte.
*/
bool touchpad5_get_snap_sample( touchpad5_t *ctx, uint16_t *snap_data );
/**
* @brief TouchPad 5 snap detection function.
* @details This function checks for snap criteria defined by snap reference and predefined
* number of consecutive samples deviating from said reference.
* @param[in] ctx : Click context object.
* See #touchpad5_t object definition for detailed explanation.
* @param[out] snap_buffer : Snap buffer with snap status data .
* @param[in] snap_buffer_size : Buffer size of the 16-bit snap data.
* @param[out] snap_reference : Pointer to the reference data calculated inside within each iteration.
* @return true - Snap detected,
* false - Snap not detected.
*
* @note Snap functionality must be enabled in control settings byte second byte.
*/
bool touchpad5_detect_snap( touchpad5_t *ctx, uint16_t *snap_buffer, uint8_t snap_buffer_size, uint16_t *snap_reference );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
touchpad5_cfg_t touchpad5_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
touchpad5_cfg_setup( &touchpad5_cfg );
TOUCHPAD5_MAP_MIKROBUS( touchpad5_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == touchpad5_init( &touchpad5, &touchpad5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
Delay_100ms();
if ( TOUCHPAD5_ERROR == touchpad5_default_cfg ( &touchpad5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
Delay_1sec( );
if ( TOUCHPAD5_ERROR == touchpad5_check_version( &touchpad5, &ver_info ) )
{
log_error( &logger, " Cannot read version.\r\n " );
for ( ; ; );
}
Delay_100ms();
if ( TOUCHPAD5_ERROR == touchpad5_check_bl_status( &touchpad5, &bl_status ) )
{
log_error( &logger, " Cannot read bootloader status.\r\n " );
for ( ; ; );
}
Delay_100ms();
if ( ver_info.product_num != TOUCHPAD5_IQS550_PRODUCT_NUMBER )
{
log_error( &logger, " Incorrect product number.\r\n " );
for ( ; ; );
}
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, " Product number %u \r\n", ( uint32_t ) ver_info.product_num );
log_printf( &logger, " Project number %u \r\n", ( uint32_t ) ver_info.project_num );
log_printf( &logger, " Version %.1f \r\n", ver_info.version );
log_printf( &logger, " Hardware ID %x \r\n", ( uint32_t ) ver_info.hw_id );
log_printf( &logger, " Hardware revision %x \r\n", ( uint32_t ) ver_info.hw_revision );
log_printf( &logger, " Bootloader status %x \r\n", ( uint16_t ) bl_status );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
Delay_1sec( );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, " Waiting for a new touch or snap (click)\r\n" );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
Delay_1sec( );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
// Get touchpad XY data
touchpad5_get_touch( &touchpad5, &touch_data );
// Detecting the snap (click) criteria
if ( touchpad5_detect_snap( &touchpad5, snap_buffer, SNAP_BUFFER_SIZE, &snap_reference) && touch_data.touch_strength > 0 )
{
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, "\r\n* Snap (click) event occured with strength: %u *\r\n",
( uint16_t ) touch_data.touch_strength );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
Delay_1sec( );
}
// Detecting the touch criteria
else if ( touch_data.x_pos > 0 && touch_data.y_pos > 0 && touch_data.touch_strength > TOUCH_STRENGTH_THRESHOLD )
{
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, " \r\nTouch with Tag ID %u detected\r\n", ( uint16_t ) touch_data.id_tag );
log_printf( &logger, "Coordinate X = %u \r\n", touch_data.x_pos );
log_printf( &logger, "Coordinate Y = %u \r\n", touch_data.y_pos );
log_printf( &logger, "Touch strength = %u \r\n", ( uint16_t ) touch_data.touch_strength );
log_printf( &logger, "----------------------------------------------------------------\r\n\r\n" );
Delay_ms( 100 );
}
// Monitoring to determine whether the reset occurred on the device after the last ack reset
if ( touch_data.xy_info & TOUCHPAD5_SHOW_RESET )
{
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_error( &logger, "\r\n Unexpected reset occured. \r\n" );
log_printf( &logger, "----------------------------------------------------------------\r\n\r\n" );
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
bool touchpad5_get_snap_sample( touchpad5_t *ctx, uint16_t *snap_data )
{
bool status = false;
uint16_t snap_reg_data_avg = 0;
// Get snap status for desired number of channels
if ( TOUCHPAD5_ERROR == touchpad5_get_status( ctx, TOUCHPAD5_SNAP_STATUS, &snap_reg_data, SNAP_NUMBER_OF_CHANNELS ) )
{
status = false;
}
else
{
for ( int i = 0; i < SNAP_NUMBER_OF_CHANNELS; i++ )
{
snap_reg_data_avg += snap_reg_data[ i ];
}
snap_reg_data_avg /= SNAP_NUMBER_OF_CHANNELS;
status = true;
}
*snap_data = snap_reg_data_avg;
return status;
}
bool touchpad5_detect_snap( touchpad5_t *ctx, uint16_t *snap_buffer, uint8_t snap_buffer_size, uint16_t *snap_reference )
{
bool status = false;
snap_idx = 0;
tmp_count = 0;
tmp_reference = 0;
snap_calc_no_samples = 0;
// Get snap averaged samples
for ( int i = 0; i < snap_buffer_size; i++ )
{
if ( false == touchpad5_get_snap_sample( ctx, &snap_buffer[ snap_idx ] ) )
{
return status;
}
++snap_idx;
}
// Update reference value
tmp_reference = snap_buffer[ 0 ];
snap_idx = 1;
while ( snap_idx < snap_buffer_size )
{
if ( snap_buffer[ snap_idx++ ] == tmp_reference )
{
++tmp_count;
}
}
if ( tmp_count == snap_buffer_size - 1 )
{
*snap_reference = tmp_reference;
}
// Snap detection algorithm - detecting 1 to snap_max_no_samples for confirmed snap
for ( int i = 0; i < snap_buffer_size; i++ )
{
// first snapped index saved
if ( snap_buffer[ i ] != *snap_reference )
{
snap_idx = i;
++snap_calc_no_samples;
}
}
for( int i = snap_idx; i < snap_buffer_size; i++)
{
if ( snap_buffer[ ( i + 1 ) % snap_buffer_size] != *snap_reference )
{
++snap_calc_no_samples;
}
else
{
snap_calc_no_samples = 0;
}
}
if ( snap_calc_no_samples >= 1 && snap_calc_no_samples <= snap_max_no_samples )
{
status = true;
}
return status;
}
// ------------------------------------------------------------------------ END