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

Motor runs continuously with joystick
http://www.robotc.net/forums/viewtopic.php?f=1&t=7679
Page 1 of 1

Author:  FTC mentor [ Mon Jan 13, 2014 5:54 pm ]
Post subject:  Motor runs continuously with joystick

Having trouble with the joystick program. We have 4 Tetrix motors; 2 are drive motors and the the other 2 control the flag raise and the pullup for this year's FTC competition. Three out of the 4 motors work great. The right drive motor runs continously; the right joystick does not work at all. See program below for review. Any help is greatly appreciated.

task main()
{
initializeRobot();

waitForStart(); // wait for start of tele-op phase

while (true)
{
getJoystickSettings(joystick);
joyleft=joystick.joy1_y1;
joyright=joystick.joy1_y2;
if(abs(joyleft)<27)
{
joyleft=0;
}
if(abs(joyright)<27)
{
joyright=0;
}
motor[MotorLeft]=joyleft;
motor[MotorRight]=joyright;
if(joy1Btn(4)==1)
{
motor[Flag]=100;
}
if(joy1Btn(2)==1)
{
motor[Flag]=-100;
}
if(joy1Btn(5)==1)
{
motor[Pullup]=100;
}
if(joy1Btn(6)==1)
{
motor[Pullup]=-100;
}
if(joy1Btn(5)==0&&joy1Btn(6)==0)
{
motor[Pullup]=0;
}
if(joy1Btn(4)==0&&joy1Btn(2)==0)
{
motor[Flag]=0;
}
}
}

Author:  BurningLights [ Mon Jan 13, 2014 6:43 pm ]
Post subject:  Re: Motor runs continuously with joystick

Hmm, the code seems OK. If your controller has a switch on the back, check to make sure that it is set to D mode, not X.

Author:  MHTS [ Tue Jan 14, 2014 3:51 am ]
Post subject:  Re: Motor runs continuously with joystick

Also pay attention to the game controller picture in the joystick dialog especially the values of the two sticks when they are released. RobotC sometimes goes crazy and gives you large values even though you did not touch the sticks. If that happens, you may need to close RobotC and restart it. Also, when plugging in the game controllers to the USB ports, do not touch the sticks. It may zero calibrated incorrectly if you do.

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