Problems with partner joystick

We’re trying to program for 2 drivers. However, this is the first time we used a partner joystick. Currently, the link light does not light up at all.

We know the robot drives with a single driver code. However we are not 100% certain if our telephone cable or joystick works. We tried 3 different telephone cables and our partner joystick is new. Our main joystick is a year old, however we do know it worked with 2 drivers last year. I highly doubt it was damaged since then.

This is our current code.

#pragma config(Motor,  port1,           LeftRoller,    tmotorVex393, openLoop)
#pragma config(Motor,  port2,           FrontRight,    tmotorVex393, openLoop)
#pragma config(Motor,  port3,           BackRight,     tmotorVex393, openLoop)
#pragma config(Motor,  port4,           FrontLeft,     tmotorVex393, openLoop)
#pragma config(Motor,  port5,           BackLeft,      tmotorVex393, openLoop)
#pragma config(Motor,  port6,           Funnel,        tmotorVex269, openLoop)
#pragma config(Motor,  port7,           LeftLift,      tmotorVex393, openLoop)
#pragma config(Motor,  port8,           RightLift1,    tmotorVex393, openLoop)
#pragma config(Motor,  port9,           RightLift2,    tmotorVex269, openLoop)
#pragma config(Motor,  port10,          RightRoller,   tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
	int X2 = 0, Y1 = 0, X1 = 0, threshold = 15;

	while(true)
	{


	if(abs(vexRT[Ch3]) > threshold)
Y1 = vexRT[Ch3];
else
Y1 = 0;
//Create "deadzone" for X1/Ch4
if(abs(vexRT[Ch4]) > threshold)
X1 = vexRT[Ch4];
else
X1 = 0;
//Create "deadzone" for X2/Ch1
if(abs(vexRT[Ch1]) > threshold)
X2 = vexRT[Ch1];
else
X2 = 0;

//Remote Control Commands
    motor[FrontLeft] = vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
		motor[BackRight] = - vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];
		motor[FrontRight] = -vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
		motor[BackLeft] =  vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];


		if (vexRT[Btn7LXmtr2]==1)
			{
				motor[Funnel]=127;
			}

		else if (vexRT[Btn7RXmtr2]==1)
			{
				motor[Funnel]=-127;
			}

		else if (vexRT[Btn8LXmtr2]==1)
			{
				motor[LeftLift]=-127;
				motor[RightLift1]=127;
				motor[RightLift2]=127;
			}
		 else if (vexRT[Btn8RXmtr2]==1)
			 {
			 motor [LeftLift] = 80;
		   motor [RightLift1] = -80;
		   motor [RightLift2] = -80;
				}
		else if (vexRT[Btn6UXmtr2]==1)
			{
				motor[RightRoller]=-127;
				motor[LeftRoller]=-127;
			}
	  else if (vexRT[Btn5UXmtr2]==1)
	   {
	     motor[LeftRoller]=127;
	     motor[RightRoller]=127;
	   }
	  else
	  	{
	  		motor[LeftLift] = -20 ;
				motor[RightLift1] = 20 ;
				motor[RightLift2] = 20 ;
				motor[LeftRoller] = 0 ;
				motor[RightRoller] = 0 ;
				motor[Funnel] = 0 ;
	  }
	}
}

Hard to say if the joystick works or not, use the ROBOTC joystick debug window and see if values are changing. The code does look incorrect, rather too many “else” statements I suspect. A little formatting would help you see this type of thing. Try this.

#pragma config(Motor,  port1,           LeftRoller,    tmotorVex393, openLoop)
#pragma config(Motor,  port2,           FrontRight,    tmotorVex393, openLoop)
#pragma config(Motor,  port3,           BackRight,     tmotorVex393, openLoop)
#pragma config(Motor,  port4,           FrontLeft,     tmotorVex393, openLoop)
#pragma config(Motor,  port5,           BackLeft,      tmotorVex393, openLoop)
#pragma config(Motor,  port6,           Funnel,        tmotorVex269, openLoop)
#pragma config(Motor,  port7,           LeftLift,      tmotorVex393, openLoop)
#pragma config(Motor,  port8,           RightLift1,    tmotorVex393, openLoop)
#pragma config(Motor,  port9,           RightLift2,    tmotorVex269, openLoop)
#pragma config(Motor,  port10,          RightRoller,   tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
    int X2 = 0, Y1 = 0, X1 = 0, threshold = 15;

    while(true)
        {
        if(abs(vexRT[Ch3]) > threshold)
            Y1 = vexRT[Ch3];
        else
            Y1 = 0;
        
        //Create "deadzone" for X1/Ch4
        if(abs(vexRT[Ch4]) > threshold)
            X1 = vexRT[Ch4];
        else
            X1 = 0;
        
        //Create "deadzone" for X2/Ch1
        if(abs(vexRT[Ch1]) > threshold)
            X2 = vexRT[Ch1];
        else
            X2 = 0;

        //Remote Control Commands
        motor[FrontLeft]  =  vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
        motor[BackRight]  = -vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];
        motor[FrontRight] = -vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
        motor[BackLeft]   =  vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];


        if (vexRT[Btn7LXmtr2] == 1)
            motor[Funnel] = 127;
        else
        if (vexRT[Btn7RXmtr2] == 1)
            motor[Funnel] = -127;
        else
            motor[Funnel] = 0;
            
        if (vexRT[Btn8LXmtr2] == 1)
            {
            motor[LeftLift]   = -127;
            motor[RightLift1] = 127;
            motor[RightLift2] = 127;
            }
        else
        if (vexRT[Btn8RXmtr2] == 1)
            {
            motor [LeftLift]   =  80;
            motor [RightLift1] = -80;
            motor [RightLift2] = -80;
            }
        else
            {
            motor[LeftLift]    = -20 ;
            motor[RightLift1]  =  20 ;
            motor[RightLift2]  =  20 ;
            }       
        
        
        if (vexRT[Btn6UXmtr2] == 1)
            {
            motor[RightRoller] = -127;
            motor[LeftRoller]  = -127;
            }
        else
        if (vexRT[Btn5UXmtr2] == 1)
            {
            motor[LeftRoller]  = 127;
            motor[RightRoller] = 127;
            }
        else
            {
            motor[LeftRoller]  = 0 ;
            motor[RightRoller] = 0 ;
            }
    }
}

Thanks for a speedy reply :slight_smile:

I’m not much of a programmer, but would the part in your code that says

 if (vexRT[Btn7LXmtr2] == 1)
            motor[Funnel] = 127;
        else
        if (vexRT[Btn7RXmtr2] == 1)
            motor[Funnel] = -127;
        else
            motor[Funnel] = 0;
            
        if (vexRT[Btn8LXmtr2] == 1)

need “{}”?

Also a few newbie questions. . .
Where can I find the Joystick debug window?
What’s the difference between "else"s, and "else if"s. I noticed your code used elses a lot more than else ifs

You don’t need brackets if it’s only one statement that follows.
An “else if” is sort of like a line of backups. If the first if statement doesn’t work, then it’ll go on to the next else if. If that one is also false, then it’ll go to the next else if, etc. You use else at the end if there are no more conditions to be checked and all other possibilities not checked in the if and else ifs resolve to false.

Ah ok. So use If as an intro, Else ifs like body paragraphs, and Else as a conclusion. Thanks:)

Forgot to mention: We first tethered the controls incorrectly, but we fixed it before the thread was made. We originally tethered the joysticks together then tethered the main joystick to the robot. However, we changed tether to vexnet. We do know vexnet works well on our robot.

Ill give you guys an update on monday

Under the Advanced Tools menu

[ATTACH]7758[/ATTACH]

It then shows this window.

[ATTACH]7759[/ATTACH]

You can see now raw joystick data.

Well my code was your code, it was slightly reformatted and a couple of unneeded “else” statements removed. One thing to remember, and Cody touched on this in his tutorial (well the first version, I didn’t have time to watch the new ones yet) is that “white space” is ignored by the compiler. What this means is that this


        if (vexRT[Btn7LXmtr2] == 1)
            motor[Funnel] = 127;
        **else**
        **if (vexRT[Btn7RXmtr2] == 1)**
            motor[Funnel] = -127;
        else
            motor[Funnel] = 0;

is the same as this


        if (vexRT[Btn7LXmtr2] == 1)
            motor[Funnel] = 127;
        **else if (vexRT[Btn7RXmtr2] == 1)**
            motor[Funnel] = -127;
        else
            motor[Funnel] = 0;

I just happen to like the “if” statement on a new line, both are correct and a matter of personal preference.
joystick_viewer.jpg

Ah, that’s what tripped me up.

When using the vexnet joystick viewer, it says that the firmware is out of date. I tried updating it, it then said the controllers were up to date…:confused:. tried it again, still said the controller was out of date

Joystick firmware should probably be 3.23, that’s what has been available for several months. What do you see if using the “software inspection” menu?

Other than complaining about software version, did it work?

Are you using a full VEXnet joystick as the partner joystick or the $30 low cost version?

Sorry:o, I should have taken photos. I believe The firmware did say it needed to be 3.23, but for some reason, it said the version we had was 0.00. We didn’t use the software inspection menu. . . we downloaded the stuff through download firmware.

I tried the code out, and it did not solve the second driver issue.

We are currently using the $30 version: http://www.vexrobotics.com/vex/products/accessories/control/276-1891.html

We also tried swapping our controllers today to see if the partner port was faulty on the main joystick, however there was no luck either. It is true however, that the joystick is old, but we do know that joystick worked with 2 driver control last year

Try to put a jumper switch in analog port 11 to activate partner joystick in default code

We have the same problem and we’re looking for a solution

This thread is three years old, ignore all those firmware version numbers, we moved on a lot since then.

Anyone knows how to solve it? Please