Adding GPS to Flip32+ and Cleanflight
Flip32 and Flip32+ (10 DOF version of Flip32 with built-in barometer and magnetometer) are nice little flight controllers. And cheap. Some call them clones of Naze32, but this is not completely true. Yes, they are very similar, share the same hardware, but they are not identical. I would say they are better than Naze32 since have more features and are easier to extend. But that is not the topic.
One of coolest features of every drone is GPS support. This allows for both Position Hold and even navigation support. I will not explain how to configure Position Hold and navigation on Flip32+ and Cleanfligh today. The reason is simple: I'm still trying to fully understand PID controllers used in those modes: Pos, PosR and NavR. And it is not going very well I must say. Position Hold in low wind is OK, but navigation and PH in wind conditions is unreliable and I'm still unable to configure it to work well. But GPS even without Position Hold has some use. For example, Home marker on OSD when flying FPV.
In this tutorial I will use Ublox Neo-6M GPS module, Flip32+ 10DOF and Cleanflight 1.9.0.
First of all, we have to set one of serial ports to act as GPS port. This is done on "Ports" tab of Cleanflight Configurator. In case of Naze32/Flip32 this will be UART2 located on input pins 3 (TX) and 4 (RX). The only problem with this UART is that it is shared with receiver PWM input ports. In case of serial receiver or PPM receiver, there is no problem. But, when our radio is using separate input port for each chanel (Parallel PWM) there will be a change of input mapping:
- CH1 Roll
- CH2 Pitch
- UART2 TX
- UART2 RX
- CH3 Throttle
- CH4 Yaw
- CH5 AUX1
- CH6 AUX2
Luckily, this will be done automatically when we enable GPS later on.
So, open Ports tab, select GPS on UART2 and select correct baud rate. In case on new Ublox Neo-6M, it will be 9600.
Next, we have to connect GPS module to flight controller. GND and 5V can be taken from any free pin, GPS TX line have to be connected to UART2 RX (pin 4) and GPS RX line to UART2 TX pin (4). Do not worry if you will mix TX/RX lines. If you will not connect them correctly, you will not burn anything. It will just not work.
Next step is to enable GPS. Open "Configuration" tab, check GPS and select "Ublox" protocol and "Auto-detect" Ground Assistance Type. Save, reboot and connect 5V power supply to Flip32. USB power is not enought for Neo-6M GPS. After reboot GPS should be enabled and running. You can check signal and fix on "GPS" tab.
If you failed, recheck wiring, check external power supply (usually 5V from BEC) and serial configuration. Maybe you selected wrong baud rate. Check you GPS module configuration.
The last thing is using GPS for Position Hold. This is tricky and looks like not working very well in current Cleanflight (1.9.0). Still, until now I was able to make that somehow work in low wind conditions. But Return To Home mode is highly unstable and it crashed my 500 quadcopter twice. If you want to try, here is some information you will need.
GPS navigation and Position Hold uses 3 PID controllers: Pos, PosR and NavR and some CLI properties:
- Pos PID controller is used when multicopter is withing gps_wp_radius from desired position. It's computing desired speed for fine navigation,
- PosR (Position Rate) PID controller is used when multicopter is also within gps_wp_radius from desired location and computes direction of movement,
- NavR PID controller (Navigation Rate) is used when multicopter is outside of gps_wp_radius to determine movement direction,
- CLI
- gps_wp_radius in centimeters sets area around GPS coordinates to use PosR controller for fine navigation,
- nav_controls_heading - when enabled (1) and magnetormeter is present, will set drone front towards current movement direction,
- nav_speed_min and nav_speed_min set min and max navigation speed in cm/s,
- nav_slew_rate has something to do with smoothing but did not checked that yet
If you have and success with Position Hold and Return To Home and Cleanflight, share the knowledge. There are many dark areas here.
I'm Paweł Spychalski and I do things. Mainly software development, FPV drones and amateur cinematography. Here are my YouTube channels: