Intermediate
30 min

Immerse yourself in a world of seamless control with IQS525 and PIC32MZ2048EFH100

Swipe, Tap, Excel

Touchpad 2 Click with Flip&Click PIC32MZ

Published Aug 09, 2023

Click board™

Touchpad 2 Click

Dev Board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Navigate through tasks effortlessly with a touchpad that merges sensitivity and responsiveness, seamlessly harmonized with the processing prowess of a dedicated microcontroller

A

A

Hardware Overview

How does it work?

Touchpad 2 Click is based on the IQS525, a capacitive sensing controller designed for multitouch applications using a projected capacitance touch panel from Azoteq. It offers high-sensitivity proximity/hover detection and contact (touch) detection. The device has an internal voltage regulator and Internal Capacitor Implementation (ICI) to reduce external components, which can be noticed on the Click board™ (very few additional components are required by this IC). Advanced integrated signal processing capabilities yield a stable, high-performance capacitive controller with high sensitivity. On the front side of the Touchpad 2 Click, 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. An electrode consists of multiple diamond-shaped

elements, each connected to the next with a conductive neck. The controller uses the projected capacitance charge transfer principle on the touchpad area. When a conductive object such as a human finger approaches the sense plate, the detected capacitance will decrease. Observing the measured results at various sensing points on the touchpad area enables the controller to determine proximity/hover detection and contact (touch) detection on all channels and accurately determine the coordinates on the touch area. Due to the advanced sensitivity of the IQS525, multiple non-contact (proximity hover) coordinates also can be obtained. These hover coordinates can predict the touch coordinate of an approaching user before the touch is made, allowing innovative user interface options. Multiple filters are implemented to suppress, detect noise, and track slow varying environmental conditions and avoid the effects

of possible drift. Touchpad 2 Click communicates with MCU using a standard I2C 2-Wire interface, with a clock frequency of up to 100kHz in the Standard and 400kHz in the Fast Mode. An additional ready signal, routed on the INT pin of the mikroBUS™ socket, is added, which indicates when the communication window is available. Thus, it is optimal for the response rate to use the INT pin as a communication trigger, but polling is also a less attractive option. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before use with 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.

Touchpad 2 Click top side image
Touchpad 2 Click bottom side image

Features overview

Development board

Flip&Click PIC32MZ is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,

it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication

methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Flip&Click PIC32MZ double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
RD9
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RA2
SCL
I2C Data
RA3
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Touchpad 2 Click Schematic schematic

Step by step

Project assembly

Flip&Click PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Flip&Click PIC32MZ as your development board.

Flip&Click PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
Flip&Click PIC32MZ MB1 Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Flip&Click PIC32MZ MCU step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.

Software Support

Library Description

This library contains API for Touchpad 2 Click driver.

Key functions:

  • touchpad2_check_version - TouchPad 2 check version function

  • touchpad2_get_touch - TouchPad 2 get touch function.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief TouchPad2 Click example
 *
 * # Description
 * This library contains API for the TouchPad 2 Click driver.
 * The library contains drivers to get touch details,
 * the number of touches, X and Y coordinates and touch strength. 
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes I2C driver, check communication and reads device version information.
 *
 * ## Application Task
 * This is an example that demonstrates the use of the TouchPad 2 Click board. 
 * Read XY data consisting of a status byte, the number of touches,
 * X and Y coordinates and touch strength data. 
 * Results are being sent to the Usart Terminal where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "touchpad2.h"

static touchpad2_t touchpad2;
static log_t logger;
touchpad2_ver_info_t ver_info;
touchpad2_touch_t touch_data;

void application_init ( void ) {
    log_cfg_t log_cfg;              /**< Logger config object. */
    touchpad2_cfg_t touchpad2_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.

    touchpad2_cfg_setup( &touchpad2_cfg );
    TOUCHPAD2_MAP_MIKROBUS( touchpad2_cfg, MIKROBUS_1 );
    err_t init_flag = touchpad2_init( &touchpad2, &touchpad2_cfg );
    if ( init_flag == I2C_MASTER_ERROR ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    touchpad2_default_cfg ( &touchpad2 );
    log_info( &logger, " Application Task " );
    Delay_ms( 1000 );
    
    touchpad2_check_version( &touchpad2, &ver_info );
    Delay_ms( 100 );
    
    if ( ver_info.product_num != TOUCHPAD2_IQS525_PRODUCT_NUMBER ) {
        log_error( &logger, " Communication Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    
    log_printf( &logger, "------------------------\r\n" );
    log_printf( &logger, " Product number : %u \r\n", ver_info.product_num );
    log_printf( &logger, " Project number : %u \r\n", ver_info.projec_num );
    log_printf( &logger, " Version        : %.1f \r\n", ver_info.version );
    log_printf( &logger, " HW ID          : %u \r\n", ver_info.hw_id );
    log_printf( &logger, " HW Revision    : %u \r\n", ver_info.hw_revision );
    log_printf( &logger, "------------------------\r\n" );
    Delay_ms( 1000 );
    
    log_printf( &logger, " Waiting for a new touch\r\n" );
    log_printf( &logger, "------------------------\r\n" );
    Delay_ms( 100 );
}

void application_task ( void ) {
   
    touchpad2_wait_ready( &touchpad2 );
    
    touchpad2_get_touch ( &touchpad2, &touch_data );
    Delay_ms( 100 );
    
    if ( ( touch_data.id_tag == TOUCHPAD2_ID_TAG_TOUCH_1 ) || 
         ( touch_data.id_tag == TOUCHPAD2_ID_TAG_TOUCH_2 ) ||
         ( touch_data.id_tag == TOUCHPAD2_ID_TAG_TOUCH_3 ) ||
         ( touch_data.id_tag == TOUCHPAD2_ID_TAG_TOUCH_4 ) ||
         ( touch_data.id_tag == TOUCHPAD2_ID_TAG_TOUCH_5 ) ) {
        log_printf( &logger, "  Number of touches : %d \r\n", ( uint16_t ) touch_data.no_of_fingers );
        log_printf( &logger, "- - - - - - - - - - - - -\r\n" );
        log_printf( &logger, "  Coordinate X = %d \r\n", touch_data.x_pos );
        log_printf( &logger, "  Coordinate Y = %d \r\n", touch_data.y_pos );
        log_printf( &logger, "- - - - - - - - - - - - -\r\n" );
        log_printf( &logger, "  Touch Strength   : %u  \r\n", ( uint16_t ) touch_data.touch_str );
        log_printf( &logger, "------------------------ \r\n" );
        Delay_ms( 500 );    
    }
}

void main ( void ) {
    application_init( );

    for ( ; ; ) {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.