Hello,
I'm currently working on a project that utilizes 2 of Sparkfun's SEN-19895 which includes 6DOF accelerometers (ISM330DHCX) paired with MMC5983MA magnetometers to determine the relative orientation or more specifically the inclination angle between two surfaces on a bent metal tube (setup picture below). I am using Jremington's Mahony implementation linked here -> GitHub - jremington/ISM330DHCX_fusion: Mahony fusion filter for 6DOF
I understand the proper way to determine these angular differences between the two accelerometers would be quaternion division, but I'm not quite sure how to implement that and so I have opted to simply find the difference between the two outputted angles (pitch or roll, whichever holds the angle I am interested in measured).
The setup is quite stable when the tube is stationary but it consistently measures 1 degree under the real inclination angle of the mounting surfaces. Additionally, as soon as I tilt the whole assembly into a new position the difference in the angles seems to increase or decrease by a maximum a degree depending on how much I've tilted it. I believe this may be due to their calibration and so I am attempting to recalibrate each sensor following the guide here -> Tutorial: How to calibrate a compass (and accelerometer) with Arduino | Underwater Arduino Data Loggers
I am using the following code to collect 500 points while rotating the sensor. A sample collection of data is below. I believe the outputted units from the ISM33DHX are milli-g and I am unsure how to process this data into a format that magneto will accept as I currently receive an error "Problem with file ...". I read this post LSM303DLHC - Calibration, Pitch, Roll and Tilt Compensated Heading which explains how they pre processed their data according to the bit depth and sensitivity listed on their data sheet but I cannot find or interpret this information on the data sheet for the ISM33DHX. If anyone has any information or recommendations on my issue, process or setup please let me know, It would be greatly appreciated.
ISMcaldata.txt (11.1 KB)
/*
example1-basic
This example shows the basic settings and functions for retrieving accelerometer
and gyroscopic data.
Please refer to the header file for more possible settings, found here:
..\SparkFun_6DoF_ISM330DHCX_Arduino_Library\src\sfe_ism330dhcx_defs.h
Written by Elias Santistevan @ SparkFun Electronics, August 2022
Product:
https://www.sparkfun.com/products/19764
Repository:
https://github.com/sparkfun/SparkFun_6DoF_ISM330DHCX_Arduino_Library
SparkFun code, firmware, and software is released under the MIT
License (http://opensource.org/licenses/MIT).
*/
#include <Wire.h>
#include "SparkFun_ISM330DHCX.h"
SparkFun_ISM330DHCX myISM;
// Structs for X,Y,Z data
sfe_ism_data_t accelData;
sfe_ism_data_t gyroData;
int acc_mag_count = 500; //collect this many values for calibration
void setup(){
Wire.begin();
Serial.begin(115200);
if( !myISM.begin() ){
Serial.println("Did not begin.");
while(1);
}
// Reset the device to default settings. This if helpful is you're doing multiple
// uploads testing different settings.
myISM.deviceReset();
// Wait for it to finish reseting
while( !myISM.getDeviceReset() ){
delay(1);
}
Serial.println("Reset.");
Serial.println("Applying settings.");
delay(100);
myISM.setDeviceConfig();
myISM.setBlockDataUpdate();
// Set the output data rate and precision of the accelerometer
myISM.setAccelDataRate(ISM_XL_ODR_104Hz);
myISM.setAccelFullScale(ISM_4g);
// Set the output data rate and precision of the gyroscope
myISM.setGyroDataRate(ISM_GY_ODR_104Hz);
myISM.setGyroFullScale(ISM_500dps);
// ** The following lines are commented as this filter is not used in the current working code **
// Turn on the accelerometer's filter and apply settings.
// myISM.setAccelFilterLP2();
// myISM.setAccelSlopeFilter(ISM_LP_ODR_DIV_100);
// Turn on the gyroscope's filter and apply settings.
myISM.setGyroFilterLP1();
myISM.setGyroLP1Bandwidth(ISM_MEDIUM);
Serial.println("Turn sensor SLOWLY and STEADILY in all directions until done");
delay(5000);
Serial.println("Starting...");
for (int i = 0; i < acc_mag_count; i++) {
if( myISM.checkStatus() ){
myISM.getAccel(&accelData); //data is only retrieved when these lines are called
myISM.getGyro(&gyroData); // ^^
Serial.print(accelData.xData);
Serial.print(", ");
Serial.print(accelData.yData);
Serial.print(", ");
Serial.print(accelData.zData);
Serial.println(", ");
delay(150);
}
else
{
delay(100); //wait for data ready
}
}
Serial.print(F("Done collecting"));
}
void loop(){
delay(100);
}
1 post - 1 participant