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)
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.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
Delay_100ms( );
}
#define C3DHALL_MAP_MIKROBUS(cfg, mikrobus)
Definition c3dhall.h:67
void c3dhall_cfg_setup(c3dhall_cfg_t *cfg)
Config Object Initialization function.
C3DHALL_RETVAL c3dhall_init(c3dhall_t *ctx, c3dhall_cfg_t *cfg)
Initialization function.
void application_init(void)
Definition main.c:38
Click configuration structure definition.
Definition c3dhall.h:128
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.
{
uint8_t angle_alpha;
uint8_t angle_beta;
Delay_100ms( );
{
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
{
log_printf( &logger, " ADC Failure \r\n" );
log_printf( &logger, " Electrical failure \r\n" );
log_printf( &logger, " Gain code is less \r\n" );
log_printf( &logger, " Gain code is greater \r\n" );
log_printf( &logger, " Fast norm below 30 \r\n" );
log_printf( &logger, " The norm is less \r\n" );
log_printf( &logger, " The norm is greater \r\n" );
log_printf( &logger, " Analog Chain Rough off \r\n" );
log_printf( &logger, " Angle ALPHA in deadzone \r\n" );
log_printf( &logger, " Angle BETA in deadzone \r\n" );
log_printf( &logger, " More than one error \r\n" );
else
log_printf( &logger, " Unknown error \r\n" );
log_printf( &logger, "-------------------------\r\n" );
Delay_1sec( );
}
}
#define C3DHALL_F_DEADZONEALPHA
Definition c3dhall.h:97
#define C3DHALL_F_ROCLAMP
Definition c3dhall.h:96
#define C3DHALL_F_ADCSATURA
Definition c3dhall.h:90
#define C3DHALL_F_FIELDTOOLOW
Definition c3dhall.h:94
#define C3DHALL_F_GAINTOOLOW
Definition c3dhall.h:91
#define C3DHALL_F_NORMTOOLOW
Definition c3dhall.h:93
#define C3DHALL_F_FIELDTOOHIGH
Definition c3dhall.h:95
#define C3DHALL_F_ADCMONITOR
Definition c3dhall.h:89
#define C3DHALL_F_DEADZONEBETA
Definition c3dhall.h:98
#define C3DHALL_F_GAINTOOHIGH
Definition c3dhall.h:92
#define C3DHALL_MULTIPLE_ERRORS
Definition c3dhall.h:99
#define C3DHALL_NO_ERRORS
Definition c3dhall.h:88
void c3dhall_read_all_data(c3dhall_t *ctx, c3dhall_all_data_t *all_data)
Read 8 bytes data from sensor function.
uint8_t c3dhall_calculate_angle(c3dhall_t *ctx, uint16_t data_angle)
Calculate angle function.
void application_task(void)
Definition main.c:63
All data structure definition.
Definition c3dhall.h:148
uint16_t data_error
Definition c3dhall.h:151
uint16_t data_angle_a
Definition c3dhall.h:149
uint16_t data_angle_b
Definition c3dhall.h:150
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.