# PixHawk Flashing and Setup

This guide will show you how to install, flash and configure the PixHawk. I'll be using Rctimer's distribution of the PixHawk, which is called the FixHawk. From now on, I'll use these terms interchangeably. The FixHawk will be installed and configured in an Rctimer Q600 quad-copter, which I highly recommend if you're looking for an awesome frame, but these directions should apply to any quad-copter installation and configuration.

## Overview

The PixHawk hardware and software is an open source project. The original development and current maintainers are led by Lorenz Meier at ETH Zurich.

### Open source designs

The open source hardware design means that anyone can produce the Pixhawk hardware and the boards are fundamentally the same. There is no such thing as a "clone" when the plans are freely available via open source. They can be made by anyone and Rctimer has done a great job building their "FixHawk", which is one of these boards.

You'll want to wire it up like this. The ports are all labeled, so you shouldn't have much trouble:

## Ground Station Program

There are 3 different ground station programs you can use to flash and configure your flight controller. The ground station program you use will determine the firmware that is installed on the flight controller.

• QGroundControl

• Newest ground station program, maintained by Lorenz Meier at ETH Zurich. Not as complete, time tested or robust as APM, but new features like position hold via lidar and other cool things are coming to this software stack

• Installs the newest firmware (px4)

• Mission Planner

• Has the most guides / documentation online

• Windows Only

• It has the most features

• Installs the older but more robust, APM firmware

• APM Planner 2.0

• Cross Platform, I use this ground station program on my mac

• It does not have all the features of Mission Planner, but it has almost all of them

• Installs the APM firmware, which is the same as Mission Planner

• Go to Downloads and scroll to the bottom of the page.

Before we configure the flight controller, let's setup our radio. I'm using 9x with OpenTX on it. My radio doesn't have a 6 position switch, so I'll make one.

We'll configure a 6 position switch by mixing a 2 position switch with a 3 position switch.

• go to channel 5 on the mixer tab, assign Source to the 3 position switch 3POS and the CURVE to CV3, hit exit to go back to the menu tab

• press menu to highlight the row for channel 5, then press down to add a mixed input to channel 5

• click and hold menu on the new row and set the input to AIL, change the curve back to the default, Diff 0

• go to the curves tab and pick curve 3, change the type to 3 point and set the points to 81, 48 and 15. hold exit to get out of the curves edit page

checkout Mark's awesome guide for a full explanation: http://eastbay-rc.blogspot.com/2013/06/opentx-setting-six-position-switch.html

You should get this when you're done:

CH05
+100%3POS Curve(Curve 1)
* +100%AIL


## Flashing and Setup

If you want to use the newer PX4 firmware, the only docs are for "developers" over at dev.px4.io, but they are applicable to users as well.

### PX4 Firmware

For initial setup, you should follow this video guide:

### APM:Copter Firmware

Since APM is time tested and proven, I'll be using that. I hope that PX4 will be as usable and well documented soon and I can switch over.

Pick the Initial Setup tab, go to Install Firmware Pick APM:Copter V[some numbers] Quad

Click Yes when it asks if we're sure we want to upload the firmware.

When it asks to unplug the board, unplug the board, then hit OK after you plug it back in.

I had some trouble flashing the board with my mac and VMWare Fusion, so I had to switch to my windows laptop.

Eventually, you'll get a success message and it will tell you that if this is the first time flashing 3.2, you'll need to re-calibrate your compass.

Disconnect the USB cable and connect the Radio Telemetry. Pick the COM port, set the baud to 57600 and hit connect.

Pick Wizard tab on the left and follow the guide. This will walk you through the copter configuration.

When you get to the RC calibration screen, disable the CURVE you set on channel 5 by setting it back to the default value while you set the endpoints on all channels. When you're done, turn CURVE 3 back on.

Pick the COM port and set the baud to 57600

If your telemetry won't connect, and you've re-wired your own cable like I have, try swapping the RX and TX pins. That worked for me :)

### Voltage and Current Monitor

Voltage and current monitor configuration can be found under Inital Setup -> Optional Hardware -> Battery Monitor -> Advanced

If you're using the Rctimer 90A, 7S Power Module, you'll want to use these settings:

# Pins are from the pixhawk pinout description
Voltage Pin: 2
Current Pin: 3

# I found this value by adjusting it while measuring the battery voltage with an external battery checker
Voltage Divider (calced): 10.35

# This is a 0-offset, 90A sensor that outputs up to 3.3V, so 90A/3.3V gives about 27 Amps per Volt
Amperes per volt: 27


Be sure to set the proper FS_BATT_VOLTAGE, even if you're not using the battery failsafe, to get an audible alarm via the buzzer when the battery is low.

Also, you can set the ARMING_MIN_VOLT to make sure you don't take off with too low of a voltage.

Here's what the settings look like in APM Planner 2.0

Check on the radio calibration tab, that when you move the rudder stick (left stick in my case) the YAW channel moves left and right.

Flying PPM on mode 2, I needed to swap my RCMAP_ROLL and RCMAP_YAW. You can find these under the Config/Tuning tab -> All Settings

Once configured, test your failsafe settings as described in the APM guide and below. If you do not configure and test your failsafe, your copter could fly away. Do not skip this!

Be sure that on a failsafe event, channel 5 is set to RTL, Loiter or LAND. See this warning for details.

Using ArduPilot, your receiver must output analog RSSI, with any voltage range (e.g. 0-3.3v or 0.5.0v). Unfortunately, reading RSSI injected into a RC channel is not supported. Connect:

Receiver Out -> PixHawk In

PWM or SBUS Output -> RC Pin


Then set

RSSI_PIN = 103


#### Throttle Failsafe

Start by testing your throttle channel. When you turn off the radio, it must go at least 10 points lower than the Throttle Failsafe PWM value. I increased the Throttle PWM value to 980 to ensure this happens. This test makes sure that the Throttle Failsafe action occurs when the radio link is lost.

#### Immediate Disarm Failsafe

Next test that the copter is disarmed from stabilize or Acro mode when the throttle is 0 and the radio link is lost. Turn on everything, with props removed, arm the copter in stabilize or acro mode then turn off your transmitter. The copter should disarm immediately.

#### Land or RTH Failsafe

Test that the copter returns to home (if there is a GPS lock and there was a GPS lock when armed) or lands (if no GPS lock or home position was set). Connect to the copter via Telemetry. Turn everything on, with props removed, arm and throttle up. Turn off the transmitter. Watch your ground station, the flight mode should switch to LAND or RTH.

If you can, test once without a GPS lock and then test with a GPS lock and ensure the mode changes to LAND the first time and RTH the second time.

#### Retake Control After Failsafe

Ensure you can re-take control after a failsafe event. Trigger a failsafe with the throttle up, as in the test above, but immediately turn your transmitter back on. Then try changing flight modes. You should regain control and be able to switch flight modes.

#### Other Failsafes

There are a few other failsafes that do not require configuration, but you should be aware of:

• EKF / DCM Check & Failsafe

• This is essentially GPS failsafe. If the copter's IMU estimates do not match the GPS position. EKF will be triggered. By default the action is to LAND when this happens, you can change it to AltHold with the FS_EKF_ACTION setting.

#### Landing

By default, after returning home, the copter will land. Change this with the RTL_ALT_FINAL parameter, if you want it to over instead of land.

### GPS Setup

Once you get your firmware installed and configured, sit the copter by a window or outside and plug in the USB or a battery and wait until it has a 3D GPS lock.

• Mission Planner's main screen will show you the GPS lock status

• For PX4, if you open QGroundControl and under Widgets pick the MAVLink Inspector, you can monitor the raw GPS data.

### Compass

Before you fly, you should verify that the magnetic interference from your motors will not disorient your copter. If you fail to do this and your motors generate too much magnetic interference, your copter will behave highly erratically or even fly away. Do not skip this!

To do this, strap down your quadcopter (or put the props on the wrong way, so that when turned on, they push the copter towards the ground).

Always use threadlock when securing your prop nuts or use nylock nuts.

Then launch the Compass Motor Configuration from the Initial Setup -> Manditory Hardware -> Compass.

With props on, and the copter secured, press and hold the arm button. Click start in the ground control app on the Compass Motor Configuration page.

Slowly and smoothly throttle up to 75%, wait 5 to 10 seconds and cut the throttle quickly. You'll see a chart like this. The screenshot below is from APM Planner 2.0:

Interference under 15% is safe. 15-30% is probably OK. If you see interference go over 30%, you should move your magnetometer (usually attached to the external GPS) further away from any ESC power wires.

### Gimbal

Let's configure the ASP Gimbal to allow extra RC channels to control Pitch and Yaw.

First, I mapped channels 6 and 7 to the potentiometers (nobs) on my transmitter. I also assigned a single switch to the channels. I used the same switch for both channels, so that when the switch is off, the two channels are set to their mid-point, 1500, and when they switch is on, both channels get values from the potentiometers. I also mapped this switch to channel 8 on my transmitter and will configure it to pass through to the gimbal controller.

Then I enabled RC pass-through on the PixHawk by setting:

RC6_FUNCTION=1
RC7_FUNCTION=1
RC8_FUNCTION=1


This will allow the values from the transmitter to pass-through the PixHawk. Connect the gimbal's RC_PITCH and RC_YAW to channels 6 and 7 in the OUTPUT pin group. I also connected channel 8 to the RC_ROLL channel, however I'll be using this to control the gimbal mode, not the roll, see the configuration below.

Then configure the gimbal using SimpleBGC:

Note that I've set the Low command to Level Roll and Pitch to Horizon, this is so the camera keeps it's normal orientation when the transmitter switch is off. If this were not enabled, the gimbal would stop wherever it was when the switch was flipped from on to off, instead of returning home.

Set pitch and yaw limits along with any channel reversing you want. I also set the expo to 70 and doubled the limit acceleration value, for finer grain control:

### OSD

Jump the minimosd 5v pads and do not connect the 12v line from your video transmitter to the OSD. Bypass the OSD and send 12v straight to the camera.

Connect the OSD UART to TELEM2

See the OSD Guide for more wiring information.

I used a Sony Super HAD camera with a plastic case an mounting bracket, like this one: http://www.surveilzone.com/26%2A26mm-Plastic-Case-13-CMOS-700TVL-Mini-CMOS-Camera-Super-WDR-g-1414

It fits nicely here, just bolt it on with a few 3mm bolts:

Open OSD_Config.exe in the Released folder and make sure your video format matches the camera you're using:

Update the firmware:

Update the charset:

Then configure the OSD:

Finally, configure the flight controller to send data to the MinimOSD. In Apm or Mission Planner, open the Full Parameter list and search for SR2

Enter the following values:

SR2_EXT_STAT, 2
SR2_EXTRA1, 10
SR2_EXTRA2, 10
SR2_EXTRA3, 2
SR2_PARAMS, 10
SR2_POSITION, 3
SR2_RAW_CTRL, 1
SR2_RAW_SENS, 2
SR2_RC_CHAN, 2


Hit Write to to write the parameters and test it out.

The full MinimOSD Extra manual is here: https://github.com/diydrones/MinimOSD-Extra/wiki

At this point, you can put on your ABS props and test fly or head back to the ASP Gimbal Build and Setup guide or the Q600 Build.