This document describes how to connect an ArduPilotMega with qGroundControl via USB (helpful for first tests of your micro controller).
ArduPilotMega is an Arduino based Autopilot micro controller, programmable with C/C++. Arduino based stuff is nice, because it does not require much of hardware knowledge to get started.
qGroundControl is is a ground station which can be used to fly a UAV/Drone and it can be used to visualize/test/log data from MAVlink compatible devices (for example the ArduPilotMega).
Preparing the ArduPilotMega
There is not much todo on the hardware side as long as you use the official firmware. At the writing of this post, APM 2.1.2 was the firmware used. It can be "flashed" with the Arduino IDE (using avrdude) or with the APM Mission Planner. You have probably already done this.
Secondly, you need to configure your plane. In my case it's a Multiplex funjet. My configuration looks like this.
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-// $Id$
// NOTE: set dip 4 HIGH (for elevon mix)
// DIP Settings for Funjet:
// 1: LOW
// 2: HIGH
// 3: LOW
// 4: HIGH
// Servo channels
// 1: Left Elevon
// 2: Right Elevon
// 3: Throttle
// 5: AP Control
// enable HMC5843 - Triple Axis Magnetometer Rev 1.2
#define MAGNETOMETER ENABLED
#define AIRSPEED_SENSOR ENABLED// #define AIRSPEED_RATIO 1.9936
// ALTITUDE_MIX OPTIONAL
// Configures the blend between GPS and pressure altitude.
// 0 = GPS altitude, 1 = Press alt, 0.5 = half and half, etc.
//#define ALTITUDE_MIX 0.5
Once you have compiled and uploaded the code and your configuration you are ready to test sensor data in qGroundControl. Note that no special configuration is needed for the MAVLink protocol on the APM side (as of V 2.1.2) which communicates with qGroundControl.
Make sure that SW2 on the APM is set to flight mode (turned to flight direction) and connect APM via USB cable to your computer.
You might first test if the APM is sending some binary output over USB. To do this use your favorite terminal program (like hyperterm.exe, minicom or Arduino IDE's Serial Console).
When verified that the binary serial output is sent, start qGroundControl and click on the "Connect Link" Button. The default settings are reasonable, make sure using 115200 baud and select your serial port.
Now change to Engineer's view. You might not get any data yet (left panel with sensor options is empty). In this case APM does not yet know what to transmit. Make sure the «Calibration and Onboard Parameters» widget is shown. Insert 3.3, 10 or 50 Hz in all possible data streams. I read that 50Hz is preferable because the main loop of APM runs on 50Hz. If it causes problems with the serial connection, a lower frequency might help. As soon as these values are set, they are stored in the APM's EEPROM. So these values are present after a reboot of the APM which (I think) is a really nice feature.