Testing a DIYDrones magnetometer in HK's GCS

Testing a DIYDrones magnetometer in HK's GCS from Pete Hollands on Vimeo.

I test the DIY Drones magnetometer ( HMC5843 magnetometer breakout board ) using Happy Killmore's Ground Control Station connected using SERIAL_UDB_EXTRA telemetry format, to a UAV DevBoard V3 running
MatrixPilot (revision 729 of trunk).


UAVDevBoard / MatrixPilot:​p/​gentlenav/​wiki/​Home?tm=6

HK GCS:​p/​happykillmore-gcs/​

DIY Drones Store:​HMC5843_Triple_Axis_Magnetometer_p/​br-hmc5843-01.htm

Self Calibrating Mathematics, and software to integrate via I2c written by William Premerlani:-​profile/​WilliamPremerlani

Source Code:​p/​gentlenav/​source/​browse/​trunk/​libUDB/​magneto_udb.c

E-mail me when people leave their comments –

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

Join diydrones


  • Well,

    I just tried running the same test again and I couldn't get the serial connection. I had to go into the Vista device manager and disable/enable the com port and that did the trick.

  • Hi pixhawk,

    I was using COM port 9 on my Vista laptop and getting data on the debug console window.

    I just tried it again and it's working. My only guess is I was doing the wrong sequence of operations?

    It didn't work on my first three tries. If I figure out what went wrong, I'll post it. Anyway, here is a picture of the GCS running successfully on Vista......

  • Hi!


    Do the Vista issues persist? In case yes, can you give me the COM port number you were trying to connect to? We're using it on XP, Vista and Win 7, so there should be no issue.

    And another question: Do you see any data in the debug console window when connecting the serial port? If you select the right serial port from the drop-down, you should see some kb/s indication and raw data.

  • Developer

    @Bryan. Very Cool. That's super to see these GCS's being put to good use.


    BTW: Bill gave some simple and good advice. When positioning the magnetometer, and checking for motor effects, it's best to have an ordinary old fashioned hand compass in hand.

  • Developer

    @HK, I actually was not that sure about the units for vx,vy,vz so I went with meters / second. (that is what it should be as MAVlink is using standard SI units).

    vx is meter / second East. vy is meters / second North. So you need the square root (vx ** 2 + vy **2) for ground speed in m/s . And a tan2(vx,vy) to get the angle in radians (not sure about parameter order there), before converting to degrees of the compass.

  • Pete, I've got it in MAVlink, I just didn't know if there were any accel, gyro or mag data in MatrixPilot.


    Also, how should I use vx and vy to get ground speed in the Global Position message?

  • Pete,

    I just ran qgrouncontrol on my desktop running XP and it worked. Mystery solved....

    Here's a pic of Mag output deviation when a magnet was placed nearby.


  • Developer

    HK,  I think you were looking for the magnetometer data ? It is part of the following message which you are already parsing ...(It's the third triplet after accelerometer and gyros).

    mavlink_msg_raw_imu_send(MAVLINK_COMM_0, usec,
                     (int16_t)   udb_yaccel.input,
                     (int16_t) - udb_xaccel.input, (int16_t) udb_zaccel.input,
                     (int16_t)   ( udb_yrate.input + 32768 ),
                     (int16_t) - ( udb_xrate.input + 32768 ),
                     (int16_t)   ( udb_zrate.input + 32768 ),
                      (int16_t) magFieldRaw[0], (int16_t) magFieldRaw[1], (int16_t) magFieldRaw[2]) ;


  • Yes, GPS raw. I'll have to look into that "Global Position" message.


    I'll also have to take a look at QGroundControl to scale my output. Thanks Pete...


    EDIT: Pete, how should I use vx and vy to get ground speed?

  • Developer

    @HK, so the MAVLink messages for sensors are starting to come through. I don't think the X-Accel value is always correct. And the X gyro in the enclosed picture is definitely wrong (although usually it's correct). I enclose the corresponding QGroundConrol graph from the same session. Thanks.


    You will not in the enclosed picture that HKGCS does not use the "Global Position" message that I'm sending from MatrixPilot. (No Lat, Long or Altitude). I expect you are using the GPS raw message for now ?  Pete


This reply was deleted.