Help modifying servo.h to give a 400hz signal

I figured out the solution finally. To update at 400hz the code must be changed to

#define MIN_PULSE_WIDTH       1000// the shortest pulse sent to a servo
#define MAX_PULSE_WIDTH      2000// the longest pulse sent to a servo
#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached
#define REFRESH_INTERVAL    2500// minumim time to refresh servos in microseconds
#define SERVOS_PER_TIMER       1     // the maximum number of servos controlled by one timer
#define MAX_SERVOS   (_Nbr_16timers  * SERVOS_PER_TIMER)

The key is 1 servo per timer. If you want to run 8 ESCs the max rate is 200hz with servos per timer at 2. Hope this helps someone.

Notably this will only work for the MEGA because it has four timers.

1 Like