ROBOTC.net forums
http://www.robotc.net/forums/

yet another programming issue
http://www.robotc.net/forums/viewtopic.php?f=52&t=2117
Page 1 of 1

Author:  dallasrobotics [ Tue Jan 19, 2010 6:32 pm ]
Post subject:  yet another programming issue

Ok so our only problem this time and hopefully our last is that when we push a button which gives us more power to the motors also disables our shooting mechanism.If the button is released the shooter works. For mor information we also puch a button to activate the joystick to control the shooter power. here is the code. I don't see any difference between the two statements for the shooter in fact they were copied over so I don't know why they don't work when the robot is in "boost." Thanks for your help.

#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Hubs, S2, HTMotor, HTServo, none, none)
#pragma config(Motor, mtr_S1_C1_1, motorLeft, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, motorRight, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S2_C1_1, thrower, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S2_C1_2, motorG, tmotorNormal, openLoop)
#pragma config(Servo, srvo_S1_C2_1, launcher, tServoNormal)
#pragma config(Servo, srvo_S1_C2_2, scoopLeft, tServoNormal)
#pragma config(Servo, srvo_S1_C2_3, scoopRight, tServoNormal)
#pragma config(SrvoPosition, Position01, 242, 128, 128, 128, 128, 128, 128, 128)
#pragma config(SrvoPosition, Position02, 186, 128, 128, 128, 128, 128, 128, 128)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"
task main()
{
while(true)
{
getJoystickSettings(joystick);

while(joy1Btn(5) != 1) // without boost
{

//single joystick control
motor[motorLeft] = (((joystick.joy1_y1*25)/-127) + (joystick.joy1_x1*25)/-127);
motor[motorRight] = (((joystick.joy1_y1*25)/-127) - (joystick.joy1_x1*25)/-127);

if(joy2Btn(6) != 1)
{
motor[thrower] = 0;

}

if(joy2Btn(6) == 1)
{
//variable thrower speed
motor[thrower] = ((joystick.joy2_y2*100)/-127);

}


if(joy2Btn(7) == 1)
{
servo[launcher] = 255;
servoChangeRate[launcher] = 0;
}



if(joy2Btn(5) == 1)
{
servo[launcher] = 186;
servoChangeRate[launcher] = 0;

}

if(joy1Btn(1) == 1)
{
servo[scoopLeft] = 0;
servo[scoopRight] = 255;
servoChangeRate[scoopLeft] = 0;
servoChangeRate[scoopRight] = 0;
}

if(joy1Btn(2) == 1)
{
servo[scoopLeft] = 245;
servo[scoopRight] = 10;
servoChangeRate[scoopLeft] = 0;
servoChangeRate[scoopRight] = 0;
}
}


while(joy1Btn(5) == 1) // with boost
{

// single joystick control
motor[motorLeft] = (((joystick.joy1_y1*75)/-127) + (joystick.joy1_x1*75)/-127);
motor[motorRight] = (((joystick.joy1_y1*75)/-127) - (joystick.joy1_x1*75)/-127);

if(joy2Btn(6) != 1)
{
motor[thrower] = 0;

}

if(joy2Btn(6) == 1)
{
//variable thrower speed
motor[thrower] = ((joystick.joy2_y2*100)/-127);

}


if(joy1Btn(1) == 1)
{
servo[scoopLeft] = 0;
servo[scoopRight] = 255;
servoChangeRate[scoopLeft] = 0;
servoChangeRate[scoopRight] = 0;
}

if(joy1Btn(2) == 1)
{
servo[scoopLeft] = 245;
servo[scoopRight] = 10;
servoChangeRate[scoopLeft] = 0;
servoChangeRate[scoopRight] = 0;
}


}

}
}

Author:  dallasrobotics [ Tue Jan 19, 2010 6:37 pm ]
Post subject:  Re: yet another programming issue

Ok sorry but believe it or not it fixed itself. I was messing with something else and then it started working correctly.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/