# Using Neblina as an Accurate Inclinometerby Omid Sarbishei, Ph.D.

Posted on July 12, 2017 at 3:06 pm3:06 pm

Accelerometers have been used to detect inclination (tilt) angle for decades. When the sensor is stationary, the accelerometer reading will directly represent the gravity vector in the sensor’s frame of reference. Comparing the gravity vector in the sensor frame, i.e., $$\hat{G}$$, with the reference gravity vector in the earth frame, i.e., $$G$$, (which always points toward the center of the earth), we can calculate the inclination angle between the two vectors $$\hat{G}$$ and $$G$$. For a 2-axis accelerometer the inclination angle is computed as follows:

$$Angle = atan2(a_y,a_x)$$

Accelerometers typically require a fine calibration mechanism to account for cross-axis sensitivity, mechanical deformation, soldering effects, temperature variation, etc. Even though most manufacturers conduct careful calibration procedures for accelerometers at factory, the aforementioned effects can particularly compromise the accuracy of these sensors, when they are integrated with bigger systems and soldered on Printed Circuit Boards (PCB). Under such conditions, if accelerometers are not accompanied by a careful re-calibration procedure, the delivered inclination (tilt) angles might have major errors exceeding 2-4 degrees.

Neblina™ is Motsai’s in-house motion tracking system-on-module, which integrates accelerometers with several other components:

Neblina is equipped with re-calibration features for accelerometers, in order to reach high accuracy in delivering the inclination angle. Two calibration procedures are available on Neblina, which can be chosen based on the user’s preference.

#### Quick Calibration

This is a simple one-step calibration procedure, which requires putting the device on a relatively flat surface in a stationary position. A command can be sent to the device, e.g., over Bluetooth, to issue the calibration process, and then voilà, the calibration is done!

This calibration method is very useful for applications, where placing the device in multiple precise orientations is not feasible, and the inclination angle has a limited range. The method incorporates a rotation matrix and a gain value to bring back the offset readings from sensors to the right frame of reference. The interesting fact about this approach is that it does not calibrate the sensor across all possible orientations. Instead, the calibration is optimized for small inclination angles around the one and only calibration position. For instance, if you calibrate the device on a table, you should be able to track inclination angles in the range of -10 to 10 degrees with a very high accuracy (less than 0.2 degrees error). However, the inclination angle at 180 degrees might not be as accurate. We have conducted two experiments to elaborate on these points, which are discussed at the end of this blog post.

#### Complete Calibration

This method requires placing the device in 6 stationary positions. Each position will match one side of an orthogonal cube. The calibration positions must match the following 3-axis sensor readings $$(1g,0,0), (-1g,0,0), (0,1g,0), (0,-1g,0), (0,0,1g), (0,0,-1g)$$. Each time you place the device in one of these stationary positions, a command can be sent to the device, e.g., over Bluetooth, to capture a new calibration position. After sending the command 6 times (corresponding to each calibration position), Neblina will compute 12 calibration parameters using a least-squares-fit algorithm and will store these calibration parameters in its memory for later use.

This calibration method is only applicable, when placing the device in 6 orthogonal positions is feasible, e.g., by placing Neblina inside a cube. The sensor has to be stationary and attached to the cube tightly for the calibration to be accurate. This calibration takes into account all possible orientations for improved accuracy. Hence, it is not limited to small inclination angles like the previous method. The user can decide to extract either raw or calibrated accelerometer data from Neblina.

### Room Temperature Experiment

Neblina has been tightly attached to the inside of an orthogonal metal cube for the purpose of this experiment. The cube is then placed on different accurate angle blocks with an angle error less than 0.001 degrees covering several inclination angles with a 1-degree increment. The angle blocks are shown below:

The two calibration methods on Neblina have been evaluated alongside the raw readings (Bosch’s factory calibrated data) in terms of the accuracy of the delivered inclination angles. The results of capturing inclination angles are summarized below:

Angle Range (degrees) Raw Angle Error RMS/Max Quick Calib Angle Error RMS/Max Complete Calib Angle Error RMS/Max
(-10,10) 2.34/2.76 degrees 0.07/0.198 degrees 0.07/0.16 degrees
(-30,30) 2.34/2.76 degrees 0.12/0.238 degrees 0.08/0.18 degrees
(-180,180) 2.33/2.76 degrees 0.63/4.981 degrees 0.09/0.24 degrees

The raw angle captured by Bosch’s factory calibrated accelerometer readings is off by 2.34 degrees in average across all regions (orientations). The quick calibration shows great promise within the small inclination ranges. The RMS error remains at 0.07 degrees for the inclination range of (-10,10) degrees, while the maximum error is bounded by 0.198 degrees. However, the solution becomes inefficient at high inclination angles. In fact, the error becomes even larger than the raw angle at 90 degrees inclination (maximum error of 4.981 degrees). The complete 6-position calibration performs well across all regions (orientations) with 0.09 degrees RMS error and a maximum error of 0.24 degrees. It is notable that the accuracy of the complete calibration across all orientations is comparable with the quick calibration method within the inclination range of (-30,30) degrees.

### Cold Temperature Experiment

Temperature variation can majorly compromise the sensitivity and offset of the MEMs accelerometers. Therefore, we conducted another experiment to evaluate the accuracy of the inclination angles under cold temperature. To set this up, a small fridge with an average inside temperature of ~4 degrees have been used. We first placed the orthogonal cube including Neblina inside the fridge for 2 hours to reach a stable temperature. Then to test each angle, we first placed the cube on an angle block inside the fridge, closed the door, and then waited for another 10 minutes to reach stable readings. Neblina has been constantly streaming raw/calibrated accelerometer data over Bluetooth Low Energy (BLE) interface to the host (iOS tablet). From our observations, only a wait time of 1-2 minutes has been long enough to reach stable accelerometer readings inside the fridge after the initial 2 hour setup wait time, but we have considered the wait time to be ~10 minutes for each angle measurement just to be more precise with the environmental conditions. The accuracy of the two calibration procedures as well as the raw angles are summarized below:

Angle Range (degrees) Raw Angle Error RMS/Max Quick Calib Angle Error RMS/Max Complete Calib Angle Error RMS/Max
(-10,10) 0.97/1.18 degrees 0.08/0.23 degrees 0.11/0.23 degrees
(-180,180) 0.96/1.47 degrees 0.35/2.52 degrees 0.13/0.24 degrees

The results mostly agree with the previous experiment under room temperature. The accuracy of both calibration methods remains high within the small inclination range of (-10,10) degrees, while the 6-position calibration majorly outperforms the quick calibration across other regions (higher inclination angles). The raw angles are also off by 0.96 degrees in average across all regions, which is relatively high.

In summary, the two experiments indicate that over ~20 degrees variation in temperature, a re-calibration procedure using the built-in features on Neblina will deliver inclination angles with a similar high accuracy.