fredag 4 april 2014

Multiwii GPS Airplane

                     updated 2016-07-06 (Updated links)

This is a addon to the
How to setup a Multiwii Airplane

Download the stable 2.3 Version of FixedWing Nav code
Recommended for Flight controllers based on ProMini.(Atmega 328P)

Or the experimental Waypoint version.
Recommended for Flight controllers based on Mega processors.
MultiWii_FW_150431 with failsafe fix
Use with WinGui from EosBandi for setting waypoints.
http://eosbandi.com/downloads/

What to expect from a MWii GPS plane?

The code supports.RTH & GPS-Hold.With the simplest FlightController and a Gps. Perfect for exploring the surroundings with your FPV plane.

A good presentation of RTH mode borrowed from Spencer Trejo

Connection Diagram



GPS-Hold

Can only be enabled With AUX switch.
Check both Angle mode and GPS Hold in Gui.
When GPS-Hold is activated The position is saved in a 3D Waypoint.
The plane will Navigate and try to "hit" the WP continuously and maintaining altitude.
No pattern is programmed and the plane fly the shortest way back.
Often in a circle or figure eight.


RTH (Return to home)

Can be enabled With AUX switch or by Failsafe.
Check both Angle mode and RTH in Gui.















When RTH is activated the plane will start Climb to reach safe Altitude.
If RTH is enabled Higher than set altitude it will start navigation and keep that altitude.
If altitude is safe the plane will start to Navigate to home Position.

Only use Angle/Horizon + Gps Home/Hold together.
Do NOT Activate BARO Or MAG for navigation.
It will interfere with the navigation code.

When the plane reaches SAFE_DECSCEND_ZONE the plane will begin descending to correct altitude.
The plane will keep flying in hold mode and continuously pass home.

If Failsafe is active at return The plane will Disarm motor and descend to a "Landing"




PID settings is made in Gui.
ALT & NavR.

Return Altitude can be set with
PosR D-parameter.
Scale is in km...
50m is set as defaut.
250m is Max.




=====================================================
This settings is done  in  Config.h .
=====================================================

#define MAXTHROTTLE 2000 
Because you  want Full Power sometimes!

Select your GpsType

In My case
#define GPS_PROMINI_SERIAL    115200
#define NMEA
Or 
#define I2C_GPS



Failsafe function

#define FAILSAFE
The obvious reason to have GPS in a plane!
FAILSAFE can take over the plane and fly it to Launch point if the Radio is lost.
When Home is reached the plane will stop motor and attempt to make a "Landing"

If Transmitter sends commands below 980µs Mwii will enable Failsafe!
Angle and GPS_HOME become activated.

If you can program failsafe function
on your Receiver Program throttle
To Below 980µs
Or set the switches for RTH.


Safety settings...

#define MOTORSTOP
Give you the chance to Cut motor off with the Throttle Stick.
If Throttle is lowered to zero motor will stop.
Nice when doing preflight checks

Warning...
If you stop motor during Navigation the plane Will most likely Stall!
There is a small protection programmed but it might not be enough.
(Common Aviation Physics...)

=====================================================
This settings is temporarily  in  Gps.h .
=====================================================
The following settings controls the behavior of the plane during Navigation.
Default settings gives quite soft characteristics.

This values can be set to Zero if Ex Rudder is not used.
#define GPS_MAXCORR    20  // Degrees banking Allowed by GPS
.#define GPS_RUDDER        15  // Maximum Rudder

#define GPS_MAXCORR    35  // Is Suitable for Flying Wing.

#define GPS_MAXCLIMB   15     // Max allowed Degrees climbing . To much can stall the plane.
#define GPS_MAXDIVE      15     // Diving . To much can overspeed the plane.

A Flying Wing usually need  around 30 - 40 degrees Maxcorr to tighten the turns.

#define CRUICETHROTTLE    1600
The vale  Throttle keeps when Altitude is correct for "Long Distance".
Should be set to a comfortable speed well over Stall Speed.

#define IDLE_THROTTLE      1300
When the plane is descending this is the lowest allowed Throttle.

#define SAFE_NAV_ALT        20  // Meters
To avoid  trees & buildings etc The plane will make a climb straight forward before Navigation starts.

#define SAFE_DECSCEND_ZONE  50 // Meters
 Radius around home where descending is OK

Note!...Don't forget the pre launch check!...

After takeoff, test RTH to ensure Home is set correctly before Going on a FPV mission

A bonus feature With RTH (Autolaunch)

If you enable RTH on the ground before Takeoff.
The plane will perform a full RTH cykle.
Climb, return and start circle....

Odd behavior on Rudder

Rudder have a tendency to try to hold the heading during Aileron/Elevator turns.
It can make the plane fly Sideways and other strange phenomena.
The cure is to Set YAW_I = Zero.

=====================================================

A example for a simple setup for RTH

FlightController  < $25
GPS module      < $20

A complete AutoPilot capable to save your plane  under 50$
I'm sure you can find even cheaper setups if you search on Ebay.

=====================================================