|
Re: please explain more...
Posted by Jerry Eckert.
Engineer from Looking for a team in Raleigh, NC sponsored by .
Posted on 3/15/2000 8:48 PM MST
In Reply to: Re: please explain more... posted by Nate Smith on 3/15/2000 6:09 PM MST:
: As for losing part of our range, when I attempted to scale down the drive train output to 50% of the joystick value in order to create our 'turbo boost' function, using the code shown below:
: (for forward)
: p1_yfilt = (p1_yfilt)/2 min 128 max 254
: (for reverse)
: p1_yfilt = (p1_yfilt*3)/2 min 0 max 126
: in one direction, i would lose all output unless the 'turbo' function was on, and in the other, it would always act as if the turbo was turned on.
I don't have the PBASIC manual handy, but it looks like the problem might be that the precedence of min/max is higher than division. In other words, I suspect PBASIC evaluated your statements as:
p1_yfilt = (p1_yfilt)/(2 min 128 max 254), and
p1_yfilt = (p1_yfilt*3)/(2 min 0 max 126)
Try rewriting them as follows:
p1_yfilt = (p1_yfilt/2) min 128 max 254, and
p1_yfilt = ((p1_yfilt*3)/2) min 0 max 126
Jerry
__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.
|