|Sep 08, 2013, 05:58 PM|
Joined Mar 2013
Upgrading My F450 Quadcopter from kk2.0 to ArduFlyer/APM 2.5
Upgrading My F450 Quadcopter from kk2.0 to ArduFlyer/APM 2.5
Like many drone enthusiasts, my first DIY quadcopter build used the HobbyKing KK2.0 flight control board. I went through several iterations of my KK2.0 quadcopter and I still highly recommend the KK2.0 for beginners and anyone looking for an affordable, capable flight control board. It's got support for just about any multirotor configuration you can imagine and the auto-level feature is solid, especially with updated firmware. However, I wanted to try out a more advanced flight control board because I have a strong interest in autonomous flight and wanted to be able to program waypoints and missions. After doing a ton of research about the various autopilot flight control boards out there, I decided on the APM and more specifically, the APM clone ArduFlyer from RCTimer. Identical to the 3DRobotics APM and available at a lower price point, the ArduFlyer boasts capabilities comparable to some other flight controllers that cost literally thousands of dollars more. Along with the ArduFlyer, I will be using the RCTimer 915MHz Telemetry Kit and the u-Blox CN-06 GPS Receiver v2.0.
Preparing the ArduFlyer Board
The cables that come with the GPS and the telemetry air module can be set aside; they don't fit the ArduFlyer, which comes standard with two cables for connecting the GPS and telemetry. Also included with the ArduFlyer is a packet of headers. One drawback of the ArduFlyer compared to the 3DRobotics APM is that you must solder the headers on the board yourself. That's the first step I took to get this project going. I chose to use the straight headers as opposed to the 90 degree 'side-entry' set. One of the sets of 8 headers goes on the "Inputs" section at one end of the board and one goes on the "Outputs" section at the other end. The long set goes on the side where the USB plug is. You can optionally remove the last two rows of three pins on the long set of headers as shown in the photo below. Use a sharp utility or exacto knife to carefully cut the plastic. If you plan on powering the ArduFlyer using the built in BEC in your speed controllers, be sure to solder the two pin header into the holes labeled JP1. That's what I'll be doing initially. Later on I'll add a UBEC or 3DR power module.
Here's the back view with another look at the JP1 placement. Be sure all the solder joints are secure and that there are no shorts.
Mounting the ArduFlyer to the Frame
Once all the headers were soldered onto my ArduFlyer, the next step was to clear off some space on my FlameWheel F450 frame. I removed the KK2.0 board, the receiver, and the Velcro holding them both down. I cleaned the surface well so I would be able to attach the new board securely. I also removed the propellers, because I'll need to calibrate my radio and ESCs later on and don't want to risk losing a finger.
Using a couple of strips of foam double-sided tape, I mounted the ArduFlyer in the exact center of the frame, being careful to orient it so that the "Front" arrow on the board pointed towards the front of my quad. In this case the white arms on the frame are in the front.
Connecting the ESCs to the ArduFlyer
Once the board is secured on the frame, the next step is to connect the ESCs. Coming from a KK2.0, you will notice that the motor numbering is different with the ArduFlyer. The ESC cables plug into the "Outputs" section at the back of the board. For an X configuration quadcopter, the top right motor is #1, the bottom left motor is #2, the top left motor is #3, and the bottom right motor is #4. Here's a handy diagram showing the motor number layout as well as the direction of rotation and the type of propeller each motor should use.
Here's my quad with the ESC cables attached to the ArduFlyer. The black wire of the ESC connection should be on the edge of the board, and the white wire should be on the innermost pin.
Installing the GPS and Telemetry Radio
Next, I attached the GPS and telemetry air module to the frame and plugged the cables into the appropriate places on the ArduFlyer board. I secured both with double sided foam tape, and added a couple of small zipties to the GPS unit as well. Note the placement of the telemetry air module. Be sure not to block any connectors on the ArduFlyer board.
Turnigy 9x Receiver Installation
Next I added the Turnigy 9x receiver, held to the frame with a strip of industrial strength Velcro, and attached the wires to the ArduFlyer. The receiver wires attach to the header on the front of the ArduFlyer board labeled "Inputs" and start with #1, which is the furthest away from the edge of the board with the USB port. For the Turnigy 9x, the receiver should be attached as follows. You can get flying with just channels 1-4, but you'll want the ability to set up a few different flight modes to take full advantage of the ArduFlyer.
Channel 1 - Input 1
Channel 2 - Input 2
Channel 3 - Input 3
Channel 4 - Input 4
Channel 5 - NOT CONNECTED
Channel 6 - Input 5
Channel 7 - Input 6
Channel 8 - Input 7
The channel 1 - input 1 connection should be made using a 3 wire servo lead. On the receiver, the black or brown wire goes towards the bottom of the receiver and on the outer edge of the ArduFlyer board. The rest of the channels can be connected using single jumper wires, because only one of the pins for each channel needs to be connected. Another option is to use standard 3 wire servo leads and remove two of the wires. For all channels besides channel 1, connect the top pin on the receiver with the innermost pin on the ArduFlyer. Here's a closeup.
Before flying, I tucked the receiver antenna wire snugly through one of the holes on the frame arm to keep it away from the propellers.
Covering the ArduFlyer Barometer
The last thing to consider as far as the physical assembly goes is the barometer. On the ArduFlyer, the barometer is used for altitude sensing and is a small silver rectangle near the front of the board with two small holes in the top. Light and wind can affect the barometer reading, so to alleviate this and get more accurate altitude data, it is recommended to attach a small piece of dark colored foam to the board to cover the barometer. I used a tiny square of non-conductive dark grey foam and hot glued it to the board on each side of the barometer. Make sure not to get any glue into the holes on the barometer. Some recommend using tape to hold down the foam, which would also work.
Barometer with foam glued over it.
That's pretty much it for the build as far as hardware goes. Now its time to install the open source Mission Planner software, connect to the ArduFlyer, and configure the settings for my maiden flight.
Installing Mission Planner and Connecting the ArduFlyer
I went here to download the latest version of Mission Planner. I use it on a MacBook Pro running Windows 7 via Bootcamp. Installation for me was completely painless. If you have trouble, consult the resources at the bottom of this post for help and troubleshooting. Be sure you don't connect the ArduFlyer to your computer before you install Mission Planner, as that can apparently cause problems with driver installation.
Once Mission Planner was installed and running on my computer, I connected the ArduFlyer board to the computer via a micro USB cable. The LEDs on the ArduFlyer board should light up and start blinking. Here's an article from the APM wiki that shows where the various LEDs are on the board and what they mean.
LEDs and their behavior
Power (Green): On when powered
A (red): Solid = armed, motors will spin when throttle raised; Single Blink = disarmed, motors will not spin; Double Blink = disarmed, motors will not spin, cannot arm because of failure in pre-arm checks
B (yellow): Only flashes along with A and B during calibration or as part of the in-flight auto trim feature
C (blue): Solid = GPS working, 3D lock; Blinking = GPS working, no Lock; OFF = GPS not attached or not working
PPM/Serial: Flashing when data detected
The first time you plug it in, the power LED will be on, and the red and blue LEDs will start blinking. It might take a moment for the red and blue to start blinking. Depending on your location the blue GPS indicator light may go solid after a few minutes, indicating a GPS lock. However, if you are inside it might not get a lock so don't worry if it doesn't. It is tempting to click the "Connect" icon at the top right of the Mission Planner interface immediately, but don't do it. First you'll have to load the correct firmware onto the ArduFlyer.
Installing the Quadcopter Firmware on the ArduFlyer with Mission Planner
The first step in configuring the ArudFlyer is to load the firmware for the type of vehicle you have. I will be loading the Quadcopter firmware (choosing the specific type of quadcopter configuration such as"X" or "+" comes later).
To do so, I clicked on Initial Setup in the top row of icons, Install Firmware on the left sidebar, and finally the quadcopter icon with "Arducopter V3.0.1 Quad" under it (note that the firmware version number will change as updates are released, so it might not always say V3.0.1).
Once I did that, the firmware was uploaded and then verified.
Connecting Mission Planner to the ArduFlyer
Now that the quadcopter firmware is loaded, it's time to connect Mission Planner to the ArduFlyer. Click on the Flight Data icon at the top of the screen, which will bring you to a screen with the heads up display and sensor data on the left side of the screen and the Google satellite map on the right side. Make sure the correct COM port is selected at the top right and that the baud rate is set to 115200. I only had one COM port available, so it wasn't hard to figure out which one it was. If you have multiple COM ports and you aren't sure which one it is, there are some tricks to figure it out. See the resources section at the end of this post for helpful troubleshooting links.
Once you have the correct COM port selected and the baud rate set to 115200, click Connect. A dialog box will pop up as the software attempts to connect to the ArduFlyer. It will start a countdown, and in my experience it rarely takes more than a few seconds to connect and start getting parameters.
Once the connection is established the red plug in the top right corner will turn green and the Mission Planner interface will start displaying data from the sensors on the ArduFlyer. You can verify the sensors are working by tilting and moving the quadcopter and watching the heads up display in Mission Planner. In my case, I also had a GPS lock so it displayed my location on the map.
Configuring and Calibrating the ArduFlyer
Now that I've got a successful connection, I can continue with configuring and calibrating the ArduFlyer board. Back in the Initial Setup section, there are some more menu options available on the left side. First, I'll need to tell my ArduFlyer that I want my quadcopter to be flying in X configuration. To do so, I clicked on Frame Type on the left sidebar and selected the "X" option.
Next I moved on to Compass. Under Orientation, I selected On Board APM because I'll be using the built in compass instead of an external one.
After Compass, I clicked on Accel Calibration, which is where I'll calibrate my ArduFlyer's sensors. I clicked on the green Calibrate Accel button in the center of the screen, and followed the instructions. It prompts you to set the quadcopter level, on its left side, on its right side, nose down, nose up, and on its back. Afterward if everything went smoothly, it will say "Calibration successful."
Setting up Multiple ArduFlyer Flight Modes on the Turnigy 9x Radio
I'm using the Turnigy 9x 9 channel radio, which is a popular radio among multirotor builders. It's affordable and has a strong feature set. For other radios, the next few steps will be slightly different. Before calibrating the radio, I had to do some configuration on the transmitter itself to enable switching between flight modes. The ArduFlyer allows for six flight modes to be pre-programmed and you can switch between these modes in flight with your transmitter. Without going into too much technical detail, the transmitter communicates with the receiver using a PWM (pulse width modulation) signal, which is defined as "a series of repeating pulses of variable width". The ArduFlyer changes its flight mode based on the PWM signal it receives from the transmitter. By configuring the switches on the Turnigy 9x transmitter to send different PWM values, it is possible to switch flight modes. I will be using the 2-position Gear switch and the 3-position F. Mode switch. There are six combinations of switch positions and each will correlate to a different flight mode. The F. Mode switch has 3 labeled positions from top to bottom: N, 1, and 2. The Gear switch positions are unlabeled, its position is either front (toward the side of the trasmitter facing you, with the controls on it) or back. There are several ways to accomplish this that can be found on various forums and blogs. This is what worked for me.
Before I started, I unplugged the ArduFlyer from the computer, turned on my Turnigy 9x transmitter, then plugged the ArduFlyer back into the computer and connected to it through Mission Planner the same way I did before. Now the transmitter and receiver are connected.
The first step is to make sure the transmitter is in Acro mode. If it is, the home screen will display an airplane on the bottom right.
If not, you'll have to change the setting. Press Menu, then Menu again to enter the System Settings menu, then go down to Type Sele and press Menu again to select this item.
You will see a list of three types, Heli, Acro, and Glid. If not already selected, move down to Acro and press Menu to select this mode, then Exit until you get back to the main menu.
For the next step, the ArduFlyer needs to be connected to the computer via USB again. Make sure the transmitter is on, then connect to the ArduFlyer from Mission Planner the same way you did previously. Click on Initial Setup then Flight Modes. You will see a list of six flight mode menus with a PWM range to the right and at the top, a "Current PWM" value. The transmitter will need to be configured to send a PWM signal within each of these ranges to switch to the corresponding flight modes on the ArduFlyer.
To program the switches to modify the PWM values, first I went to the Func Settings menu on the Turnigy 9x transmitter by pressing Menu, then pressing the DN (Down) button to highlight the wrench icon then Menu again to enter the Func Settings menu. I needed to get to the Aux-Ch menu item, which is at the end of page 2 of the menu options, so rather than skipping down through 2 pages of menus, by hitting UP once I went right to it.
Once Aux-Ch is highlighted, I pressed Menu again to enter the Aux-Ch menu. In this menu, I changed CH5 to Gear and change CH8 to Thro Hold, then pressed Menu again to save and exit to the Func Settings menu.
Back at the Func Settings menu, I clicked up a few items to Prog. Mix menu item and pressed Menu to select it.
Once in the Prog. Mix menu, the screen displays a list of Mix 1 through Mix 7. I will be using mixes 1 through 3 to configure my switches. Each mix corresponds to one position of the F. Mode switch and will be able to change the PWM between two values using the Gear switch. To get started with the setup I selected Mix 1.
First I made sure the F. Mode switch was set to N (top position) and the Gear switch was set to the back position. Then in the Mix 1 settings, I set State to ACT, Master to GYR, Slave to FLP, and SW to NOR. Then, I adjusted the DNRATE until the Current PWM on my Mission Planner screen was close to 1165. On my transmitter, the DNRATE was 071. Others might vary slightly but should be close to this value. To configure a second flight mode, I moved the Gear switch to the front position and adjusted the UPRATE setting until the Current PWM was close to 1295. On my transmitter, the UPRATE was -039. When all the settings were correct, I pressed Menu again to save and return to the Prog. Mix menu.
Next, I moved on to Mix 2.
To configure Mix 2, I first set the F. Mode switch to 1 (middle position) and the Gear switch to the back position. Then I set State to ACT, Master to GYR, Slave to FLP, and SW to ID1. I then adjusted the DNRATE until the Current PWM in Mission Planner was about 1425. My DNRATE was 008. Then, I moved the Gear switch to the front position and adjusted the UPRATE until the Current PWM was around 1555. My UPRATE was 024. Again, I pressed Menu to save the settings and exit to the Prog. Mix menu.
Finally, I moved on to Mix 3.
To set up Mix 3, I moved the F. Mode switch to 2 (bottom position) and moved the Gear switch to the back position. I set State to ACT, Master to GYR, Slave to FLP, and SW to ID2. Then I adjusted the DNRATE until the Current PWM was about 1685. My DNRATE was -055. I moved the Gear switch to front position and adjusted the UPRATE until the Current PWM was about 1795. My UPRATE was 082. Then I pressed Menu to save followed by Exit until I got back to the home screen.
To verify that everything was working, I watched the Flight Modes screen in Mission planner and verified that when I moved the F. Mode and Gear switches I could change between all six flight modes. You can now set each flight mode using the menus in Mission Planner. I set mine to Stabilize, Stabilize Simple, Alt Hold, Loiter, RTL, and Auto, though on my first flight I won't be using all of them. Descriptions of the flight modes can be found on the ArduCopter wiki.
Calibrating the Turnigy 9x Radio with Mission Planner
The next step is calibrating the radio. In Mission Planner, I clicked on Initial Setup at the top, Radio Calibration on the left side of the screen, and the green Calibrate Radio button.
You will be presented with two dialog boxes. Ensure that your ESCs are not connected to power and that there are no propellers on your motors.
Follow the instructions in the second dialog box and move all the sticks to all four corners so the max and min value of every channel is recorded. Also flip the F. Mode and Gear switches through all positions.
After moving all sticks and switches to all positions, the ranges of your transmitter's controls will be shown by red lines on the status bars for each control. Click the green Click when Done button, and you should see a popup window listing the PWM ranges for all of your channels.
Setting up Telemetry Radios
The telemetry radio set allows you to view sensor and GPS data and change settings on the ArduFlyer wirelessly. This can be useful for mapping waypoints and troubleshooting in the field.
I'm using the 915MHz telemetry set from RCTimer which includes an air module, which I earlier installed on my quadcopter, and a ground module, which connects to my computer's USB port. Setup of these radios should be straightforward, but if you run into trouble, check out the resources section at the end of the post for troubleshooting advice.
Here's how I got my telemetry set working. The first step is to attach the antennas to both modules. This a simple process and they screw on easily. The next thing to make sure of is that the ArduFlyer is NOT connected to the computer via USB. Telemetry will not work if it is. During this process I powered my ArduFlyer with a USB "wall wart" style charger similar to those used for cell phones.
It is important to do the following steps in the correct order to get everything communicating properly. Before using Mission Planner to connect to the ArduFlyer, you have to confirm that the air and ground module can communicate with each other. To do this, I first plugged in the ground module to a USB port on my computer. The light green LED blinked slowly, indicating no connection (which is fine, because the air module hasn't been powered up yet).
With the ground module powered up and the light green LED blinking slowly, I plugged in the USB power for the ArduFlyer (to a wall wart, NOT to the computer). After a few seconds, both of the green LEDs went solid, indicating that the telemetry radios were connected to each other.
Once both telemetry radios are connected to each other and have solid green LEDs, it is time to open Mission Planner. I went to the Initial Setup section, then clicked on 3DRadio on the left side. There are two areas for settings one that says Local (ground module) and one that says Remote (air module). For now the settings are all empty. The COM port settings at the top right may need to be adjusted, on my computer I had to change it from COM3 to COM4. The baud rate for telemetry is 57600, so this needs to be changed as well. Click on the green Load Settings button, and the radios will attempt to communicate and populate both settings areas. On mine it took a few seconds and all the fields were filled in. The values for the Local and Remote settings should all be identical.
Once the settings were all populated, I clicked the green Save Settings button and waited until it said "Done" at the bottom left.
Now that the radios are communicating and the settings are loaded, I clicked Connect at the top right. After a couple of seconds, I got the familiar "Got param" dialog box as the connection was established.
To verify the connection, I clicked back over to Flight Data and verified that sensor and GPS data was coming in.
MAKE SURE PROPS ARE OFF!
The final configuration step before my first test flight was to calibrate the ESCs. I unplugged the USB from the ArduFlyer, since I'll be using the battery to power the ESCs and ArduFlyer during this process. Again, MAKE SURE PROPS ARE OFF.
Here's the process I followed to calibrate my ESCs. Different ESCs may differ slightly in the the number and pattern of beeps they make, but all of the ESCs I've used follow a similar procedure.
Arming the ArduFlyer and Maiden Flight
Now I've got everything set up and I'm ready to take her out for a spin. The last thing to do is verify that the motors are spinning the correct way and add the props. Since I didn't change anything with the motor wiring, my motors were all still spinning the correct direction. Refer to the diagram earlier in this post for a reminder of which prop types go on which motors.
For my first test flight, I took my gear and computer to an open field without a lot of people around, and connected to the internet via a wifi hotspot.
Then I powered up my radio transmitter, connected my telemetry ground module to my computer, moved the quadcopter a safe distance away, connected the battery, waited for the solid green lights on both telemetry radios, started Mission Planner, and connected.
I was ready to fly and the last step was to arm my motors. To do so I moved the throttle stick down and to the right for about 5 seconds. When it was armed, the heads up display showed ARMED, and the red light on the ArduFlyer board went from blinking to solid. I gave it some throttle and took off.
For the first flight I took it easy, left it in Stabilize mode, and made sure all the controls behaved as I expected. I had to do some very minor trimming but overall the quad was very stable, especially without any tuning, which is a topic for another post.
The end result
I'm happy with my results thus far, but there are a couple of things I'll want to work on sooner rather than later:
GPS placement - having the GPS near things like the ArduFlyer, ESCs, and radio receivers can cause interference that weakens the signal. I tried Loiter mode for a couple minutes and the quad drifted quite a bit. One thing that will probably help is building or buying a stand to raise the GPS up above the other components and sheild it on the bottom.
Tuning - I did not do any tuning at all for the intial flight. I can definitely acheive more stable flight and more accurate Loiter behavior if I tune the PID settings a bit. Soon I'll put together a post about tuning and finding the settings that work best for this quadcopter.
Resources and Troubleshooting
I wouldn't have been able to complete this build without spending a ton of time soaking up other peoples' knowledge and experience on forums and blogs. The multirotor hobby is still relatively new and much of the technology is open source and advancing quickly, so the community is indispensable when troubleshooting issues. Here's a list of sources and posts that I read before and during this build that saved me a ton of time and frustration:
I had to cut out some pictures I wanted to use to get past the limit on photos in posts. I have a full build log with more pictures on my blog here