Compass setup drives me mad

Hi, I'm trying to setup my quad, using an old APM1 which I bought broken but was able to repair by replacing some parts (mainly ADC converter IC on shield, and a replacing the PPM signal converter AtMega238). Everything is working except that I can't get the compass to work right!

Since the APM doesn't have an integrated magnometer, Im using an external HMC5883L from diydrones (or maybe sparkfun, I cannot tell and don't know since I bought it used).

I've installed in component side up, pins facing backwards (in relation to flying direction and APM placement), which should yeild ROTATION_NONE setting for COMPASS_ORIENT, right?

Anyways, after running live calibration I get the following offsets (-53, -63, -5). I've done this several times and get pretty much the same values everytime.

Now pointing my quad to the north, gives north in HUD correctly, connected to the MissionPlanner via USB. Turning it 180 degrees gives South, everything cool so far. But when I turn the quad from north towards south clock-wise the HUD shows that I'm traversing through West!, The West and East has become swapped!

So I've tried (even if I'm relatively confident of my compass placement) other COMPASS_ORIENT settings, but then everything seems off.

Please help, any ideas?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • ROLL_180 as user defined compass orientation fixed the problem... Still angry at the way it's done tough...

  • Hmm, looking at the code (here at work =), important stuff this is. I can see some fishy things going on:

    In compass.h (libraries):

    #if CONFIG_HAL_BOARD == HAL_BOARD_APM1
    # define MAG_BOARD_ORIENTATION ROTATION_ROLL_180

    So my default mag orientation is ROLL_180...

    And from AP_Compass_HMC5843.cpp (I assume this is also used for 5883L, since there's no specific source for 5883L)

    In method AP_Compass_HMC5843::read() I can see the following:

    // apply default board orientation for this compass type. This is
    // a noop on most boards
    rot_mag.rotate(MAG_BOARD_ORIENTATION);

    // add user selectable orientation
    rot_mag.rotate((enum Rotation)_orientation.get());

    // add in board orientation from AHRS
    rot_mag.rotate(_board_orientation);

    rot_mag += _offset.get();

    This seems to imply that the default hard-coded ROLL_180 is applied ON TOP of the user selectable orientation!, which means I should add another ROLL_180 for user selectable orientation to flip it into correct orientation again... duh, or just edit the code. I was under the impression that the default orientation for each board was set in the COMPASS_ORIENT param on factory reset, not hardcoded...

    I think I'll solve this mystery once I get home. I'll report back with final results (if anyone interrested). I guess noone runs the APM1 boards anymore =)

  • Yeah, me too. I'll try to turn it upside down (components facing down) when I come home from work. Altough it goes against all logic... I'm attaching a picture of the current installation, compass i secured with hotglue in a "snusdosa" mounted approx 10cm above the quad body (to avoid magnetic interference). The GPS is placed beside the compass PCB.

    More info on the setup:

    ArduCopter v3.0.1

    AHRS_ORIENTATION = default (I guess 0).

    There is no special code for the APM1 compass orientation? I'll have to start checking code, maybe it wants it upside down for COMPASS_ORIENTATION 0 as default if running APM1. The guide for APM1 (in the old wiki) tells you to place it upside down, pins forward.

    https://code.google.com/p/ardupilot-mega/wiki/MagAPM1

    However if I was doing such an installation (as per pictures in link), I would think that the ROLL180 would be the correct setting to use.

    photo.JPG

  • I was thinking that maybe the board was upside down.
  • Oops, pins are facing forwards. Got it wrong in first post
This reply was deleted.

Activity