How does it work?
Compass 4 Click is based on the AK09915, a complete 3-axis magnetic sensor with signal processing from AKM. The AK09915 incorporates magnetic sensors for detecting terrestrial magnetism in the X-axis, Y-axis, and Z-axis, a sensor driving circuit, signal amplifier chain, and an arithmetic circuit for processing the signal from each sensor. The output signal of each axis sensor is multiplexed, pre-amplified processed, and digitized by a 16-bit A/D converter (ADC). A three-axis magnetometer can be programmed to measure the magnetic component for each axis, within the full-scale range of ±4912 μT and sensitivity of 0.15 µT per LSB.
The AK09915 has an analog circuit, digital logic, and interface block integrated on a chip. It also supports nine different Operation Modes that can be chosen by setting the appropriate registers. When the Single Measurement Mode is set, the magnetic sensor measurement starts. After magnetic sensor measurement and signal processing is finished, measured magnetic data is stored in measurement data registers, and then the AK09915 transits to Power-Down Mode automatically. On transition to Power-Down Mode, Data Ready (DRDY) bit turns to “1”. When any of the measurement data registers are read, the DRDY bit turns to “0”. It remains “1” on the transition from Power-Down Mode to another Mode. Data Ready output pin of the AK09915 labeled as the DRY is routed to the INT pin of the mikroBUS™ socket. Besides Data Ready pin, this Click board™ also has the Reset pin (RST), routed to the appropriate position on the mikroBUS™.
Compass 4 Click provides the possibility of using both I2C and SPI interfaces with a maximum frequency of 2.5MHz for I2C and 4MHz for SPI communication. The selection can be performed by positioning SMD jumpers labeled as COMM SEL to an appropriate position. Note that all the jumpers must be placed to the same side, or else the Click board™ may become unresponsive. While the I2C interface is selected, the AK09915 allows the choice of the last two significant bits (LSB) of its I2C slave address. This can be done by using the SMD jumper labeled as ADDR SEL. Depending on the positions of each of the ADDR SEL jumpers, four different addresses can be set.
This Click Board™ is designed to be operated only with a 3.3V logic level. A proper logic voltage level conversion should be performed before the Click board™ is used with MCUs with different logic levels.
Specifications
Type
Compass,Magnetic
Applications
Suitable for applications such as electrical compass, position sensing, general magnetic field measurement and more.
On-board modules
Compass 4 Click is based on the AK09915, a complete 3-axis magnetic sensor with signal processing from AKM
Key Features
Full scale range of ±4912 μT, sensitivity of 0.15 µT per LSB, resolution at 16bits, Noise Suppression Filter (NSF)
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 4 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 | COMM SEL | Left | Communication Interface Selection: Left position SPI, Right position I2C |
JP5-JP6 | ADDR SEL | Left | I2C Address Selection: Left position 0, Right position 1 |
Compass 4 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | -0.3 | 3.3 | 3.6 | V |
Sensitivity | – | 0.15 | – | µT/LSB |
Full scale measurement range | – | ±4912 | – | μT |
Resolution | – | 16 | – | bit |
Operating Temperature Range | -30 | – | +85 | °C |
Software Support
We provide a library for the Compass 4 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 4 click.
Key functions:
void compass4_configuration ( uint8_t cfg1, uint8_t cfg2 )
– Configuration functionuint8_t compass4_get_axis ( compass4_axis_t *axis )
– Gets XYZ Axis valueuint8_t compass4_get_magnetic_flux ( compass4_flux_t *flux )
– Gets magnetic flux of XYZ axis value
Examples description
The application is composed of three sections :
- System Initialization – Initializes I2C or SPI module and all necessary GPIO pins
- Application Initialization – Initializes driver inti, reset module, configuration module for measurement and cheeks communication with the module.
- Application Task – Reads magnetic flux or x, y, z-axis, and logs data to USB UART every 1 second.
- Note – SPI communication only works when the jumpers for the slave address are at GND.
void application_task ( ) { compass4_flux_t flux; char demo_text[ 20 ]; uint8_t err; err = compass4_get_magnetic_flux( &flux ); if ( err != 0 ) { mikrobus_logWrite( ">> Measurement error ", _LOG_LINE ); } else { mikrobus_logWrite( ">> Magnetic flux data <<", _LOG_LINE ); FloatToStr( flux.x, demo_text ); mikrobus_logWrite( ">> X: ", _LOG_TEXT ); mikrobus_logWrite( demo_text, _LOG_LINE ); FloatToStr( flux.y, demo_text ); mikrobus_logWrite( ">> Y: ", _LOG_TEXT ); mikrobus_logWrite( demo_text, _LOG_LINE ); FloatToStr( flux.z, demo_text ); mikrobus_logWrite( ">> Z: ", _LOG_TEXT ); mikrobus_logWrite( demo_text, _LOG_LINE ); } mikrobus_logWrite( ">>____________________<<", _LOG_LINE ); Delay_ms( 1000 ); }
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
- SPI Library
- Conversions 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.