kriswiner / EM7180_SENtral_sensor_hub

(Affordable) Ultimate Sensor Fusion Solution
https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution/
96 stars 37 forks source link

Acceleration Data Extraction #24

Open afnan opened 6 years ago

afnan commented 6 years ago

Hi,

I am using sensor fusion board with ESP8266. Everything works exceptionally well. However, I am interested to get acceleration value along with yaw, pitch, and roll. When I try to put the sensor in passthrough mode reading from yaw, pitch and roll become zero and I cannot get ax,ay and az other than zero.

Question is that is it possible to use both modes together? if not any other way out to get acceleration? maybe through Quaternions?

kriswiner commented 6 years ago

You can read scaled accel, gyro, and mag data in normal mode while also getting hardware yaw, pitch, and roll, etc. Not sure what else you are trying to do here...

On Mon, May 21, 2018 at 4:02 AM, afnan notifications@github.com wrote:

Hi,

I am using sensor fusion board with ESP8266. Everything works exceptionally well. However, I am interested to get acceleration value along with yaw, pitch, and roll. When I try to put the sensor in passthrough mode reading from yaw, pitch and roll become zero and I cannot get ax,ay and az other than zero.

Question is that is it possible to use both modes together? if not any other way out to get acceleration? maybe through Quaternions?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/24, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qvKdF06_WHS-ziPPWPjcePNC_8Pyks5t0p7QgaJpZM4UG0D7 .

afnan commented 6 years ago

Ah, Thank you for the hidden hint. The scale factor aRes is zero which makes the output zero. Another question.

ax = (float)accelCount[0] * aRes - accelBias[0]; // get actual g value, this depends on scale being set ay = (float)accelCount[1] * aRes - accelBias[1]; az = (float)accelCount[2] * aRes - accelBias[2];

This code returns Acc:ax, ay, az: -0.01, 0.01, 0.13

It varies upon motion but does not change or go over 1. Is there any way I can test these values?

Thanks

kriswiner commented 6 years ago

I don't know what you are doing here Afnan, but in normal mode, the sensor values are obtained as follows:

if(!passThru) {

// If intpin goes high, all data registers have new data if(newData == true) { // On interrupt, read data newData = false; // reset newData flag

// Check event status register, way to chech data ready by polling rather than interrupt uint8_t eventStatus = readByte(EM7180_ADDRESS, EM7180_EventStatus); // reading clears the register

// Check for errors if(eventStatus & 0x02) { // error detected, what is it?

uint8_t errorStatus = readByte(EM7180_ADDRESS, EM7180_ErrorRegister); if(errorStatus != 0x00) { // is there an error? Serial.print(" EM7180 sensor status = "); Serial.println(errorStatus); if(errorStatus == 0x11) Serial.print("Magnetometer failure!"); if(errorStatus == 0x12) Serial.print("Accelerometer failure!"); if(errorStatus == 0x14) Serial.print("Gyro failure!"); if(errorStatus == 0x21) Serial.print("Magnetometer initialization failure!"); if(errorStatus == 0x22) Serial.print("Accelerometer initialization failure!"); if(errorStatus == 0x24) Serial.print("Gyro initialization failure!"); if(errorStatus == 0x30) Serial.print("Math error!"); if(errorStatus == 0x80) Serial.print("Invalid sample rate!"); }

// Handle errors ToDo

}

// if no errors, see if new data is ready if(eventStatus & 0x10) { // new acceleration data available readSENtralAccelData(accelCount);

// Now we'll calculate the accleration value into actual g's
ax = (float)accelCount[0]*0.000488;  // get actual g value
ay = (float)accelCount[1]*0.000488;
az = (float)accelCount[2]*0.000488;

}

if(eventStatus & 0x20) { // new gyro data available readSENtralGyroData(gyroCount);

// Now we'll calculate the gyro value into actual dps's
gx = (float)gyroCount[0]*0.153;  // get actual dps value
gy = (float)gyroCount[1]*0.153;
gz = (float)gyroCount[2]*0.153;

}

if(eventStatus & 0x08) { // new mag data available readSENtralMagData(magCount);

// Now we'll calculate the mag value into actual G's
mx = (float)magCount[0]*0.305176f;  // get actual G value
my = (float)magCount[1]*0.305176f;
mz = (float)magCount[2]*0.305176f;

}

if(eventStatus & 0x04) { // new quaternion data available readSENtralQuatData(Q); }

// get MS5637 pressure if(eventStatus & 0x40) { // new baro data available rawPressure = readSENtralBaroData(); pressure = (float)rawPressure*0.01f +1013.25f; // pressure in mBar

// get MS5637 temperature
rawTemperature = readSENtralTempData();
temperature = (float) rawTemperature*0.01f;  // temperature in degrees C

} } }

Are you trying to get the scales sensor data while using normal mode or passthrough mode? If pass through, why are you using a board with an EM7180, why not just use an MPU9250 breakout board?

On Mon, May 21, 2018 at 1:00 PM, afnan notifications@github.com wrote:

Ah, Thank you for the hidden hint. The scale factor aRes is zero which makes the output zero. Another question.

ax = (float)accelCount[0] aRes - accelBias[0]; // get actual g value, this depends on scale being set ay = (float)accelCount[1] aRes - accelBias[1]; az = (float)accelCount[2] * aRes - accelBias[2];

This code returns Acc:ax, ay, az: -0.01, 0.01, 0.13

It varies upon motion but does not change or go over 1. Is there any way I can test these values?

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/24#issuecomment-390765133, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qnRmwvFGE8p_x9W626zEZzS5NcsDks5t0xzqgaJpZM4UG0D7 .

afnan commented 6 years ago

I believe the main logic you suggest above is same as mine (in terms of acquiring Acceleration data). I got zero values due to aRes variable being zero in my equation. Before diagnosing the this problem I thought values are zero so I should try passthrough mode.

Now I am getting values in normal mode, not passthrough mode.

So as values are Scaled as you said, removing aRes from my equation but applying accelBias is correct?

Thanks

kriswiner commented 6 years ago

You are mixing passthrough and normal mode methods, so no this is not correct, aRes and accelBias are not used in normal mode.

On Mon, May 21, 2018 at 2:04 PM, afnan notifications@github.com wrote:

I believe the main logic you suggest above is same as mine (in terms of acquiring Acceleration data). I got zero values due to aRes variable being zero in my equation. Before diagnosing the this problem I thought values are zero so I should try passthrough mode.

Now I am getting values in normal mode, not passthrough mode.

So as values are Scaled as you said, removing aRes from my equation but applying accelBias is correct?

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/24#issuecomment-390782324, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qg0kwqmfsuQRkKrs7Oa-XHrGLPhkks5t0yvWgaJpZM4UG0D7 .

afnan commented 6 years ago

Just to understand a bit more. When does acceleration correction from eeprom is applied to acceleration reading? in your code above what is 0.000488

x = (float)accelCount[0]*0.000488; // get actual g value ay = (float)accelCount[1]*0.000488; az = (float)accelCount[2]*0.000488;

kriswiner commented 6 years ago

0.000488 is how the Sentral accel data is converted to g's, the scale factor. It is fixed for all settings of the full range. This is one example how normal mode differs from passthrough mode.

On Mon, May 21, 2018 at 2:09 PM, afnan notifications@github.com wrote:

Just to understand a bit more. When does acceleration correction from eeprom is applied to acceleration reading? in your code above what is 0.000488

x = (float)accelCount[0]0.000488; // get actual g value ay = (float)accelCount[1]0.000488; az = (float)accelCount[2]*0.000488;

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/24#issuecomment-390783790, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qiJpQKtxhbMrfngAaV4asNyEImS3ks5t0y0kgaJpZM4UG0D7 .

afnan commented 6 years ago

awesome. Thanks