Jump to content
  • Join our community

    Sign-up for free and join our friendly community to chat and share all things R/C!

External compass on multiwwi pro flight controller


baorevo

Recommended Posts

I have a flight controller (multiwii pro + gps from h/king)that is very capable on one of my quads but as the frame has power distribution on the chassis pcb style this causes a magnetic field that causes havoc with the onboard compass. This in turn renders the position hold unstable and i cant even try rth or waypoints as it needs a solid compass reading............................

Solution disable the on board compass and use an external one ....................haha but how (they said it cant be done) it can

Now as i cant phsicaly disable the on board compass (if you dont it creates i2c errors due to having 2 modules on the same bus.....i found out the hard way) as you can on some boards i opted for the radical step ......

Rip the sucker off !!!!! well carfully pry it off actually with an exacto knife) the result

bee2f6a1-2689-4346-b34e-098ae858f223_zps

Spot the missing compass chip hehe

heres the external compass module i used an hmc5883l (these can be got from a few places , i got mine here in france but h/king and bangood sell them under a different form with the same reference)

http://www.hobbyking.com/hobbyking/store/__26861__Arduino_HMC5883L_Triple_Axis_Compass_Magnetometer_Sensor_Module_Breakout.html?strSearch=hmc

now you have all you need its time to attack the arduino code

you need to undefine one line in def.h (attention not config.h , this is later)

in def.h do a search for #define MPU6050_I2C_AUX_MASTER

you will get this part of the code

#if defined(FREEIMUv043) || defined(MICROWII)

#define MPU6050

#define HMC5883

#define MS561101BA

#define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}

#define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}

#define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}

#define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050

#undef INTERNAL_I2C_PULLUPS

#endif

You need to undefine #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050

so the code will look like this

#if defined(FREEIMUv043) || defined(MICROWII)

#define MPU6050

#define HMC5883

#define MS561101BA

#define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}

#define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}

#define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}

//#define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050

#undef INTERNAL_I2C_PULLUPS

#endif

its just to stop multiwii looking for the on board compass that we so nicely ripped off and banished lol

next up you need to open config.h

and define the new compass module

so in config h look for this section

/* I2C magnetometer */

//#define HMC5843

#define HMC5883

//#define AK8975

//#define MAG3110

as you can see i have defined HMC5883

now all that is left to do is connect the module to the i2c port that is 3.3v there are 2 i2c ports one is 5v and the other is 3.3v but the pinouts are marked on the board

the compass needs to be orientated as in this photo of mine

IMG_20140614_172232_zpsc676c179.jpg

once youve done all that you need to calibrate the compass and calibrate the acc also while you are at it..... just put it on a mast after like the gps

This is how i have fun on windy hot days lol

Edited by baorevo
Link to comment
Share on other sites

  • 3 months later...

Thanks for the inspiration. I was able to do the same, except removing the 588L chip. I chose to cut the SDL line coming from pin16. This way I can always solder the connection again if I need to use it in the future.

med_gallery_35270_3658_482225.png
After cutting it, I was able to uncomment #define MPU6050_I2C_AUX_MASTER
Then I plugged in the external compass of my GPS (with integrated compass) into the same I2C port you used and it worked. Only problem was the GPS had the mag chip on the other side (upside down)... so I now have my gps antenna pointing down. I'll see about changing the code to invert it if its even possible.
Edited by drvii
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...