|
Re: Slow down teh motors!
If my memory serves me right, all pwm values are usigned chars (which gives them the 0 - 255) range. If you subract 127 from anything less than 127, it is going to wrap around to 255 because it cant handle negative signs.
If I am right about the pwm variables all being unsigned chars, then your problem is subtracting the 127 from the value. The fix would to be create a temporary integer variable, give it the value of the pwm, do the math, and then reassign it.
int temp13 = pwm13;
int temp14 = pwm14;
int temp15 = pwm15;
int temp16 = pwm16;
if (p1_sw_trig == 1)
{
pwm13 = (temp13-127)/2+127;
pwm14 = (temp14-127)/2+127;
pwm15 = (temp15-127)/2+127;
pwm16 = (temp16-127)/2+127;
}
Also, as posted above, you could just cast it to an int.
__________________
Team 1546 Chaos Incorporated
2005- SBPLI Rookie All Stars
2006- SBPLI Sportsmanship award.
Gotta hand it to the straight line autonomous mode, the most effective defense out there.
Proud beyond belief of the accomplishments of the second year, 20th ranked, 6 wins and 6 losses Chaos Incorporated.
|