After using many Arduino libraries, I figured it was time to return the favor and contribute one myself. Perhaps someone can use it. I didn't find anything like it anywhere else for controlling many digital capable servos simultaneously at high refresh rates.
Interupt driven to free up resources (as opposed to the softwareservo library). High refresh rates reduce input lag times in unstable systems (Quad, FBL heli, Segway etc.). Theoreticaly synchronization reduces "wobble" where synchronization is critical. e.g.3 servo heli swashplates.
The maximum safe servo refresh rate of the original servo.h library is the max number of servos * the max PPM width eg. 2500us plus a little overhead.
I took the Arduno interupt driven servo library and the Software servo library and made a hybrid simultaneous interupt driven servo library out of them. Result, a digital servo/esc capable simultaneous servo library. At the moment only one port (B,C or D) can be chosen at once. 8 Servos (PortB 6) simultaneously up to 333Hz is possible. I only use it at the moment at 200Hz though.
Theory: Sorts all the PPMs in ascending order, shift the non simultaneous and following ones by 25micro seconds, which is a bit more than the minimum needed so that the interupts don't get in the way of each other and mess up the PPM/PWM widths. Uses Timer 1.
I've only tested it on a Arduino pro-mini 16MHz and the Uno, so it is very Atmega 328 specific because of the Port calls. Its still a work in progress, but it does the job very well at the moment in my balancing robot project. The only problem to date seems to be that the interupts don't work very well with simultaneous Serial transmisions. This is no big problem for me, because at my 200Hz cycle time I can send my Serial info after the servo has fired but before the next cycle between the 3ms and 5ms time. I've synchronized my main program loop to the servo routine timer counter.
Long story short. I'm new here. Where and how is the best way to post my library other than attaching it here (shows up only if you are logged in I think) and any hints as to why the above problem occurs?
SimultServoV2.zip (9.83 KB)