Building my own quadcopter, stability issues.

Hi everybody

I'm building my own quadcopter from scratch (mostly) and have a really hard time getting it stable in flight. That's why I'm turning to the afficionados (you) for some support.

3691257455?profile=originalOnce again: This is my own build with my own electronics and my own code, so don't assume that I've made any sensible decisions.

Secondly: It is flying (see top) but not at all like I'd would like it to.

The goal:
A rock stable, semi autonomous flight where my input dictates pitch and roll angle. My yaw input controlls yaw rate. Throttle is currently manual, but later (should the rest work and no horrible accident have happened in the meantime) I'd propably like to loiter without any input at all (my barometers are quite precise)

The discrepancy:Currently, my input is rather sluggish and the drone itself has a hard time stabilizing itself properly with a rather high time constant and (apparently) some noise introduced by ... something.
However, this is not just a simple "tune your PID constants, duh..." problem. At least I don't think so.

The frame: is self printed out of PLA. (The Hovership MHQ2 was the basis: http://www.thingiverse.com/thing:511668) therefore not perfectly aligned, rigid and rather heavy I suspect.
4 Motors (Quantum MT2204 KV:2300) are driven by 12A Afro Esc (standard firmware) and calibrated.
The build is inherently unstable sind the center of mass is above the center of thrust (but not too bad).

The electronics: Consists of 2 Arduino Pro Minis (16 MHz), a 9 DOF sensor stick (ADXL345, HMC5883L, ITG-3200), a Bosch Barometer (currently not in use) and some other circuitry for battery sensing, LED driving and stable voltages at 5 and 3.3 V. All of it is connected over I2C at 1 MHz clock speed. The electonics are separated from the motor frame with rubber dampeners.

The code: AHRS is done through DCM algorithm (the only thing "borrowed" because I'm mathematically challenged and couldn't get my kalman filter working properly). The slave arduino is only polling my RC receiver (through interrupts) and sending the data on request to the master. The master is calculating all the rest and also sends the servo signals to the four esc.

More detail:
AHRS code is polled at 100 Hz (and works quite well). The calculation incl. data transfer takes around 4000 ms. The radio is polled at 50 Hz. From this, the calculations are done for my desired angles and yaw rate (100 Hz). The error between is and desired is fed to PID controllers for pitch, roll and yaw rate. They also update at 100 Hz in sync with the AHRS code. The output of the PID's goes to a feed forward logic which translates into a speed for every motor.

Example: my Throttle input goes from 0 to 180 (servo angle standard), and my PID controllers for axis and yaw rate go from -1 to 1 which is then multiplied by a constant (currently 40 for angles) and fed into this linear combination: motor_front_left = throttle + pid_pitch + pid_roll + pid_yaw_rate. The other motors are just the same but with different signs obviously. There is a low pass filter for the differntial PID term and the I term is currently limited at half the max output (-0.5, 0.5).
There is some other code running for safety and stuff, but basically that's it. I cannot poll at higher rates because my code just can't run faster and I don't have a clever scheduler (yet?). I already tried to optimize it as good as I possibly can at the moment and it manages to run without hickups. What has to be said though is that the PPM signals I'm sending to the esc are not interrupt based and therefore hogs all the processing power for up to 2 ms (which is not too tragic since the rest fits into the remaining 8 ms.

So I tried to tune my PID constants on a rig with just one axis able to move and already there it becomes clear that I'm missing some important point/concept. I get it somewhat stable but it never even gets close to the kind of stability I've seen from others. I haven't linearized my motors (force vs rpm), but from what I've measured (with a somewhat defective esc) it's not too far off.

So at this point I'm not quite sure anymore what to do apart from trial and error. It just seems to me, that the time constant for the whole dynamic system is too high. And that's something a simple PID can't improve upon. The gains are close to their max and instability is not too far off. So what's causing the presumed delay? Motors? ESC? Should I do something completely different? Please enlighten me.

Also, if some ArduPilot dev reads this: Respect for what you could squeze out of one Arduino Mega!

Regards,

Flo

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Too much text? Too simple? No community value?

    In anycase, I have programmed a task scheduler to improve cpu utilisation and squeeze in all the tasks which are not too time critical after all the critical stuff. Helps a lot already and I have almost no glitches. The I term of the PID control has a max value of 1/4 of the max output and increased gain values (not sure if sensible). Flying behaviour is still laggy but I can keep it in the air.

    I will try to reprogram the DCM to make it sharper and less cpu intensive so I can have higher update rates (currently 160 Hz). Then I'll try to tune PID in flight (which I'm really scared of at this point because I need both hands at the controls).
    And if that doesn't do the trick I'm back with a video.

    Flo

This reply was deleted.

Activity