Nathan
05-11-2006, 15:12
Hi, I'm programming the Vex SquareBot in MPLAB IDE, and am having some problems programming the movement since one of the motors on the SquareBot is inverted. I tried this code:
void normal_operation()
{
int R_Joy_Up = 127; // These hold the joystick values.
int L_Joy_Up = 127; // Only R_Joy_Up & L_Joy_Up are used in tank mode.
int R_Joy_Down = 127; // This probably isn't really needed, to be cleaned up after project completed.
int L_Joy_Down = 127;
int R_Joy_Right = 127;
int L_Joy_Right = 127;
int R_Joy_Left = 127;
int L_Joy_Left = 127;
int temp;
while(autonomous != 255)
{
R_Joy_Up = GetRxInput( 1,2 );
L_Joy_Up = GetRxInput( 1,3 );
if(L_Joy_Up > NEUTRAL)
{
temp = L_Joy_Up - 127;
L_Joy_Up = NEUTRAL - temp;
}
else if(L_Joy_Up < NEUTRAL)
{
temp = L_Joy_Up - 127;
L_Joy_Up = NEUTRAL - temp;
if(L_Joy_Up <= 0)
{
L_Joy_Up = 253;
}
}
autonomous = GetRxInput(1,5);
drive ( R_Joy_Up, L_Joy_Up );
PrintToScreen ( "L_Joy_Up: %d\n" , (int)L_Joy_Up );
Wait(1);
}
My code works fine, until I move the left joystick on the vex controller all the way to the bottom. The the motor suddenly reverses direction :(
Does anyone have any suggestions? I really appreciate the help :)
Thanks,
Nathan
void normal_operation()
{
int R_Joy_Up = 127; // These hold the joystick values.
int L_Joy_Up = 127; // Only R_Joy_Up & L_Joy_Up are used in tank mode.
int R_Joy_Down = 127; // This probably isn't really needed, to be cleaned up after project completed.
int L_Joy_Down = 127;
int R_Joy_Right = 127;
int L_Joy_Right = 127;
int R_Joy_Left = 127;
int L_Joy_Left = 127;
int temp;
while(autonomous != 255)
{
R_Joy_Up = GetRxInput( 1,2 );
L_Joy_Up = GetRxInput( 1,3 );
if(L_Joy_Up > NEUTRAL)
{
temp = L_Joy_Up - 127;
L_Joy_Up = NEUTRAL - temp;
}
else if(L_Joy_Up < NEUTRAL)
{
temp = L_Joy_Up - 127;
L_Joy_Up = NEUTRAL - temp;
if(L_Joy_Up <= 0)
{
L_Joy_Up = 253;
}
}
autonomous = GetRxInput(1,5);
drive ( R_Joy_Up, L_Joy_Up );
PrintToScreen ( "L_Joy_Up: %d\n" , (int)L_Joy_Up );
Wait(1);
}
My code works fine, until I move the left joystick on the vex controller all the way to the bottom. The the motor suddenly reverses direction :(
Does anyone have any suggestions? I really appreciate the help :)
Thanks,
Nathan