How does it work?
Compass 2 Click is based on the AK8963, a 3-axis electronic compass from AKM Semiconductor. This electronic compass includes an A/D converter for magnetometer data output in two selectable resolutions. The sensitivity for 14-bit resolution is typically 0.6μT/LSB, while for 16-bit, it is typically 0.15μT/LSB. Some other functions built into this electronic compass are a power-on reset circuit, data ready indicator, a magnetic sensor overflow monitor function, a self-test function for a built-in internal magnetic source, and very low power consumption.
The AK8963 has several operating modes. All internal circuits are turned off in Power-down mode while all registers are accessible (fuse ROM data cannot be read correctly). In Signal measurement mode, the sensor is measured, and data is processed. The Continuous measurement mode differs from the Single measurement because the sensor is measured periodically at 8Hz or 100Hz, after which the data is processed. The third measurement mode is an External trigger measurement that will start after the AK8963 gets a trigger input. To check if the sensor is working normally, AK8963 uses the Self-test mode. This test the AK8963 achieves by generating a magnetic field by its internal magnetic source, and then the sensor is measured. The last is the Fuse ROM access mode, which reads Fuse ROM data (sensitivity adjustment data for each axis).
This Click board™ allows using both I2C and SPI interfaces. Selection is made by positioning SMD jumpers marked SPI I2C to the appropriate position. All jumpers must be on the same side, or the Click board™ may become unresponsive. When the I2C interface is selected, the AK8963 allows the choice of its I2C address, using the ADDR SEL SMD jumper set to an appropriate position marked 1 or 0. In addition to the general reset function (RST pin), there is also the INT pin used as an interrupt signal to tell the host MCU about the status of the AK8963, and the TRG pin which serves as a trigger pin to make the AK8963 to enter the External Trigger measurement mode.
This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.
Specifications
Type
Compass,Magnetic
Applications
Can be used for the development of applications based on position detection, navigation and orientation for portable devices
On-board modules
AK8963 – 3-axis electronic compass from AKM Semiconductor
Key Features
Low power consumption, high sensitivity, selectable resolution, selectable interface, several operating modes, magnetic sensor overflow monitor function, and more
Interface
I2C,SPI
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
S (28.6 x 25.4 mm)
Input Voltage
3.3V
Pinout diagram
This table shows how the pinout on Compass 2 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-JP4 | SPI I2C | Right | Communication Interface Selection SPI/I2C: Left position SPI, Right position I2C |
JP5-JP6 | ADDR SEL | Right | I2C Address Selection 0/1: Left position 0, Right position 1 |
Compass 2 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | – | 3.3 | – | V |
Measurement Range | – | ±4900 | – | μT |
Sensitivity in 14-bit Resolution | – | 0.6 | – | μT/LSB |
Sensitivity in 16-bit Resolution | – | 0.15 | – | μT/LSB |
Software Support
We provide a library for the Compass 2 Click as well as a demo application (example), developed using MIKROE compilers. The demo can run on all the main MIKROE development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager (recommended), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Compass 2 Click driver.
Key functions
-
This function gets the data from one specified axis.
-
This function prepares the device for a new measurement.
-
This function does a hardware reset of the device.
Example Description
The example prepares the device for a new measurement and reads and displays data from all three axes.
void application_task ( )
{
int16_t x_axis;
int16_t y_axis;
int16_t z_axis;
compass2_new_measurement( &compass2 );
log_printf( &logger, " --- Axis ---rn" );
x_axis = compass2_get_axis_data( &compass2, COMPASS2_X_AXIS );
y_axis = compass2_get_axis_data( &compass2, COMPASS2_Y_AXIS );
z_axis = compass2_get_axis_data( &compass2, COMPASS2_Z_AXIS );
log_printf( &logger, "X: %drn", x_axis );
log_printf( &logger, "Y: %drn", y_axis );
log_printf( &logger, "Z: %drn", z_axis );
log_printf( &logger, "----------------rn" );
Delay_ms( 2000 );
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager (recommended), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Compass2
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 MIKROE compilers.
mikroSDK
This Click board™ is supported with mikroSDK – MIKROE 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.