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

Running two controllers via the Partner Port
http://robotc.net/forums/viewtopic.php?f=53&t=2742
Page 1 of 1

Author:  Dracco1993 [ Thu Nov 11, 2010 6:24 pm ]
Post subject:  Running two controllers via the Partner Port

I am trying to program our robot for this year's VEX competitions and I can not find how to run both controllers. Basically I am looking to drive with the first controller and move an arm and hang with the second controller. Right now I have the code all done and working so that I can preform all the functions with one controller, but I can't figure out how to code in the second controller or how you would read the inputs from it. We have a competition in two weeks so it would be great if I could get this working very soon.


Thanks!

Author:  jbflot [ Mon Nov 15, 2010 12:55 pm ]
Post subject:  Re: Running two controllers via the Partner Port

Hi Jordan -

If you've got the hardware all configured correctly, accessing values from the 2nd controller is as easy as accessing it from the 1st. To access the value, use the keyword you would usually use, but append "Xmtr2" to the end of it.

For instance, if I wanted to access the value of the Down button in group 5, on the 2nd controller, I'd use "vexRt[Btn5DXmtr2]" instead of just "vexRT[Btn5D]".

Author:  jbflot [ Mon Nov 15, 2010 4:12 pm ]
Post subject:  Re: Running two controllers via the Partner Port

In the sample program below, joystick values from Controller 1 are controlling the driving motors, and a button from Controller 2 is controlling an arm. Hope that helps!

Code:
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop)
#pragma config(Motor,  port6,           armMotor,      tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  while(time1[T1] < 90000)
  {
    motor[leftMotor] = vexRT[Ch3];
    motor[rightMotor] = vexRT[Ch2];

    if(vexRT[Btn6UXmtr2] == 1)
    {
      motor[armMotor] = 40;
    }
    else if(vexRT[Btn6DXmtr2] == 1)
    {
      motor[armMotor] = -40;
    }
    else
    {
      motor[armMotor] = 0;
    }
  }
}

Author:  Dracco1993 [ Mon Nov 15, 2010 6:58 pm ]
Post subject:  Re: Running two controllers via the Partner Port

Thank you! I have got everything working now. =)

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