Hover Control of Quadcopter - advice and help please!

Hello guys,

I have a Gaui 330x, and I am required to implement on it a hover control algorithm. I am quite new to quadrotors, but i'm willing to try. My objective is to make it hover at a constant height from ground when the hover control switch is turned on, and still be able to move it along the x-y plane (back/forth/left/right). When the hover control switch is off, control is manual using the radio controller.

These are the things that I have:

  1. Gaui 330x quad (which came with GUEC 344 gyro, and 4 GM-410 Scorpion Brushless Motors with ESCs)
  2. FUTABA 7-Channel Radio Controller
  3. FUTABA Receiver Module
  4. Arduino Duemilanove
  5. PING))) Ultrasound Sensors

What I have done so far is, I've placed the Duemilanove between the receiver module and the gyro unit. By doing so, I wish to manipulate the signal that is being communicated between the receiver and the gyro (looks like a PWM signal, please correct me if I am wrong). I notice that the speed of the propellers changes with the pulse width of this signal, when the throttle stick position is varied.

My idea is, on manual control, the signal goes in and out of the Duemilanove unchanged. On hover control mode, the signal gets manipulated by the Duemilanove before it is communicated to the gyro unit. Manipulation is simply changing the pulse width of the PWM, to either increase the speed (when below desired height) or decrease the speed (when above desired height) of the propellers.

Am I doing the right thing to control the quad? Is the signal a PWM signal? It'll be great if someone can help! Thanks in advance!

Bernard

Your understanding is correct. Servos and ESCs both use the same PWM scheme which any number of googleable references will describe.

The receiver would ordinarily send the signals directly to the motors, but in your case the gyro is used to intercept the signals and make adjustments to those signals to keep the copter level.

In your case, what you're asking to do is to intercept those signals again and inject adjustments for holding altitude. It's certainly possible but a little goofy; I'd suggest replacing the gyro and using something like a KKmulticopter board (many clones available for under $50) which has a reprogrammable ATMegaxx8 at its heart so you could adjust the open source firmware and add code for your ping sensors.

Hi Chagrin, thanks for the suggestion!

I am doing this as a university project, and if I replace the gyro with KKmulticopter, does it seem like I'm cheating? What I'm trying to say is that, is the KKmulticopter something that is pre-programmed and all I have to do is just plug and play? I need to show that I've done some work to deserve some marks. :frowning:

I managed to get the signal thru the Duemilanove (Receiver - Duemilanove - Gyro), but there seem to be something wrong. The propeller speeds increase when I pushed the throttle stick up, but they were rather faster than I expect them to be. And when I lower the throttle stick position to decrease the speed, the propeller speeds didn't seem to change, and when I lower the stick pass a certain level the blades stopped completely.

I simulated everything on the oscilloscope before testing on the system and it seemed fine, except for one problem. The frequency of the signal that the Duemilanove changes ( +- 0.5 Hz) and sometimes I notice that the input signal from the receiver module also changes slightly by the same amount. Would this change in frequency affect the functionality of the whole system? Or is it because of my codes?

Here are my codes (I'm no expert programmer, please correct me if there are flaws in my codes):

#include <PlainPWM.h>

  // Initialise
  int pin_in = 7; // Input pin
  float pWidth_in; // Input signal pulsewidth
  float freq = 69.93; 
  float dutyOut;

  // Create PWM object
  PlainPWM PWM;

  // Declare ports and pins
  uint8_t pin_out = PINB0;
  volatile uint8_t *port = &PORTB;

  // Setup 

  void setup()
  {
    PWM.InitPWM(port, pin_out, freq, 0);
  };

  void loop()
  {
    pWidth_in = pulseIn(pin_in, HIGH);  // microseconds
    dutyOut = (pWidth_in/1000000)*100*freq;
    PWM.SetDutyCycle(dutyOut);
  };

PlainPWM.h library was developed by Mr. Didier Longueville. You can find his article on it here : http://didier.longueville.free.fr/arduinoos/?p=2193

Thanks!

Google doesn't seem to reveal anything interesting about the GAUI quadcopter or its gyro unit or "AQDCS" which appears to be a closed proprietry flight control system.

leobernard:
And when I lower the throttle stick position to decrease the speed, the propeller speeds didn't seem to change, and when I lower the stick pass a certain level the blades stopped completely.

When you drive a DC motor without a load on it, using a PWM signal, flywheel action will keep the motor spinning between pulses.

IOW, let your finger rest on the shaft to provide a load and then see if your motor doesn't slow down.

roncoop:

leobernard:
And when I lower the throttle stick position to decrease the speed, the propeller speeds didn't seem to change, and when I lower the stick pass a certain level the blades stopped completely.

When you drive a DC motor without a load on it, using a PWM signal, flywheel action will keep the motor spinning between pulses.

IOW, let your finger rest on the shaft to provide a load and then see if your motor doesn't slow down.

We are talking about brushless motors and ESC with servo-style PWM control - your comment about putting a finger on the shaft sounds like a recipe for ending in the casualty department of the local hospital with a flayed finger...

I simulated everything on the oscilloscope before testing on the system and it seemed fine, except for one problem. The frequency of the signal that the Duemilanove changes ( +- 0.5 Hz) and sometimes I notice that the input signal from the receiver module also changes slightly by the same amount. Would this change in frequency affect the functionality of the whole system? Or is it because of my codes?

Only the pulse widths should matter, the pulse spacing should not be critical (in a well behaved system).

leobernard:

  void loop()

{
    pWidth_in = pulseIn(pin_in, HIGH);  // microseconds
    dutyOut = (pWidth_in/1000000)100freq;
    PWM.SetDutyCycle(dutyOut);
  };

You've got a casting problem with dutyOut.

Thanks guys, for the replies..

Chagrin,

You've got a casting problem with dutyOut.

What's a casting problem..? :cold_sweat:

MarkT,

Only the pulse widths should matter, the pulse spacing should not be critical (in a well behaved system).

The function that I use in my codes to generate the PWM uses duty cycle as its parameter. Calculation of the duty cycle depends on the frequency and I have declared frequency as a constant in my codes (that's the frequency of the original signal). :frowning:

Hi guys,

I just realised that my radio controller operates on PPM (PCM switchable). Does it matter, in my case? I am only modifying the signal after the receiver module, where the radio signal would have been decrypted. Thanks!