View unanswered posts | View active topics It is currently Fri Oct 24, 2014 11:30 pm






Reply to topic  [ 3 posts ] 
Motor runs continuously with joystick 
Author Message
Rookie

Joined: Mon Jan 13, 2014 5:27 pm
Posts: 1
Post 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;
}
}
}


Mon Jan 13, 2014 5:54 pm
Profile
Online
Expert
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 138
Post 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.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://cof7468.weebly.com/.


Mon Jan 13, 2014 6:43 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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.


Tue Jan 14, 2014 3:51 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.