-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calibrate Accelerometer #120
Comments
Check here for an accel/gyro calibration function: https://github.com/kriswiner/MPU-9250/blob/master/MPU9250_MS5637_AHRS_t3.ino and adapt as needed. |
Thanks for the fast reply! I really appreciate it. |
I don't use Sparkfun's library even though they based it one one of my sketches. They chose a really old sketch for some reason that had some errors and omissions. The sketch I linked to is more up to date, has accel/gyro as well as mag calibration and I recommend you use it. Well, virtual beer is OK too! |
Thanks for the beer. You can calculate the offset bias calibrations and store them in your sketch to avoid calibrating each time. For gyro and accel the device should be motionless and flat. Fir mag calibration, you have to move the device around to sample all of the 3D response surface. If you print out the calibration values on the serial monitor, you can just subtract these from your data stream on subsequent startup without having to calibrate anymore unless the environmental conditions (location and temperature, mostly) change. |
hey, |
Yes, there is a bug in the calibration code. The calibration has to be done with the sensor facing up in order to get the correct calibration. |
lol, that's good to know. |
Hi I'm looking through your excellent calibration information. I'm trying out the sketch from above. I have installed the <i2c_t3.h> library but I'm getting this compile errors. Mainly round wire not being defined. I see that the wire.h is commented out but un-commenting still gives errors. Am I missing something? |
@NickMortimer can you post the exact error message after uncommenting the header file? |
i2c_t3.h is only for the Teensy 3.X MCU. Is that what you are using?
…On Fri, Jul 21, 2017 at 7:55 AM, Christopher B ***@***.***> wrote:
@NickMortimer <https://github.com/nickmortimer> can you post the exact
error message after uncommenting the header file?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qsEpkcf1JXJ63Hl54rN9jQsyvNKWks5sQLvtgaJpZM4MPt3I>
.
|
Ah sorry for the delay I have been what we say here in Australia out in the bush! I'm using Pro mini but I'm ordering Teensy right now! |
So I have un-commented the wire and taken out i2c_t3.h and get the following, seems to be a problem with I2C_MASTER not being defined. could be me? C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void setup()': myIMU:312: error: 'I2C_MASTER' was not declared in this scope Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
myIMU:312: error: 'I2C_PINS_16_17' was not declared in this scope Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
myIMU:312: error: 'I2C_PULLUP_EXT' was not declared in this scope Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
myIMU:312: error: 'I2C_RATE_400' was not declared in this scope Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void loop()': myIMU:521: error: 'MadgwickQuaternionUpdate' was not declared in this scope
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void MS5637PromRead(uint16_t*)': myIMU:1219: error: 'I2C_NOSTOP' was not declared in this scope
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'uint32_t MS5637Read(uint8_t, uint8_t)': myIMU:1233: error: 'I2C_NOSTOP' was not declared in this scope
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'uint8_t readByte(uint8_t, uint8_t)': myIMU:1340: error: 'I2C_NOSTOP' was not declared in this scope Wire.endTransmission(I2C_NOSTOP); // Send the Tx buffer, but send a restart to keep connection alive
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void readBytes(uint8_t, uint8_t, uint8_t, uint8_t*)': myIMU:1352: error: 'I2C_NOSTOP' was not declared in this scope Wire.endTransmission(I2C_NOSTOP); // Send the Tx buffer, but send a restart to keep connection alive
exit status 1 |
You'll need i2c_t3.h if you use i2c_t3 function calls. This will only work
on a Teensy 3.X though.
…On Tue, Jul 25, 2017 at 5:31 AM, Nick Mortimer ***@***.***> wrote:
So I have un-commented the wire and taken out i2c_t3.h and get the
following, seems to be a problem with I2C_MASTER not being defined. could
be me?
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void
setup()':
myIMU:312: error: 'I2C_MASTER' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
^
myIMU:312: error: 'I2C_PINS_16_17' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
^
myIMU:312: error: 'I2C_PULLUP_EXT' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
^
myIMU:312: error: 'I2C_RATE_400' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT, I2C_RATE_400);
^
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void
loop()':
myIMU:521: error: 'MadgwickQuaternionUpdate' was not declared in this scope
MadgwickQuaternionUpdate(-ax, ay, az, gx*PI/180.0f, -gy*PI/180.0f, -gz*PI/180.0f, my, -mx, mz);
^
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void
MS5637PromRead(uint16_t*)':
myIMU:1219: error: 'I2C_NOSTOP' was not declared in this scope
Wire.endTransmission(I2C_NOSTOP); // Send the Tx buffer, but send a restart to keep connection alive
^
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'uint32_t
MS5637Read(uint8_t, uint8_t)':
myIMU:1233: error: 'I2C_NOSTOP' was not declared in this scope
Wire.endTransmission(I2C_NOSTOP); // Send the Tx buffer, but send a restart to keep connection alive
^
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'uint8_t
readByte(uint8_t, uint8_t)':
myIMU:1340: error: 'I2C_NOSTOP' was not declared in this scope
Wire.endTransmission(I2C_NOSTOP); // Send the Tx buffer, but send a
restart to keep connection alive
^
C:\Users\mor582\Documents\Arduino\myIMU\myIMU.ino: In function 'void
readBytes(uint8_t, uint8_t, uint8_t, uint8_t*)':
myIMU:1352: error: 'I2C_NOSTOP' was not declared in this scope
Wire.endTransmission(I2C_NOSTOP); // Send the Tx buffer, but send a
restart to keep connection alive
^
exit status 1
'I2C_MASTER' was not declared in this scope
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qqXoICadG4txnzIjhExQx_EsII2hks5sReAMgaJpZM4MPt3I>
.
|
Hello Kris! I have been wondering how to calibrate MPU9250 on Unity. I am using Serial, Madgwick source codes |
Just use the calibration functions from one of my sketches.
…On Wed, Aug 16, 2017 at 12:44 AM, Bobur23 ***@***.***> wrote:
Hello Kris! I have been wondering how to calibrate MPU9250 on Unity. I am
using Serial, Madgwick source codes
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qkzjkfJW0r_9ZecUbz5Q87JY1Txuks5sYp3TgaJpZM4MPt3I>
.
|
Hi Kris, Sorry to bother you again I'm having real problems getting my calibration to work. I have a 9 DOF using on the inside of a large and very magnetic statue of the Moon. The 9 DOF is on the lighting system inside the moon. I have attached some output. I would really value your opinion! It's a standard ax,ay,az,gx,gy,gz,hx,hy,hz format Thanks Nick |
Ok I think my problem is that the statue is fixed and my light assembly moves that is the worst possible combination "It is also important to recognize that effective compensation of hard- and soft-iron distortions is dependent upon the distorting material(s) rotating/moving with the sensor. An example would be mounting the sensor in an aircraft; any materials that are part of the aircraft that exhibit a distorting effect would move as the aircraft and mounted sensor move, and it would generally be possible to compensate for the associated hard- and soft-iron effects. In contrast, it is much more difficult—if not impossible—to compensate for distorting effects exhibited by material external to the aircraft/sensor platform. Thus, it is important to understand not only how compensation may be applied, but also to recognize those conditions under which effective compensation techniques are not possible." So that leaves me with a bit of a problem! Nick |
I think you might want to try this then:
https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution/
we use for small quadcopters with brushed dc motors pulling variable 0 - 2
Amps each so there is a stron fixed and variable magnetic field, yet we
maintain accurate orientation estimation.
…On Mon, Oct 2, 2017 at 7:35 AM, Nick Mortimer ***@***.***> wrote:
Ok I think my problem is that the statue is fixed and my light assembly
moves that is the worst possible combination
"It is also important to recognize that effective compensation of hard-
and soft-iron distortions is dependent upon the distorting material(s)
rotating/moving with the sensor. An example would be mounting the sensor in
an aircraft; any materials that are part of the aircraft that exhibit a
distorting effect would move as the aircraft and mounted sensor move, and
it would generally be possible to compensate for the associated hard- and
soft-iron effects. In contrast, it is much more difficult—if not
impossible—to compensate for distorting effects exhibited by material
external to the aircraft/sensor platform. Thus, it is important to
understand not only how compensation may be applied, but also to recognize
those conditions under which effective compensation techniques are not
possible."
So that leaves me with a bit of a problem!
Nick
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qiHHqFPUTeUPvOJ4u6jHP0vNBztNks5soPS1gaJpZM4MPt3I>
.
|
Can you calibrate the mag inside the globe? There is auto mag calibration
on the EM7180 so might not even be an issue, but if you can manually
calibrate inside it would be easier. No guarantees, but if you can't do an
adequate job with the MPU9250+EM7180 them I would suppose an inexpensive
IMU solution is hopeless.
…On Mon, Oct 2, 2017 at 4:26 PM, Nick Mortimer ***@***.***> wrote:
[image: 19621396_10212892259760688_2032012674_n]
<https://user-images.githubusercontent.com/4338975/31103852-d97f20c6-a80b-11e7-89c8-7a8ff7e5bfe3.jpg>
Thanks once again your input. Here's a picture of the structure, I don't
need to be too accurate but as you can see there is a lot of steel on the
supports, the light system is inside the globe!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qlQiKZuAnjAddDdeIwkiENb5FUVbks5soXE4gaJpZM4MPt3I>
.
|
Yep I was not involved with the design, I wanted shaft encoders on the axis but it was built before I was on board! Yep The cal data I posted is the sensor mounted on the light system. Checking with a standard compass you can get needle reversals at points close to the bottom of the structure! |
Yes, but is a fixed field so can be calibrated out
…On Wed, Oct 4, 2017 at 7:51 AM Nick Mortimer ***@***.***> wrote:
[image: figure_5-1]
<https://user-images.githubusercontent.com/4338975/31182464-82b098b4-a956-11e7-9e2b-628525832ffc.png>
So this is the problem. This was a vertical circle!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qrU6sn3JtauoZyQiko4F5oHufwOaks5so5uLgaJpZM4MPt3I>
.
|
No at this time I can fix the calibration if I'm only interested in one plain as soon as I change the orientation of the sensor and sweep it a gain I get a completely different result mainly because the thing causing the deviation is in a fixed location and thus it's distance to the sensor is varying. I'm going to tell them to get some shaft encoders! Thanks once again for your replies and information! |
Hello kris,
I had some doubt that how can verify data.So,i have verify with android application. I have comparing data with SENSOR KINETICS (app),and its very different readings. So,what should be issue? |
One or both are wrong?
Did you calibrate the sensors?
Are you using an MCU to give a fusion rate > 1 kHz?
Are you feeding the Madwick filter the data in the proper order?
…On Tue, Jan 9, 2018 at 3:53 AM, jenextech ***@***.***> wrote:
Hello kris,
I have used your code with mpu9250 and testing data.
I had some doubt that how can verify data.So,i have verify with android
application.
I have comparing data with SENSOR KINETICS (app),and its very different
readings.
So,what should be issue?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qnkxoYHzKVIblNPMH7spazR1OhNsks5tI1NTgaJpZM4MPt3I>
.
|
I dont know which one is wrong but one of the two is wrong. So,how can i verify raw data as well as all result of code.(yaw,pitch,roll 9 axis data with particular units)? And below lines of code shows that sample rate is 1 kHz. // Configure MPU9250 gyro and accelerometer for bias calculation And i have also one another doubt about quaternions. quaternion is represented by qw + i qx + j qy + k qz. In your code we can get q[0], q[1], q[2], q[3]. Thanks in advanced. |
You didn;t answer any of my questions, hard to help without this info.
…On Wed, Jan 10, 2018 at 2:44 AM, jenextech ***@***.***> wrote:
I dont know which one is wrong but one of the two is wrong.
I have used your code as it is,no any additional configuration has done.
So,how can i verify raw data as well as all result of code.(yaw,pitch,roll
9 axis data with particular units)?
Thanks in advanced.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qjNij-DXEqDobhCspsVljmqHVp3Zks5tJJSKgaJpZM4MPt3I>
.
|
Sorry if i had not respond your question.But i told you. As you asked me about which one is wrong? I want to verify IMU data.So,from android application we can measure 9-axis data. So,how can i verify it?. |
Hi Kris, I went through your accel/gyro calibration with the device at rest, and the magnetometer calibration while performing figure eights. If I rotate the device parallel to the ground, the yaw seems to work well. However, I'm seeing that a change in the roll of the device also causes a large change in the yaw. Any ideas of what might be causing this or where I can look to fix it? Thanks so much for putting this library together! I've modified it from your Stm32 Mbed code to use Stm's HAL library for the Stm32f401. If you would like, I can provide that code for you. |
I will assume you verified that your sensors are properly calibrated.
How are you passing the sensor data tot he Madgiwck or Mahony fusion
filter? NED?
…On Tue, Feb 27, 2018 at 7:01 AM, Hushel Roberts ***@***.***> wrote:
Hi Kris,
I went through your accel/gyro calibration with the device at rest, and
the magnetometer calibration while performing figure eights. If I rotate
the device parallel to the ground, the yaw seems to work well. However, I'm
seeing that a change in the roll of the device also causes a large change
in the yaw.
Any ideas of what might be causing this or where I can look to fix it?
Thanks so much for putting this library together! I've modified it from
your Stm32 Mbed code to use Stm's HAL library for the Stm32f401. If you
would like, I can provide that code for you.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qn0bSSDpwdhTWNRfqPTvLYHsQluxks5tZBjNgaJpZM4MPt3I>
.
|
Yes, I can verify my magnetometer data with a 2-D plot like you have in your magnetometer calibration article. I'm not sure of how I would verify accel/gyro data though after running the calibration on those. Any tips on that would be great. I do see that the accel/gyro trims are within roughly 1-2% of factory settings. Yes, I believe the data is provided in the N.E.D. orientation. I'm using your example code from here: |
mpu9250.MahonyQuaternionUpdate(ax, ay, az, gx*PI/180.0f,
gy*PI/180.0f, gz*PI/180.0f, my, mx, mz);
This is wrong, not NED.
Filter needs, (An, Ae, Ad, Gn, Ge, Gd, Mn, Me, Md).
For gyro and accel calibration. Place sensor flat and motionless. Is gyro
0, 0, 0? Is accel 0, 0, 1?
…On Tue, Feb 27, 2018 at 1:18 PM, Hushel Roberts ***@***.***> wrote:
Yes, I can verify my magnetometer data with a 2-D plot like you have in
your magnetometer calibration article. I'm not sure of how I would verify
accel/gyro data though after running the calibration on those. Any tips on
that would be great. I do see that the accel/gyro trims are within roughly
1-2% of factory settings.
Yes, I believe the data is provided in the N.E.D. orientation. I'm using
your example code from here:
https://os.mbed.com/users/onehorse/code/MPU9250AHRS/
file/4e59a37182df/main.cpp/
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qpyWRgxC8KMoILoDVyII5khyyHCfks5tZHE-gaJpZM4MPt3I>
.
|
Ok, I've remapped those ax, ay, az, etc to the order that the filter expects. It looks like it is working much better now. Thanks for that! For the accel calibration, I'm getting 0.02, 0.01, 1.00 which looks about right. The gyro is giving me values around 0.2, 0.3, 0.01. Are those close enough to zero consider accurate? I'm trying to get this within the 2 degrees of accuracy. |
You might get 4 degrees rms heading accuracy. In part it depends on the
fusion rate your MCU is capable of. What are you using again?
…On Wed, Feb 28, 2018 at 9:16 AM, Hushel Roberts ***@***.***> wrote:
Ok, I've remapped those ax, ay, az, etc to the order that the filter
expects. It looks like it is working much better now. Thanks for that!
For the accel calibration, I'm getting 0.02, 0.01, 1.00 which looks about
right. The gyro is giving me values around 0.2, 0.3, 0.01. Are those close
enough to zero consider accurate? I'm trying to get this within the 2
degrees of accuracy.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qqkbVzua_1WUcdB-SaGKo4kmR0eFks5tZYm9gaJpZM4MPt3I>
.
|
I'm using a stm32f401 running at 84Mhz. It looks like the Teensy runs at 180Mhz, and I'm guessing I need something close to that to get greater precision. |
F401 has an FPU so you will be able to get fusion rates >20 kHz which is
more than enough.
…On Wed, Feb 28, 2018 at 11:41 AM, Hushel Roberts ***@***.***> wrote:
I'm using a stm32f401 running at 84Mhz. It looks like the Teensy runs at
180Mhz, and I'm guessing I need something close to that to get greater
precision.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qhasWL9PmsEv2QZ_aJKBI5KEHNveks5tZav7gaJpZM4MPt3I>
.
|
I have problem with my mpu 9250 .I use this code( https://github.com/kriswiner/MPU-9250/blob/master/MPU9250_MS5637_AHRS_t3.ino) to calibrate .But the values are not changing and I used to get these in serial monitor Gyro temperature is 30.8 degrees C Please help me.I am new |
always zero irrespective of the movements !! |
Are you using the data ready interrupt?
…On Wed, Jun 20, 2018 at 6:47 AM, aabdulkadar ***@***.***> wrote:
always zero irrespective of the movements !!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qoiH3IpBevKtbk5Cx4uYGqzgzVTnks5t-lJ9gaJpZM4MPt3I>
.
|
Thank you for the fast response. I am reading like what I written below / If intPin goes high, all data registers have new data
readGyroData(gyroCount); // Read the x/y/z adc values
} |
" int intPin = 8;"
Are you using interrupt pin on Teenst pin 8?
…On Wed, Jun 20, 2018 at 10:24 PM, aabdulkadar ***@***.***> wrote:
Thank you for the fast response
// If intPin goes high, all data registers have new data
if(newData == true) { // On interrupt, read data
newData = false; // reset newData flag
readMPU9250Data(MPU9250Data); // INT cleared on any read
// readAccelData(accelCount); // Read the x/y/z adc values
here is my reading part
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qtohQkQUmwss3heWLpW60IaXV2_uks5t-y32gaJpZM4MPt3I>
.
|
yes..I checked with 2 and 12 also ..No change |
I changed intpin to 3 and it works Digital temperature value = 20.00 C but even it is at rest,acceleration values are not zero..? |
Dear Kris,
thank you so much for this beautiful library!
Anyhow, I have a small question. I only need acceleration data in my project, but I don't know how to calibrate the IMU.
my Code so far:
The problem is that sqrt(ax^2 + ay^2 + az^2) is not 1 when I don't move the IMU. Can you please tell me, how to calibrate the Sensor? (The problem is still there, if I use the "-myIMU1.accelBias[0];" or not!).
Here are the values with respect to which axis is pointing into the direction of gravity:
Thank you!!
Additionally, it would be nice if you could tell me, how to change the sensors full-scale-range to ± 8g. I changed the code in the MPU9250.cpp file, line185:
but I don't feel that this is how it is meant to be ;)
Steffen
The text was updated successfully, but these errors were encountered: