Try changing
Code:
prepwm01 = wFL + 127;
prepwm02 = 127 - wFR;
prepwm03 = wRL + 127;
prepwm04 = 127 - wRR;
to
Code:
prepwm01 = (int)wFL + 127;
prepwm02 = 127 - (int)wFR;
prepwm03 = (int)wRL + 127;
prepwm04 = 127 - (int)wRR;
and
Code:
pwm01 = prepwm01;
pwm02 = prepwm02;
pwm03 = prepwm03;
pwm04 = prepwm04;
to
Code:
pwm01 = (char)prepwm01;
pwm02 = (char)prepwm02;
pwm03 = (char)prepwm03;
pwm04 = (char)prepwm04;
Also, I don't see any reason all of the doubles at the top couldn't be ints.
It doesn't look like any of the possible values would be outside the range of an int and using floating points with the controller is never a good idea.
Unless you know what you're doing, using floats and doubles usually lead to messed up numbers like what you're getting.
Hope that helps.