Intermediate
30 min

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

Swipe, Tap, Excel

Touchpad 2 Click with EasyPIC v8

Published Aug 09, 2023

Click board™

Touchpad 2 Click

Dev. board

EasyPIC v8

Compiler

NECTO Studio

MCU

PIC18F47K40

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

EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the EasyPIC v8 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 a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 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.

EasyPIC v8 horizontal image

Microcontroller Overview

MCU Card / MCU

PIC18F47K40

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

3728

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
RB0
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RC3
SCL
I2C Data
RC4
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

EasyPIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyPIC v8 as your development board.

EasyPIC v8 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 40 hardware assembly
EasyPIC v8 DIP MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

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.