RC Hovercraft

A hovercraft is a vehicle that floats above the ground on a cushion of air; this cushion is provided by a fan blowing downwards and a flexible skirt used to direct the air. My RC hovercraft uses two brushless DC motors, a servo, an Arduino Uno, and two 1000 mAh batteries.

Engineer

Ryan S.

Area of Interest

Computer Engineering

School

Cupertino High School

Grade

Incoming Junior

Reflection

Overall, my time at BlueStamp was a fun, rewarding, and educational experience. Over these six weeks I gained lots of knowledge in the fields of electrical, computer, and mechanical engineering. I’ve also gained knowledge about my own skills and confidence in my abilities as an engineer. I feel more confidant in my own abilities to solve problems on my own than ever before. I will defiantly be more prepared and more confidant in undertaking my own large engineering projects in the future, and I can’t wait to see where these skills will take me in the future.

Final Milestone

Modifications | Obstacle avoidance

In order to make my RC hovercraft avoid obstacles, I would need to use an ultrasonic sensor. And to use an ultrasonic sensor, I would need to use an Arduino micro-controller. My first task was getting the Arduino to control the servo. But because I still wanted to have some control over the hovercraft, I decided to connect both the receiver and the servo to the Arduino. I designated a switch on my controller to act as the on/off switch for obstacle avoidance, but Arduino can’t process signals from RC receivers. Not without a bit of coding, of course.
Arduino Uno
My first task was to determine how to get the Arduino to read signals from the receiver. After some searching around online, I found some open source code that I decided to base my code off of. I would need to extend the functionality of the code, as the code from the website read signals, but didn’t output any.
Next, I had to send signals from the Arduino to my ESC and servo. After some more digging around online,  I discovered that you could simply map the value of the input from the receiver to a corresponding value from 1,000 to 2,000, and send that to the output pin using the Servo library included with Arduino.
Finally, I had to integrate the ultrasonic sensors, which measure the distance between themselves and the object in front of them. I found a website online that explained how they worked and how to use the Arduino to read the distance between the ultrasonic sensor and the object in front of it. Using this, I was able to connect my ultrasonic sensor to the Arduino.
Next, I had to send signals from the Arduino to my ESC and servo. After some more digging around online,  I discovered that you could simply map the value of the input from the receiver to a corresponding value from 1,000 to 2,000, and send that to the output pin using the Servo library included with Arduino.
I then connected all the wires to my Arduino and created the electrical diagram for all the wires connected to the Arduino:
Electrical Diagram (Arduino)
Controller mapping (final)
Now, I could focus on writing the code that would control the hovercraft and interpreting the information from the ultrasonic sensor. I decided that I didn’t want to have the sensor running all the time, as this would drain my batteries faster and could make navigating in confined spaces difficult. So, I mapped one of the switches on the top of the controller to be the toggle for obstacle avoidance mode.
While testing, I realized that as the farther away an object was from the ultrasonic sensor was, the less precise the reading would be. For example, when I pointed the sensor at the ceiling (about 2 meters away), it would flicker between 1000 and 2000 (measured in centimeters). I wasn’t working with distances this extreme, but the effect was still present when I wanted to detect obstacles 50 centimeters away. To prevent this from making the hovercraft swerve when no obstacle was present, I made the Arduino wait for at least 10 consecutive readings less than 50 before the hovercraft swerved. Because the sensor measures distance very frequently, this had little effect on my hovercraft’s “reaction time” to seeing obstacles.
Next, I needed to decide what my RC hovercraft would do when it detected an obstacle in its path. The first step was to overwrite the signal from the transmitter and give the Arduino control of the hovercraft. Because my RC hovercraft has no dedicated, the fastest way to stop it was to simply turn off the motor providing lift. After that, I would need to steer the hovercraft 180 degrees, then hand control back to the user. So, I wrote the code such that immediately after detecting and confirming the presence of an obstacle, the bottom motor immediately shuts off and the rudders turn all the way to the right. It remains like this for 1 second so the hovercraft can come to a complete stop. Then, the bottom motor is turned back on, and the servo rudders remain turned to the right for 1.5 seconds. This is roughly the amount of time it takes for the hovercraft to do a 180-degree turn. Control is then handed back to the user.
However, I quickly discovered a problem with this. The code for making the RC hovercraft turn would run twice regardless of whether is faced an obstacle after the turn. To combat this issue, I created a variable in my code that would track whether or not the code had already run. After running, this variable was set to TRUE and stayed that way until ten consecutive measurements from the ultrasonic that were greater than 50 were completed. This fixed the issue with the code running twice.
*After testing, I changed the range of the ultrasonic sensor to 70 cm
#include <EnableInterrupt.h>
#include <Servo.h>
/*Libraries that are required for the code to run.
 *NOTE: The EnableIntrrupt is not included with Arduino, you will need to download it
 *manually*/
//Defining constants and variables
Servo esc;
Servo servo;

#define SERIAL_PORT_SPEED 9600
#define RC_NUM_CHANNELS  3

bool hasRun = false;

const int trigPin = 10;
const int echoPin = 11;
long duration;
long distance;

int runCount = 0;
int count = 0;
/*
 * CH1 SWITCH
 * CH2 STEERING
 * CH3 THROTTLE
 */
#define RC_CH1  0
#define RC_CH2  1
#define RC_CH3  2

#define RC_CH1_INPUT  A5
#define RC_CH2_INPUT  A1
#define RC_CH3_INPUT  A0

uint16_t rc_values[RC_NUM_CHANNELS];
uint32_t rc_start[RC_NUM_CHANNELS];
volatile uint16_t rc_shared[RC_NUM_CHANNELS];

void rc_read_values() { 
  //reads values from RC channels
  noInterrupts();
  memcpy(rc_values, (const void *)rc_shared, sizeof(rc_shared));
  interrupts();
}

void calc_input(uint8_t channel, uint8_t input_pin) { 
   //Calculates the duration of each pulse from the reciever
  if (digitalRead(input_pin) == HIGH) {
    rc_start[channel] = micros();
  } else {
    uint16_t rc_compare = (uint16_t)(micros() - rc_start[channel]);
    rc_shared[channel] = rc_compare;
  }
}

void calc_ch1() { calc_input(RC_CH1, RC_CH1_INPUT); }
void calc_ch2() { calc_input(RC_CH2, RC_CH2_INPUT); }
void calc_ch3() { calc_input(RC_CH3, RC_CH3_INPUT); }

void setup() {
  //Initializes serial port and tells Arduino which pins are connected to what
  Serial.begin(SERIAL_PORT_SPEED);

  pinMode(RC_CH1_INPUT, INPUT);
  pinMode(RC_CH2_INPUT, INPUT);
  pinMode(RC_CH3_INPUT, INPUT);

  enableInterrupt(RC_CH1_INPUT, calc_ch1, CHANGE);
  enableInterrupt(RC_CH2_INPUT, calc_ch2, CHANGE);
  enableInterrupt(RC_CH3_INPUT, calc_ch3, CHANGE);

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  servo.attach(9);
  esc.attach(13);
}

void loop() {
  rc_read_values();
  int toggle;
  int steering;
  int hover;

  toggle = rc_values[RC_CH1]; // min 992, max 1984
  steering = rc_values[RC_CH2]; // min 996, mid 1488, max 1988
  hover = rc_values[RC_CH3]; // min 996 max 2000

  if (steering == 0){
    steering = 92;
  }

  steering = map(steering, 996, 1988, 47, 137);
  hover = map(hover, 996, 2000, 1000, 2000);

  //Outputs data to the serial monitor for easier debugging
  Serial.print("Switch: "); Serial.print(toggle); Serial.print("\t");
  Serial.print("Servo :"); Serial.print(steering); Serial.print("\t");
  Serial.print("Throttle: "); Serial.print(hover); Serial.print("\t");
  Serial.print("Distance :"); Serial.print(distance); Serial.println("\t");
  Serial.print("runCount: "); Serial.print(runCount); //Serial.print("\t");
  Serial.print("Distance :"); Serial.print(distance); //Serial.println("\t");
  Serial.print("HasTurned: "); Serial.print(hasRun); Serial.println("\t");
  if (toggle <= 1500) {
    //Obstacle avoidance OFF
    esc.write(hover);
    servo.write(steering);
  } else {
    //Obstacle avoidance ON
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    duration = pulseIn(echoPin, HIGH);
    distance = duration * 0.034/2;

    if (distance <= 60) {
      runCount = 0;
      count = count + 1;
      if (count > 5 && hasRun == false) {
        count = 0;

        Serial.println("TURN");
        hasRun = true;
        servo.write(47);
        esc.write(1000);
        delay(1500);
        esc.write(1250);
        delay(3000);
      } else {
        esc.write(hover);
        servo.write (steering);
      }
    } else if (runCount > 10) {
      hasRun = false;
      esc.write(hover);
      servo.write (steering);
    } else {
      runCount = runCount + 1;
      esc.write(hover);
      servo.write (steering);
    }
  }
}

Third Milestone

Finishing Touches

Controller mapping (old)
Controller mapping (new)
The first thing that I decided to improve in my RC hovercraft was the way that my transmitter was set up. I had the left stick controlling the motor that enabled the hovercraft to float because the left stick was not spring loaded, so it stays in place after you release it. I then had to map the throttle to the right stick, which was spring loaded, so I had to hold down the stick if I did not want the motor to run, which made replacing batteries difficult. This also had the added effect of making the RC hovercraft more difficult to control, since other RC vehicles I had used in the past used the left stick for throttle and right stick for steering.
I looked through the instruction manual that came with my transmitter to see if I could find a way to change the sensitivity on the right stick so that I could set the center of the stick’s range of motion to keep the motor off. I couldn’t find a way to do this, but I did find another solution to my problem. I found out that you can use the two knobs located in the upper center of the transmitter to control motors, so I mapped the hover motor to one of the knobs, and then mapped throttle to the left stick and steering to the right stick. This made the hovercraft much easier to control and work on.
With the controls fixed, the second issue I had to address was the steering. Depending on how the parts were distributed, the hovercraft pulled either to the left or to the right. Steering in the opposite direction of the pull was ineffective. So, I started by trying to fix the balance, hoping that a balanced hovercraft would be able to turn easier. I eventually fixed the balance issues, but the hovercraft was still unable to steer effectively. I tried adding a larger rudder on top of my servo, but handling didn’t improve much. I realized that the rudder could not redirect all the air coming from the fan, so I had to come up with a more effective method to redirect air. Other examples of hovercraft used more than one rudder, working in tandem to redirect air. I emulated this on my RC hovercraft, adding two additional rudders in addition to the one that was already there. This greatly improved handling and made the hovercraft much easier to drive.
Hovercraft rear rudder
Hovercraft
Then, I was ready to permanently secure the body in place. I used superglue to glue the sides of the RC hovercraft to the base, then glued on the top. I originally wanted to have a door on the top of the hovercraft that would allow me to replace the batteries, but due to the location of the motors, I had to move the batteries to the front. I used RC hinges to secure the front of the hovercraft while making sure that I could still access the batteries.
After that, I decided to cover the gap between the base and main body of the hovercraft, because the skirt kicks up a considerable amount of dust that eventually finds its way into the main compartment of the RC hovercraft. I used black electrical tape to cover the gap.

Second Milestone

Connecting the electronics

Before I started working on the electronics of my RC hovercraft, I researched each of the parts that I would need. I’ve listed part names and what they do below:
ESC (Electronic Speed Controller): Required to run brushless DC motors. Converts low-power electrical signals from the receiver into high-power DC signals. I’ve linked a YouTube video on the right that goes into ESCs in greater detail.
BEC (Battery Eliminator Circut): A part of the ESC, uses the ESC’s connection to power and sends some of the power back to the receiver. Eliminates the need to connect the battery to both the ESC and receiver.
Brushless DC motor: A type of DC motor that is longer-lasting and more reliable than normal DC motors. On the right, I’ve linked a video that explains how they work.
I was able to use this information to create a full electrical diagram of my RC hovercraft:
Hovercraft Electrical Diagram
Deans Connectors
My battery originally came with Mini Tamiya connectors, which were difficult to buy, so I was unable to connect my battery to my ESC. I ended up deciding to switch out the Mini Tamiya connectors for Deans connectors (shown left), which were cheaper, more durable, and more reliable.
Soldering the Deans connectors proved to be a difficult task, but I found a video (which I’ll link below) demonstrating how to properly solder the connectors. I also needed to solder bullet connectors onto the wires connecting the ESC to the motor, but luckily, the ESCs came with them pre-installed and the motors included them inside the box, so I didn’t have to order any more.
Hovercraft
Unfortunately, the receiver for my transmitter was unable to pair with my transmitter, so I had to order a new one. While waiting for my new receiver, I found a video (linked below) that showed a method of controlling the motor using an Arduino and a potentiometer. Following the steps, I was able to test the skirt of my hovercraft and was able to attach it to the body after verifying that it worked properly.
After my receiver arrived, I was quickly able to get the electronics connected and working. I had to remove the red wire on one of the BECs in order to not send too much power to the receiver. I had to make slight modifications to the body in order to get the servo and the thrust motor to fit. After that, I connected all the ESCs, motors, and batteries to the new receiver.
After verifying that all the parts worked as expected, I was able to take the hovercraft for a test flight. Unfortunately, because the hovercraft was so unbalanced, the craft kept pulling to the left and was difficult to control. I aim to fix this problem in my next milestone, in addition to properly securing the body onto the base of the RC hovercraft.
Hovercraft

First Milestone

Building the body of the hovercraft

I started the design of the RC hovercraft by creating a CAD diagram of the body using SketchUp. Because this was my first time using SketchUp, I had to spend some time learning the ropes before I felt comfortable enough to begin using the software to design the body. The design of my body is the same general shape as the one found in the instructable linked below, but modified to be sleeker and simpler.

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Hovercraft
Next, I cut out the pieces that I would need to use to assemble the body. I did this by measuring the angles and lengths of the sides using the built-in tools in SketchUp. I then traced the shape onto pieces of depron, a lightweight foam that was chosen due to its strength and light weight. Then, I used an X-ACTO knife to cut out each individual piece. For identical pieces, I would first cut out one piece, then trace the outline onto another piece of depron.
Before gluing the pieces together, I taped them together to ensure that they would fit. I ended up having to re-cut some of the pieces in order to get them to fit snugly. After taping the pieces together, I started to work on the skirt and the bottom of the hovercraft. The skirt is a flexible material used to direct air from a fan downwards. This is how hovercrafts are able to hover. For the skirt, I used black waterproof nylon. Under the skirt, the base of the hovercraft is hollow in the middle and has slits cut out along the edge that will (hopefully) cause the distribution of air in the skirt to be balanced. The air then escapes downward through a hole I cut in the bottom of the skirt.   While working on the bottom, I realized that I would also need to add in the fan used for lift because the base would be inaccessible after I put the skirt on. As you can see in the image to the right, the motor was too tall to completely fit under the body, so I cut a hole in the top that would allow the body to fit over the base.
Hovercraft

When gluing the body together, I decided not to glue the top cover of the body, because I was still unsure of the dimensions of the electronics and whether or not the skirt spread out airflow evenly. The skirt and the area covered by it are still easily accessible if I need to make changes. As for the rest of the body, I chose to use super glue because of its light weight and strength. I used tape to hold the pieces together while I applied glue and gave it time to set. The process went surprisingly smoothly, but I did get some glue on my fingers that I had to clean off with paint thinner.

Overall, this milestone took me longer than anticipated because tracing the parts onto depron proved to be difficult. Taping the pieces together also took longer than expected because some parts were not cut accurately and it was difficult to re-cut them.

The next milestone is getting all the electronics into the body of my RC hovercraft and working.

Starter Project

The useless machine

Useless machine
My starter project was the useless machine. The circuit includes a potentiometer that is used as the switch. When the switch is flipped on, an arm extends out of the box and turns the machine off. When the machine is flipped on, current flowing from 3 AAA batteries drives the motor and makes it turn clockwise. The motor is attached to an arm, so the arm begins moving upwards. The arm pushes apart a movable door on the top and pushes the switch in the opposite direction. This reverses the current to the motor and causes the motor to turn counterclockwise. The arm retreats back under the door, where the back of the arm pushes a switch that stops the flow of current to the motor. Along the way, I ran into an issue when the switch was flipped and the motor wouldn’t move, despite the batteries being installed. This issue was fixed when I realized that one of the batteries had incorrectly been installed. So I reinstalled the battery, and the problem was fixed. Overall, this was an enjoyable project that introduced me to electrical engineering as well as soldering.

Leave a Comment

Start typing and press Enter to search