What was missing so far is a Processor Expert component for it. This post is about closing this gap…
The Freescale Xtrinsic MMA3110 is a 3-axis digital magnetometer (from the MAG3110 Datasheet):
- I2C Bus Interface up to 400 kHz
- 16bit X, Y and Z magnetometer values with 15bit user offset
- Full scale ±1000 µT and a sensitivity of 0.10 µT
- ‘Fast’ mode to read only 8bit values and auto-address-increment
- Multiple data rates and oversampling rates
- Polling or interrupts
- Temperature sensor (needs user calibration, see below)
The component has settings to connect to the I2C bus and to enable the optional interrupt pin:
Additionally, there is an optional command line shell interface.
The MAG3110 has a register to read out the temperature (DIE_TEMP, address 0x0F). What puzzled me was that I was always reading 0xff or 0x00 as temperature. According to the data sheet, it shall report the temperature in °C, but is not factory trimmed:
“The register contains the die temperature in °C expressed as an 8-bit 2’s complement number. The sensitivity of the temperature sensor is factory trimmed to 1°C/LSB. The temperature sensor offset is not factory trimmed and must be calibrated by the user software if higher absolute accuracy is required. Note: The register allows for temperature measurements from -128°C to 127°C
but the output range is limited to -40°C to 125°C. The temperature data is updated on every measurement cycle.” (Source: MAG3110 Data Sheet)
This offset can be added in the component properties.
The component has methods to access all functions and registers of the device:
I have put on GitHub here an application which demonstrates the usage of the component:
Make sure you load the latest Processor Expert components from GitHub too. See this post for details.
The application uses a shell interface to the MAG3110:
As the sensor is disabled by default, the command
turns it on.
it shows the status and settings of the device:
it writes the X, Y and Z magnetometer values to the console:
turns the trace off.
The example application has the I2CSPY component added. Using it I can dump the registers of the MAG3110:
With this MAG3110 component it makes it easy for me to use the Freescale MAG3110 magnetometer sensor. I expect that the MAG3110 component and demo application will evolve over time, but so far I’m really happy with the results. Freescale has an extra eCompass software package available which I have downloaded, but not really used yet. So still more stuff to explore ;-).
Happy Compassing 🙂