Hello and welcome to our community! Is this your first visit?
Register

Altitude Hold

This page is a chapter in 'Introduction to additional features'

Altitude Hold

General description

Altitude Hold is a control mode in which the altitude of your copter existing at time of engagement is maintained automatically by analyzing pressure data provided by the barometric pressure sensor and if installed by a ultrasonic sensor (supported in flight software version 3.0 or greater).

Software

In order to activate Altitude Hold with barometer and/or ultrasonic sensor in the software you need to (un)comment the appropriate lines in "UserConfiguration.h", so it may look like this:

Code:
#define AltitudeHoldBaro // Enables BMP085 Barometer (experimental, use at your own risk)
#define AltitudeHoldRangeFinder // EXPERIMENTAL : Enable altitude hold with range finder
Moreover your transmitter/receiver combination must provide a sixth channel (connected to "AUX1" pin on the shield) which should be assigned to a 2-way switch on your transmitter. If the received value of this channel is under 1750, Altitude hold mode is switched on, otherwise it's off.
To verify the correct operation of your switch, connect the copter to your computer, start the AeroQuad configurator, turn on your transmitter and select "Vehicle status" in the "Information Display" fly-out. Here you will notice the columns "Aux1" and "Altitude Hold" - check if flipping the switch causes the desired change in Altitude Hold mode. If that's not the case, calibrate your transmitter again or check the connection between the receiver and the AeroQuad shield.

Altitude Hold switch (click on images for higher resolution)

Hardware

Barometric Pressure Sensor BMP180

Specifications

  • Digital two wire (I²C, TWI, “Wire”) interface
  • Wide barometric pressure range
  • Flexible supply voltage range (1.8V to 3.6V)
  • Ultra-low power consumption
  • Low noise measurements
  • Factory-calibrated
  • Includes temperature sensor
  • Low-profile with a small footprint


Shop link: AeroQuad Store

Schematic: Link
Datasheet: Link

Mounting

Note:
The pictures below show the BMP085 sensor which is discontinued and replaced by the BMP180 sensor. Nevertheless the information given below applies to the BMP180 sensor in the same manner.

It's important to protect the sensor against direct sunlight and airflow from the propellers to ensure correct readings and sensor data of high quality. There are two possible methods to achieve this:

If you are using an AeroQuad shield, the most comfortable way is to insert the sensor from the bottom of the shield and solder its pins from the top. Be careful to match the pin assignments, meaning that each of the barometer board's pins is correctly in its hole in the shield. Installing the barometer under the shield will help reduce the aerodynamic effects from propellers which may give errors in pressure readings.



An alternative method is to cover your barometer with foam earphone covers mounted with double sided tape or shrink tubing.
  1. Easiest way to do this, is to pull an about 4x3cm big piece of shrinking tubing over a folding meter stick and heat it a bit so that it fits on the one hand closely to the folding meter stick, but on the other hand can still be taken off.


  2. Now take the shrinking tubing off and cut out a piece of foam which is big enough to cover the upper and lower side of the breakout board.




  3. Wrap the foam around the sensor board and pull the shrinking tube over the foam.


  4. In the last step heat the shrinking tubing up again, until it fits tightly to sensor board.


Barometric Pressure Sensor MS5611-01BA03 (AeroQuad32 flight control board)

Specifications

  • High resolution module, 10 cm
  • Fast conversion down to 1 ms
  • Low power, 1 µA (standby < 0.15 µA)
  • QFN package 5.0 x 3.0 x 1.0 mm
  • Supply voltage 1.8 to 3.6 V
  • Integrated digital pressure sensor (24 bit ΔΣ ADC)
  • Operating range: 10 to 1200 mbar, -40 to +85 °C
  • I2C and SPI interface up to 20 MHz
  • No external components (Internal oscillator)
  • Excellent long term stability

Datasheet: Link

Mounting

It's important to protect the sensor against direct sunlight and airflow from the propellers to ensure correct readings and sensor data of high quality. To achieve this either use the protective case specifically designed for the AeroQuad32 v2 flight control board or simply put a piece of foam on the pressure sensor and secure it with hot glue.

Ultrasonic Range Finder Maxbotix LV-EZ0

There are two versions of the MaxBotix LV-EZ0 - it is necessary to know which one you own as they have a different scale factor.

Specifications

  • 42kHz Ultrasonic sensor
  • Operates from 2.5-5.5V
  • Low 2mA supply current
  • 20Hz reading rate
  • RS232 Serial Output - 9600bps
  • Analog Output - 10mV/inch
  • PWM Output - 147uS/inch
  • Range: 0 to 255 inches (0 to 6.45m)
  • Small, light weight module
Shop link: AeroQuad Store

Datasheet: Link

The LV-EZ0 current sold in the AeroQuad store has an MB1200 on it - this means the output has a resolution of 1cm. The ones previously sold in the store use the MB1000 - the output has a resolution of 1 inch. It is important that you know which one you have, as you will need to modify ".../Libraries/AQ_RangeFinder/MaxSonarRangefinder.h"", line 46:

Code:
//{ ALTITUDE_RANGE_FINDER_INDEX, A1, 24, MB1200},    
{ ALTITUDE_RANGE_FINDER_INDEX, A1, 0, MB1200}, // <--- this line!
//{ FRONT_RANGE_FINDER_INDEX, A2, 25, MB1000},
//{ RIGHT_RANGE_FINDER_INDEX, A3, 26, MB1000},
//{ REAR_RANGE_FINDER_INDEX, A4, 27, MB1000},
//{ LEFT_RANGE_FINDER_INDEX, A5, 28, MB1000}
As you can see, the last variable is MB1200 or MB1000. If you're using an MB1200, simply connect the analog output to A1, compile with AltitudeHoldSonar enabled, and upload the code. If you're using the MB1000, you'll need to change MB1200 to MB1000 on the uncommented line, compile with sonar enabled, and upload. You can also change with analog port is used by changing A1 to A2, or whatever port you want to use.

Mounting

It's important to isolate the sensor against vibrations produced by the copter to ensure correct readings and sensor data of high quality. To achieve this simply put a piece of foam between the frame and the sensor.

Connection to flight controller board

The ultrasonic sensor which is pointing down to the ground needs to be connected to Analog Pin 1 (or "RNG" on AeroQuad32 v2 borad) on the AeroQuad32 board and the v2.0/2.1 shield like in the figure shown below.
For users of the AeroQuad32 v1 board it's advisable to power the sensor from an external source, e.g. from the ESC BEC. On the AeroQuad32 v2 board the power already comes from the ESC BEC of ESC No. 3, so you can connect it directly to the 3-header pins marked below.

Ultrasonic sensor wiring diagram:

AeroQuad32 v2 board

AeroQuad32 v1 board

v2.1 shield

v2.0 shield

Operation

When you activate altitude hold, the AH controller notes your current altitude and throttle setting. The altitude becomes the to-hold target while your current throttle setting becomes the base setting against which the AH controller makes small adjustments to try to stay on the target altitude.

Note:
You should try and get the throttle position such that the copter is already hovering before trying to activate altitude hold, otherwise the controller will be fighting against the wrong setting all the time.

If you have both a barometer and a range finder, the AH controller will automatically choose which to use for current altitude determination. There's no indication of which is in use at any given moment, making troubleshooting a tad more difficult.

If you have these features enabled, activating position hold or autolanding implicitly activates altitude hold.

Tuning

If you are looking at the "Altitude Hold" tab of the Configurator you will notice some adjustments that can be made to tune the Altitude Hold algorithm.

ParameterDescription
Altitude Proportional/Integral/DerivativeThese are the constants for the Altitude Hold PID. This PID takes the difference between the current altitude and the target altitude and produces the throttle adjustment. (Actually, these constants are used when the AH controller is paying attention to the barometer. When it's using the range finder, it effectlivly doubles the P constant.)
Altitude Windup GuardPlaces a limit on the integrated error that makes the I term work.
Throttle Bump ValueThe amount of throttle shift that needs to be given to cause the Altitude Hold algorithm to start varying the target altitude. So if you push up a little, it will start moving up. Put it back to the hold position and it'll continue to hold in the new height.
Throttle Panic ValueThe amount of throttle shift that will force altitude hold off. So if you slam the throttle up or down a lot, it will cut out the Altitude Hold until you toggle it again. Note that, if you move the throttle stick up or down a lot, this throttle value will be directly applied to the motors after Altitude Hold is disabled!
Minimum Throttle Adjust
Maximum Throttle Adjust
Places upper and lower bounds on the throttle adjustment that the AH PID is allowed to make.
Altitude Smooth FactorAH sends raw altitude measurements through an exponential moving average filter to tone down spikes and noise before presenting it to the PID controller. The smoothing "factor" is a value between 0 and 1. The smaller the value is, the less jitter and smoother the altitude readings will be, but at the expense of increasingly laggy. (I.e: A factor of 0.2 means that the current smoothed altitude reading is 20% of the current raw altitude reading plus 80% of the previous smoothed altitude.) Normally the default doesn't need to be changed if your barometer is properly protected against direct sunlight and wind as described above.
Z Dampening Proportional/Integral/DerivitaveThese PID values should not be used at the moment, so leave them zeroed.

Throttle bump, panic, and min/max adjust values are on a scale of 1000. They're relative to the throttle setting that was saved on entry to AH.

Additional information


This page has been seen 43,343 times.

    • Created by on
      Last updated by on