Transform Your RC Quadrotor Into a Computer Controlled Quadrotor (The Easiest Way)

23K4521

Intro: Transform Your RC Quadrotor Into a Computer Controlled Quadrotor (The Easiest Way)

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:

https://www.instructables.com/id/Fly-a-Mini-drone-W...

https://www.instructables.com/id/Easy-Android-contr...

https://www.instructables.com/id/Brain-Controlled-R...

https://github.com/alvarop/protox

http://dzlsevilgeniuslair.blogspot.com/2013/11/mor...

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:

http://www.prweb.com/releases/VECPAV/Draganflyer/p...

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).

Why MATLAB?

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.

15 Comments

Wondering why the OP did not use the trainer port that is available on many RC radios? Most had a PPM input.
You are right but for bigger remote controllers; for the cheap quadrotor I used, it has no trainer port.
What pins did you connect the LPF to on the arduino?
Also, our team is trying to do this, but we are only overriding one potentiometer- the height control. How would you suggest orienting the LPF for only the one pot override? Thanks!
Hi and apologies for my late reply.
The Arduino pins used for the quadrotor control (the ones connected to LPFs) are shown at the beginning of the code; they are pin 11 for the height control, pin 10 for the motion control along x-axis (pitch angle), pin 9 for the motion control along y-axis (roll angle), and pin 6 for the heading control (yaw angle), as shown below.

// constants won't change. They're used here to set pin numbers:
const int HeightPin = 11; // The pin used to control the height
const int XPin = 10; // The pin used to control the move along x-axis
const int YPin = 9; // The pin used to control the move along y-axis
const int YawPin = 6; // The pin used to control the heading

I am using four LPFs, one for each control variable. If you want to control only the height, you "cut" the connection of the height potentiometer and connect it to the Arduino PWM pin through an LPF.

Good luck,


how to controle my drone
The method of control shown in the project is manual control. You use the arrows, the space bar, and the ENTER key on the keyboard to control the drone. The suggested control method however is an autonomous method that uses a camera to pick the drone's position and feed it back to the computer. A path planning algorithm is also running on the computer that picks the desired position or goal position to the drone based on a given requirement. The computer, knowing now the drone's position and its desired position, controls the drone via a PID or a nonlinear controller to its goal point or through the desired path.
HI! I have a question. How do I know if the LPF circuit is not working? Will it produced non-desired output voltage or no voltage at all? thank you
Hi,

If there is a connection problem there will be no voltage at all. If the values of the R and C of the LPF is not accurate, the output voltage will not be consistent. This means that if we need an output of 2.5 volts for 50% duty cycle, we will get less than 2.5 volts if the values are not appropriate.
thank you for your response. and may i know the ground for pwm circuit is connected to where in the controller? to the ground of controller?
Nice tutorial! I was wondering if it possible to use one of these cheap drone transmitters (like for eachine e010/011) can be connected to PC and used for some games and simulators?
Thank you!
Well, I don't think so... Connecting a transmitter to a PC requires that the transmitter itself contains a microprocessor that sends the computer the joystick(s) information according to a given serial communication protocol. Let's say that the transmitter has two joysticks, it means that it has four different data packets that need to be sent to the PC according to a communication protocol suitable for the computer or the game itself. Moreover, many games accept only well known controllers/joysticks.

However, you may use the cheap transmitters to send data to the PC. You have to make a receiver circuit (or use its own receiver), and connect its output to a microcontroller (Arduino for example) and make the arduino to resend data received according to a suitable communication protocol to the PC. You have to know the accepted/suitable communication protocols for the computer games OR you may receive the data sent with any protocol but you write your own game on the PC...

All what you need is imagination, and you'll be able to do whatever you want
Sadly this is beyond my knowledge in this area. I just wanted to connect my drone transmitter to play game simulators on my PC. Unfortunately didn't find any tutorial on how to do it myself.
I think there are some cheap transmitters that can be bought from the internet for such application.

Good luck,
Amazing technique could you clarify a few things though. First how do you build a low pass filter(its circuit diagram and what resistors you use) also when controlling from computer cant you set levels from 0-100 to set the speed of the quadrotor? also how do you locate the ground pin (is it important to do that)on transmitter while connecting aurdino to potentiometer
Actually, the low pass filter circuits are shown in Step3. You can see the 670 Ohms resistor and the 10 nF capacitor used to form the low pass filters. Kindly note that these values were chosen experimentally by trial and error. Your project might need different values, just try different RC configurations. For the computer control, you can write a MATLAB/Visual Basic/C code to set speed levels for the quadrotor. All you need is a good programming experience and a good knowledge about the RC filter you have designed. Which PWM value gives the mid speed? this can be done experimentally as shown in the figures of Step 3. On the transmitter, the ground pin is the (-) negative side of the batteries. This can be found by following the (-) sign on the batteries' bed, or by locating the mid pin of any potentiometer (of any joystick). You may need to check it with the beeper of a multimeter.