User:HWal

From PaparazziUAV
Revision as of 13:04, 21 September 2019 by HWal (talk | contribs) (Restore user page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

My Paparazzi Twinstar2 UAV experience


General

Changes during the progress of my project

My project started in autumn 2009. The Paparazzi project has evolved significantly since then. This document reflects how a Paparazzi fixed wing aircraft is configured in mid november 2010.


About me

  • Automation and electricity engineer, graduated in 1972 (!)
  • Main hobby: Model aircraft since I was a boy.
  • Computer experience: Some programming in RPGII for IBM business machines. A little programming in Basic and Pascal.


The project

Main focus: Getting airborne with Paparazzi UAV.

Primary goal: Obtain Auto2 flight with a fixed wing model aircraft in other patterns than just a circle.

Secondary goal: Equip the plane with metheorological equipment (pressure, temperature sensors...) and receive online readings from the plane while in flight.


To maintain focus on getting airborne I bought the TWOG with boot loader installed. The GPS and ppm board were configured from the supplier.

Later on I intend to manage bootloader install myself, and use of the “tunnel” for GPS access. The ppm board works well as received from the supplier, so I’ll leave that alone for now.


The Paparazzi project is very flexible and seems (maybe for this reason) a bit complicated. There are more than one way to connect things. I have chosen to use IR sensors for attitude sensing. Due to the plane having four servos, I have chosen to power these, the RC receiver and the ppm board from a separate UBEC.


I run Ubuntu 10.04 on my “Paparazzi laptop”. At home I also run Paparazzi on my stationary PC. It was on the stationary machine I first tried the new “xml only” airframe file before I eventually converted my Ground Station laptop to this configuration method with success.


I have tried not to repeat the wiki too much in this page. However I have added links to the wiki as needed.


Hardware

Paparazzi / UAV equipment

The equipment was bought from CheBuzz and PPZUAV during autumn/winter of 2009/2010, consisting of:

  • TWOG v1
  • IR sensors
  • Paparazzi GPS13 v0.9 (*)
  • SPK LEA-5 GPS
  • 2 x Aerocomm AC4790 modems with interface cables and Duck antennas
  • 2 x XBee PRO Series 2 - 2.4 GHz modems with ground station adapter and duck antenna for the ground modem (*)
  • ppm decoder by Hendrix and Moa
  • USB-serial adapter - Sparkfun FTDI basic 3.3V DEV-08772
  • Necessary cables for flashing and connecting the components


(*) This equipment is on a rig at the moment, but I have tested it and have dedicated it to a Cessna-like foam plane I have assembled.


R/C equipment and link

I use a Futaba 10CG 2.4 GHz transmitter with R617FS receiver. This radio is also used to control conventional R/C planes I have.

The three position switch (C) on the transmitter is used to change modes. This is mixed into channel 7, which again is connected to channel 8 on the ppm board. The ppm encoder manual is of great help when connecting this part of the installation.


Airframe

My project airframe is a Multiplex Twinstar2. This airframe has documented many successful flights equipped with Paparazzi autopilot. It has four servos; two for the ailerons, one for the elevator and one for the rudder.


Note: Rudder control has later been disconnected, see below.


Ground station Computer

A cheap Compaq Presario Laptop with Vista on it was bought. I shrinked the Windows partition on the disk so that I got 100GB unused space. Then Ubuntu 9.04 was downloaded and installed on the free disk space.


Note: Ubuntu 9.04 was replaced with 10.04 in october 2010.


Software

Installing Paparazzi on the laptop

I followed the instructions in the Installation page and installed the system.


During installation a new directory, paparazzi3, was created in my home directory.


Note: It was important to read through the Installation page in advance and select the method that was relevant. I chose to download the source code from Subversion and compiled with make.


Preparing suitable configuration files

After presenting a question to the community, Chris (hendrix) from Hellas emailed me a set of his files for the Multiplex Easyglider. I decided to adapt these to my Twinstar2 project.


Editing the configuration files to my needs

I wanted 57600 baud for the ground station and airplane. Also I wanted to use the transparent serial (pprz) protocol as recommended for ordinary users. These are the configuration I edited to fit my setup:


.../conf/conf.xml
.../conf/control_panel.xml
.../conf/airframes/twinstarhw.xml
.../conf/flight_plans/basic.xml
.../conf/radios/T10CG.xml


I regularly edit these files. If you would like a copy of my current configuration files, please email me at helgewal@gmail.com.


Simulation

There are instructions for simulation in the Simulation page. The following shows a simulation setup where I have used my own configuration files:


Paparazzi Center was started and the following options chosen:

A/C: TWINSTAR_II_HW
Airframe: airframes/twinstarhw.xml
Flight plan: flight_plans/basic.xml
Settings: settings/basic.xml
Radio: radios/T10CG.xml
Telemetry: telemetry/default.xml
Target: sim
Session: Simulation


Note: After pushing Execute it is important to wait 10 seconds until Holding point is active (highlighted green in the notebook) before hitting the Takeoff and Launch buttons.


Electrical connections

Power supply connections:

Power supply

Telemetry connections, alternatives used:

Telemetry

Please observe notes 1) and 2) about Gnd connections.


After experiencing a number of TWOG resets while powering up the autopilot, I chose to connect a separate power supply (BEC) for the servos, RC receiver and ppm board. This is advisable if the plane has more than two small servos.


Note: It is of great importance that in a setup like mine the + lead from the motor ESC is isolated. Also it is important to avoid ground loops.


Telemetry

The equipment was connected as shown in the diagrams above. See the relevant alternative for each instance.


Communicating with TWOG via the FTDI USB-serial adapter

Paparazzi Center was started and the following options chosen:

A/C: TWINSTAR_II_HW
Airframe: airframes/twinstarhw.xml
Flight plan: flight_plans/basic.xml
Settings: settings/basic.xml
Radio: radios/T10CG.xml
Telemetry: telemetry/default.xml
Target: ap
Session: Flight USB-serial_cable@9600


Note: Line 2 in .../conf/flight_plans/basic.xml was updated with position data for my local model airfield.


The Clean button was pushed, then Build to generate the airframe files.

With the autopilot still not connected to the battery, the USB port on TWOG was connected to the USB port on the laptop via the adapter cable. TWOG was powered up, and Upload pushed.


Successful flashing was indicated by these lines:

....
Found USB device
BootROM code: 2.12
Part ID: 0x0402FF25 (LPC2148, 512k Flash, 32k+8k RAM)
BootLoader version: 1.3
#########
Starting software at 0x00004000
....


Then battery supply was disconnected from the TWOG. More detailed wiki instructions is found in the Compiling page.


The serial port on the FTDI board was connected to SERIAL on the TWOG (only RX, TX and GND, remember RX -> TX and TX -> RX). Then the USB port on the laptop was connected to the USB port on the FTDI adapter, and the TWOG was powered up again.


I hit Execute in Paparazzi Center and could see blinking from the TX / RX leds on the FTDI board. The GCS got populated.


The responses (Manu, Auto1, Auto2) from the three different positions of the Mode switch (C) on The RC transmitter was observed in the GCS, and servo function was verified in Manual mode.


Communicating with TWOG via XBee 2.4 GHz modems

The X-CTU program (for Windows) was downloaded here . I first connected the airborne modem to the ground station adapter, and the adapter to the PC with the USB cable. Then the X-CTU configuration program was started. I had not ever used this program before so took my time just to get familiar with (at least some of) the options. The baudrate was set to 57600bps and the modem set as END DEVICE AT. The configuration was then written to the modem. Next the ground station modem was connected to the ground station adapter. The baudrate was set to 57600 bps and the modem set as COORDINATOR AT. The configuration was written to the modem.


The airborne modem (with the wire antenna) was then connected to the TWOG.


Paparazzi Center was started and the following options chosen:

A/C: TWINSTAR_II_HW
Airframe: airframes/twinstarhw.xml
Flight plan: flight_plans/basic.xml
Settings: settings/basic.xml
Radio: radios/T10CG.xml
Telemetry: telemetry/default.xml
Target: ap
Session: Flight XBee 2.4GHz or AC4790 900MHz@57600


The Clean button was pushed, then Build to generate the airframe files.

Upload was performed and after power cycle, Execute.

The blinking from led’s on the ground station modem adapter told me that communication was ok, and GCS was populated.


Communicating with TWOG via AC4790 900MHz modems

The configuration program (for Windows) was downloaded here . I followed Download-->Software Downloads and installed the Configuration Utility.

I first connected airborne modem to the Sparkfun FTDI adapter and started AeroComm_OEM.exe. This also was a new utility to me and took its time to get familiar with. The modem was configured as shown below.

Next the ground station modem was connected to the FTDI adapter and configured.


Ground station modem:

AC4790 Ground modem

Ground station modem configuration:

Ground modem conf

Airborne modem configuration:

Airborne modem conf


Note: The Destination address on one modem is the MAC Address of the other, and vice versa.


The airborne modem was then connected to the TWOG.

The procedure for Build, Upload and Execute is equal to the procedure for the XBee’s.


Getting messages from the GPS

As already mentioned I bought the GPS configured for Paparazzi. The GPS tab was opened in the Notebook, where I could confirm that the TWOG received messages by watching the columns representing each sattellite. This test is best carried out outdoors, as sometimes indoors the GPS will not be able to see any satellites.


External data

Downloading map tiles

In the GCS I chose Maps-->Maps Policy-->http, and then Maps-->Maps fill. Map tiles started to fill the screen. As I zoomed out I coud download more tiles. More info on downloading maps is found on the Maps page.


After downloading a number of tiles Maps fill would not work anymore, and I got an error message. I have read that Google Maps ban your ip for 24 hours after a certain number of tiles have been downloaded, so I waited till the next day. After some re-tries during the next days I eventually managed to get the tiles I needed for my area. The tiles are stored in …/var/maps for later use.


Note: To make sure Paparazzi uses the right http link for tile download, svn update was run first.


Getting ground altitude data for my part of the world

Living in Norway, I could not find SRTM data published by NASA. I could however find the data I needed here .


This is described in the Maps page in the wiki. The appropriate zip file was downloaded and implemented like this:

unzip P31v2.zip				A new directory P31 is created
cd P31					Go to the new directory
bzip2 *					Compress the files
mv * .../paparazzi3/data/srtm		Move the files to their correct location


Other peripherals

ppm pulses from the RC transmitter

To measure the ppm pulses I needed the ppm messages. I did the following:


  • Opened ...paparazzi3/conf/telemetry/default.xml
  • Copied the ppm message in the “fbw” process from “debug” mode to “default” mode


After compiling and flashing, a Messages window was opened in Paparazzi Center. This time the ppm message was transmitted to the GCS. With all trims in the RC transmitter set to zero, I noted the max, neutral and min values for each channel. The values in the message was divided by 15 to get the ppm values. More about this in the Radio Control page in the wiki.


The values were entered into both the radio file .../conf/radios/T10CG.xml, and the airframe file .../conf/airframes/twinstarhw.xml (in the servos section).


IR sensors neutral

I made a box from two styrofoam blocks where I carved out room for the sensors. My box is relatively small and there is only about 2,5cm - 3cm of styrofoam around the sensors. The sensors were enclosed in the box for 10 minutes or so before adjustments were carried out.


A Messages window was opened in Paparazzi Center -->tools-->Messages and I observed the IR_SENSORS message. The target was to make the readings for ir1, ir2 and vertical equal to zero.


These are typical values to start with in the airframe file:

<define name="ADC_IR1_NEUTRAL" value="511"/>
<define name="ADC_IR2_NEUTRAL" value="511"/>
<define name="ADC_TOP_NEUTRAL" value="510"/>


If for example the reading for Ir1 showed -4 in Messages, then ADC_IR1_NEUTRAL was changed by four units. The airframe was re-flashed and the result observed. If things got worse I just made the change the other way. In the end I managed readings that altered between 1 and 0.


Note: I have later repeated this adjustment by enclosing only one of the two IR boards in the styrofoam box at a time. This seems to work well.


Hardware installation and tuning

Installing the equipment in the plane

As mentioned above in the circuit diagram I have a separate power supply for the servos, RC receiver and ppm encoder board. This is to prevent TWOG from being reset by variations in voltage caused by changing servo current draw.


IR sensors and GPS:

IR and GPS


The horizontal IR sensor board was mounted on a small plastic tube on top of the wing. The sensors have a tilted orientation, which means that each sensor “look” in a 45 degrees angle from the longitudinal and lateral axis. Tilted or not tilted orientation is configurable in the airframe file.


The vertical IR sensors board was mounted under the rear part of the left wing. I made a hole through the wing making it possible for one thermopile to look straight up.


In my setup, the orientation of sensors and responses in the IR_SENSORS message is as follows:

Sensor				Location		Response
ir1 (horizontal)		Front right		Positive when warm
ir1 (horizontal)		Rear left		Negative when warm
ir2 (horizontal)		Rear right		Positive when warm
ir2 (horizontal)		Front left		Negative when warm
vertical			looking down		Positive when warm
vertical			looking up		Negative when warm


It is sensible to spread the electronics in the plane as much as possible to avoid interference, and also place the usb flash socket in an easily accessible location.


Checking correct IR sensor response in the PFD

The following was checked:


  • That the PFD showed everything the right way round, i.e. Blue (sky) up, and brown (ground) down.
  • That the PFD showed level when the plane was kept level. The horizontal IR sensor board was adjusted mechanically to suit.
  • That the PFD showed correct tilting direction and angle when it was tilted in different directions and angles.


To compensatate from what seemed a too small roll response angle I increased VERTICAL_CORRECTION in the INFRARED section from 1.5 to 1.7.


Flying and trimming the plane in Manual mode

When flying in Manual, all trims on the transmitter were set to zero, and the linkages adjusted mechanically to make the plane fly straight and level with no stick input from the RC transmitter.


A number of flights were carried out to gain experience with the telemetry and log files.


Tuning in Auto1

I selected the tuning.xml file in Paparazzi Center, compiled the aircraft and flashed the TWOG. Placed myself on an open field, held the plane over my head and engaged Auto1. Tilted the plane in every direction and I noted that the ailerons responded correctly, and that the elevator moved the wrong way. This was corrected by reversing the max/min values for the elevator in the airframe file and in the radio file.


Then I engaged Manual and threw the plane. Climbed to a secure height and engaged Auto1, ready to return to Manual quickly if needed. The plane drifted a bit to the left. The two important parameters in the airframe file for tuning in this mode are ROLL_NEUTRAL_DEFAULT and PITCH_NEUTRAL_DEFAULT.


The ROLL_NEUTRAL_DEFAULT parameter needed -2.9 degrees adjustment

The PITCH_NEUTRAL_DEFAULT parameter was ok at 0


Note: These values are entered in radians in GCS-->Notebook-->Settings-->control-->ir., and in degrees in the airframe file.


After a number of flights I have learned to remember the elevator position that gives neutral flight with no stick input. The trim of the Twinstar2 is sensitive to the expansion and shrinking of the foam fuselage with changing temperatures. I have therefore disconnected the rudder control and fixed it with tape in neutral position. This works just fine. And, before every flying session I adjust the elevator trim mechanically to the neutral flight position.


I did some turns in Auto1 to verify that the plane could roll sufficiently both left and right. Also I banked and tilted the plane to some stupid angles in flight, let go of the TX sticks and observed the plane level out by itself quite nicely.


Two important gains:

ROLL_ATTITUDE_GAIN

The plane was banked to one side in Auto1, then I abruptly let go of the aileron stick. The plane returned gently to level flight. ROLL_ATTITUDE_GAIN was increased in 500 unit steps until the plane just started to oscillate when I let go of the stick. Then I reduced the value by approx 500 units to avoid oscillation, and still keep the gain as high as possible.


PITCH_PGAIN

This gain was never actually tuned, but rather chosen as an intermediate value between values I have seen in other airframe files.


Note: Increasing the gain means increasing the number (even if it becomes more negative).


Auto2 flight

Before trying the first Auto2 flight I edited the flight plan and placed the Standby waypoint in a suitable positon, so that I could follow the plane closely with my eyes and take over manual control if needed. Also I chose a sensible max_dist_from_home at 275m. In the airframe file I entered a DEFAULT_CIRCLE_RADIUS of 75m.


Then the following was performed:

1.  Started Paparazzi Center. Compiled and flashed the autopilot
2.  Started the GCS
3.  Turned on the RC transmitter, throttle at zero, Manual mode
4.  Powered up the plane and verified that the telemetry link worked
5.  Checked that all control surfaces moved in the right direction in Manual and Auto1
6.  Waited until Notebook-->Flight Plan showed Geo init and then entered Holding Point
7.  Clicked the Takeoff button and then the Launch button
8.  Held the plane firmly and briefly entered Auto2 to verify that engines throttled up
9.  Back to Manual mode, engines stopped
10. If not already active, double clicked the Standby block in GCS


The plane was thrown in the air and flown in Manual mode to a safe altitude, near the Auto2 cruising altitude.


Then Auto2 was engaged on the RC transmitter. The plane adjusted its heighth and started to circle the Standby waypoint.


That's it. A great feeling of achievement.


Flying circles:

Circles

Circle and figure eight:

Circles and eights

Further progress

  • I have some improvements to do on the tuning of my Twinstar2. However, a Funjet RR is in my workshop waiting for a Paparazzi installation.
  • I have ordered an EagleTree Airspeed sensor. I hope to implement this shortly in my airframe and use it to improve flying and also receive messages from it in the GCS.
  • As mentioned in my secondary goal I would like to implement some metheorological equipment in the plane. This work has not started yet.
  • I also plan to spend more time trying to understand more about how the software works.