Friday, May 17, 2013

RC Electric Glider Autopilot Conversion

Scope

This document provides a brief description of the conversion of a RC plane to autonomous control with an Ardupilot (http://code.google.com/p/ardupilot-mega/wiki/Introduction) system.

I started this project about 1 1/2 years ago and worked on it off and on.  My main problem was keeping track of the details, hence this guide.  If you have the time or inclination, then you can finish it off in a week!

­
I chose a large, positively stable RC Electric Glider from Sussex Model Centre (http://www.sussex-model-centre.co.uk/default.asp) in the UK. The plane has a 2 meter wingspan with 3 degrees of dihedral and swept up wing tips.

A positively stable glider will fly on its own even when the electronics are dead and it will eventually land all by itself too.  It will simply glide into the ground and ground effect will make it flair.  So if you can find it and there are not too many trees about, then you should always be able to recover your plane intact.  I prefer having a plane that can fly more than once.

The control surfaces consist of a rudder and elevator only. On a plane with this much sweep up, ailerons are not needed. When one lets go of the controls and cuts the engine, the plane should fly itself, level out and glide at a shallow slope. The large wing area allows the plane to carry some extra weight while still maintaining a good glide capability. This makes it relatively easy to do an autonomous conversion and fit fun sensors, such as a camera with a radio down link (an old Android phone will do!).

RC Electronics

The normal airborne RC schematic is shown below.


The normal RC setup is quite simple and consists of two batteries, a RC receiver, two servos, an Engine Speed Controller (ESC) and a powerful electric motor.

RC Receiver

I prefer Futaba RC gear.  It provides good value for money and works reliably.  The Futaba receiver is a very tiny little thing and is wired up as shown below:

Autopilot Electronics

The airborne RC/Autonomous schematic is shown below.


There are three main changes. Since a whole lot of electronics is added, the Receiver battery is removed to save weight. This requires a different Engine Speed Control or Switching Battery Eliminator Circuit (ESC/SBEC). The Ardupilot and associated electronics are added and the servos and throttle are rerouted, while the Flaps circuit is used as a failsafe/manual override switch.

DC-DC Convertor

An alternative solution is to keep the existing ESC and add a switch mode PSU, such as a Sparkfun BOB-09370, 6A, 0.59V to 5V, DC/DC convertor (https://www.sparkfun.com/products/9370) as shown below:

This little widget can be used to convert the 8.4V Motor Battery to 5V for the RC Receiver and servos, which will save the weight of an additional NiMH 4.8V receiver battery, but it will reduce the endurance somewhat.

The output voltage of this convertor is adjustable (the default output voltage is only 0.59V). It requires a 1k34, 0.5% precision resistor between the Trim and Gnd pins for a 5V output (alternatively use a 4k7 multi-turn trimpot for adjustment from 3V3 to 5V).

The ON/OFF input doesn't work – it is permanently on. The Power Good signal is also good for nothing and the SEQ pin is a very high voltage and not of any use either, so just put pins in Gnd, Vin and Vout, glue a trimpot to the bottom and ignore the rest.

Batteries

Note that NiMH cells are 1.2V nominal (1.4V while charging) while LiPo cells are 4.2V nominal. Do not discharge NiMH below 1.1V per cell and LiPo below 3V per cell.

The Motor battery used by this glider is a 7 cell Tornado 3800 NiMH pack that provides 8.4V nominal, or 9.8V when fully charged and 7.7V when flat.

The receiver battery is a 4 cell NiMH Hi-Energy pack that provides 4.8V nominal. The above DC/DC convertor can be used to eliminate this battery to save some space and weight.

Note that NiMH cells self discharge very rapidly, losing 20% in the first day and 4% per day thereafter.  So you got to charge them each time before use.  From new, they will actually improve a bit during the first few charge/discharge cycles.

Autopilot

Full details on the Ardupilot is on the project Wiki (http://code.google.com/p/ardupilot-mega/wiki/Introduction).

My Ardupilot is a version 1.4 device with external magnetometer, GPS and Pitot sensors. The kit of parts is shown below:

On the version 1.4 board, three axis accelerometers and a pressure sensor are built in. The fully assembled unit (except for the magnetometer) is shown below:


The Magnetometer is mounted upside down behind the “No GPS!” connector on the blue board, as shown below. Add some tape to it as insulation against the other connector pins:


The GPS module plugs into the red board, as shown below. The red wire is on the outside:


Later models also integrate the magnetometer and GPS receiver, but otherwise the boards are much the same.

Put some insulation tape on the bottom of the GPS unit and after soldering the Magnetometer down, you can glue the GPS receiver down next to it on the Blue board using either hot glue (removable with a knife) or epoxy (never to be removed again). Take care not to cover the air pressure sensor with glue. The pressure sensor should instead be covered with a small sponge to protect it against blowing air from the propellor.

Note that it is useful to install the battery monitor resistors, even if you do not have a radio downlink, since it enables the Mission Planner to read the battery voltages when the USB lead is plugged into your computer.

Hookup

The boards are labeled very well, considering the small space available, but it is difficult to determine how exactly to wire up the servos and receiver – a magnifying glass helps. The hookup is described in detail here (http://code.google.com/p/ardupilot-mega/wiki/RC) and is summarized below.

Typically, the RC channel assignments are as follows:

RC Channel
Function
APM Connector (v1.0)
APM Connector (v1.4)
1
Roll - Aileron
IN 0
IN 1
2
Pitch - Elevator
IN 1
IN 2
3
Throttle
IN 2
IN 3
4
Yaw - Rudder
IN 3
IN 4
5
Landing Gear
IN 4
IN 5
6
Autopilot control (Flaps)
IN 7
IN 8

Note that RC 6 (Flaps) goes to IN 8 (AP Control). You could use anything with a switch on your RC transmitter, usually channel 5 or 6.

Also, a glider with a lot of dihedral, doesn't need ailerons, leaving channel 1 empty.
In a space constrained glider body, you need to make every wire exactly the right length, else the system may not fit. Also, every piece of wire is extra weight, which is another incentive to keep them all as short as possible. Two inch servo cables worked for me between the RC receiver and autopilot (Sparkfun has).

The only way that I could fit the parts into the glider body, was to slide it all in via the cockpit and then pack pieces of sponge around it, to keep the parts from moving around. A hard mounting frame of any sort just could not go in, so I gave up and cut up a bath sponge with scissors.

The complete hookup is described in the diagram below. Note that on the Engine Controller, the Brown wire is Ground, so I coloured it black with a marker pen to reduce confusion. If any wire colour codes are funny, check it out with a multi-meter!

Obviously the connector polarity is important.  On the 3-row connector, the ground (black) is always closest to the board edge.

On a test bench, power to the AP is supplied either via the USB connector (5V) or via two pins on the Red board (6V to 12V). If the available space is very narrow, as on a typical glider, then solder two power pins to the board and angle them inward at 45 degrees, instead of outward.

In the plane, the 5V power can also be supplied via the RC Receiver pins. So I simply plug the above mentioned Sparkfun BOB power supply into the RC Receiver position 7/B, which then powers the Servos and Auto Pilot.  Beware of the engine starting unexpectedly if the transmitter is off.

When mounting the things in the plane, it is important to point the IMU in the right direction, as shown below. The infamous No GPS connector must face the front:


If you install the autopilot in the cockpit, then the servo wires will be at the back, towards the servos mounted under the wing, thus keeping the wires short, as shown in the fuzzy picture below taken with my Mac webcam.  I made the test jig from a wood shelf kit and a cheap plastic spirit level that I got at Carrefour, to hold the plane horizontal in its flying position.  I'm still looking for a compass.


The battery is on the bottom, there is a piece of plywood above it, with the servos, PSU, RC Receiver and AP on top. In the cockpit there is the engine controller on the floor and the engine in the nose, with all wires as short as possible. One RC antenna is threaded to the back and the other to the front.

The AP board must be tied down immovably, otherwise the calibration could change while the plane is flying, causing the control system to do interesting maneuvers. You probably also don't want the battery to shift and change the Centre of Gravity while flying. A couple of rubber bands and some sponge can keep things in place.

Power up

The plane must be horizontal in its flying position and facing north, when the system is turned on.

Immediately after turn on, the IMU is calibrated, so you need to make a jig with a spirit level and a compass for the plane as in the picture above. Put some lead diving weights on the jig and provide straps to hold it. This is needed for static tests. You got to run the system, see how long the battery lasts and verify that everything keeps working for the duration of a mission.

You must turn the Transmitter on before turning on the plane electronics, otherwise the engine may start at full speed. If you hear the receiver Beep when you turn on, either the Throttle is wide open or the Transmitter is off – turn the plane off immediately or you may lose a finger in the propellor.

I installed two sliding switches on the side of the cockpit – one for the engine and one for the AP electronics. This way, I can run the AP with the motor in a safe position.

For the first few brief smoke tests (no more than a few seconds), I suggest that you remove the propellor from the engine for finger safety. However, do not run the engine without a load for extended periods.  If the magic smoke stays inside the electronics, then you can mount the propellor. Another old safety trick is to drop a small towel over the propellor - then if you accidentally move the throttle, it will just go 'whomp' with no damage done.

There is a safety diode in the AP.  The USB connector will only power the AP, not the receiver or servos.  However, if you plug the BOB PSU into the RC receiver, then it will power the Servos and AP through the connected wires.

Mission Planner

The next problem is the mission planner software.  It is unfortunately a legacy Windows DotNet application and takes some effort to install.  I got it to work on Virtualbox on Windows XP.

Mission Planner connects via USB to the AP.  It will check the board version and upload the correct firmware.   So that is a problem worthy of another post.

La voila! Enjoy the flight.

Herman




No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.