Forum Rule: Always post complete source code & details to reproduce any issue!
Page 7 of 7 FirstFirst ... 5 6 7
Results 151 to 158 of 158

Thread: MPU-9250 Teensy Library

  1. #151
    Senior Member ninja2's Avatar
    Join Date
    Aug 2016
    Location
    Adelaide, Australia
    Posts
    151
    To what extent does the accuracy of calibrateAccel depend on how well/accurately I position the IMU relative to the true vertical, and for each of the 6 axis positions? This strikes me as the achilles heel, but maybe your routine is smarter than I realise.

  2. #152
    Senior Member brtaylor's Avatar
    Join Date
    Mar 2016
    Location
    Portland, OR
    Posts
    235
    Quote Originally Posted by hw999 View Post
    Hi Brian, of course I noticed the terminal messages. A couple of times telling me "switch". I coded a calibration routine for the 9250 as well - quite dumb with instructions how to position the sensor. I suspected in your calibration must be some magic that does the calibration without positioning the sensor. Have the impression just switching the light on and off does the trick. (please don't take my comment too serious).

    By the way - why six times ? x-axis positive/negative etc ? I did three measurements - one for each axis, positive or negative did not matter.
    You won't be able to estimate both a bias and a scale factor unless you do both the positive and negative direction for each axis; you would only be able to estimate one of those by either attributing all error as a bias or all error as a scale factor. By adding the extra information through doing both directions for each axis, you're able to use the higher order error model.

  3. #153
    Senior Member brtaylor's Avatar
    Join Date
    Mar 2016
    Location
    Portland, OR
    Posts
    235
    Quote Originally Posted by ninja2 View Post
    To what extent does the accuracy of calibrateAccel depend on how well/accurately I position the IMU relative to the true vertical, and for each of the 6 axis positions? This strikes me as the achilles heel, but maybe your routine is smarter than I realise.
    My code isn't that smart. Eventually, I'd like to do something like a gauss newton sphere fitting model, but I was running into other error sources for that, so for now I'm just using the min and max values measured in each axis. So error in orientation during calibration leads to error in the output value.

    If we consider vertical to 0, the error in terms of m/s/s would then be:
    Code:
    9.807*sin(angle, rad)
    The bias in each axis is estimated as:
    Code:
    (min + max) / 2
    And the scale factor in each axis is estimated as:
    Code:
    9.807/((abs(min) + abs(max)) / 2)
    Last edited by brtaylor; 12-27-2017 at 11:13 PM.

  4. #154
    Senior Member
    Join Date
    Jul 2014
    Location
    New York
    Posts
    547
    Hi Brian,

    Eventually, I'd like to do something like a gauss newton sphere fitting model, but I was running into other error sources for that, so for now I'm just using the min and max values measured in each axis.
    I have a windows app that was converted from python that does exactly what you want. It is essentially Fabio Versano wrote for his FreeIMU. Had to make a couple of minor modifications though. If you want it is posted at: https://github.com/mjs513/FreeIMU-Up...er/FreeIMU_GUI, sources and exe version. There is an option to save to eeprom - never tried it though.

    Mike

  5. #155
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    5,187
    mjs513 / brtaylor:
    To get my onehorse bottom mounted i2c MPU9250 to work on T_3.6 it uses Wire and works with: MPU9250 IMU(Wire,0x69, 47, 48); // Set scl=47 and sda=48 { he just restocked these so they are in production }

    I edited the MPU9250 to allow this : MPU9250(TwoWire &bus,uint8_t address,uint8_t sclPin=255,uint8_t sdaPin=255);

    Since that works on Wire with setSCl and setSDA I have working changes and was going to offer a pull request.

    Then I saw the mjs513 fork that changes to i2c_t3 for Teensy - this likely would be better in long run.

    Brian - do you anticipate altering your 'master' branch one way or another - or should I fork mjs513?

    I've got the GPS PPS on interrupt giving cycle counter resolution for TIME_STAMP for GPS Serial start bit and was going to do the same for the MPU9250 i2c interrupt - now that I found my T_3.6 with the 9250 soldered on.

    As long as (typically unused) cycle counter is not zeroed elsewhere - it is perhaps 99.8% in +/- 13 cpu ticks (in 55 hr run) - and the math/return is over 6X faster than micros

  6. #156
    Senior Member
    Join Date
    Jul 2014
    Location
    New York
    Posts
    547
    @degragster:
    My 9250 fork/pull request was actually against Brian's old MPU9250 library that used the i2c_t3 library. He recently changed to use just wire/spi so the library could be used on other boards besides the teensies. The library has also changed a bit since the original implementation so my fork has actually been obe'd. So don't fork my version, its not the latest version. Probably should have closed it. Think you might be using an older version of the 9250 library if it is still using i2c_t3?

    PS. I've been using Onehorse's MPU-9250 breakout board exclusively for these tests. Great little board.

  7. #157
    Senior Member brtaylor's Avatar
    Join Date
    Mar 2016
    Location
    Portland, OR
    Posts
    235
    Quote Originally Posted by defragster View Post
    mjs513 / brtaylor:
    To get my onehorse bottom mounted i2c MPU9250 to work on T_3.6 it uses Wire and works with: MPU9250 IMU(Wire,0x69, 47, 48); // Set scl=47 and sda=48 { he just restocked these so they are in production }

    I edited the MPU9250 to allow this : MPU9250(TwoWire &bus,uint8_t address,uint8_t sclPin=255,uint8_t sdaPin=255);

    Since that works on Wire with setSCl and setSDA I have working changes and was going to offer a pull request.

    Then I saw the mjs513 fork that changes to i2c_t3 for Teensy - this likely would be better in long run.

    Brian - do you anticipate altering your 'master' branch one way or another - or should I fork mjs513?

    I've got the GPS PPS on interrupt giving cycle counter resolution for TIME_STAMP for GPS Serial start bit and was going to do the same for the MPU9250 i2c interrupt - now that I found my T_3.6 with the 9250 soldered on.

    As long as (typically unused) cycle counter is not zeroed elsewhere - it is perhaps 99.8% in +/- 13 cpu ticks (in 55 hr run) - and the math/return is over 6X faster than micros
    You should be able to use the following with the most current version of the MPU-9250 library:

    https://github.com/bolderflight/MPU9250

    Code:
    MPU9250 IMU(Wire,0x68);
    
    void setup() {
      Wire.setSCL(47);
      Wire.setSDA(48);
      IMU.begin();
    }
    As Mike pointed out, I switched from i2c_t3 to Wire a few months ago to enable the library to be used on other Arduino devices. Thankfully, for Teensy LC and 3.x, the Wire.setSCL and Wire.setSDA functionality is still present.

    Brian

  8. #158
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    5,187
    Indeed as shown in setup() - "Wire.setSCL(47); and Wire.setSDA(48);" - works since the pins are native to Wire.

    I went in expecting to add i2c_t3 to get underpins - when I was looking in WIRE source and reminded of the setSDA/SCL - so put that into class .begin as suggested above. Then gIthUb stole some life from me as I wandered around seeing and not seeing i2c_t3 between old branch and Mike's fork - and indeed I saw that was an old fork.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •