magneticrotary2 2.0.0.0
Main Page

Magnetic Rotary 2 click

‍Magnetic Rotary 2 Click is a compact add-on board used for accurate magnet-position sensing. This board features the AEAT-9922, an angular magnetic rotary sensor providing accurate angular measurement over a full 360 degrees of rotation from Broadcom Limited. The AEAT-9922 uses integrated Hall sensor elements with complex analog and digital signal processing within a single device. The absolute angle measurement provides an instant indication of the magnet's angular position with a selectable and one-time programmable resolution from 10 to 18 bits.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Oct 2021.
  • Type : SPI type

Software Support

We provide a library for the MagneticRotary2 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 from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for MagneticRotary2 Click driver.

Standard key functions :

Example key functions :

Example Description

‍This example demonstrates the use of Magnetic Rotary 2 click board by reading and displaying the magnet's angular position in degrees.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
magneticrotary2_cfg_t magneticrotary2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
magneticrotary2_cfg_setup( &magneticrotary2_cfg );
MAGNETICROTARY2_MAP_MIKROBUS( magneticrotary2_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == magneticrotary2_init( &magneticrotary2, &magneticrotary2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( MAGNETICROTARY2_ERROR == magneticrotary2_default_cfg ( &magneticrotary2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define MAGNETICROTARY2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition magneticrotary2.h:202
@ MAGNETICROTARY2_ERROR
Definition magneticrotary2.h:255
void application_init(void)
Definition main.c:28

Application Task

‍Reads the magnet's angular position in degrees every 100ms and displays the results on the USB UART.

void application_task ( void )
{
float angle = 0;
if ( MAGNETICROTARY2_OK == magneticrotary2_get_angle ( &magneticrotary2, &angle ) )
{
log_printf( &logger, " Angle: %.2f degrees\r\n\n", angle );
Delay_ms ( 100 );
}
}
@ MAGNETICROTARY2_OK
Definition magneticrotary2.h:254
void application_task(void)
Definition main.c:63

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.MagneticRotary2

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.