Find the magnet's absolute angular position
A
A
Hardware Overview
How does it work?
Angle 7 Click is based on the AS5600, an easy-to-program magnetic rotary position sensor with a high-resolution 12-bit analog or PWM output from ams AG. The AS5600 is a Hall-based rotary magnetic position sensor using planar sensors that convert the magnetic field component perpendicular to the surface of the chip into a voltage. It measures the absolute angle of a diametric-magnetized on-axis magnet while at the same time rejecting stray magnetic fields. By default, the output represents a range from 18 to 360 degrees. It is also possible to define a smaller range to the output by programming a zero angle (start position) and a maximum angle (stop position). First, the signals coming from internal Hall sensors are amplified and filtered before their conversion by the ADC and then processed by the hardwired CORDIC block to compute the angle and magnitude of the magnetic field vector. The intensity of the magnetic field is used by the
automatic gain control (AGC) to adjust the amplification level to compensate for temperature and magnetic field variations. After that, the output stage uses the angle value provided by the CORDIC algorithm. The user can choose between an analog output representing the angle as a ratiometric linear absolute value and a digital PWM-encoded output representing the angle as the pulse width. The selection can be made by positioning the SMD jumper labeled OUT SEL in an appropriate position marked as AN or INT. Angle 7 Click communicates with MCU using the standard I2C 2-Wire interface with a maximum clock frequency of 1MHz, fully adjustable through software registers. Also, the DIR SEL jumper allows users to select the polarity of the output relative to rotation direction by positioning the SMD jumper in an appropriate position marked as CW or CCW allowing clockwise or counterclockwise rotation. A unique addition to this board
is a position for a Rotary Magnet Holder designed to be used alongside a magnetic rotary position sensor allowing fast prototyping and quick measurements during development. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Both mikroBUS™ power rails have protection in the form of diode MAX40200, controllable through an EN pin on the mikroBUS™ socket to prevent any unwanted back voltage. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development. In the case of using a logic level of 5V, it is necessary first to remove the resistor R6 and then switch the VCC jumper to the 5V position.

Features overview
Development board
PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive
mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI
GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
48
RAM (Bytes)
8196
You complete me!
Accessories
Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.
Rotary Magnetic Holder is an addition designed for use alongside a magnetic rotary position sensor. It comes with a plastic stand measuring 22x16x10 millimeters (L x W x H), as well as an adjustable shaft with a 6mm diameter magnet. The plastic frame has four round feet that fit into holes in the board near the magnetic rotary position sensor, with a 6mm diameter hole on top to match the adjustable shaft that carries the magnet. This shaft has a height adjustment screw on it, allowing the user to adjust it between 18 and 22 millimeters. This way, fast prototyping and quick measurements of the magnet characteristics are allowed during development.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for Angle 7 Click driver.
Key functions:
angle7_get_status
This function reads the status data.angle7_get_angle
This function reads the calculated angle in degrees.angle7_get_magnitude
This function reads the magnitude data.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief Angle7 Click 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.
*
* ## 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.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "angle7.h"
static angle7_t angle7;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
angle7_cfg_t angle7_cfg; /**< Click config object. */
/**
* 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.
angle7_cfg_setup( &angle7_cfg );
ANGLE7_MAP_MIKROBUS( angle7_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == angle7_init( &angle7, &angle7_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ANGLE7_ERROR == angle7_default_cfg ( &angle7 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
float voltage, raw_angle, angle;
uint16_t magnitude;
uint8_t status;
if ( ADC_ERROR != angle7_read_an_pin_voltage ( &angle7, &voltage ) )
{
log_printf( &logger, " AN voltage: %.3f V\r\n", voltage );
}
if ( ANGLE7_OK == angle7_get_angle ( &angle7, &angle ) )
{
log_printf ( &logger, " Angle: %.2f Degrees\r\n", angle );
}
if ( ANGLE7_OK == angle7_get_magnitude ( &angle7, &magnitude ) )
{
log_printf ( &logger, " Magnitude: %u\r\n", magnitude );
}
if ( ANGLE7_OK == angle7_get_status ( &angle7, &status ) )
{
log_printf ( &logger, " Status:" );
if ( status & ANGLE7_STATUS_MAGNET_DETECTED )
{
log_printf ( &logger, " Magnet Detected \r\n Magnet Strength:" );
if ( status & ANGLE7_STATUS_MAGNET_TOO_STRONG )
{
log_printf ( &logger, " Too Strong \r\n\n" );
}
else if ( status & ANGLE7_STATUS_MAGNET_TOO_WEAK )
{
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 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
Additional Support
Resources
Category:Magnetic