Difference between revisions of "Airspeed sensor"

From PaparazziUAV
Jump to navigation Jump to search
Line 1: Line 1:
By default, airspeed is estimated by measuring the GPS ground speed. This gives reasonable results particularly in calm conditions. Airspeed sensors measure actual airspeed resulting in better performance especially in windy conditions.  
By default, airspeed is estimated by measuring the GPS ground speed. This gives reasonable results particularly in calm conditions. Airspeed sensors measure actual airspeed resulting in better performance especially in windy conditions.  


=Connecting the EagleTree Airspeed Sensor=
==Connecting the EagleTree Airspeed Sensor==


The module is low cost and comes with a very good pitot tube (Prandtl style, pitot-static tube) that includes static and dynamic ports. The autopilot code has been modified to regulate the throttle in order to keep the airspeed constant (and a minimum ground speed).
The [http://www.eagletreesystems.com/Support/manuals/airspeed-v3.pdf 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 I2C interface that connects directly to the Tiny/TWOG I2C port. The autopilot code has been modified to regulate the throttle in order to keep the airspeed constant (and a minimum ground speed). The airspeed sensor should be set to operate in the default RAW mode (not switched to 3rd party mode).


The EagleTree Airspeed sensor is quite easy to connect to the Tiny/TWOG . The sensor has an I2C interface that connects directly to the Tiny/TWOG I2C port. I was able to figure out the slave address and decode the raw output of the sensor. The results are quite good,
First, connect the sensor directly to the TWOG (J6). The sensor module wires are:
First, connect the sensor directly to the TWOG (J6). The sensor module wires are:
Red wire: 5V
    Red wire: 5V
White wire: Ground
    White wire: Ground
Yellow wire: SDA
    Yellow wire: SDA
Brown wire: SCL
    Brown wire: SCL
   
   
Then, in the airframe file (near the end of the file), you have to add:
Add the following to the end of the "VERTICAL CONTROL" section of the airframe file:
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
 
At the end of the "VERTICAL CONTROL" section of the airframe file, you have to add:
     <!-- auto airspeed and altitude inner loop (for airspeed sensor) -->
     <!-- auto airspeed and altitude inner loop (for airspeed sensor) -->
     <define name="AUTO_AIRSPEED_SETPOINT" value="15.0" unit="m/s"/>
     <define name="AUTO_AIRSPEED_SETPOINT" value="15.0" unit="m/s"/>
Line 27: Line 20:
     <define name="AUTO_GROUNDSPEED_IGAIN" value="0.25"/>     
     <define name="AUTO_GROUNDSPEED_IGAIN" value="0.25"/>     
Note that the SETPOINT values may need to be adjusted to suit your airframe.
Note that the SETPOINT values may need to be adjusted to suit your airframe.
 
Then, in the airframe file (near the end of the file), you have to add:
    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
 
See paparazzi3/conf/airframes/easystar2.xml for an example airframe configuration.
See paparazzi3/conf/airframes/easystar2.xml for an example airframe configuration.


Thanks to [http://vrhome.net/vassilis/ Vassilis] for developing and testing the code.
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).
[[Image:Airspeed.png]]
The following two plots are 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.
[[Image:PlotAS2.png]]
The altitude gains were the easiest to tune. Altitude is maintained fairly decently, at the end the altitude setpoint was changed (aggressive climb mode was disabled). This is still using the GPS altitude, barometric altitude has been implemented but not tested yet (Kalman parameters may need some tuning).
[[Image:09_10_01__18_19_21_alt.png]]
The benefits of the airspeed hold are obvious in this example. The throttle adjusts to keep the airspeed close to the setpoint.
[[Image:09_10_04__17_50_27_as1.png]]
 
The following aspects still need to be looked at:
    * Test EagleTree sensors in 3rd party mode
    * Revert to GPS measurements if any of the sensors fail
 
Thanks very much to [http://vrhome.net/vassilis/ Vassilis] for developing and testing the code.

Revision as of 02:25, 26 July 2010

By default, airspeed is estimated by measuring the GPS ground speed. This gives reasonable results particularly in calm conditions. Airspeed sensors measure actual airspeed resulting in better performance especially in windy conditions.

Connecting the 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 I2C interface that connects directly to the Tiny/TWOG I2C port. The autopilot code has been modified to regulate the throttle in order to keep the airspeed constant (and a minimum ground speed). The airspeed sensor should be set to operate in the default RAW mode (not switched to 3rd party mode).

First, connect the sensor directly to the TWOG (J6). The sensor module wires are:

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

Add the following to the end of the "VERTICAL CONTROL" section of the airframe file:

   <define name="AUTO_AIRSPEED_SETPOINT" value="15.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="6.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 airframe.

Then, in the airframe file (near the end of the file), you have to add:

   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

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

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 two plots are 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 altitude gains were the easiest to tune. Altitude is maintained fairly decently, at the end the altitude setpoint was changed (aggressive climb mode was disabled). This is still using the GPS altitude, barometric altitude has been implemented but not tested yet (Kalman parameters may need some tuning). 09 10 01 18 19 21 alt.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

The following aspects still need to be looked at:

   * Test EagleTree sensors in 3rd party mode
   * Revert to GPS measurements if any of the sensors fail

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