An Adaptive Speed Control and Obstacle Detection in MAV using HCSR04 Ultrasonic Sensor

Download Full-Text PDF Cite this Publication

Text Only Version

An Adaptive Speed Control and Obstacle Detection in MAV using HCSR04 Ultrasonic Sensor

Pavithra B. G

GSSS Institute of Engineering & Technology for Women, Mysuru – 570016.

Sushma S J

GSSS Institute of Engineering & Technology for Women, Mysuru – 570016.

Siva Subba Rao Patange CSIR-National Aerospace Laboratories,

Bangalore – 560017, India.

AbstractThis paper demonstrates Ultrasonic sensor is defined by measuring the distance of obstacle avoidance. This sensor are measure the range of obstacle. In this paper an algorithm was successfully detected the obstacle distances. This sensor works only sound pulse and it is converting from sound signals to electrical signals. Initially if present the obstacle in front of sensors, it was detected. This ultrasonic sensor works based on sound of things or human sounds. In this paper an algorithm has been developed with RPM speed variation and controlling of the vehicle. Hence avoid the collision of MAV vehicle. This algorithm was interfaced with Arduino Uno board and this Arduino Uno board acts as both input and output of control board. The quadcopter of ESC is control the speed of motors and the any obstacle is present in front of ultrasonic sensor. Ultrasonic sensors were plotted different colour waveform. This result said that ultrasonic sensor detect the obstacle around 315 cm in indoor environment. This ultrasonic sensor is best compare to other sensors like IR sensor, LASER sensor etc. Each sensor has different characteristics and features. This algorithms were implemented is useful of avoid the obstacle of MAV and decreasing processing time, speed than other algorithm.

Keywords Ultrasonic sensor, Quadcopter, Servomotors, Electronic speed control, Arduino Uno board, RPM meter


    The MAV means micro air vehicle. This is used only hobby purpose. This MAV will be flying in any environment condition i.e. outdoor and indoor environment condition. In this project, moving safety vehicle is importance. Consider there were tested to many sensors like IR sensor, LASER sensors, sound sensors etc. using cameras and It was done. The ultrasonic sensor is sends sound wave and gets back to echo pin. These ultrasonic sensors consist of transmitter and receiver module and it has Atmega16a MC. The pulse transmits from microcontroller to ultrasonic sensors and triggered with the transmitter pulse. Here to designed and developed for many methods as successfully to detect the obstacle from the target graph are done. In measuring the distance was comes lots of errors. IR sensor can detect less distance.


    The main concept of ultrasonic sensor is detecting the obstacle and processing time will be decreasing. It offers highest accuracy and resolution. These sensors can detect ranging up to 400 cm. In practically, from 2 cm to 315 cm measuring the distance in indoor environment condition but outdoor environment is working properly. This ultrasonic

    sensor has transmitter and receiver module. The ultrasonic sensor contained 4 pins namely VCC, trig, Echo and GND.

    Fig. 1. Ultrasonic sensor HC-SR04

    Fig. 2. Working principle of Ultrasonic Sensor

    The transmitter signal called as trigger of input signal and reflected signal called as echo of output signal. Ultrasonic sensor required 5 V DC power supply with operating current 15ma, measuring angle around 30 degree and resolution of this sensor is 0.3 cm. the ultrasonic sensor working principle is sends the signals from trigger to reflected the echo pin. The ultrasonic sensor of transmitter is sends the signals to receiver. The ultrasonic senor has one feature i.e. hit and bounce characteristics, whenever there is obstacle and present nearer it. Again transmitter sends the signal in this way. Its totally working on echo pin. The ultrasonic distance can be calculated in method. The signal sends 8 clock cycles. This ultrasonic sensor provides about at 5 V for 10msec. this is applied for trig pin in the sensor. It sends cycles of 8 pulses of 40 kHz. It waits for some interval of time for reflects the signal. Then reflects the signal from the echo pin there will be a delay for period automatically and it is equal to distance of the object.

    • Speed of the sound is 340m/s

    • Distance of the obstacle is time/ 58 in cm

    • Distance of the obstacle is time /148 in inches

  3. ARDUINO UNO BOARD AND APM BOARD The board acts as control board of input and output. This

    board can give the information to the Arduino IDE software. It is reprogrammed device and Atmega 328 processor used.

    Fig. 3. Arduino Uno board

    This Arduino Uno board is interfacing with Arduino IDE software by using USB cable. The software is working in C program or java. That Arduino IDE version is 1.8.5 version and it consisting of 13 digital pins, 6 analog pins, +5V, 2 GNDS, USB interface, external power supply. Once program is load on the Arduino board and its starts working. This Arduino board interfacing with Pixhawk board and Arduino Uno board is collecting the data from 4 sensors. The APM board has one telemetry ports. TEL is used to communicate from the RC transmitter to the ground station and also it is used to communicate with the Arduino Uno board.

    Fig. 4. APM board

    A TEL port act has a UART port and when the transmitter is interactive with the Arduino board and PIXHAWK autopilot board. The PIXHAWK analog pins are connected to the 8- channel transmitter and this transmitter is connected to the RC transmitter for continuing to the vehicle. This gives the information to ESC and also gives the suitable speed of the motor.

    The above figure 5 is block diagram of quadcopter of MAV using 4 sensors. The 4 sensors are connecting all the 4 sides, these Ultrasonic sensors send the signals to the obstacles and again get back to echo signal. The Arduino Uno board collects the data from all 4 sensors then distance at which obstacle is present and nearer it. This operation is to be performed and maintained the time here and also notes the time information. This Arduino Uno board connected with the APM board for suitable pin diagram. APM board gives the information or data to ESC and provides certain speed of the motors and it complete autopilot board. Next the APM board connected with ESC. This ESC is control the speed of motors using manual mode, whenever there is obstacle. Servomotors are provides certain speed. Therefore ESC will provide high current to move the servomotor at higher speed. MAV system accepts powered with 12.5V and this power goes all equipments of this system. APM consists of many internal sensors like gyroscope, accelerometer, GPS etc. the servomotors directly not connected through ESC by using this channel. Transmitter information of autopilot board is collected from telemetry to ground station. In mission planner of the baud rate is fixed and the ground station has telemetry and same baud rate received. The MAV data displayed on software of mission planner and when power gives this system automatically saved the data, graph everything. Initially calibrating the quadcopter using mission planner compass and accelerometer calibrations are performed. The ultrasonic sensors distance and voltage can be viewed as Arduino IDE of serial monitor.


      First 4 ultrasonic sensors of quadcopter was used and before connecting the quadcopter AP has to calibrated. The calibrations are GPS, compass, Ultrasonic sensor. The suitable program was dumped on the Arduino board depending on MAV. In program, ultrasonic sensor pis, pitch and roll condition should have to mention and Mavlink library files also added in that ARDUINO IDE software.



        (ATmega 328 PROCESSOR)

        The MAV has transmitter and receiver part in the ground station, received the data from the sensors and quadcopter of MAV used

        SENSOR 1

        SENSOR 2

        SENSOR 4





        Fig. 5. Block Diagram of MAV Quadcopter

        Fig. 6. Complete setup of MAV

        SENSOR 3

        The 4ultrasonic sensor was connected to Arduino board along with digital pins. The 4 sensors can be connected from ultrasonic sensor of trig pin to Arduino board of digital pins as well as ultrasonic sensor of echo pin to Arduino board of digital pin, this information mentioned in code and also assigned limit distance is 100 cm. this board was interfacing with Arduino software. Initially code dump to Arduino board, from Arduino board to APM board like this have to setting all obstacle data was taken individually pasted through the mission planner and voltage versus distance displayed on mission planner and automatically plotted. Fig 6 is complete setup of MAV vehicle. The quadcopter implemented with all 4 sensors.

        Rom sensors information transmits to flight control board of mission planner software. The servomotor connected with ESC. The ultrasonic sensor sensors measuring around 30 degree angle and this measured in 4 sides. The 3 connected with APM board. The ultrasonic sensors pin o transmitter and echo are connected with Arduino board given power supply to the MAV and it takes around 12.5 V. This autopilot system works based on telemetry. This project main idea is used to detect the obstacle, developing the algorithm, to find the RPM speed whenever there is obstacle.

        1. METHODOLOGY

          This project MAV wants to detect the obstacle, avoid the collisions and last is note down speed of motor using RPM meter. This system starts flying, when MAV is on, and calculating the distance by using sensors. The ultrasonic sensor sending sound pulse continuously and then distance data collected by 4 sensors, when collected the distance data from all sensors, its start working.

          Fig. 7. Flow diagram of obstacle avoidance

          The above algorithm of obstacle detection is as shown in fig 7. Initially assign the sensor distance in the code, If the collected data distance is less than 30 cm for example first consider one sensor, obstacle is present in front end side, that vehicle will move to left or right or back and I will come back and action like this it is working. When present obstacle in one sensor, it will take action by pitch or roll movement i.e. right left or back or front and it will go to flight. Again obstacle is present in 2 sensors, it will get 2 sides of pitch or roll movement and again it will got flight. Next obstacle is present 3 sensors, it will move only one side i.e. either left or right or back or front and the system will go to flight. Last obstacle is present all 4 side sensors. It will take only up or down direction and system come back, it will go to flight. Again come back to loop. These systems detect the distance in only indoor environment.


          Tests were conducted and satisfactory results were obtained. The obstacle was present from 2 to 31 cm and corresponding reading was collected in mission planner. Then pitch and roll movement shown in different colour. Then serial plotter of ultrasonic sensor is shows the distance versus voltage is as shown fig. the voltage gives different colours when obstacle is present and distance was depends on obstacle. The result was shown by mission planner with different object. This graph comes by mission planner software. This is automatically when fly that vehicle. The telemetry is connected to the board and that result was move to the ground station through telemetry and to mission planner, telemetry has been connected. Then code was dumped on Arduino board and distance was collected this distance shown in serial monitor of Arduino IDE software. All the distance was displayed for required pitch and roll movement. This movement was shown in plot figure 8.

          Fig. 8. Serial plotter showing Pitch and Roll

          The above figure 8 shows Serial plotter showing Pitch and Roll movement. Roll represented by green colour, pitch represented by red colour. In X axis time showed and in y-axis roll and pitch movement showed. This value represents pitch was increases when obstacle is present in pitch movement, roll movement was increases when obstacle is present in roll side.

          Fig. 9. RPM speed ofMotor 0 and 2

          Fig. 10. RPM speed of Motor 1 and 3

          The above figure 9 and 10 graph can be seeing the speed variations by the motors and also distance. Experimental condition is done using MAV. When the vehicle moving initially RPM speed will be constant value around then there is no obstacle. Then one front side sensors senses the obstacle, the front motors speed is increases depending on the distance and back 2 motors decreases the speed and vice versa. Then I will take back and passes by the suitable directions and this motors speed variations working depends on the environment conditions.

        3. CONCLUSION

In this paper different obstacle and RPM speed test were conducted using 4 sensors and motors. The voltage initially constant some range when on the MAV and indicates with different obstacle. The mission planner used to identify the location of the moving vehicle and to take voltage and distance reading, plotted automatically. These algorithms were conducted that detect the obstacle and calculate the RPM speed of the vehicle. The mission planner was used to take with respect to distance and voltage values are more suitable for obstacle detection in quadcopter for indoor environment. The algorithm showed that the obstacle was detected and collision avoided.


The authors would like to thank the Director, Mr. Jitendra J Jadhav CSIR-National Aerospace Laboratories for his persistence to carry out the work and Dr. Satish Chandra, Head Structural Technologies Division (STTD) for providing all the facilities for completing this work. My Special thanks to Mr. Rohith, Project Assistant and Mr. TiruPathi, Project Assistant of, Structural Technologies Division (STTD), CSIR-National Aerospace Laboratories, for their help.


  1. K R Prashanth, Preetham Shankpal, B Nagaraja, Govind R. Kadambi, S R Shankapal, Real time obstacle avoidance and navigation of a quad- rotor mav using optical flow algorithms, SASTECH Journal, Volume 12, Issue -1, April 2013.

  2. Jeffery B. Saunders, Brandon Call, Andrew Curtis, Randal W. Beard, Static and dynamic obstacle avoidance in miniature air vehicles, American institute of Aeronautics and Astronautics, September 2005.

  3. Nils Gageik, Thilo Müller, Sergio Montenegro, Obstacle detection and collision avoidance using ultrasonic distance sensors for an autonomous quadrocopter, University of Wurzburg, Aerospace Information Technology (Germany), september 2012.

  4. Kirill E. Shilov, Vladimir V. Afanasyev and Pavel A. Samsonov, Vision-based navigation solution for autnomous indoor obstacle avoidance flight, International Micro Air Vehicle Conference and Flight Competition, 2013.

  5. James F. Roberts, Timothy S. Stirling, Jean-Christophe Zufferey and Dario Florean, Quadrotor using minimal sensing for autonomous indoor flight Ecole Polytechnique Fédérale de Lausanne (EPFL), Lausanne, 1015, Switzerland,2007.

  6. J. Junell, E. Van Kampen, Adaptive path planning for a vision-based quadrotor in an obstacle field, Delft University of technology Aerospace Engineering, Control and Simulation, 2016.

  7. O. Gunesh war Singh, Self-navigating quadcopter, International Journal of Computer Science and Information Technologis, Vol.6 , No. 3, 2015.

  8. K. Shrivastava, A, Verma, and S. P. Singh, Distance measurement of an object or obstacle by ultrasound sensors using p89c51rd2, International Journal of Computer Theory and Engineering, Vol. 2, No. 1 February, 2010.

  9. William E. Green and Paul Y. Oh A multimodal mav for situational awareness in near-earth environments, Drexel Autonomous Systems Lab, Drexel University, Philadelphia, 2007.

  10. Sulaiman Sabikan, Sophan Wahyudi Nawawi and Shahdan Sudin, A Servay of onboard sensor for quad rotors collision avoidance system, Department of Electrical Engineering Technology, Fakulti Technology Krjuruteraa. 2012.

Leave a Reply

Your email address will not be published. Required fields are marked *