kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.02k stars 469 forks source link

Inaccurate Yaw Values, with a seemingly calibrated Magnetometer #341

Open silaswaxter opened 5 years ago

silaswaxter commented 5 years ago

Dear Kris, I'm a junior in high and am working on a science research project. I am using an MPU9250, a Teensy 3.2, and the "MPU9250BasicAHRS_t3.ino" with the display code removed. I am having issues getting an accurate Yaw. I have read some of the other issues and it seems that it would be an issue with the magnetometer not being calibrated. However, I followed the steps to calibrate it (see video to correct me if the figure-eight motion is wrong) and graphed my values (see graph link below). The graph shows concentric spheres that have a radius of ~250 mG. I also have an filtering rate > 1kHz. Below is a video of my device. Notice that when I accelerate along an axis, the yaw values drift. I have also had issues in the past where the degrees will be increasing until they hit about 260 then they start decreasing even though my rotational velocity is approx. constant. Any help would be greatly appreciated. Thanks, Silas

Graph:https://drive.google.com/file/d/1wPDlHVcQsQg9OosKEtmkQXdNJDlerU_m/view?usp=sharing Video:https://drive.google.com/file/d/1cub582lOsj0S1ebk31tZGa7HnVYIuDq0/view?usp=sharing

kriswiner commented 5 years ago

Hard to tell from your plot but accel and gyro offset biases have to be corrected as well as mag offset bias and scaling for best results. Easy checks on these are" sensor flat andat rest, accle = 0, 0, 1 G, gyro - 0, 0, 0 dps. For mag, Mz should be equal and opposite when sensor facinf up vs facing down.

Likely causesof your problems 1) need faster sample rate, maybe run accel and gyro at 1 kHz, mag at 100 Hz. Feed sensor data into Madgwick/Mahony ilter in consisten NED or ENU order, i.e.

Madgwick(AN, AE, AD, GN, GE, GD, MN, ME, MD). Or similar for ENU.

Are you taking your local magnetic declination into account. Won;t affect yaw drift but will affect where 0 degree heading points.

On Sat, Jan 12, 2019 at 10:43 AM SilasWaxter notifications@github.com wrote:

Dear Kris, I'm a junior in high and am working on a science research project. I am using an MPU9250, a Teensy 3.2, and the "MPU9250BasicAHRS_t3.ino" with the display code removed. I am having issues getting an accurate Yaw. I have read some of the other issues and it seems that it would be an issue with the magnetometer not being calibrated. However, I followed the steps to calibrate it (see video to correct me if the figure-eight motion is wrong) and graphed my values (see graph link below). The graph shows concentric spheres that have a radius of ~250 mG. I also have an filtering rate > 1kHz. Below is a video of my device. Notice that when I accelerate along an axis, the yaw values drift. I have also had issues in the past where the degrees will be increasing until they hit about 260 then they start decreasing even though my rotational velocity is approx. constant. Any help would be greatly appreciated. Thanks, Silas

Graph: https://drive.google.com/file/d/1wPDlHVcQsQg9OosKEtmkQXdNJDlerU_m/view?usp=sharing Video: https://drive.google.com/file/d/1cub582lOsj0S1ebk31tZGa7HnVYIuDq0/view?usp=sharing

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

silaswaxter commented 5 years ago

While laying flat with the z axis normal to the ground, my gyro readings are less than +- 0.10 deg/s, ax is between 0 and -5 mg, ay is -25 mg +- 5, az is 1000 mg +- 5, mz started at 600 then I flipped it and it was at -440, then I flipped back to normal position and it was 440. Tested it back and forth two more times and it was 440 and -440. Why is the mag reading in the beginning different? While retesting, I tested my angles again. This time I tested the Pitch and Roll. My yaw would go up to 90 then start coming back down, even thought my rotational velocity was constant. My roll, however, would range from -180 to +180. I am confused as to why there is a difference in my range of degrees. This is the code used to convert between quaternions and Euler Angles. a12 = 2.0f (q[1] q[2] + q[0] q[3]); a22 = q[0] q[0] + q[1] q[1] - q[2] q[2] - q[3] q[3]; a31 = 2.0f (q[0] q[1] + q[2] q[3]); a32 = 2.0f (q[1] q[3] - q[0] q[2]); a33 = q[0] q[0] - q[1] q[1] - q[2] q[2] + q[3] q[3]; pitch = -asinf(a32); roll = atan2f(a31, a33); yaw = atan2f(a12, a22); pitch = 180.0f / PI; yaw = 180.0f / PI; yaw += 15.2f; // Declination at Seaside, Oregon is 15 degrees 20 minutes if(yaw < 0) yaw += 360.0f; // Ensure yaw stays between 0 and 360 roll = 180.0f / PI; lin_ax = ax + a31; lin_ay = ay + a32; lin_az = az - a33;

I adjusted for my local magnetic declination, but it doesn't point in one consistent location as 0. It changes especially after I accelerate one way around the z-axis, then return it. As far as update rate, I am using the magnetometer on 100 hz. I haven't changed the update rate of the accel or gyro, but the function you included, which returns your update rate of the filter is running at an average of 1875 hz and drops to about 800 every so often. I assume this is when the new data is read from the sensor. Is the default order of the Mahony/Madgwick Filter not NED or ENU? Is there a better filter to use? I am using the Mahony right now. Thanks again, Silas

kriswiner commented 5 years ago

You choose which accel axis is to point to true North. Then feed the filter data in the right order, NED or ENU.

On Sat, Jan 12, 2019 at 12:16 PM SilasWaxter notifications@github.com wrote:

While laying flat with the z axis normal to the ground, my gyro readings are less than +- 0.10 deg/s, ax is between 0 and -5 mg, ay is -25 mg +- 5, az is 1000 mg +- 5, mz started at 600 then I flipped it and it was at -440, then I flipped back to normal position and it was 440. Tested it back and forth two more times and it was 440 and -440. Why is the mag reading in the beginning different? While retesting, I tested my angles again. This time I tested the Pitch and Roll. My yaw would go up to 90 then start coming back down, even thought my rotational velocity was constant. My roll, however, would range from -180 to +180. I am confused as to why there is a difference in my range of degrees. This is the code used to convert between quaternions and Euler Angles. a12 = 2.0f (q[1] q[2] + q[0] q[3]); a22 = q[0] q[0] + q[1] q[1] - q[2] q[2] - q[3] q[3]; a31 = 2.0f (q[0] q[1] + q[2] q[3]); a32 = 2.0f (q[1] q[3] - q[0] q[2]); a33 = q[0] q[0] - q[1] q[1] - q[2] q[2] + q[3] q[3]; pitch = -asinf(a32); roll = atan2f(a31, a33); yaw = atan2f(a12, a22); pitch = 180.0f / PI; yaw = 180.0f / PI; yaw += 15.2f; // Declination at Seaside, Oregon is 15 degrees 20 minutes if(yaw < 0) yaw += 360.0f; // Ensure yaw stays between 0 and 360 roll = 180.0f / PI; lin_ax = ax + a31; lin_ay = ay + a32; lin_az = az - a33;

I adjusted for my local magnetic declination, but it doesn't point in one consistent location as 0. It changes especially after I accelerate one way around the z-axis, then return it. As far as update rate, I am using the magnetometer on 100 hz. I haven't changed the update rate of the accel or gyro, but the function you included, which returns your update rate of the filter is running at an average of 1875 hz and drops to about 800 every so often. I assume this is when the new data is read from the sensor. Is the default order of the Mahony/Madgwick Filter not NED or ENU? Is there a better filter to use? I am using the Mahony right now. Thanks again, Silas

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

silaswaxter commented 5 years ago

I didn't change the order of what was fed to the filter. I am using the default, NED, with the accel's x-axis pointed north, but the value is the opposite because gravity is positive down. This is my input into the function.

MahonyQuaternionUpdate(-ax, ay, az, gxPI/180.0f, -gyPI/180.0f, -gz*PI/180.0f, my, -mx, mz);

kriswiner commented 5 years ago

That should work.

On Sat, Jan 12, 2019 at 1:02 PM SilasWaxter notifications@github.com wrote:

I didn't change the order of what was fed to the filter. I am using the default, NED, with the accel's x-axis pointed north, but the value is the opposite because gravity is positive down. This is my input into the function.

MahonyQuaternionUpdate(-ax, ay, az, gxPI/180.0f, -gyPI/180.0f, -gz*PI/180.0f, my, -mx, mz);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-453780676, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qns3f-z6UzV35R4-pLV_Gk9zY1KDks5vCk1SgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

What is the problem with my yaw?

kriswiner commented 5 years ago

No idea

On Sat, Jan 12, 2019 at 1:10 PM SilasWaxter notifications@github.com wrote:

What is the problem with my yaw?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-453781255, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qpxszO2KdfP-VAjPD394nDLAo2Niks5vCk9MgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

Okay, thanks for your help anyways. And thank you for the code it is definitely appreciated.

kriswiner commented 5 years ago

Took a look at that old sketch you are using. I hope you understood enough to comment out these lines:

readMagData(magCount); // Read the x/y/z adc values getMres(); magbias[0] = +470.; // User environmental x-axis correction in milliGauss, should be automatically calculated magbias[1] = +120.; // User environmental x-axis correction in milliGauss magbias[2] = +125.; // User environmental x-axis correction in milliGauss

How are you managing the mag calibration?

On Sat, Jan 12, 2019 at 1:36 PM SilasWaxter notifications@github.com wrote:

Okay, thanks for your help anyways. And thank you for the code it is definitely appreciated.

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

silaswaxter commented 5 years ago

I didn't have "readMagData(magCount); // Read the x/y/z adc values" commented out. I assume if it wasn't commented out, it would read the mag values whenever the 'new-data flag' was raised as well as whenever the 'new-mag-data flag' was raised. However, I tested it with the line commented out. The yaw was stuck between 210 and 225. When uncommented, the yaw was a lot better. I also noticed that my desk is metal. When I moved my device away from the desk, the angles were within 5 degrees when moving 90 degrees. I also shook the sensor all around then brought it back. It would return quite fast and would be within +-2 degrees. The yaw seemed to deal better with accelerations after some time had gone by. Does that make sense with the filter?

I removed all the other lines. I was reading another post and you were saying the best yaw you can expect to get is within 5 degrees. https://github.com/kriswiner/MPU9250/issues/115. Would that change with a higher filtering rate? For my application, I plan to display the euler angles in a C# app I'm programming for windows. The sensor module will communicate to the computer with a bluetooth module, the HC-08 (1mb/s). Sending over the raw accelerometer, gyroscope, and magnetometer data and filtering on the computer would mean a faster filtering rate. Would this increase the accuracy of yaw?

My mag calibration uses the code below. I am rotating the sensor along all of its axis while moving in a figure eight at 1-2 rev/sec.

void magcalMPU9250(float dest1, float dest2) { uint16_t ii = 0, sample_count = 0; int32_t mag_bias[3] = {0, 0, 0}, mag_scale[3] = {0, 0, 0}; int16_t mag_max[3] = {-32767, -32767, -32767}, mag_min[3] = {32767, 32767, 32767}, mag_temp[3] = {0, 0, 0};

Serial.println("Mag Calibration: Wave device in a figure eight until done!"); delay(4000);

// shoot for ~fifteen seconds of mag data
if(Mmode == 0x02) sample_count = 128;  // at 8 Hz ODR, new mag data is available every 125 ms
if(Mmode == 0x06) sample_count = 1500;  // at 100 Hz ODR, new mag data is available every 10 ms

for(ii = 0; ii < sample_count; ii++) { readMagData(mag_temp); // Read the mag data
for (int jj = 0; jj < 3; jj++) { if(mag_temp[jj] > mag_max[jj]) mag_max[jj] = mag_temp[jj]; if(mag_temp[jj] < mag_min[jj]) mag_min[jj] = mag_temp[jj]; } if(Mmode == 0x02) delay(135); // at 8 Hz ODR, new mag data is available every 125 ms if(Mmode == 0x06) delay(12); // at 100 Hz ODR, new mag data is available every 10 ms }

// Serial.println("mag x min/max:"); Serial.println(mag_max[0]); Serial.println(mag_min[0]); // Serial.println("mag y min/max:"); Serial.println(mag_max[1]); Serial.println(mag_min[1]); // Serial.println("mag z min/max:"); Serial.println(mag_max[2]); Serial.println(mag_min[2]);

// Get hard iron correction
mag_bias[0]  = (mag_max[0] + mag_min[0])/2;  // get average x mag bias in counts
mag_bias[1]  = (mag_max[1] + mag_min[1])/2;  // get average y mag bias in counts
mag_bias[2]  = (mag_max[2] + mag_min[2])/2;  // get average z mag bias in counts

dest1[0] = (float) mag_bias[0]*mRes*magCalibration[0];  // save mag biases in G for main program
dest1[1] = (float) mag_bias[1]*mRes*magCalibration[1];   
dest1[2] = (float) mag_bias[2]*mRes*magCalibration[2];  

// Get soft iron correction estimate
mag_scale[0]  = (mag_max[0] - mag_min[0])/2;  // get average x axis max chord length in counts
mag_scale[1]  = (mag_max[1] - mag_min[1])/2;  // get average y axis max chord length in counts
mag_scale[2]  = (mag_max[2] - mag_min[2])/2;  // get average z axis max chord length in counts

float avg_rad = mag_scale[0] + mag_scale[1] + mag_scale[2];
avg_rad /= 3.0;

dest2[0] = avg_rad/((float)mag_scale[0]);
dest2[1] = avg_rad/((float)mag_scale[1]);
dest2[2] = avg_rad/((float)mag_scale[2]);

Serial.println("Mag Calibration done!"); }

kriswiner commented 5 years ago

4 degree heading accuracy is what you should expect with good calibration using the MPU9250.

And, yes, keep the sensor away from strong external mag fields is required to get best results

These:

magbias[0] = +470.; // User environmental x-axis correction in milliGauss, should be automatically calculated magbias[1] = +120.; // User environmental x-axis correction in milliGauss magbias[2] = +125.; // User environmental x-axis correction in milliGauss

are obviously offset biases for a particular MPU9250 I used years ago, not applicable to your sensor. Some people keep these values in their sketch and wonder why they can;t get accurate heading!.

On Sat, Jan 12, 2019 at 11:24 PM SilasWaxter notifications@github.com wrote:

I didn't have "readMagData(magCount); // Read the x/y/z adc values" commented out. I assume if it wasn't commented out, it would read the mag values whenever the 'new-data flag' was raised as well as whenever the 'new-mag-data flag' was raised. However, I tested it with the line commented out. The yaw was stuck between 210 and 225. When uncommented, the yaw was a lot better. I also noticed that my desk is metal. When I moved my device away from the desk, the angles were within 5 degrees when moving 90 degrees. I also shook the sensor all around then brought it back. It would return quite fast and would be within +-2 degrees. The yaw seemed to deal better with accelerations after some time had gone by. Does that make sense with the filter?

I removed all the other lines. I was reading another post and you were saying the best yaw you can expect to get is within 5 degrees. #115 https://github.com/kriswiner/MPU9250/issues/115. Would that change with a higher filtering rate? For my application, I plan to display the euler angles in a C# app I'm programming for windows. The sensor module will communicate to the computer with a bluetooth module, the HC-08 (1mb/s). Sending over the raw accelerometer, gyroscope, and magnetometer data and filtering on the computer would mean a faster filtering rate. Would this increase the accuracy of yaw?

My mag calibration uses the code below. I am rotating the sensor along all of its axis while moving in a figure eight at 1-2 rev/sec.

void magcalMPU9250(float dest1, float dest2) { uint16_t ii = 0, sample_count = 0; int32_t mag_bias[3] = {0, 0, 0}, mag_scale[3] = {0, 0, 0}; int16_t mag_max[3] = {-32767, -32767, -32767}, mag_min[3] = {32767, 32767, 32767}, mag_temp[3] = {0, 0, 0};

Serial.println("Mag Calibration: Wave device in a figure eight until done!"); delay(4000);

// shoot for ~fifteen seconds of mag data if(Mmode == 0x02) sample_count = 128; // at 8 Hz ODR, new mag data is available every 125 ms if(Mmode == 0x06) sample_count = 1500; // at 100 Hz ODR, new mag data is available every 10 ms

for(ii = 0; ii < sample_count; ii++) { readMagData(mag_temp); // Read the mag data for (int jj = 0; jj < 3; jj++) { if(mag_temp[jj] > mag_max[jj]) mag_max[jj] = mag_temp[jj]; if(mag_temp[jj] < mag_min[jj]) mag_min[jj] = mag_temp[jj]; } if(Mmode == 0x02) delay(135); // at 8 Hz ODR, new mag data is available every 125 ms if(Mmode == 0x06) delay(12); // at 100 Hz ODR, new mag data is available every 10 ms }

// Serial.println("mag x min/max:"); Serial.println(mag_max[0]); Serial.println(mag_min[0]); // Serial.println("mag y min/max:"); Serial.println(mag_max[1]); Serial.println(mag_min[1]); // Serial.println("mag z min/max:"); Serial.println(mag_max[2]); Serial.println(mag_min[2]);

// Get hard iron correction mag_bias[0] = (mag_max[0] + mag_min[0])/2; // get average x mag bias in counts mag_bias[1] = (mag_max[1] + mag_min[1])/2; // get average y mag bias in counts mag_bias[2] = (mag_max[2] + mag_min[2])/2; // get average z mag bias in counts

dest1[0] = (float) mag_bias[0]mResmagCalibration[0]; // save mag biases in G for main program dest1[1] = (float) mag_bias[1]mResmagCalibration[1]; dest1[2] = (float) mag_bias[2]mResmagCalibration[2];

// Get soft iron correction estimate mag_scale[0] = (mag_max[0] - mag_min[0])/2; // get average x axis max chord length in counts mag_scale[1] = (mag_max[1] - mag_min[1])/2; // get average y axis max chord length in counts mag_scale[2] = (mag_max[2] - mag_min[2])/2; // get average z axis max chord length in counts

float avg_rad = mag_scale[0] + mag_scale[1] + mag_scale[2]; avg_rad /= 3.0;

dest2[0] = avg_rad/((float)mag_scale[0]); dest2[1] = avg_rad/((float)mag_scale[1]); dest2[2] = avg_rad/((float)mag_scale[2]);

Serial.println("Mag Calibration done!"); }

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

silaswaxter commented 5 years ago

Would a faster filter rate increase the accuracy? Should I switch to the MAX21100/LIS3MDL or the EM7180/LSM9DS0?

kriswiner commented 5 years ago

Faster filter rate all else being equal will not improve accuracy, but could improve stability and lower latency.

Accuracy depends, in order, on:

  1. Sensor quality
  2. Sensor calibration ...
  3. fusion filter update rate ...
  4. sensor fusion filter.

On the other hand, the fusion filter in the EM7180 is much better than the simple Madgwick or Mahony filters, and is capable of routinely providing 2 degree heading accuracy or better. See this https://github.com/kriswiner/EM7180_SENtral_sensor_hub/wiki/K.-Limits-of-Absolute-Heading-Accuracy-Using-Inexpensive-MEMS-Sensors .

So for improvement in heading accuracy, I would suggest using the MPU9250 and a fast MCU like an STM32L4 for Madgwick/Mahony fusion on the host (or off the host on a separate compute engine) for up to 4 degree heading accuracy.

LSM6DSM+LIS2MDL and a fast MCU like an STM32L4 for Madgwick/Mahony fusion on the host (or off the host on a separate compute engine) for up to 3 degree heading accuracy.

The MPU9250 and EM7180 for up to 2 degree accuracy, or the LSM6DSM+LIS2MDL+EM7180 for 1 - 2 degree heading accuracy.

These results require excellent sensor calibration, with somewhat more laborious but easily done calibration methods.

On Sun, Jan 13, 2019 at 9:05 AM SilasWaxter notifications@github.com wrote:

Would a faster filter rate increase the accuracy? Should I switch to the MAX21100/LIS3MDL or the EM7180/LSM9DS0?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-453846793, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qipGz-WeZ2mp0VHXtQtvzc2n32zfks5vC2dFgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

Can the EM7180 perform sensor fusion on seperate sensor modules? How do I get "excellent sensor calibration, with somewhat more laborious but easily done calibration methods."

silaswaxter commented 5 years ago

On further reading, it seems each sensor would have there own EM7180. I need the best accuracy possible, as the device I'm creating is used for medical purposes.

kriswiner commented 5 years ago

My advice is to buy one of these https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution-lsm6dsm-lis2md/ and test it for your application then. The only problem will be if you want to design your own version, then you will need to license the EM7180 firmware from us.

On Sun, Jan 13, 2019 at 9:31 AM SilasWaxter notifications@github.com wrote:

On further reading, it seems each sensor would have there own EM7180. I need the best accuracy possible, as the device I'm creating is used for medical purposes.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-453849272, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlQ-jrxnkFaBX3xWaI7wqG_0ktU1ks5vC22NgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

Ok. I plan to turn the device into a product eventually, but I don't think I am going to create my own version of the sensor. Theoretically speaking, how many units could you produce in a month?

kriswiner commented 5 years ago

First of all, the EM7180 manages all of the sensors on the board, meaning the accel, gyro, magnetometer and pressure sensor. So just one EM7180 is required. I have hundreds of the boad I linked to and can have produced thousands given 45 days notice. How many will you be needing?

On Sun, Jan 13, 2019 at 9:45 AM SilasWaxter notifications@github.com wrote:

Ok. I plan to turn the device into a product eventually, but I don't think I am going to create my own version of the sensor. Theoretically speaking, how many units could you produce in a month?

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

silaswaxter commented 5 years ago

I'm just ordering 1 right now so I can produce my prototype, but within the next year, I plan to start my business and start selling my product, which uses two of them. I think the business will take off, but we will see. Thanks again for all your help I really appreciate it.

silaswaxter commented 5 years ago

I just got the EM7180_LSM6DSM_LIS2MDL_LPS22HB. I am unsure how to get started.

kriswiner commented 5 years ago

Run this one a sensoble MCU:

https://github.com/kriswiner/EM7180_SENtral_sensor_hub/tree/master/EM7180_LSM6DSM_LIS2MDL_LPS22HB_Butterfly

after connecting 3V3, GND, SDA. SCL and an interrupt pin.

On Sat, Jan 19, 2019 at 8:05 PM SilasWaxter notifications@github.com wrote:

I just got the EM7180_LSM6DSM_LIS2MDL_LPS22HB. I am unsure how to get started.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455835899, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qnHhg2f2xnwg12xOIcARM66bs4nmks5vE-sVgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

I tried that, but it is for the butterfly MCU correct? I don't have that. Is there a sketch for an arduino or teensy?

kriswiner commented 5 years ago

You'll have to make some small modification for those. Not too hard...

On Sat, Jan 19, 2019 at 8:09 PM SilasWaxter notifications@github.com wrote:

I tried that, but it is for the butterfly MCU correct? I don't have that. Is there a sketch for an arduino or teensy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455836073, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlfHPcdSqymYgxYUC-LSlJ6xSvImks5vE-wTgaJpZM4Z8yoX .

kriswiner commented 5 years ago

Maybe try this library instead.

https://github.com/simondlevy/EM7180/blob/master/examples/MasterTest/MasterTest.ino

On Sat, Jan 19, 2019 at 8:11 PM Tlera Corporation tleracorp@gmail.com wrote:

You'll have to make some small modification for those. Not too hard...

On Sat, Jan 19, 2019 at 8:09 PM SilasWaxter notifications@github.com wrote:

I tried that, but it is for the butterfly MCU correct? I don't have that. Is there a sketch for an arduino or teensy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455836073, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlfHPcdSqymYgxYUC-LSlJ6xSvImks5vE-wTgaJpZM4Z8yoX .

kriswiner commented 5 years ago

This one os probbly closer for an AVR arduino.

https://github.com/kriswiner/ESP32/tree/master/EM7180/EM7180_LSM6DSM_LIS2MDL_LPS22HB_ESP32

On Sat, Jan 19, 2019 at 8:12 PM Tlera Corporation tleracorp@gmail.com wrote:

Maybe try this library instead.

https://github.com/simondlevy/EM7180/blob/master/examples/MasterTest/MasterTest.ino

On Sat, Jan 19, 2019 at 8:11 PM Tlera Corporation tleracorp@gmail.com wrote:

You'll have to make some small modification for those. Not too hard...

On Sat, Jan 19, 2019 at 8:09 PM SilasWaxter notifications@github.com wrote:

I tried that, but it is for the butterfly MCU correct? I don't have that. Is there a sketch for an arduino or teensy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455836073, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlfHPcdSqymYgxYUC-LSlJ6xSvImks5vE-wTgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

"Global variables use 2702 bytes (131%) of dynamic memory, leaving -654 bytes for local variables. Maximum is 2048 bytes." Is there any variables I can remove without messing up the filtering? I only need the orientation in Euler angles. However, accuracy is most important.

kriswiner commented 5 years ago

Better get a real MCU...

On Sat, Jan 19, 2019 at 8:50 PM SilasWaxter notifications@github.com wrote:

"Global variables use 2702 bytes (131%) of dynamic memory, leaving -654 bytes for local variables. Maximum is 2048 bytes." Is there any variables I can remove without messing up the filtering? I only need the orientation in Euler angles. However, accuracy is most important.

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

kriswiner commented 5 years ago

You mentioned Teensy, this should work just fine.

On Sat, Jan 19, 2019 at 8:51 PM Tlera Corporation tleracorp@gmail.com wrote:

Better get a real MCU...

On Sat, Jan 19, 2019 at 8:50 PM SilasWaxter notifications@github.com wrote:

"Global variables use 2702 bytes (131%) of dynamic memory, leaving -654 bytes for local variables. Maximum is 2048 bytes." Is there any variables I can remove without messing up the filtering? I only need the orientation in Euler angles. However, accuracy is most important.

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

silaswaxter commented 5 years ago

Are the hardware quaternions/angles what I want for accuracy or do I need to do some processing on the mcu?

kriswiner commented 5 years ago

You can choose to output quaternions and construct Euler angles on the host or you can choose to output Euler angles directly.

On Sun, Jan 20, 2019 at 1:31 PM SilasWaxter notifications@github.com wrote:

Are the hardware quaternions/angles what I want for accuracy or do I need to do some processing on the mcu?

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

silaswaxter commented 5 years ago

Do the sensor definitions effect the EM1780's abillity to process the data or are they there for passing the data through the EM1780 to the MCU?
Example: "// LPS22H definitions uint8_t LPS22H_intPin = 5;

/ Specify sensor parameters (sample rate is twice the bandwidth) Choices are P_1Hz, P_10Hz P_25 Hz, P_50Hz, and P_75Hz / uint8_t PODR = P_25Hz; // set pressure amd temperature output data rate uint8_t LPS22Hstatus; float temperature, pressure, altitude;"

kriswiner commented 5 years ago

Thos are there for bypassing the EM7180, but I don;t think the interrupts are set up properly in that sketch. That sketch is for using master mode, where the definitions you pasted don't matter.

On Sun, Jan 20, 2019 at 2:23 PM SilasWaxter notifications@github.com wrote:

Do the sensor definitions effect the EM1780's abillity to process the data or are they there for passing the data through the EM1780 to the MCU? Example: "// LPS22H definitions uint8_t LPS22H_intPin = 5;

/ Specify sensor parameters (sample rate is twice the bandwidth) Choices are P_1Hz, P_10Hz P_25 Hz, P_50Hz, and P_75Hz / uint8_t PODR = P_25Hz; // set pressure amd temperature output data rate uint8_t LPS22Hstatus; float temperature, pressure, altitude;"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455908216, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qg_2xemfOXv-lTu34-96iQtpHiK3ks5vFOx5gaJpZM4Z8yoX .

kriswiner commented 5 years ago

If you just want quaternions or Euler angles and nothing else, then Simon's minimalist library is probably what you want to use.

On Sun, Jan 20, 2019 at 2:27 PM Tlera Corporation tleracorp@gmail.com wrote:

Thos are there for bypassing the EM7180, but I don;t think the interrupts are set up properly in that sketch. That sketch is for using master mode, where the definitions you pasted don't matter.

On Sun, Jan 20, 2019 at 2:23 PM SilasWaxter notifications@github.com wrote:

Do the sensor definitions effect the EM1780's abillity to process the data or are they there for passing the data through the EM1780 to the MCU? Example: "// LPS22H definitions uint8_t LPS22H_intPin = 5;

/ Specify sensor parameters (sample rate is twice the bandwidth) Choices are P_1Hz, P_10Hz P_25 Hz, P_50Hz, and P_75Hz / uint8_t PODR = P_25Hz; // set pressure amd temperature output data rate uint8_t LPS22Hstatus; float temperature, pressure, altitude;"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455908216, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qg_2xemfOXv-lTu34-96iQtpHiK3ks5vFOx5gaJpZM4Z8yoX .

silaswaxter commented 5 years ago

Ok do you have a link?

kriswiner commented 5 years ago

The one I sent you?

On Sun, Jan 20, 2019 at 2:29 PM SilasWaxter notifications@github.com wrote:

Ok do you have a link?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455908616, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qumbNGCdambwhGryqTiVCA85Y-z2ks5vFO2-gaJpZM4Z8yoX .

silaswaxter commented 5 years ago

I don't think so. It doesn't mention Simon anywhere. The ones you sent me have all the other data in them.

kriswiner commented 5 years ago

https://github.com/simondlevy/EM7180/blob/master/examples/MasterTest/MasterTest.ino

On Sun, Jan 20, 2019 at 2:34 PM SilasWaxter notifications@github.com wrote:

I don't think so. It doesn't mention Simon anywhere. The ones you sent me have all the other data in them.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-455908964, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qhUidiJ-VvOJw1BsyhbUmc4iNfK3ks5vFO7sgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

Thank you!

silaswaxter commented 5 years ago

Dear Kris, I ordered another sensor. I intend to use 2 of them on the same device. Is there a way I can change the i2c address? I know I can use an i2c multiplexer, but is there a pin on the sensor similar to the MPU9250's AD0/SD0, which will alter the address of the EM7180?

kriswiner commented 5 years ago

There is but it is not exposed to the user on these boards. if you use a Butterfly or Dragonfly or even a Teensy you can simply run one on two separate I2C buses.

On Sat, Jan 26, 2019 at 8:49 PM SilasWaxter notifications@github.com wrote:

Dear Kris, I ordered another sensor. I intend to use 2 of them on the same device. Is there a way I can change the i2c address? I know I can use an i2c multiplexer, but is there a pin on the sensor similar to the MPU9250's AD0/SD0, which will alter the address of the EM7180?

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

silaswaxter commented 5 years ago

I cant. I switched to the ESP-WROOM-32. It has integrated bluetooth, which is nice bc it will cut down the size and complication of the device. I will just use a multiplexer. Thanks.

kriswiner commented 5 years ago

Or use the nRF52 add-on board, much lower power than ESP32 especially if coupled with the Butterfly.

On Sat, Jan 26, 2019 at 8:56 PM SilasWaxter notifications@github.com wrote:

I cant. I switched to the ESP-WROOM-32. It has integrated bluetooth, which is nice bc it will cut down the size and complication of the device. I will just use a multiplexer. Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-457889191, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qiB0ugY9iKjF5-klz05hd9yaCP5Rks5vHTFjgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

I think I'm gonna stick with the esp. I can't use BLE bc the c# library im using, 32 feet, doesnt support it. If I have issues with battery life I'll reconsider.

silaswaxter commented 5 years ago

When you make the produce the sensors, do you place the components on the pcbs by hand?

kriswiner commented 5 years ago

Only the prototypes, then I send them to the fab for production if I decide to sell them.

On Sat, Jan 26, 2019 at 9:10 PM SilasWaxter notifications@github.com wrote:

When you make the produce the sensors, do you place the components on the pcbs by hand?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-457889765, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qo3O7fobgPOPVVw6i-0TSmF2Abwqks5vHTTSgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

What is the minimum number of units per order? I am asking because eventually I need to have something like this on the EM7180 sensor. micro-usb_breakout Originally I was thinking that I would get a single layer pcb made that would connect the EM7180 and the micro-usb breakout. Now I wondering if it would be better to modify your pcb design and add a female micro-usb component.

P.S. sorry if the link got messed up this is the first time I tried that.

kriswiner commented 5 years ago

Why do you need usb on the sensor breakout?

On Sat, Jan 26, 2019 at 9:25 PM SilasWaxter notifications@github.com wrote:

What is the minimum number of units per order? I am asking because eventually I need to have something like this on the EM7180 sensor. micro-usb_breakout https://www.aliexpress.com/item/10pcs-MICRO-USB-To-DIP-Adapter-5pin-Female-Connector-B-Type-PCB-Converter-Breadboard-USB-01/32867946438.html?spm=2114.search0104.3.58.b1131037sUzjaq&ws_ab_test=searchweb0_0,searchweb201602_1_10065_10068_10130_10890_10547_319_10546_317_10548_10545_10696_453_10084_454_10083_10618_10307_538_537_536_10059_10884_10887_100031_321_322_10103-10890,searchweb201603_53,ppcSwitch_0&algo_expid=ca64687f-327c-4d11-acc1-177abda41f17-8&algo_pvid=ca64687f-327c-4d11-acc1-177abda41f17 Originally I was thinking that I would get a single layer pcb made that would connect the EM7180 and the micro-usb breakout. Now I wondering if it would be better to modify your pcb design and add a female micro-usb component.

P.S. sorry if the link got messed up this is the first time I tried that.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-457890348, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qo35r-raBxu_zN82M0SU24gjxyJ0ks5vHThMgaJpZM4Z8yoX .

silaswaxter commented 5 years ago

Each sensor is going to connect to the mcu via a usb cable.

kriswiner commented 5 years ago

This seems odd to me, why not via I2C?

On Sat, Jan 26, 2019 at 10:07 PM SilasWaxter notifications@github.com wrote:

Each sensor is going to connect to the mcu via a usb cable.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/341#issuecomment-457891985, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qpX3u7QSMEpgmqyqK5Ix3P-Il7jFks5vHUIugaJpZM4Z8yoX .

silaswaxter commented 5 years ago

Im going to use I2C over the usb cable. I want to use the usb cable bc they are common, replaceable, and cheap.