Faster Servos, Smoother Projects
A post to introduce a new library RCArduinoFastLib.
The library supports upto 20 servos on an Arduino in two banks of 10.
The two banks can have an independent refresh rate allowing you to run ESCs at high frequency on one bank and Servos at 50Hz on the other - or everything at the same frequency, whatever you choose.
The library includes two main optimisations over the standard servo library-
1) It does not reset timer1 so you can safely use timer1 for timing tasks in your project such as reading RC Pulse widths. This might not sound like much but its many times faster than having to call millis which means less time inside ISRs and less glitches.
2) The library avoids using digitalWrite which give another speed boost.
So if you want more servos, adjustable refresh rates, faster code or smoother RC Projects read on -
The library usage is similar to the standard library
// attach servo objects, these will generate the correct
// pulses for driving Electronic speed controllers, servos or other devices
// designed to interface directly with RC Receivers
// the refresh rate can be set through independent control of the framespace -
// lets set a standard rate of 50 Hz by setting a frame space of 10 * 2000 = 3 Servos + 7 times 2000
// Set the pulse width for a servo -
I will post a follow up with some usage examples on the RCArduino blog