So I'm working on a new project - a pair of LED goggles with

So I’m working on a new project - a pair of LED goggles with animated eyebrows. The eyebrows are run with servos, and those work wonderfully, if a tad bit noisy. The problem comes when I try to use FastSPI to run the LED rings. The servos start twitching, and the commands I use start not working at all. Remove FastSPI, everything works correctly.

I am just using the basic “Servo.h” that comes with the arduino install. Is there a better way to run them?

What pins are you using and what controller (arduino, teensy, etc…). Also it looks like the servo library uses some timers - so it may require interrupts - which writing the ws2811 and friends require disabling.

oh, sorry.

Arduino Uno, pins 6 + 7 for the servos, pin 8 for the LED rings.

Edit: From some cursory reading, the servo wants a signal every 20ms to define the position. Basically, a pulse every 20ms of between 1 and 2ms to define the position. So there’s some math involved as well to go from “20 degrees” to “1.08ms pulse”.

Some possible things throwing off - the disabling/reenabling of interrupts may be messing with the timer/timing of the servos - which I don’t have a good fix for at the moment. A less likely possibility is noise crossing from 8 to 6/7 messing with the servos.

As for whether the interrupts being off means you aren’t updating as often as you should or whether the timing of the updates is off, I can’t quite speak to that yet - I haven’t messed much with servos.

Feeling adventurous? I can give you a file to play with and see if it helps.

Sure, why not? I’ll need to update to the latest version of FastSPI first, I assume. I haven’t done so due to lazy. :stuck_out_tongue:

What version are you running on currently? Trying to anticipate how much change you’ll need to make. I’m going to shoot you a file to replace the one currently in your library with, my laptop is currently doing some processing where it’s using the camera so I can’t use it, but I’ll try to pull the test file together for you in a few.

I just upgraded to the latest version. Not an issue - there’s hardly any code in the servo test that I was using, so I don’t really mind if I have to start over entirely.

I actually did restart, and pulled some of my code from my helmet, for better interlacing of effects. the commands now work, but I am still getting the twitchiness - which is purely because it’s missing an interrupt. Better than it was! :smiley:

Here’s the code:

So I’ve SORT of solved it. By detaching and re-attaching to the servos when drawing on the LEDs, I can minimize the twitching. There’s still a tiny bit, but it’s pretty close now. it just seems I can’t just attach to the servo, update it, and detach it, though. Which is a pain.