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
EasyPIC v7a is the seventh generation of PIC development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 8-bit PIC microcontrollers from Microchip and has a broad set of unique functions, such as the first-ever embedded debugger/programmer over USB-C. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyPIC v7a allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of the EasyPIC v7a development board
contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use various external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-
established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from PIC10F, PIC12F, PIC16F, PIC16Enh, PIC18F, PIC18FJ, and PIC18FK families. EasyPIC v7a is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC
MCU Memory (KB)
64
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
3648
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output
After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.
Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.
In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".
The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.
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