Is there any reason that you couldn't use "int"s to store your motor speeds and have a greater range of values with the higher precision obtained by using the CCP (that is, instead of using the gain and center #defines)? I looked through the code and don't see why this wouldn't work, what i mean is something like this as a change to the PWM() function:
Code:
void PWM(unsigned int pwm_13, unsigned int pwm_14, unsigned int pwm_15, unsigned int pwm_16)
{
// int temp_pwm_13;
// int temp_pwm_14;
// int temp_pwm_15;
// int temp_pwm_16;
// .........
// calculate the number of 100 ns timer ticks
// needed to match the desired PWM pulse width
temp_pwm_13 = (PWM_13_GAIN * ((int)pwm_13 - 127)) + PWM_13_CENTER;
temp_pwm_14 = (PWM_14_GAIN * ((int)pwm_14 - 127)) + PWM_14_CENTER;
temp_pwm_15 = (PWM_15_GAIN * ((int)pwm_15 - 127)) + PWM_15_CENTER;
temp_pwm_16 = (PWM_16_GAIN * ((int)pwm_16 - 127)) + PWM_16_CENTER;
// load the CCP compare registers
CCPR2L = LOBYTE(pwm_13);
CCPR2H = HIBYTE(pwm_13);
CCPR3L = LOBYTE(pwm_14);
CCPR3H = HIBYTE(pwm_14);
CCPR4L = LOBYTE(pwm_15);
CCPR4H = HIBYTE(pwm_15);
CCPR5L = LOBYTE(pwm_16);
CCPR5H = HIBYTE(pwm_16);
//..............
Also, could CCPR1L and CCPR1H (or 2-5) each be 255? I ask this because with the default GAIN and CENTER values, the maximum I believe is 21400 (that is for the two combined as one word), as opposed to 65535.