Partner joystick problems

For the first time in robotics I am using the vex partner joystick, ONLY one problem. One a button is pressed on the partner joystick it creates a delay in sending control codes to the robot. This would be fine, but what happens, is the diver is telling the robot to move forward and try’s to stop it, but the 2nd driver has pressed a button on the partner joystick causing the robot to remain go forward for a split second. Anyone else ever had this problem? Anyone know how to fix it??

Could you post your code, please?

I cannot be sure without seeing your code, but I am pretty sure what is happening is that you are sending conflicting values to the motor. In your instance, the 1st driver is saying motor = 127, and the second driver is saying motor = 0 and this will confuse the heck out of the robot and cause it to stutter, essentialy the robot with switch between sending 127 to the motors and 0 to the motors, and depending on exactly how the code is layed out (for example if you use if else statements) one command could completely override the other. this could be a good thing ( for example if you want the main controller to totally override commands from the partner controller) but if you get them mixed up one command could override another when you don’t want it to


task usercontrol()
{//Open usercontrol
	while(1 == 1)//Create Loop for following code
	{//Open the loop
		//deadzonecheck for 4wd--------------------------------------------------------- Channel 1 and Channel 2
		deadZoneCheck();
		motor[FrontL] = Channel2 + Channel1;
		motor[BackL] = Channel2 + Channel1;
		motor[FrontR] = Channel2 - Channel1;
		motor[BackR] = Channel2 - Channel1;
		// ON/OFF IntakeConveyor----------------------------------------------------------------Btn7
		if (vexRT[Btn7D] == 1)
		{
			motor[IntakeConveyor] = 120;
		}
		else if (vexRT[Btn7U] == 1)
		{
			motor[IntakeConveyor] = -120;
		}
		else
		{
			motor[IntakeConveyor] = 0;
		}
		// Full Speed Launcher Partner(L4,L5,L6,L7)-----------------------------------------
		if(vexRT[Btn8UXmtr2] == 1)
		{
			if(pressed == false)
			{
				motor[L4] = 60;
				motor[L5] = 60;
				motor[L6] = 60;
				motor[L7] = 60;
				wait1Msec(300);
				motor[L4] = 80;
				motor[L5] = 80;
				motor[L6] = 80;
				motor[L7] = 80;
				wait1Msec(300);
				motor[L4] = 100;
				motor[L5] = 100;
				motor[L6] = 100;
				motor[L7] = 100;
				wait1Msec(300);
				motor[L4] = 120;
				motor[L5] = 120;
				motor[L6] = 120;
				motor[L7] = 120;
				wait10Msec(60);
				pressed = true;
			}
			else
			{
				motor[L4] = 0;
				motor[L5] = 0;
				motor[L6] = 0;
				motor[L7] = 0;
				wait10Msec(50);
				pressed = false;
			}
		}

If you guys want the full code I can private message the file. let me know

What’s with all the 300mS delays?

wait1Msec(300);

They wil stall the code for over a second when the button is pressed.

It looks like you are ramping motors, if you want to do this move all this code into it’s own task so it can run concurrently with the drive control code.


wait1Msec(300);

This is to start the motors up slowly. Do u perhaps have a example of where i should move the code?

Something like this.

task partnerJs()
{
        bool pressed = false;
        
        while(1)
        {
            // Full Speed Launcher Partner(L4,L5,L6,L7)-----------------------------------------
            if(vexRT[Btn8UXmtr2] == 1)
            {
                if(pressed == false)
                {
                    motor[L4] = 60;
                    motor[L5] = 60;
                    motor[L6] = 60;
                    motor[L7] = 60;
                    wait1Msec(300);
                    motor[L4] = 80;
                    motor[L5] = 80;
                    motor[L6] = 80;
                    motor[L7] = 80;
                    wait1Msec(300);
                    motor[L4] = 100;
                    motor[L5] = 100;
                    motor[L6] = 100;
                    motor[L7] = 100;
                    wait1Msec(300);
                    motor[L4] = 120;
                    motor[L5] = 120;
                    motor[L6] = 120;
                    motor[L7] = 120;
                    wait10Msec(60);
                    pressed = true;
                }
                else
                {
                    motor[L4] = 0;
                    motor[L5] = 0;
                    motor[L6] = 0;
                    motor[L7] = 0;
                    wait10Msec(50);
                    pressed = false;
                }
            }
        wait1Msec(25);
        }
}

task usercontrol()
{   //Open usercontrol

    // start second task
    startTask( partnerJs );
    
    while(1 == 1)//Create Loop for following code
        {
        //Open the loop
        //deadzonecheck for 4wd--------------------------------------------------------- Channel 1 and Channel 2
        deadZoneCheck();
        motor[FrontL] = Channel2 + Channel1;
        motor[BackL] = Channel2 + Channel1;
        motor[FrontR] = Channel2 - Channel1;
        motor[BackR] = Channel2 - Channel1;
        
        // ON/OFF IntakeConveyor----------------------------------------------------------------Btn7
        if (vexRT[Btn7D] == 1)
            {
            motor[IntakeConveyor] = 120;
            }
        else if (vexRT[Btn7U] == 1)
            {
            motor[IntakeConveyor] = -120;
            }
        else
            {
            motor[IntakeConveyor] = 0;
            }
        }
}

thanks

Here is some code I created in easyC for the kids to mill over. This was to avoid waits. You can see when a button is pressed say btn1 I start a timer to use in the motor_ACC(int target, int current_CMD, int ramp) function. This function uses these parameters to return a new motor_CMD speed every 1/4 sec in this case. I could add a forth parameter to make this time interval programmable as well.

Remember this is in EasyC so I don’t have some of the tools at my disposal as RobotC and I am a first year coach with vex and am learning the software too. The target velocities of 127 and -127 in the btn1, btn2 statements could easily be joystick values too.

void OperatorControl ( unsigned long ulTime )
{
      while ( 1 ) // Insert Your RC Code Below
      {
            btn1 = GetDigitalInput ( 6 ) ;
            btn2 = GetDigitalInput ( 7 ) ;
            if ( btn1==0 )
            {
                  StartTimer ( 1 ) ;
                  motor_CMD = motor_ACC ( 127, motor_CMD, 5 ) ;
                  PrintToScreen ( "motor CMD = %d\n" , motor_CMD ) ;
                  SetMotor ( 5 , motor_CMD ) ;
            }
            if ( btn2 == 0 )
            {
                  StartTimer ( 1 ) ;
                  motor_CMD = motor_ACC ( -127, motor_CMD, 10 ) ;
                  PrintToScreen ( "motor CMD = %d\n" , motor_CMD ) ;
                  SetMotor ( 5 , motor_CMD ) ;
            }
      }
}

In the motor_ACC function we see each time we enter the function I get the current timer value. If this value is Greater then 250ms then if target velocity is Greater than current_CMD add ramp value to current_CMD, use my LimitMotorCMD to assure the value is always between -127 and 127, reset the timer to “0”, return the new command velocity. Do the opposite if target is less than current or just return the current if time is not greater than interval.

*not in this code but should be considered is if the (current_CMD ± ramp) over shoots the target to only return the target.

int motor_ACC ( int target, int current_CMD, int ramp )
{
      timer_Current = GetTimer ( 1 ) ;
      if ( timer_Current > 250 )
      {
            if ( target > current_CMD  )
            {
                  current_CMD = LimitMotorCMD ( current_CMD + ramp ) ;
                  PresetTimer ( 1 , 0 ) ;
                  return current_CMD ;
            }
            else
            {
                  current_CMD = LimitMotorCMD ( current_CMD - ramp ) ;
                  PresetTimer ( 1 , 0 ) ;
                  return current_CMD ;
            }
      }
      else
      {
            current_CMD = LimitMotorCMD ( current_CMD ) ;
            return current_CMD  ;
      }
}

Limit Motor CMD:

int LimitMotorCMD ( int power )
{
      if ( power > 127 )
      {
            return 127 ;
      }
      else if ( power < -127 )
      {
            return -127 ;
      }
      else
      {
            return power ;
      }
}