TOP Contributors

  1. MIKROE (2657 codes)
  2. Alcides Ramos (354 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136900 times)
  2. FAT32 Library (70034 times)
  3. Network Ethernet Library (56005 times)
  4. USB Device Library (46308 times)
  5. Network WiFi Library (41934 times)
  6. FT800 Library (41232 times)
  7. GSM click (29022 times)
  8. PID Library (26434 times)
  9. mikroSDK (26401 times)
  10. microSD click (25387 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

3D Hall click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.15

mikroSDK Library: 2.0.0.0

Category: Magnetic

Downloaded: 110 times

Not followed.

License: MIT license  

This application use to determine angle position

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "3D Hall click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "3D Hall click" changes.

Do you want to report abuse regarding "3D Hall click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


3D Hall click

3D Hall click carries the MLX90333 Triaxis Hall sensor, capable of detecting the position of any magnet in nearby space. It does so by being sensitive to three components of flux density (BX, BY, BZ)

3dhall_click.png

click Product page


Click library

  • Author : MikroE Team
  • Date : Feb 2020.
  • Type : SPI type

Software Support

We provide a library for the c3DHall Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for c3DHall Click driver.

Standard key functions :

  • Config Object Initialization function.

    void c3dhall_cfg_setup ( c3dhall_cfg_t *cfg );

  • Initialization function.

    C3DHALL_RETVAL c3dhall_init ( c3dhall_t ctx, c3dhall_cfg_t cfg );

Example key functions :

  • Read 8 bytes data from sensor function.

    void c3dhall_read_all_data ( c3dhall_t ctx, c3dhall_all_data_t all_data );

  • Calculate angle function.

    uint8_t c3dhall_calculate_angle ( c3dhall_t *ctx, uint16_t data_angle );

Examples Description

This application use to determine angle position.

The demo application is composed of two sections :

Application Init

Initialization driver enable's - SPI and start write log.


void application_init ( void )
{
    log_cfg_t log_cfg;
    c3dhall_cfg_t cfg;
    /** 
     * 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.

    c3dhall_cfg_setup( &cfg );
    C3DHALL_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    c3dhall_init( &c3dhall, &cfg );
    Delay_100ms( );
}

Application Task

This is a example which demonstrates the use of 3D Hall Click board. 3D Hall Click communicates with register via SPI by read data from register and calculate Alpha and Beta angle position. Results are being sent to the Usart Terminal where you can track their changes. All data logs on usb uart.


void application_task ( void )
{
    c3dhall_all_data_t all_data;

    uint8_t angle_alpha;
    uint8_t angle_beta;

    c3dhall_read_all_data( &c3dhall, &all_data );
    Delay_100ms( );

    if ( ( all_data.data_error ) == C3DHALL_NO_ERRORS )
    {
        angle_alpha = c3dhall_calculate_angle( &c3dhall, all_data.data_angle_a );
        angle_beta = c3dhall_calculate_angle( &c3dhall, all_data.data_angle_b );

        log_printf( &logger, "     Alpha : %u\r\n", ( uint16_t ) angle_alpha );

        log_printf( &logger, "     Beta  : %u\r\n", ( uint16_t ) angle_beta );

        log_printf( &logger, "-------------------------\r\n", angle_beta );
    }
    else
    {
        if ( all_data.data_error == C3DHALL_F_ADCMONITOR )
            log_printf( &logger, "       ADC Failure       \r\n" );
        else if ( all_data.data_error == C3DHALL_F_ADCSATURA )
            log_printf( &logger, "    Electrical failure   \r\n"  );
        else if ( all_data.data_error == C3DHALL_F_GAINTOOLOW )
            log_printf( &logger, "    Gain code is less    \r\n" );
        else if ( all_data.data_error == C3DHALL_F_GAINTOOHIGH )
            log_printf( &logger, "   Gain code is greater  \r\n" );
        else if ( all_data.data_error == C3DHALL_F_NORMTOOLOW )
            log_printf( &logger, "   Fast norm below 30   \r\n" );
        else if ( all_data.data_error == C3DHALL_F_FIELDTOOLOW )
            log_printf( &logger, "     The norm is less    \r\n" );
        else if ( all_data.data_error == C3DHALL_F_FIELDTOOHIGH )
            log_printf( &logger, "   The norm is greater   \r\n" );
        else if ( all_data.data_error == C3DHALL_F_ROCLAMP )
            log_printf( &logger, "  Analog Chain Rough off \r\n" );
        else if ( all_data.data_error == C3DHALL_F_DEADZONEALPHA )
            log_printf( &logger, " Angle ALPHA in deadzone \r\n" );
        else if ( all_data.data_error == C3DHALL_F_DEADZONEBETA )
            log_printf( &logger, "  Angle BETA in deadzone \r\n" );
        else if ( all_data.data_error == C3DHALL_MULTIPLE_ERRORS )
            log_printf( &logger, "   More than one error   \r\n" );
        else
            log_printf( &logger, "      Unknown error      \r\n" );

        log_printf( &logger, "-------------------------\r\n" );
        Delay_1sec( );
    }
}  

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.3DHall

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


ALSO FROM THIS AUTHOR

eFuse 2 click

0

eFuse 2 Click is a compact add-on board that contains an integrated FET hot-swap device. This board features the TPS259631, a highly integrated circuit protection and power management solution from Texas Instruments. It provides multiple protection modes against overloads, short circuits, voltage surges, and excessive inrush current.

[Learn More]

4G LTE-NA click

0

4G LTE click is an LTE Cat 1 multimode cellular network solution, featuring the compact LARA-R2 series modem from u-blox. This module supports up two LTE bands. It also features a full range of options for the high speed cellular networking and communication, such as the network indication, full embedded TCP/UDP stack, HTTP and HTTPS transfer protocols, IPv4/IPv6 dual-stack support, secondary antenna for the RX diversity, antenna detection, jamming signal detection, embedded TLS 1.2 protocol for the improved security and more. 4G LARA click can achieve data rates up to 10.3 Mbps/5.2 Mbps (downlink/uplink).

[Learn More]

8x8 R click

0

8x8 R click is a 64 LED matrix display Click board™, composed of SMD LEDs organized in 8 rows by 8 columns. It has a digital brightness control in 16 steps, it can control every LED in the display matrix independently, it blanks the display on power up to eliminate glitches and it requires a single resistor to control the current through all the LEDs at once, which simplifies the design. 8x8 R click uses a fast SPI communication protocol, allowing fast display response and no lag.8x8 R Click is an add-on board in mikroBUS form factor.

[Learn More]