View Single Post
  #5   Spotlight this post!  
Unread 04-02-2008, 19:39
Chaos in a Can Chaos in a Can is offline
Joel Spadin
FRC #1736 (Robot Casserole)
Team Role: Programmer
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Peoria, IL
Posts: 58
Chaos in a Can is an unknown quantity at this point
Send a message via MSN to Chaos in a Can
Re: Code spitting out -16256?

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.
__________________
2006 Xerox Creativity Award
2007 General Motors Industrial Design Award
2008 Judges' Award
2009 Chrysler Team Spirit Award


Last edited by Chaos in a Can : 04-02-2008 at 19:45. Reason: I wanted to.