Motor jitter on quadcopter

Hey,

I've built a quadcopter and the hardware is ready, but I get a strange behaviour: What I've done (Arduino Uno 3):

RC: I wrote a Library to use micros() and ext interrupts aswell as 3 PCInterrupts. Everything coded by me: I didn't use digitalRead() and attachInt. to speed it up. Same with PCInt: I use one int per Port (B,C,D) to avoid the need of finding the source for the int. Sensor: This is a tough one: I use a GY-86 which has a MPU6050. Therefore I use the I2Cdevlib code. This takes the fifth and last pin change interrupt. Motors: I use 4 ESCs and motors. These are fed with the Servo library.

The problem is, that the motors start to wiggle, uncontrolled, spontane and seamingly random. All 4 motors turn down just a little. Then after a very short time they are back at normal. This occurs every second or so and sometimes its 5 seconds in between. The behaviour is like when you set the motors to 0 and back to 1500us shortly afterwards.

Could this have to do with Interrupt clashes? I use 5 Interrupts for rc (4) and sensor (1). What I mean: The interrupts from the rc come in and thereby the motor ones (output) are delayed. Could this make the signal of the servo library to stop somehow? So that 1 sample or a few become 0 or so long, that it's neglected?

If I want a Servo to go 1500 for some time, do I have to call writeServo(1500); on each loop iteration, or does it save the value I gave for the last time and repeats it over until I change it?

Do you have any other ideas, where the strange motor behaviour could come from?

The Servo library is persistent, the last write() holds forever, so long as its interrupt handler can run in a timely fashion.

This means the other interrupt handlers have to be very short (few us at most).

Additionally: I’ve allready thought about writing a more “raw” servo lib myself. It would just be used to run the 4 motors I need. And I could optimize it for speed. Also the usage of TCNT1 would be possible.
Somehow like: http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-channels-rcarduinofastlib.html
Would this make a great difference? Or is the interrupt clash with 10us or so small enough to be neglectable?

Also the provided link is done with some fancy features and is quite big allready. Is it hard to write something basic like: fire 4 servos?

Thanks in advance! (Happy holidays)

@MarkT:
The interrupts are as short as I could get it:

void RC::INT0_ISR()
{
 	static uint16_t startTime = 0;
  if(PIND & (1<<PIND2)) //digital pin 2 is high
  {
    startTime = micros();
  }
  else
  {
    _signal[0] = (int)(micros() - startTime);
    _flag |= FLAG_CH1;
  }
}

Until now I don’t know any other thing (except for the tcnt1 thing mentioned) to speed this up even more.

  • I’ve done tests and run a neutral positioning of the rc transmitter for a minute. This code runs quite fast and has 10us delay as an absolute max (with 3 channels active). So I guess this would be the worst clash from that side.

Then again one problem misinterpreted:
It was just that Receiver and Arduino were not grounded together - I counted on the fact, that there is only one battery on board. But obviously from the BEC (battery eliminating circuit) of the ESCs (elec speed controller) to the arduino there is a difference in ground, even though they get supplied by the same source.

So I can just say: Ground everything together and fly :)!