Project tutorial
Ground Proximity Sensing with Ultrasonic Sensor

Ground Proximity Sensing with Ultrasonic Sensor © GPL3+

It is a miniature counterpart of radio altimeter used on commercial aircrafts to be used with RC aircrafts and multirotors.

  • 4,326 views
  • 0 comments
  • 8 respects

Components and supplies

About this project

Ground Proximity Sensing for RC Aircrafts and Multirotors

The only difference between Ultrasonic Sensor and Radio Altimeter is that former uses "Sound waves" and latter uses "Light waves" and hence the difference between their speed of propagation in atmosphere.

Introduction

The Barometric Altimeter provides altitude with respect to fixed datum that is AMSL – Above Mean Sea Level altitude. The IMU – Inertial Measurement Units like MEMS – Micro Electro Mechanical Systems can only provide the information of attitude of aircraft relative to its axis. So there is a need for third sensor to measure height of aircraft above ground and relative vertical movement between aircraft and ground (terrain). Such system exists in modern airplanes as GPWS – Ground Proximity Warning System, which employs RAM – RADAR Altimeter to measure the AGL-Above Ground Level height. Since the compact sized programmable RAM is not available to be used with R.C. System, we should have to rely on other means to measure the distance. That way is to use the Ultrasonic Distance Measuring Unit, which is widely available and reliable in its operating range.

Importance

The falling of the aircraft can be measured by IMUs like MPU-6050, MPU-9250 and so many. But what if aircraft is in level flight at constant altitude and the ground is coming closer to the aircraft due to slope or there is a sudden step in ground like a stone or anything else, it can lead to a catastrophe. Such incidents are known as CFIT - Controlled Flight Into Terrain in Aeronautical studies. Measuring the obstacles beneath the aircraft is importance of this project. All you need to do is just attach this system on aircraft and place the Ultrasonic sensor under the aircraft facing downwards towards land.

About our system

The theory of operation of echo location is simple :

  • The Transmitter sends a pulse of Ultrasonic sound of some time interval.
  • This pulse travels through the air and if there is some obstruction, than it reflects from obstruction.
  • The Receiver receives this reflected pulse and the measures the time delay between transmission and receiving of pulse.
  • Since, the propagation of sound wave can be fairly considered as straight, the sound wave covers twice the distance between the transmitter and the obstruction during this time period.
  • So, the distance can be found using the simple formula of speed as follows :

Note that the code is fully compatible with Arduino MEGA without any modification and so same pin numbers as of UNO.

Measurement Principles

Principle of Distance Measurement :

  • Using Echo - Location

Principle of Sensing :

  • The Brightness of LED is negatively proportional to the height.
  • The Rate of Blink is Proportional to Rate of Descent

So, the brightness of LED increases if the aircraft gets closer to the ground at lower height and decreases if aircraft gets away from ground at moderate height. Also the "Blinking Frequency" will increase if aircraft is falling and decrease if aircraft is climbing.

Note that we have considered the range of 0 to 1 meter above ground for achieving above noted goals in following codes. However, you can extend your range up to the reliable operating range of your Ultrasonic distance measurement sensor which is generally up to 4 meters.

Actual setup

Code for Height - Brightness of LED

int triggerpin=10;
int echopin=11;
long duration;
long distance;
long x;
void setup() {
 // put your setup code here, to run once:
pinMode(triggerpin,OUTPUT);
pinMode(echopin,INPUT);
pinMode(9,OUTPUT);
Serial.begin(9600);
}
void loop() {
 // put your main code here, to run repeatedly:
digitalWrite(triggerpin,LOW); 
delayMicroseconds(2);
digitalWrite(triggerpin,HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin,HIGH);
duration=pulseIn(echopin,HIGH);
x=(duration/2)/29.1;                //1/29.1=0.034 ~ speed of sound converted into centimeters per microsecond
Serial.print("Distance :");
Serial.print(x);
x=map(x,0,100,255,0);      //mapping the intensity as per distance
Serial.print("\t");
Serial.print(x);
Serial.println();
if(x<255 && x>10)                 //code stability condition
{
 analogWrite(9,x);
 }
 else if (x<10) 
 {
   analogWrite(9,0);
   }
   else 
   {
     analogWrite(9,0);
   }
}
 int triggerpin=10;
int echopin=11;
long duration;
long distance;
long x;
long x1=45;
int z;
void setup() {
 // put your setup code here, to run once:
pinMode(triggerpin,OUTPUT);
pinMode(echopin,INPUT);
pinMode(9,OUTPUT);
Serial.begin(9600);
}
void loop() {
 // put your main code here, to run repeatedly:
digitalWrite(triggerpin,LOW);
delayMicroseconds(2);
digitalWrite(triggerpin,HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin,HIGH);
duration=pulseIn(echopin,HIGH);
x=(duration/2)/29.1;
Serial.print("Distance :");
Serial.println(x);
z=(x1-x)/2;
x1=x;
Serial.print("\t z :");
Serial.println(z);
z=map(z,-10,6,1000,5);
analogWrite(9,HIGH);
delay(z);
analogWrite(9,LOW);
delay(z);
}
In above sketches, the pin 9 is attached LED.

Note that above code for rate of change of height is very fine tuned to measure very slight descent of aircraft downwards, you can change the sensitivity by changing the values in map function in above code, but proceed with keeping reality of flight in mind, where it is most essential to measure even the slight descent of aircraft which may result in free fall further and then crash.

Videos :

The setup shown in videos is for testing purpose only, it is not mounted under an aircraft !!

Video 1

Video 2

Applications

  • For Night Flying, can be used with array of lights and may be buzzer as warning signal.
  • The data can be used to produce the terrain map, so called terrain mapping.
  • As Autopilot input to avoid collision with ground and to maintain constant AGL altitude, like to Elevator up to perform pitch up if flying closer to ground.
  • For Aerial Delivery systems to be used by E-Commerce companies.

Limitations

  • The Cone of propagation of Ultrasonic Transmitter is very narrow of order of 12° (as per our experimental measurements suggest). Meaning The Distance measurement becomes unreliable for AOA (Angle of Attack ) more than 12° or for terrain having slope larger than 12°. This limitation can be over come by pivoting the sensor on Gimbal and rotating the sensor with Servo Motor or using multiple Ultrasonic Sensors at different angles and Synchronization between these sensors.
  • The speed of Sound is a function of Temperature of ambient air and Moisture Content in air, however this limitation can be overcome by calibrating the Code with local Atmospheric conditions using any Temperature Sensor available as speed of Sound is given by :
  • So, we need to add extra code for calibration for speed of sound or just change the speed of in above code according to the temperature in which aircraft is intended to operate.

{

//Thank You ;

}

Code

stable_ultrasonic_blink.inoArduino
A code to sense rate of change of altitude of aircraft above ground in form of blinking of LED
int triggerpin=10;
int echopin=11;
long duration;
long distance;
long x;
long x1=45;
int z;
void setup() {
  // put your setup code here, to run once:
pinMode(triggerpin,OUTPUT);
pinMode(echopin,INPUT);
pinMode(9,OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(triggerpin,LOW);
delayMicroseconds(2);
digitalWrite(triggerpin,HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin,HIGH);
duration=pulseIn(echopin,HIGH);
x=(duration/2)/29.1;
Serial.print("Distance :");
Serial.println(x);
z=(x1-x)/2;
x1=x;
Serial.print("\t z :");
Serial.println(z);

if(z<-10)
{
analogWrite(9,25);
delay(1000);
analogWrite(9,LOW);
delay(1000);
}
else if(z>6)
{
analogWrite(9,25);
delay(10);
analogWrite(9,LOW);
delay(10);
}
else
{
  z=map(z,-10,6,1000,5);
analogWrite(9,25);
delay(z);
analogWrite(9,LOW);
delay(z);
}
}
stable_ultrasonic_brightnessArduino
To measure the height and change brightness of LED accordingly.
int triggerpin=10;
int echopin=11;
long duration;
long distance;
long x;
void setup() {
  // put your setup code here, to run once:
pinMode(triggerpin,OUTPUT);
pinMode(echopin,INPUT);
pinMode(9,OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(triggerpin,LOW); 
delayMicroseconds(2);
digitalWrite(triggerpin,HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin,HIGH);
duration=pulseIn(echopin,HIGH);
x=(duration/2)/29.1;                //1/29.1=0.034 ~ speed of sound converted into centimeters per microsecond
Serial.print("Distance :");
Serial.print(x);
x=map(x,0,100,255,0);      //mapping the intensity as per distance
Serial.print("\t");
Serial.print(x);
Serial.println();
if(x<255 && x>10)                 //code stability condition
{
  analogWrite(9,x);
  }
  else if (x<10) 
  {
    analogWrite(9,0);
    }
    else 
    {
      analogWrite(9,0);
    }
}

Schematics

circuitDiagram
The fritzing drawing of circuit diagram
groundproximitysensing_Ea1RJSBJWT.fzz

Comments

Similar projects you might like

Ultrasonic Sensor with LCD Display Using 433MHz

Project tutorial by mcharrison500

  • 6,005 views
  • 1 comment
  • 22 respects

Door Alarm With Ultrasonic Sensor

Project showcase by MattG

  • 9,399 views
  • 3 comments
  • 13 respects

IOT - Smart Jar Using ESP8266, Arduino and Ultrasonic Sensor

Project tutorial by Team Smazee

  • 7,669 views
  • 5 comments
  • 14 respects

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 7,296 views
  • 7 comments
  • 21 respects
Add projectSign up / Login