Time to address this issue if we want to keep our lovely Neo pixels.  Who does not love our Neos. (don't raise your hand).

The problem

"The single-wire control protocol used by NeoPixels requires a very steady data stream at 800 kilobits per second. There’s a tiny margin for error, but not very much. Bits must be issued at a precisely controlled rate…the Adafruit_NeoPixel library handles all this behind the scenes, carefully counting the time of each machine code instruction. For every pixel, there’s 24 of these:"

"Meanwhile, the Arduino is normally using small fractions of time here and there to process interrupts…certain events and situations that need to be handled immediately. You usually don’t see it, but interrupts are occurring all the time behind the scenes. Your regular sketch code stops, an interrupt service routine is called, and your code then resumes right where it left off. Interrupts help the Arduino’s delay() and millis() functions work, as well as Serial.read(), all manner of things!

These two concepts cannot coexist. Even a very short and simple interrupt routine will throw off the delicate NeoPixel timing. Therefore, the NeoPixel library temporarily disables all interrupts when issuing data, then re-enables them when done.

This is rarely a problem. You might have noticed that millis() and micros() lose time in NeoPixel sketches (the timekeeping interrupt stops whenever we write to the strip), that’s usually the extent of it.

The issue arises that servos also have very specific timing requirements of their own, and the Arduino Servo library uses interrupts to achieve this. So every time the NeoPixel library turns off interrupts, even for a moment, the servos will lose track of time (and therefore position) and shake unpredictably. How sad!

Now that we have identified the problem. The Jitterbug blues, what can we do to solve this issue?

  • Is it possible to create a block that turns off that power pin and not use a delay or interrupt?
  • It does not matter if the neo is flashing or not. Just the fact that the neo is in the program can cause servo jitter.
  • Can we turn off the Neo pixels while the servos are running?  Back and forth?
  • Do we need to go to a PCA8695a type of distribution board to run the servos and have this be turned on and off by the Ardunio program?  Is this even possible in blockly?
  • Arduino libraries have two commands called smooth servo, and servo override.  Can these be made into blocks.?

Note: this does not happen with anything except the servos, so if you are using wheels then your in good company with your friends the Neos.

Experiments conducted with Bork2