Difference between revisions of "Airspeed sensor"

From PaparazziUAV
Jump to navigation Jump to search
Line 5: Line 5:
== Connecting an EagleTree Airspeed Sensor ==
== Connecting an EagleTree Airspeed Sensor ==


The [http://www.eagletreesystems.com/Standalone/standalone.htm EagleTree Airspeed Sensor] is a low cost module and comes with a very good pitot tube (Prandtl style, pitot-static tube) that includes static and dynamic ports. It has an [en.wikipedia.org/wiki/I²C I2C] interface that connects directly to the Autopilot I2C port. The paparazzi autopilot code is able to regulate the throttle in order to keep the airspeed constant (and a minimum ground speed).  
The [http://www.eagletreesystems.com/Standalone/standalone.htm EagleTree Airspeed Sensor] is a low cost module and comes with a very good pitot tube (Prandtl style, pitot-static tube) that includes static and dynamic ports. It has an [http://en.wikipedia.org/wiki/I²C I²C] interface that connects directly to the Autopilot I²C port. The paparazzi autopilot code is able to regulate the throttle in order to keep the airspeed constant (and a minimum ground speed).  


When you buy the airspeed sensor it is set to operate in the default mode. Make sure you did not set it somehow to 3rd party mode.
When you buy the airspeed sensor it is set to operate in the default mode. Make sure you did not set it somehow to 3rd party mode.


First, connect the sensor directly to the TWOG or Tiny autopilot board via the I2C connector (J6 on the board). The wires coming from the sensor module have the following layout:
First, connect the sensor directly to the TWOG or Tiny autopilot board via the I²C connector (J6 on the board). The wires coming from the sensor module have the following layout:


  Red wire: 5V
  Red wire: 5V

Revision as of 06:10, 1 August 2010

Introduction

By default, in the airborne code, airspeed is estimated by measuring the GPS ground speed. This gives reasonable results particularly in calm weather conditions. Adding an airspeed sensor measures actual airspeed resulting in better throttle control and aircraft performance especially in windy conditions. It is possible to build your own airspeed sensor by using pressure sensors. To start with adding airspeed sensors it is easier to buy pre-build calibrated airspeeds sensors.

Connecting an EagleTree Airspeed Sensor

The EagleTree Airspeed Sensor is a low cost module and comes with a very good pitot tube (Prandtl style, pitot-static tube) that includes static and dynamic ports. It has an I²C interface that connects directly to the Autopilot I²C port. The paparazzi autopilot code is able to regulate the throttle in order to keep the airspeed constant (and a minimum ground speed).

When you buy the airspeed sensor it is set to operate in the default mode. Make sure you did not set it somehow to 3rd party mode.

First, connect the sensor directly to the TWOG or Tiny autopilot board via the I²C connector (J6 on the board). The wires coming from the sensor module have the following layout:

Red wire: 5V
White wire: Ground
Yellow wire: SDA
Brown wire: SCL

Making hardware known to the Autopilot

To get it all to work the hardware must be made know to the autopilot code. This is accomplished by adding the following near the end of the airframe file:

   # ** Use EagleTree airspeed, altitude etc. modules over I2C. If already defined else add -DAGR_CLIMB 
   ap.CFLAGS += -DUSE_AIRSPEED_ETS -DUSE_AIRSPEED -DUSE_I2C0 -DAGR_CLIMB
   ap.srcs += airspeed.c airspeed_ets.c i2c.c $(SRC_ARCH)/i2c_hw.c

Airframe configuration

Now to use real airspeed values for adjusting your aircraft autopilot behavior, add the following to the end of the "VERTICAL CONTROL" section of your airframe file:

   <define name="AUTO_AIRSPEED_SETPOINT" value="13.0" unit="m/s"/>
   <define name="AUTO_AIRSPEED_PGAIN" value="0.060"/>
   <define name="AUTO_AIRSPEED_IGAIN" value="0.050"/> 
 
   <define name="AUTO_GROUNDSPEED_SETPOINT" value="7.0" unit="m/s"/>
   <define name="AUTO_GROUNDSPEED_PGAIN" value="0.75"/>
   <define name="AUTO_GROUNDSPEED_IGAIN" value="0.25"/>  
 

Note that the SETPOINT values may need to be adjusted to suit your aircraft.

See paparazzi3/conf/airframes/easystar2.xml for an example airframe configuration.

Seeing the spped values

The airspeed can be displayed in the Messages tool by adding the AIRSPEED message to /conf/telemetry/default.xml as follows:

 <process name="Ap">
   <mode name="default">
     <message name="AIRSPEED"   period="1.0"/>
     ...

Please note that in the GCS, the strip displays ground speed and **not** airspeed by default. In order to display airspeed, drag-and-drop the airspeed message field from the Messages tool onto the 2D map of the GCS.

How does it work internally

The altitude and airspeed loops are separated as shown in the diagram below. Basically the throttle and pitch are controlled independently and are not coupled in the control loops (of course one affects the other but the control loops are independent). The airspeed is controlled by two cascaded PI loops, the first is used to regulate the ground speed and the second the airspeed. This is needed to ensure that if the ground speed drops below a certain value the airspeed will be increased to compensate (in order to maintain a valid GPS heading).

Airspeed.png


The following plot is from an actual test flight after spending some time setting the loop gains (the real-time tuning through the GCS is a time saver!). The plane was flying circles at a constant altitude (except in the end). The wind was about 5 m/s, judging from the ground speed variations. In the middle there is an example of what happens when the ground speed falls below the setpoint. Finally the altitude setpoint was changed to verify that the airspeed will be maintained while climbing.

PlotAS2.png


The benefits of the airspeed hold are obvious in this example. The throttle adjusts to keep the airspeed close to the setpoint.

09 10 04 17 50 27 as1.png


Measuring

Sometimes it is very helpful for tuning your aircraft that you only measure the airspeed without controlling you aircraft behavior. This can be accomplished in the following way:

UNTESTED! set your AUTO_AIRSPEED_SETPOINT to zero.

EagleTree sensor in direct mode

While it is possible to use the sensors in direct mode a.k.a. 3rd party mode, for regular use with the autopilot it has no specific advantage, since the paparazzi already contain code to convert values to real speed values. Using the default setting is even better if you have an eagletree logger, you do not need to reprogram the sensors if you connect them to the Autopilot board again. But maybe you have a special requirement and want to use the direct mode, it is possible. For this at the moment one needs to use the Eagletree software under Windows. Regardles that his software runs fine under Linux Wine, using is not possible since the USB port is used in HID mode and as of Wine v1.2 using the USB bus under wind this way is not possible yet. There is however work done and on its way that USB ports do work under Wine for HID device

What needs to be improved

The following aspects still need to be looked at, revert to GPS measurements only if the airspeed sensor fails. If you are able to code I would be really great if you would help out by testing and improving this part of the code.

Thanks very much to Vassilis and OpenUASfor developing and testing the code.