In this project, I am transforming a Radio Controlled (RC) quadrotor into a computer controlled drone. Similar to my previous project "Control an RC car using the computer", my future goal is to make a cheap experimental autonomous quadrotor for Control/SLAM/Navigation algorithm research purpose. In the future, I am thinking to use an over head webcam to detect the position of the quadrotor, and send this position to the computer which controls the quadrotor according to different navigation algorithms. Because my work in robotics is based on MATLAB, I developed a MATLAB code that allows the user to control the quadrotor using the keyboard.
The main contribution of this project is that it doesn't require very good hardware and programming knowledge to realize. Basic electronics and MATLAB/Arduino coding is enough to transform your RC quadrotor/helicopter/airplane into a computer controlled drone. I have seen similar projects that transform regular RC helicopters/quadrotors to computer controlled, but most of them require good knowledge of communication protocols (bluetooth, SPI, etc) and/or the reading/decryption of the commands sent by the transmitter's microcontroller. These commands are then sent by a microcontroller receiving its commands from the computer. Examples of these (cool) projects are:
However, there should be an easier way to realize the final goal. Moreover, most of the available projects transforms the quadrotor/helicopter/airplane into a computer-only controlled drone. In this project the original transmitter remains in use, and the press of a button switches the project between a computer controlled or a manually controlled drone.
This project consists of an easy Low Pass Filter (LPF) circuit connected between the transmitter and an Arduino microcontroller. When the drone is in manual mode, the transmitter is used to control the drone similar to any RC quadrotor/helicopter/airplane. When the drone is in PC mode, the Arduino receives controls from the computer and outputs the suitable PWM signals which are transformed by the LPF circuit into analog signals. The LPF circuit is connected to the transmitter circuit in a way that analog signals reach the outputs of the joysticks. A manual/PC switch disconnects the LPF terminals so the drone is controlled by the outputs of the joysticks again.
In the future, I am thinking to develop a system similar to the one below:
Step 1: Understand How the Transmitter Works
First of all, you have to understand how does the transmitter circuit work. The transmitter consists of a microcontroller connected to a 2.4 Ghz transmitter, four potentiometers, and a bunch of push buttons. The potentiometers detect the joystick commands and send them to the microcontroller as analog voltages. The microcontroller then sends digital packets as commands to the quadrotor using the 2.4 Ghz transmitter. The push buttons are used for trimming and resetting purpose.
We can control the quadrotor using the computer even by detecting the digital packet commands sent by the controller and sending them through the 2.4Ghz transmitter using the computer; or by sending the joysticks' appropriate analog voltages to the microcontroller. The first method requires the use of a Digital Data Analyzer to read and copy the packets sent by the microcontroller. The second method requires the use of a microcontroller that receives commands from the PC, and outputs the relevant analog voltages directly to the microcontroller joystick inputs.
I have chosen the second method because I don't have a digital data analyzer. First you have to find the joystick connection pins; they are located below the joystick on the other side of the PCB. The fourth and fifth figures above show how to find the output pins of the joystick potentiometers.
Let's check now the analog voltage commands sent by the joysticks. Solder wires to the potentiometer pins and to the ground (- power terminals), and connect a voltmeter between the potentiometers outputs and the ground, and check the output voltage for different joystick configurations (figures 6, 7 and 8). For my quadrotor, the voltage varies between 0 and 3.26 volts, with mid point of 1.7 volts.
Step 2: Make the Changes
After the essential testing step, we will start applying changes to the transmitter. First, we have to cut the connection between the potentiometer outputs and the microcontroller. This is important, because in PC mode we need only the analog commands sent from the PC to be detected by the microcontroller. So using a razor blade, cut the connection between the potentiometers middle pin and the microcontroller. Next, open a small window behind the cut in the green painting that covers the connection between the potentiometer pin and the microcontroller. If we connect the window with the potentiometer pin, the microcontroller receives commands from the joysticks. If this connection is removed and an analog voltage is connected to the small window, the transmitter accepts this voltage as command. The manual/PC switch should be connected between the small window and the potentiometer pin.
Solder wires to the potentiometers' middle pins. By sending analog voltage through these wires, the quadrotor can be controlled via PC and/or Arduino. Note that in the figures above, I soldered the wires before performing the cut and the window using the razor blade.
Perform these changes to all the potentiometers. Connect also a power wire to the baterries' well. This allows you to connect an external adapter to get rid of the batteries when the drone is controlled by the computer
Step 3: Make the Circuit
Once the changes on the transmitter are performed, it is the time to make the Low Pass Filter circuit. The low pass filter is very important because the Arduino is unable to produce analog voltage. To generate analog voltage using Arduino, we are going to produce Pulse Width Modulated (PWM) signals and pass them through the pass filter circuit. The frequency of the PWM signal is constant, and the duty cycles of the PWM signals passed through the LPF circuit determine the magnitude of the resulting analog voltage.
I made tests with many resistor and capacitor values to choose the best circuit configuration. I made the circuit on a prototype board, and used pins to makes it possible for the circuit to be connected directly over the Arduino board.
Step 4: The Codes: MATLAB + Arduino
After finishing the hardware, it is the time to write the codes.
I used MATLAB program to write the code that will receive the control commands from the keyboard, and send the required commands to the Arduino via the computer's USB port (serial port for the Arduino).
Actually you can use any programming language such as Java, C programming, Visual Basic etc.. I have chosen MATLAB because I used it to develop programs for ground robots, and I am thinking to use these programs to develop an autonomous version of the quadrotor.
Keyboard arrows are used to perform the forward-backward (motion along x-axis) and left-right (motion along y-axis) motions. Letter W is used for up, and letter S for down; D letter is used for yaw right turn, and A letter for yaw left turn. Finally, pressing ENTER closes the serial port and the program and stops all the rotors.
The main MATLAB program is "RC_QuadrotorControl.m", run it in order to control the quadrotor. The function "getkey.m" is used by the code to get the keyboard's pressed keys, and it should be located at the same folder with the main code.
The Arduino code "PCQuadrotor.ino" is simple: it outputs a PWM signal (thus transformed to analog signal by the Low Pass Filter) for each variable (height, x, y, yaw) according to the key pressed on the keyboard.
The comments in the MATLAB and Arduino codes are enough to explain how the codes work.
Step 5: Add the Switches
I waited a long time before ending this project because I couldn't find suitable switches. I still unable to find good switches, so I tried to end-up with a nice remote control using available switches and my kids' plastic playing bricks... sorry kids.
Step 6: Testing (video) - Future Work
This step shows how this project works. Choosing the manual mode allows the user to control the quadrotor using the remote control by manipulating the joysticks. By choosing the PC mode the joysticks are deactivated, and the quadrotor can be controlled only via the Arduino/computer/serial port.
The video below shows the testing of this project. Now, it is possible to write a MATLAB code that controls the quadrotor autonomously to follow a given path or to perform a special task according to predefined functions. This is left for future work. Note that an overhead camera should be used for position/heading information feedback. This is essential because the computer requires position and heading feedback from the quadrotor in order to perform the quadrotor control.
Note: My quadrotor sometimes resets unexpectedly whether using manual or PC mode.