MIDIUSB Library + Leonardo crashing

I am using a MIDI Control Change to move a servo connected to a Leonardo. It works! However, if I move the control too fast the MIDI connection drops and the Leonardo is unresponsive. I have a commercial animatronic board (USB-->MIDI-->MIDI Servo Controller that is working and can keep up with the same setup.

I would like to confirm that Leonardo performance could be the issue. If that's the case I'll try a SAMD21 board when it arrives in the few days.

Here's my code:

#include <Servo.h>
#include "MIDIUSB.h"

Servo myservo;

void setup() {
  Serial.begin(115200);
  myservo.attach(9);
}

void loop() {
  midiEventPacket_t rx;
  do {
    rx = MidiUSB.read();
    if (rx.header != 0) {
      int val = map(rx.byte3, 0, 127, 0, 180);
      myservo.write(val);
    }
  } while (rx.header != 0);
}

The Leonardo does NOT freeze up if I remove the Servo Library and control an LED. So perhaps there is a timer conflict between the MIDIUSB and SERVO libraries?

I have an I2C servo shield that I could use as a workaround. Will do more tests.

Likely power related.

I am powering the steppers and servos using an ATX supply. I got it working just fine by not using the Arduino Servo library. I have tested servos + steppers + neopixels simultaneously without any problems using some Adafruit PWM and Motors shields:

MIDIUSB is a great addition in 1.6.6

You didn't mention Adafruit_NeoPixel (which blocks interrupts) was part of this equation, and it's not part of the code you posted!

My initial code was just a Leonardo using the Arduino Servo library. The Leonardo seizes up after a few seconds. I figured there is a conflict with the libraries so I tried with i2c interfaces and later with Neopixels. They work just fine.

I went back to the beginning and tested with the Arduino Servo library again and it does work. As you say, it was probably a power issue. The servo I was using was pulling far too much current than normal. So now all works just fine with the Arduino servo library and the i2c shields.

Thanks,