Quad copter for robot competition

Hello all,

I'm new to the forum as well as to...well robotics in general. Anyways I'm a comp science/electrical eng tech major and in my comp architecture class, we are required to build an autonomous robot; there will be 2 winners, one for design and one for winning the maze challenge. I have a tank that I'm programming now that will be able to run the maze but also utilizes the airsoft turret on it by having automatic tracking/firing when an object gets within a certain threshold. Have the auto track working but need to write a fork() function so the driving function can run in parallel...ugg. But after looking through a lot of the forums, I ran across some quad copter builds. So I've decided to run in parallel and work on both.

Sorry for all the background, but I was hoping I could get some guidance through my builds, especially in the realm of using brushless DC motors. I'll start with my parts list and move on to my design.

Currently have:
Arduino Uno
MotorShield
ProtoShield
4 sharp 2D120X F 7x IR sensors
2x 30" square replacement aluminium towel bars from home depot for frame.
1X 24" " " for frame support

Soon to be purchased (after some reviews)
hexTronik DT750 Brushless Outrunner motor 750kv
Hobbyking SS Series 18-20A ESC (card programmable)
GWS HD8040 3 Blade Prop Counter Rotate (2pc)
GWS HD8040 3 Blade Prop (2pc pack)
maybe a Turnigy 2200mAh 3S 20C Lipo Pack (going to see if my school can provide a battery)

I am probably missing some parts but that's why I'm here, to make sure I don't look over something.

Here is my design theory. I've started on the frame and have approximately 20" of clearance between motors. I plan on being very meticulous with the construction, making sure that the center of mass stays exactly in the center. I am going to get some spray foam to fill the frame to help reduce vibration from the motors.
My short term goal is to create a quad that will lift up to about 2 feet, hover for a sec, move forward for 10 ft or so, then come back and land. I won't have a Gyro or accelerometer right now, budget cuts came down from my wife, so I plan to have the 4 IR sensors placed facing straight down near the motors and use this to determine if I am flying level. And to go forward, I will just have to test and find some benchmark ranges for all for sensors...what I was thinking is say level is at 2 ft, to go forward, front motor IR will need to read at 1.8 ft, back motor at 2.2 ft (not exact, just theory). My range is limited with the IR sensors but for now it'll have to do unless my teacher comes up with 4 ultrasonic sensors. This will only be flown indoors so there should be minimal external factors affecting the flight (ie wind, unlevel ground, ect..)
From what I've read, the Uno will be able to handle controlling the motors using the server lib. I don't think I can use the motor shield though since it can only control 2 servos. Motor speed is going to be set off a lot of testing, I'll start them all out at equal throttle then see if one is spinning faster than others then adjust from there...rinse and repeat until I have some good numbers.

Just in case anyone is wondering, I am not looking for anyone to do my project for me, I just need some mentoring along the way. But here are a few questions/concerns that I have: are the motors ok, should the ESC's work, am I missing anything, what are some potential problems, will my design theory even work?

Ohh and I have until may 5th to get this done :slight_smile:

Thanks in advance, and nice to meet you all:

Justin

I'm new to the forum as well as to...well robotics in general

I have until may 5th to get this done

Coffee.
Strong coffee.

How far along is your tank? With that deadline, if you're not at the point where you're debating what colour to paint it, you might want to reconsider starting a parallel project. It is quite amazing how much time this stuff takes. Also, I've never built a quad copter, but I'll bet that it would be mighty tricky without gyros or accelerometers.

Well the tank is almost done. Everything is wired up, just needs to be programmed. I have the basic algorithm done to drive the base and the turret function is done. To run both at the same time, I am either going to have to write a fork() function or I will just stop the drive function and let the auto aim/shoot function finish, then go back to driving and turret scanning. Worse comes to worse, I'll dump the auto turret and just make it drive through the maze since that's all it really needs to do anyways, the turret was just to make it a little cooler and different than what everyone else is doing.

For the Quad, I have a general idea of what I need to do. The only part I'm afraid of is not getting all the parts in time. The quad is going to be a lot of testing to see how the servo lib delivers power to the motors then starting at the lowest power and gradually going up until I start to get lift off, from there I will just have to see how each motor is reacting and adjust the power from there. It's not going to be perfect nor autonomous but I am hoping that I can at least get a hover at distance X function working, move forward for X amount of time, move back for X amount of time, and land. In theory it doesn't sound too bad but I know what happens when I assume things so I am prepared for some hardship.

And I have LOTS OF COFFEE and Monster drinks on hand!!

golfpro1983:
Well the tank is almost done. Everything is wired up, just needs to be programmed.

Umm, this may well not be a trivial task. I'm imagining a maze like the one used for the micromouse competition though, perhaps the problem you need to solve is less complex.

As to fork(), the arduino does not run multiple processes, although I believe there are some libraries that provide threading functionality. Happily though, for your purposes, it's fast enough that you can fake concurrent operations using millis(). The usual advice given in this instance is to look at the blinkwithoutdelay tutorial.

Yeah, its a pretty easy maze....and the algorithm I'm going to use is for a wall hugger. Go toward until front sensor detects a wall or right sensor does not, if front sensor then turn left, if right sensor, make slow 180 degree turn...rinse and repeat, same algorithm we used on the lego robot, just need to mess with the timing and power to each motor to get the turns down.

Ohh and I ordered all the parts I need, 3 days express from hobby king so next week I will have pictures of the quad build to post. Then after some utter failure tests ill let you all know so I can get the "i told you so" haha

Got the tank programmed last night and did some final adjustments this morning. Have a you tube video of it running through a mock maze that I set up that is very similar to what the competition will look like. They have the real maze set up at school so I will run it there to see how it does. I have a lego NXT robot programmed to run through the same maze and this one beats it hands down. I had some issues with the code at first because I tried programming functions for every scenario I would think could happen but ended up deleting most of it. Here is the link to my video and autonomous robot test in mock maze - YouTube

Here is the code I came up with to run it. I haven't commented it yet but if you have questions or comments about it, let me know. But for now, it's time to start concentrating on the quad copter.

#include <AFMotor.h>

int forward = 0;
int FIR = 0;  //front IR sensor
int RIR = 1;  //right IR sensor
int LIR = 2;  //left IR sensor
AF_DCMotor rmotor(3, MOTOR12_64KHZ); // create motor #3, 64KHz pwm (right motor)
AF_DCMotor lmotor(4, MOTOR12_64KHZ); // create motor #4, 64KHz pwm (left motor)
void setup()
{
  // initialize serial communication with computer:
  Serial.begin(9600);  
  rmotor.setSpeed(150);
  lmotor.setSpeed(150);  
}
int get_avg(int IRpin) //Gets 5 readings from the sensors and averages them to get rid of spikes
{                     
  int total = 0;                
  for(int x=0; x<5; x++)
  {  
     total+=analogRead(IRpin); 
     
  }  
    
  return total/5;
}


void go_forward()
{
   rmotor.setSpeed(200);
   lmotor.setSpeed(200);
   rmotor.run(FORWARD);
   lmotor.run(FORWARD); 
}

void turn_left()
{
   rmotor.run(FORWARD);
   lmotor.run(BACKWARD);
   while(get_avg(FIR)>100)
   {}
   lmotor.run(FORWARD);
}

void turn_right()
{
   lmotor.run(FORWARD);
   rmotor.run(BACKWARD);
  while(get_avg(FIR)>100)
  {}
   rmotor.run(FORWARD);

}

void loop() 
{

   int f_sensor =get_avg(FIR);
   int r_sensor=get_avg(RIR);
   int l_sensor=get_avg(LIR);
   if(f_sensor <= 100&&forward==0) 
   {
     go_forward();
     forward=1;
   }
    else
   {
     lmotor.run(RELEASE);
     rmotor.run(RELEASE);
     forward=0;
     if(l_sensor > r_sensor)
     {
       turn_right();
     }
     else
     {
       turn_left(); 
     }
   }
 
  delay(50);
}

BTW, where are you going to get (or already got?) DT750 from, it seems to be out of stock everywhere?

maybe a Turnigy 2200mAh 3S 20C Lipo Pack

I use that motor... for a quadricopter.
I assure you will need much more time if you don't use preprogrammed code like aeroquad and similia.

BUT there a problem before: 4 DT750 use 80A of power, your battery cannot provide that power (2,2A*20C=44A MAX!) you have to use at least 4000mA at 20C (~30 minutes of flight) or 2200mA at 40C(~15 minutes of flight)...

also a 20/25A ESC should be better, you won't get down because a burst of current or heat fail

take a look at aeroquad, you will learn really much

ps. to control the ESC you can use the Servo library! they use PPM not PWM!