FlexCase
IMU and Accelerometer Guide
- Read data from on-board 3-axis accelerometer, 3-axis gyroscope, and IMU temperature
- Configure sample time and resolution
- Customize for your application
Prerequisites
This is a more advanced guide intented for users integrating accelerometer data into an existing application. Please complete the following prerequisites to have the best experience with this guide:
- Complete the Quick-Start guide for a tutorial on connecting and flashing binaries
- Complete the Simulink guide for building a model into a flashable binary
- Complete the FreeMASTER guide for viewing MCU variables
Simulink Model
- Locate IMU_Accel.slx in the Simulink samples and open it. The main code area should look like the following picture.
- Based on your FlexCase version (1.2+ for full IMU or 1.1 for Accelerometer only), comment out the appropriate subsystems.
- Build the model and flash it to the FlexCase.
The IMU/Accelerometer communicates with the MCU over SPI. The first byte of the SPI message contains the relevant register address, the second byte contains commands or motion data, and any subsequent bytes contain additional motion data. For the IMU, two power-up commands are sent for the Accelerometer and Gyroscope.
FreeMASTER
If this is your first time using FreeMASTER, please see our guide on FreeMASTER basics before proceeding.
- Add the compiled .elf file to the FreeMASTER configuration as the symbol file
- Set up and establish a connection to the FlexCase
- Add data variables Ax, Ay, Az to the watch and to the oscilloscope
- If using an IMU, also add Wx, Wy, Wz, T_imu to the watch/oscilloscope
- Start the measurement
- Tilt the FlexCase to see the acceleration and rotational rate values change
If sitting on a flat surface, the FlexCase should read approximately +1G (9.81 m/s^2) in the Z direction. The start up sequence of the model sends a default sample rate and value range to the sensor before starting to poll inertial data.
Additional Information
When sending “read” commands to the accelerometer, the first bit of the address must be set to 1. For example, the Z-axis MSB address 0x2D must be changed to 0xAD to read the data.
When using “write” commands, the first bit should be set to 0. For example, when changing the update rate the addresses will remain unchanged. For example, send CTRL1_XL write with 0x10 to turn on the Accelerometer. The register mappings are different between the older and newer FlexCase versions. For example, the Accelerometer control register on the full IMU has the following format:
And the 3-axis unit uses the following format:
The IMU/Accelerometer is highly configurable. Using similar control commands, other features can be configured such as:
- Configure hardware filters
- Change the acceleration/rotational speed limits
- Configure capture mode
- Detect acceleration events (orientation change, free-fall, wake-up)
- Generate hardware interrupts
Please review IMU (1.2+) or the Accelerometer (1.1) datasheet for a full list of features and contact us if you have additional integration questions.