kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.03k stars 472 forks source link

Stabilization of Yaw #435

Open brrnd99 opened 3 years ago

brrnd99 commented 3 years ago

Hi, im new to MPUs and im currently working on improving the movement of robot so that it could move straightly and turns 90 degree when an obstruction is detected, in this case I will only nid to observe yaw. Im using this with arduino due, but was confused on the selection of code from ur library, cn i know which sketch is more suitable to be used and how what others library should be included too, already had i2c library tho.

kriswiner commented 3 years ago

Could start from here https://github.com/kriswiner/MPU9250/tree/master/AK8963_as_slave or maybe easier here https://github.com/kriswiner/ESP32/tree/master/MPU9250_MS5637_AHRS_UDP.

On Tue, Oct 20, 2020 at 8:08 PM brrnd99 notifications@github.com wrote:

Hi, im new to MPUs and im currently working on improving the movement of robot so that it could move straightly and turns 90 degree when an obstruction is detected, in this case I will only nid to observe yaw. Im using this with arduino due, but was confused on the selection of code from ur library, cn i know which sketch is more suitable to be used and how what others library should be included too, already had i2c library tho.

— 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/435, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKVGNZPVRVBBJY7B4NLSLZGC5ANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

already attempted the mpu9250basicahrs_12c code and it shows mpu failed to connect, tried the wake up code but seems like im lacking of some library. Connection as below: VCC----- 3.3V GND---- GND SCL----- A5 SDA----- A4 ADO---- GND image image Is there issue in my connection?

kriswiner commented 3 years ago

Yup, you are not connecting. What does an I2C scan show?

On Tue, Oct 20, 2020 at 8:18 PM brrnd99 notifications@github.com wrote:

already attempted the mpu9250basicahrs_12c code and it shows mpu failed to connect, tried the wake up code but seems like im lacking of some library. [image: image] https://user-images.githubusercontent.com/73152819/96669058-092b0f00-138f-11eb-8689-c9d6fa54cc4a.png [image: image] https://user-images.githubusercontent.com/73152819/96669103-1c3ddf00-138f-11eb-9aa5-d95322726830.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713269620, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKQZCEEEQ3T7O2Q3ZGLSLZHIVANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

i2c scanner show device found at 0x68

kriswiner commented 3 years ago

Are you using 0x68 as your MPU9250 I2C address?

This doesn't look like one of my sketches. Your I2C "library" is probably fubar...

On Tue, Oct 20, 2020 at 8:25 PM brrnd99 notifications@github.com wrote:

i2c scanner show device found at 0x68

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713272331, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKWWTFAX5L3J6MZVQY3SLZIDJANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

Im using this I2C library below, cn u attached ur version of i2c scanner here please...

include

void setup() { Wire.begin();

Serial.begin(9600); while (!Serial); // Leonardo: wait for serial monitor Serial.println("\nI2C Scanner"); }

void loop() { byte error, address; int nDevices;

Serial.println("Scanning...");

nDevices = 0; for(address = 1; address < 127; address++ ) { // The i2c_scanner uses the return value of // the Write.endTransmisstion to see if // a device did acknowledge to the address. Wire.beginTransmission(address); error = Wire.endTransmission();

if (error == 0)
{
  Serial.print("I2C device found at address 0x");
  if (address<16)
    Serial.print("0");
  Serial.print(address,HEX);
  Serial.println("  !");

  nDevices++;
}
else if (error==4)
{
  Serial.print("Unknown error at address 0x");
  if (address<16)
    Serial.print("0");
  Serial.println(address,HEX);
}    

} if (nDevices == 0) Serial.println("No I2C devices found\n"); else Serial.println("done\n");

delay(5000); // wait 5 seconds for next scan }

kriswiner commented 3 years ago

Your scanner sees fine.

Why not use one of the sketches I linked to?

On Tue, Oct 20, 2020 at 8:36 PM brrnd99 notifications@github.com wrote:

Im using this I2C library below, cn u attached ur version of i2c scanner here please...

include

void setup() { Wire.begin();

Serial.begin(9600); while (!Serial); // Leonardo: wait for serial monitor Serial.println("\nI2C Scanner"); }

void loop() { byte error, address; int nDevices;

Serial.println("Scanning...");

nDevices = 0; for(address = 1; address < 127; address++ ) { // The i2c_scanner uses the return value of // the Write.endTransmisstion to see if // a device did acknowledge to the address. Wire.beginTransmission(address); error = Wire.endTransmission();

if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.println(" !");

nDevices++; } else if (error==4) { Serial.print("Unknown error at address 0x"); if (address<16) Serial.print("0"); Serial.println(address,HEX); }

} if (nDevices == 0) Serial.println("No I2C devices found\n"); else Serial.println("done\n");

delay(5000); // wait 5 seconds for next scan }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713276255, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKTZYIAQ3LTPY5Y5QC3SLZJMHANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

Could start from here https://github.com/kriswiner/MPU9250/tree/master/AK8963_as_slave or maybe easier here https://github.com/kriswiner/ESP32/tree/master/MPU9250_MS5637_AHRS_UDP. On Tue, Oct 20, 2020 at 8:08 PM brrnd99 @.***> wrote: Hi, im new to MPUs and im currently working on improving the movement of robot so that it could move straightly and turns 90 degree when an obstruction is detected, in this case I will only nid to observe yaw. Im using this with arduino due, but was confused on the selection of code from ur library, cn i know which sketch is more suitable to be used and how what others library should be included too, already had i2c library tho. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#435>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKVGNZPVRVBBJY7B4NLSLZGC5ANCNFSM4SZFKULQ .

These? btw isit necessary to use the madgwick filter or its already included in ur sketches ?

kriswiner commented 3 years ago

For example.

Are you using 0x68 as the MPU9250 I2C address? How do you know?

On Tue, Oct 20, 2020 at 8:41 PM brrnd99 notifications@github.com wrote:

Could start from here https://github.com/kriswiner/MPU9250/tree/master/AK8963_as_slave or maybe easier here https://github.com/kriswiner/ESP32/tree/master/MPU9250_MS5637_AHRS_UDP. … <#m7161967903031835223> On Tue, Oct 20, 2020 at 8:08 PM brrnd99 @.***> wrote: Hi, im new to MPUs and im currently working on improving the movement of robot so that it could move straightly and turns 90 degree when an obstruction is detected, in this case I will only nid to observe yaw. Im using this with arduino due, but was confused on the selection of code from ur library, cn i know which sketch is more suitable to be used and how what others library should be included too, already had i2c library tho. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#435 https://github.com/kriswiner/MPU9250/issues/435>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKVGNZPVRVBBJY7B4NLSLZGC5ANCNFSM4SZFKULQ .

These?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713277853, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXYI2EYGPJWRN3Z6ODSLZJ5RANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

im not sure, working on it now( i2c address ).. is the adafruit library in ur sketch working fine with arduino due ?

kriswiner commented 3 years ago

Never used the arduino due, don't know what this is.

What adafruit library?

If you are using adafruit's MPU9250 library, ask them why it is not working...

On Tue, Oct 20, 2020 at 8:45 PM brrnd99 notifications@github.com wrote:

im not sure, working on it now( i2c address ).. is the adafruit library in ur sketch working fine with arduino due ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713279068, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKRBTJHYL3VRL6FWVATSLZKNTANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

For the adafruit thing sorry i overlooked the others code, so does ur sketch ( attached jusnow) includes all the function like i2c scan, main function and library required?

kriswiner commented 3 years ago

Yes, start with this https://github.com/kriswiner/ESP32/tree/master/MPU9250_MS5637 one, it should require minor mods to get it to work...if you don;t have an MS5637 baro, you can comment this stuff out.

On Tue, Oct 20, 2020 at 8:53 PM brrnd99 notifications@github.com wrote:

For the adafruit thing sorry i overlooked the others code, so does ur sketch ( attached jusnow) includes all the function like i2c scan, main function and library required?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713281650, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKUMLDW3NH7KV4R4DHLSLZLLJANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

im trying out with arduino uno, does the esp32 code works find with uno?

kriswiner commented 3 years ago

You'll need to use this https://github.com/kriswiner/ESP32/blob/master/MPU9250_MS5637/MPU9250_MS5637_AHRS.ino sketch, and add this https://github.com/kriswiner/ESP32/blob/master/MPU9250_MS5637/quaternionFilters.ino in the tab for the fusion functions, comment out the MS5637stuff...

On Tue, Oct 20, 2020 at 8:55 PM Tlera Corporation tleracorp@gmail.com wrote:

Yes, start with this https://github.com/kriswiner/ESP32/tree/master/MPU9250_MS5637 one, it should require minor mods to get it to work...if you don;t have an MS5637 baro, you can comment this stuff out.

On Tue, Oct 20, 2020 at 8:53 PM brrnd99 notifications@github.com wrote:

For the adafruit thing sorry i overlooked the others code, so does ur sketch ( attached jusnow) includes all the function like i2c scan, main function and library required?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713281650, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKUMLDW3NH7KV4R4DHLSLZLLJANCNFSM4SZFKULQ .

kriswiner commented 3 years ago

You won't get any yaw accuracy with an AVR MCU, too slow https://github.com/kriswiner/MPU6050/wiki/Affordable-9-DoF-Sensor-Fusion.

But if you make the proper mods, the sketch should at least run.

On Tue, Oct 20, 2020 at 8:58 PM brrnd99 notifications@github.com wrote:

im trying out with arduino uno, does the esp32 code works find with uno?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713283565, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKVKRDF5PBWMMSRN4ELSLZL6HANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

but what if my whole robot already using arduino due, this means i cnt get yaw reading at all? what if i change to mpu6050 then? Any way to solve if arduino uno must be used.. p.s. arduino due is similar with uno

kriswiner commented 3 years ago

In this case, I would use this https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution-lsm6dsm-lis2md/, or this https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution-mpu9250/, or even this https://www.tindie.com/products/onehorse/max32660-motion-co-processor/ for best accuracy.

On Tue, Oct 20, 2020 at 9:14 PM brrnd99 notifications@github.com wrote:

but what if my whole robot already using arduino due, this means i cnt get yaw reading at all? what if i change to mpu6050 then? Any way to solve if arduino uno must be used..

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713288898, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXJ3CSVGHCZH67QU4DSLZNY3ANCNFSM4SZFKULQ .

brrnd99 commented 3 years ago

ok i will try it, cn i ask here further more in future?

kriswiner commented 3 years ago

Ask me specific questions at tleracorp@gmail.com.

On Tue, Oct 20, 2020 at 11:04 PM brrnd99 notifications@github.com wrote:

ok i will try it, cn i ask here further more in future?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/435#issuecomment-713326443, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKTSS2MYQZ7U76YW4ITSLZ2YLANCNFSM4SZFKULQ .