Coder Social home page Coder Social logo

marksherstan / mpu-6050-9250-i2c-compfilter Goto Github PK

View Code? Open in Web Editor NEW
90.0 2.0 23.0 10.12 MB

MPU6050/9250 I2C and SPI interface. Sensor fusion using a complementary filter yields sensor Euler angles and is implemented in five different languages.

License: GNU General Public License v3.0

MATLAB 8.77% C++ 34.68% Python 35.15% JavaScript 4.47% HTML 0.21% Makefile 0.37% C 16.35%
arduino raspberry-pi imu mpu6050 mpu9250 visualization sensor nodejs p5js filter

mpu-6050-9250-i2c-compfilter's People

Contributors

marksherstan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mpu-6050-9250-i2c-compfilter's Issues

Fixing "Slider() has no valstep parameter" error msg

In running magCalSlider.py on Dexter Industries Raspbian for Robots, I received the error:
Slider() has no valstep parameter

pip3 freeze | grep matplotlib reported matplotlib version 2.0.0
sudo pip3 install --upgrade matplotlib fixed the issue (upgraded to version 3.0.3)

(Can mark issue solved/complete.)

Why no accel cal?

main.py runs a gyro cal, but not an accelerometer cal.
Is there a reason?

I created one and get these results:

Calibrating accel with 1000 points. Do not move!
aX std:16.0 min:298 max:402
aY std:17.0 min:8212 max:8316
aZ std:102.0 min:-512 max:-2

Calibration complete
	X accel offset: 351.5
	Y accel offset: 8267.1
	Z accel offset: -237.2

but I haven't tried factoring the offset into processValues()

                # Subtract the offset calibration values for the accelerometers
                # self.ax -= self.aXcal
                # self.ay -= self.aYcal
                # self.az -= self.aZcal

madgwickFilter params

Hi Mark!

You did a good job ;) but looks like something wrong with madgwickFilter in 9DOF/main.py
mx = mpu.my and my = - mpu.mx
Please add notes to your code - i thought it was mistake
// Sensors x (y)-axis of the accelerometer is aligned with the y (x)-axis of the magnetometer;
// the magnetometer z-axis (+ down) is opposite to z-axis (+ up) of accelerometer and gyro!

You can also improve your code when read raw data:

  1. replace

for ii in range(7):
rawData.append(self.bus.read_byte_data(self.MPU9250_ADDRESS, self.EXT_SENS_DATA_00 + ii))
by "rawData = self.bus.read_i2c_block_data(self.MPU9250_ADDRESS, self.ACCEL_OUT, 14)"

  1. and add try/except block - sometime self.bus.read return error while try to read raw data

10 times same Madwickfilter calculation and compFilter not used

In the 9DOF main.py program loop on line 580 you are performing the Madwick filter calculation 10 times with the same sensor values but with a different deltat. Not clear why.

Also the compFilter method in your program is not used and it is not clear why it exists.

bias applied incorrectly in magCalSlider and magCalVisualizer

In the main program magnetometer calibration routine the RAW magnetometer values are captured and the bias and scale factors are calculated.
The instructions say that the RAW values should be stored in data.txt and the bias and scale factor should then be defined in the two visualization programs. These will then display raw and corrected graphs.

In the main program : bias = RAWbias * scaleFactor * factorycalibration and scale=avgrange/axis-range
(where RAWbias=(maxRAW+minRAW)/2)

In the visualization programs however you are applying the bias to the RAW magnetometer values (retrieved from data.txt)
So you are subtracting a bias that is alread corrected with scalefactor and factorycalibration values from a RAW magnetometer value.
I think you should either subtract a raw bias from raw values or corrected bias from corrected values.

Also note that the scalefactor is calculated from RAW values but applied on corrected values. Since these are close to 1 anyway the impact is small.

That is why currently the magCalSlider each time requires further manual adjustment.

(notes :

  1. in the explanation of calibration by Kris Winer and the example routine he provides, you can see the variables mag_bias[ ] and dest1[ ] for the raw and corrected values respectively.
  2. also note that you bias correction in the main program (in the processvalues function) is correct. The error only exists in the visualization programs magCalSlider and magCalVisualizer

Note: AK8963 is set up as slave, not using direct access.

You are making reference to Kris Winer's C programs. Thank you for translating these to Python so I don't have to do it myself.

It is worth noting that on Kris' site the communication with the AK8963 normally is done using direct addressing on main AK8963 address 0C. The host reads the magnometer values directly from the AK8963. The 0C address is also visible with i2cdetect.

Only in a subfolder he explains and shows the setup with the AK8963 as slave, and this is what you are using in your Python programs. This does not work on my MPU9250 and I am not sure why. (maybe it only works for MPU6050?). I am going to change it back to direct communication.

I think it is worth making a note about this in your documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.