The movie ‘3 idiots’ has been a major inspiration is to why I have started to work on this project. The project has really been helpful in increasing my knowledge in the filed of programming, physics & mathematics. I look forward to explore more in this field and try to contribute something in the drone industry.
Also, I would like thank youtuber Joop Broking whose videos have taught me a lot for developing the drone using Arduino.
And lastly, I would like to thank my family for always supporting and believing in me.
- Hardware Building:
A drone is nothing but an object that makes use of 4 motors to fly and receives input from user at a distance (i.e. why sometimes it is called a UAV – unmanned ariel vehicle).
The given 450mm frame would make use of 1000kv brushless motors and along with propellers of 8 to 10 inches long. Incase 450mm drone frame is unavailable one can use the following table to identify which motor and propeller to purchase for a particular drone size:
Selecting the electronic speed control depends upon the maximum input current taken by the brushless motors. I choose a 30 Amp esc for safety because my motors drew current much less than 30Amps.(Electronic speed control is just a small module that will allow us to control the speed of the motor by simply sending signals in the form of pulses).
The drone physics -> since we have got 4 motors, one set of motors would rotate in clockwise direction and the other in ccw. This happens because if all motors rotate in ccw to conserve angular momentum the quadcopter will perform yaw (rotate around the z axis) motion in cw direction.
Rotation about x axis -> Pitch
Rotation about y axis -> Roll
Rotation about z axis -> Yaw
Ensure that while soldering you solder the 1 pair of esc in cw and other pair in ccw format to the brushless motors. (i.e. one pair of esc should identically be soldered to the brushless motors -> yellow to yellow wire, black to black wire and red to red wire. In the next pair just flick any 2 wires). The other end of esc should be soldered to the power distribution board which is already present on the frame.
Soldered the Xt-60 connector to the frame which will later be used to connect the battery to the power distribution board.
- Arduino Connections:
The Arduino Uno is the main brain of this quadcopter and should be present at the center because the least vibration is felt there.
The MPU 6050 should be soldered on the Arduino prototype shield and the connections should be as follows ->
Vcc ->+5v
Gnd->GND
SCL ->A5
SDA ->A4
Major NOTE-> the esc should be kept as far as possible form the mpu6050 module because if they are kept close, due to the electromagnetic interference the esc would affect the values measured by the mpu module and make the quad unstable.
The signal wires of esc should be connected to pins D4 to D7 and the receiver module (of remote) should be connected to the pins D6 to D9.
To power up the Arduino we take input directly from the power distribution board and connect a diode in between them (This is done to ensure that when the code is being flashed onto Arduino the serial port of the computer should not get damaged due to high voltage of battery).
We connect 2 resistors of 1 and 1.5 kilo ohm to measure the battery voltage (this done by making the simple voltage divider circuit). The input voltage would be used to give an alert when the battery voltage falls down below a certain limit and give user alert).
- Module explanation:
- MPU6050:
This module would form the basic Inertial measurement unit (IMU) that will be used to measure the angle of quad in all the 3 axis. The accelerometer measures the linear acceleration that will be used to calculate the force acting on the quad in g’s(using the concept of Coriolis force).The value in g’s and inverse trigonometry would allow us to calculate the angle of quad.
The reason why we make use of gyroscope is to measure the angular velocity which again will be used to measure the angles. Simply accelerometer cannot be used because when quad is in motion the values given by it would be random and erratic. Therefore, by measuring the angular velocity and some fixed value in the datasheet we can determine the angle. Hence the IMU measures angles using 2 modules. Also, to reduce noise form such microelectronic mechanical sensors (MEMS) we make the readings pass through a filter.
- Arduino: The main code is run by this module. The code initializes all the modules and ensures that proper signals are received. Also a safety mechanism is added to ensure that the quad starts only when all remote sticks are in low position.
The code has a refresh rate of 250 HZ i.e. it makes corrections in every 4000 microseconds.
In this time, it is able to generate:
- Read Gyro angular data
- Calculate PID corrections
- Compensate pulse for voltage drop
- Send calculated pulses to esc
Each pulse is made up 1000 to 2000 microseconds.
- CODE EXPLAINATION:
The code file consists of 3 codes i.e
- YMFC_setup file->
This file is used to configure the whole quadcopter before flight and store the collected data in E2PROM (this allows us to store data on Arduino even if the power is removed from Arduino). This code is used to check the center as well endpoints transmitted by the remote control i.e. what values of signal in microseconds is send by the rc, this is essential as would limit the quadcopter’s flight based on the input. It also is used to configure the 3 axis of drone and determines which part is the nose of quad(this is done to ensure that no axis reversing is require i.e. if quad turns right the IMU should measure the angles in +ve degrees as this is the convention chosen).All these readings are stored on the eeprom of Arduino and later retrieved by the other modules by using the built in functions found in the <EEPROM.h> library.
- YMFC_esc_calibrate ->
This code is essential as it is used to synchronize all the motors of the quadcopter i.e. all the motors should start at same time on giving throttle. Along with that in this code we check the angles measured by IMU and estimate the correction required(not necessary at level the quad will show all angles 0 degrees).The receiver signals are checked and lastly this code is used to balance the propellers with the motors. This balancing is done so that the vibrations produced by the motors are less and does not affect are mpu6050 module, the balancing is done by applying a piece of insulating tape on the props to dampen it.
- YMFC_flight_controller->
The most import module. In this module we make use of all the previously collected data from other modules. The code initializes and takes around 2000 readings of angles to calculate any constant error that is required to be removed when the code executes in void loop().It also ensures that the battery voltage is optimum and all signals from remote are working or not.
In the void loop function the motors are started only when a special stick sequence is performed and also a special stick sequence is used to cut the motors. Later based on the input and orientation of quad the pulses are determined and send to the esc. The most import point to note is that we have made used of machine level statements directly into our code because by using built in functions provided by Arduino ide the code was exceeding the 4000 microseconds time available to it (i.e. the refresh rate).
PID -> Proportional Integral and Derivative:
This is the most important component of the software
Proportional Term: This term generates higher output when the difference (error) between the input and the current position is high.
Integral Term : This term is used in order to remove constant errors present in the system which cannot be removed by the proportional term because it compares the previous position and current position of the quad and based on that it generates output.
Derivative Term : A serious problem called integral wind up increases the strain on the quad and can cause serious imbalance therefore we make use of derivative term which predicts the future of the trajectory and slows down the quad when the rate of change of error is to large.
Lastly, we make use of an auto-level feature which causes the drone to balance when the sticks are at center position. This is achieved all because of the IMU that enables to the quad to align with the 3-axis.
Comments