How does it work?
Compass 5 Click is based on the AK09918C, a 3-axis electronic compass with high sensitive Hall sensor technology from AKM Semiconductor. This I2C configurable electronic compass incorporates magnetic sensors for detecting terrestrial magnetism in the X, Y, and Z-axis. It has built-in ADC with 16-bit output data for each 3-axis magnetic component, a built-in magnetic sensitivity adjustment circuit and overflow monitor function, and several operating modes with a typical sensitivity of 0.15µT/LSB. It also has the limitation for the measurement range that the sum of absolute values of each axis should be smaller than 4912 μT. When the magnetic field exceeded this limitation, data stored at measurement data are not correct, which is called Magnetic Sensor Overflow.
This Click board™ includes a low-noise LDO voltage regulator SPX3819 from MaxLinear to provide the 1.8V supply voltage for the AK09918C and possesses several operating modes: Power-Down, Single Measurement, Continuous Measurement, and Self-Test Mode. When power is turned ON, an AK09918C is in a Power-Down Mode. When a specified value is set in a MODE register, the AK09918C transits to the specified mode and starts operation. When a user wants to change Operation Mode, transit to Power-Down mode first and then transit to other Modes. After Power-Down Mode is set, a period of at least 100μs is needed before setting another Mode is possible.
Compass 5 Click communicates with MCU using the standard I2C 2-Wire interface with a frequency up to 100kHz in the Standard Mode, and up to 400kHz in the Fast Mode. Since the sensor is supplied with 1.8V logic voltage level only, also featured on this Click board™ is a PCA9306 voltage-level translator from Texas Instruments. The I2C interface bus lines are routed to the dual bidirectional voltage-level translator that allows this Click board™ to be interfaced with both 3.3V and 5V MCUs.
This Click board™ is designed to be operated with both 3.3V and 5V logic voltage levels that can be selected via VCC SEL jumper. This allows for both 3.3V and 5V capable MCUs to use the I2C communication lines properly. However, the Click board™ comes equipped with a library that contains easy to use functions and an example code that can be used as a reference for further development.
Specifications
Type
Compass,Magnetic
Applications
Can be used for map heading-up purposes to realize the pedestrian navigation function.
On-board modules
Compass 5 Click is based on the AK09918C, a 3-axis electronic compass with high sensitive Hall sensor technology from AKM Semiconductor.
Key Features
Built-in ADC with 16-bit output data for each 3-axis magnetic component, a built-in magnetic sensitivity adjustment circuit and overflow monitor function, and several operating modes with a typical sensitivity of 0.15µT/LSB, and more.
Interface
I2C
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
S (28.6 x 25.4 mm)
Input Voltage
3.3V or 5V
Pinout diagram
This table shows how the pinout on Compass 5 Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED Indicator |
JP1 | VCC SEL | Left | Power Supply Voltage Selection 3V3/5V: Left position 3V3, Right position 5V |
Compass 5 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | -0.3 | – | 6 | V |
Measurement Range | ±4670 | ±4912 | ±5160 | µT |
Sensitivity | 0.1425 | 0.15 | 0.1575 | µT/LSB |
Current Consumption | – | 1.1 | – | mA |
Operating Temperature Range | -30 | – | +85 | °C |
Software Support
We provide a library for the Compass 5 Click on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Library Description
The library contains a basic functions for using Compass 5 Click.
Key functions:
void compass5_get_id ( uint8_t *company_id, uint8_t *device_id );
– Function for get ID.uint8_t compass5_set_operation_mode ( uint8_t op_mode );
– Function for set operation mode.void compass5_get_mag_data ( int16_t *axis_x, int16_t *axis_y, int16_t *axis_z );
– Full measurement axis.
Examples description
The application is composed of three sections :
- System Initialization – Initializes I2C and start to write log.
- Application Initialization – Initialization driver enables – I2C, performed power down mode, sets continuous measurement mode and start measurement, also write log.
- Application Task – (code snippet) – This is an example which demonstrates the use of Compass 5 Click board™. Measured and display sensor Magnetic data for X-axis, Y-axis and Z-axis. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on USB uart changes for every 2 sec.
void application_task ( ) { int16_t x_val; int16_t y_val; int16_t z_val; if ( compass5_check_data_ready( ) == COMPASS5_DATA_READY ) { compass5_measurement_axis( &x_val, &y_val, &z_val ); Delay_ms( 10 ); FloatToStr( x_val, log_txt ); mikrobus_logWrite( " X-axis: ", _LOG_TEXT ); mikrobus_logWrite( log_txt, _LOG_TEXT ); mikrobus_logWrite( "mG", _LOG_LINE ); FloatToStr( y_val, log_txt ); mikrobus_logWrite( " Y-axis: ", _LOG_TEXT ); mikrobus_logWrite( log_txt, _LOG_TEXT ); mikrobus_logWrite( "mG", _LOG_LINE ); FloatToStr( z_val, log_txt ); mikrobus_logWrite( " Z-axis: ", _LOG_TEXT ); mikrobus_logWrite( log_txt, _LOG_TEXT ); mikrobus_logWrite( "mG", _LOG_LINE ); mikrobus_logWrite( "--------------------", _LOG_LINE ); } Delay_ms( 2000 ); }
The full application code, and ready to use projects can be found on our LibStock page.
Other mikroE Libraries used in the example:
- I2C Library
- UART Library
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.
mikroSDK
This Click board™ is supported with mikroSDK – MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant Click board™ demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
For more information about mikroSDK, visit the official page.