Intermediate
30 min

Transform magnetic fields into valuable 3D insights with TLI493D-W2BW and PIC24FV32KA302

Your precision partner in magnetic sensing

3D Hall 8 Click with EasyPIC v8 for PIC24/dsPIC33

Published Sep 27, 2023

Click board™

3D Hall 8 Click

Dev Board

EasyPIC v8 for PIC24/dsPIC33

Compiler

NECTO Studio

MCU

PIC24FV32KA302

Unlock the full potential of 3D magnetic sensing with our cutting-edge technology, revolutionizing industries and enhancing everyday lifestyles

A

A

Hardware Overview

How does it work?

3D Hall 8 Click is based on the TLI493D-W2BW, a low-power 3D Hall sensor with an I2C interface and a Wake-Up feature from Infineon. It consists of three central functional units containing the power mode control system, a low-power oscillator, basic biasing, undervoltage detection, and a fast oscillator. Besides, it has also implemented the sensing unit, which contains the HALL biasing, HALL probes with multiplexers and successive tracking ADC, and a temperature sensor. This sensor offers several use cases, including innovative human-machine interfaces in the form of industrial and consumer joysticks and precise position control in robotics. The power mode control provides the power distribution, which manages the Start-Up behavior in the TLI493D-W2BW, a power-on reset function, and a specialized low-power oscillator, the clock source.

The sensing unit measures the magnetic field in the X, Y, and Z directions. Each X-, Y-, and Z-Hall probe is connected sequentially to a multiplexer, connected to an analog-to-digital converter. Optional, the temperature measurement feature, activated in the default state, can be determined after the three Hall channels. 3D Hall 8 Click communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings, supporting Fast Mode operation with a clock frequency up to 1MHz. The Wake-Up function has an upper and lower comparison threshold for each of the three magnetic channels (X/Y/Z). Each component of the applied field is compared to the lower and upper thresholds. If one of the results is above or below these thresholds, an interrupt is generated called a Wake-Up function. The Wake-Up mode allows the

sensor to continue making magnetic field measurements while the MCU is in the power-down state, which means the microcontroller will only consume power and access the sensor if relevant measurement data is available. An interrupt pin signals a finished measurement cycle but can also be used for I2C clock stretching. In this case, the INT pin must be connected to the SCL pin, which can be done by populating the jumper labeled JP1. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

3D Hall 8 Click top side image
3D Hall 8 Click bottom side image

Features overview

Development board

EasyPIC v8 for PIC24/dsPIC33 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit PIC24/dsPIC33 microcontrollers from Microchip and has 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 for PIC24/dsPIC33 provides a fluid and immersive working experience, allowing access anywhere and under any circumstances. Each part of the EasyPIC

v8 for PIC24/dsPIC33 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 HOST/DEVICE, USB-UART, CAN, and LIN 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 16-bit PIC24/dsPIC33 MCUs, from the smallest PIC24/dsPIC33 MCUs with only 14 up to 28 pins. EasyPIC v8 for PIC24/dsPIC33 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 for PIC24/dsPIC33 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

dsPIC

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

2048

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
RB7
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RB6
SCL
I2C Data
RB5
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

3D Hall 8 Click Schematic schematic

Step by step

Project assembly

EasyPIC v8 for PIC24/dsPIC33 front image hardware assembly

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

EasyPIC v8 for PIC24/dsPIC33 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 28 hardware assembly
EasyPIC PIC24/dsPIC33 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 via UART Mode

1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.

2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.

3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.

4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART_Application_Output

Software Support

Library Description

This library contains API for 3D Hall 8 Click driver.

Key functions:

  • c3dhall8_generic_write - 3D Hall 8 I2C writing function

  • c3dhall8_read_sensor_data - Reading sensor data function

  • c3dhall8_get_xyz_magnetic_matching - Calculating magnetic matching

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 3DHall8 Click example
 *
 * # Description
 * This application shows capability of 3D Hall 8 Click board. 
 * It configures device and reads sensor data. Sensor is capeable 
 * of reading magnetic flux density from 3 axes and temperature.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialization of device communication and application log 
 * and configures device.
 *
 * ## Application Task
 * Reads data from the device and logs it in span of 500ms.
 *
 * @author Luka Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "c3dhall8.h"

static c3dhall8_t c3dhall8;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    c3dhall8_cfg_t c3dhall8_cfg;  /**< Click config object. */
    uint8_t rx_data;

    /** 
     * 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.

    c3dhall8_cfg_setup( &c3dhall8_cfg );
    C3DHALL8_MAP_MIKROBUS( c3dhall8_cfg, MIKROBUS_1 );
    err_t init_flag = c3dhall8_init( &c3dhall8, &c3dhall8_cfg );
    if ( init_flag == I2C_MASTER_ERROR ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    
    log_printf( &logger," > Setting configuration...\r\n" );
    c3dhall8_default_cfg ( &c3dhall8 ); 

    log_info( &logger, " Application Task " );
    log_printf( &logger, "**************************************\r\n" );
    Delay_ms( 1000 );
}

void application_task ( void ) 
{
    c3dhall8_data_t sens_data;
    c3dhall8_read_sensor_data( &c3dhall8, &sens_data );
    
    log_printf( &logger, "> X[mT]: %.2f\r\n> Y[mT]: %.2f\r\n> Z[mT]: %.2f \r\n> Temperature[C]: %.2f\r\n", 
                sens_data.x_axis, sens_data.y_axis, sens_data.z_axis, sens_data.temperature );
    float magnetic_match = c3dhall8_get_xyz_magnetic_matching( &c3dhall8, sens_data );
    log_printf( &logger, "> XYZ magnetic matching: %.2f\r\n", magnetic_match );
    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.