Angle 7 click
Angle 7 Click is a compact add-on board that detects the absolute angular position of a permanent magnet. This board features the AS5600, a programmable Hall-based rotary magnetic position sensor with a high-resolution 12-bit analog or PWM output from ams AG.
click Product page
Click library
- Author : Stefan Filipovic
- Date : May 2022.
- Type : I2C type
Software Support
We provide a library for the Angle 7 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 Angle 7 Click driver.
Standard key functions :
angle7_cfg_setup
Config Object Initialization function.
void angle7_cfg_setup(angle7_cfg_t *cfg)
Angle 7 configuration object setup function.
Angle 7 Click configuration object.
Definition angle7.h:231
angle7_init
Initialization function.
err_t angle7_init(angle7_t *ctx, angle7_cfg_t *cfg)
Angle 7 initialization function.
Angle 7 Click context object.
Definition angle7.h:207
angle7_default_cfg
Click Default Configuration function.
err_t angle7_default_cfg(angle7_t *ctx)
Angle 7 default configuration function.
Example key functions :
angle7_get_status
This function reads the status data.
err_t angle7_get_status(angle7_t *ctx, uint8_t *status)
Angle 7 get status function.
angle7_get_angle
This function reads the calculated angle in degrees.
err_t angle7_get_angle(angle7_t *ctx, float *angle)
Angle 7 get angle function.
angle7_get_magnitude
This function reads the magnitude data.
err_t angle7_get_magnitude(angle7_t *ctx, uint16_t *magnitude)
Angle 7 get magnitude function.
Example Description
This example demonstrates the use of Angle 7 click board by reading and displaying
the magnet's angular position in degrees and analog voltage output as well as the magnet's status and magnitude.
The demo application is composed of two sections :
Application Init
Initializes the driver and performs the click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
angle7_init( &angle7, &angle7_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ ANGLE7_ERROR
Definition angle7.h:254
#define ANGLE7_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition angle7.h:192
void application_init(void)
Definition main.c:31
Application Task
Reads the magnet's angular position in degrees and analog voltage output
as well as the magnet's status and magnitude and displays the results on the USB UART approximately every 100ms.
{
float voltage, raw_angle, angle;
uint16_t magnitude;
uint8_t status;
{
log_printf( &logger, " AN voltage: %.3f V\r\n", voltage );
}
{
log_printf ( &logger, " Angle: %.2f Degrees\r\n", angle );
}
{
log_printf ( &logger, " Magnitude: %u\r\n", magnitude );
}
{
log_printf ( &logger, " Status:" );
{
log_printf ( &logger, " Magnet Detected \r\n Magnet Strength:" );
{
log_printf ( &logger, " Too Strong \r\n\n" );
}
{
log_printf ( &logger, " Too Weak \r\n\n" );
}
else
{
log_printf ( &logger, " Good \r\n\n" );
}
}
else
{
log_printf ( &logger, " Magnet Not Detected \r\n\n" );
}
}
Delay_ms ( 100 );
}
@ ANGLE7_OK
Definition angle7.h:253
#define ANGLE7_STATUS_MAGNET_TOO_STRONG
Definition angle7.h:152
#define ANGLE7_STATUS_MAGNET_TOO_WEAK
Definition angle7.h:151
#define ANGLE7_STATUS_MAGNET_DETECTED
Angle 7 STATUS register settings.
Definition angle7.h:150
err_t angle7_read_an_pin_voltage(angle7_t *ctx, float *data_out)
Angle 7 read AN pin voltage level function.
void application_task(void)
Definition main.c:67
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.Angle7
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. UART terminal is available in all MikroElektronika compilers.