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

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.

UART Application Output Step 1

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.

UART Application Output Step 2

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".

UART Application Output Step 3

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.

UART Application Output Step 4

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