Scissor Lift Code Help Needed

Hi everyone! Our team is building a scissor lift and we’re having several errors. When we have our scissor lift code in a separate file on its own, we don’t have any errors and our scissor lift runs smoothly, but once we place our scissor lift code with the rest of our competition code, the scissor starts chattering on the way up and down. We know it’s not a motor problem because we’ve already tested them separately. Any advice on how to fix this problem would be appreciated.

Scissor Code alone:

#pragma config(Motor,  port2,           TopLeft,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port3,           TopRight,      tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           BottomLeft,    tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port5,           BottomRight,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           Middle1,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port7,           Middle2,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port8,           ScissorLiftRight, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port9,           ScissorLiftLeft, tmotorVex393_MC29, openLoop)

#pragma platform(VEX)

#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)


#include "Vex_Competition_Includes.c"   


void pre_auton()
{
  bStopTasksBetweenModes = true;
}


task usercontrol()
{
	// User control code here, inside the loop


	while (true)
	{
	motor [ScissorLiftRight]=vexRT[Ch5];
	motor [ScissorLiftLeft]=vexRT[Ch6];


	if(vexRT[Btn7R])
	{
		motor[ScissorLiftLeft] = 127;
		motor[ScissorLiftRight] = 127;
	}
	else{
		motor[ScissorLiftLeft] = 0;
		motor[ScissorLiftRight] = 0;


	if(vexRT[Btn7L])
	{
		motor[ScissorLiftLeft] = -127;
		motor[ScissorLiftRight] = -127;
	}
	else{
		motor[ScissorLiftLeft] = 0;
		motor[ScissorLiftRight] = 0;
	}

	  UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
	}
}
}

Competition Code all together:

#pragma config(Motor,  port1,            ,             tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port2,           TopLeft,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port3,           TopRight,      tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           BottomLeft,    tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port5,           BottomRight,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           Middle1,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port7,           Middle2,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port8,           ScissorLiftRight, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port9,           ScissorLiftLeft,  tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port10,           ,             tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard!!*//


#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c"   //Main competition background code...do not modify!






void pre_auton()
{
  
  bStopTasksBetweenModes = true;


}


task autonomous()
{
  // .....................................................................................
  // Insert user code here.
  // .....................................................................................


	AutonomousCodePlaceholderForTesting();  // Remove this function call once you have "real" code.
}




task usercontrol()
{
	
	while (true)
	{
	 
	motor [TopLeft]=vexRT[Ch3];
	motor [TopRight]=vexRT[Ch2];
	motor [BottomLeft]=vexRT[Ch3];
	motor [BottomRight]=vexRT[Ch2];
	motor [Middle1]=vexRT[Ch1];
	motor [Middle2]=vexRT[Ch1];
	motor [ScissorLiftRight]=vexRT[Ch5];
	motor [ScissorLiftLeft]=vexRT[Ch6];


	if(vexRT[Btn8U] ==1)
		{
		startMotor(Middle1, 127);
		startMotor(Middle2, 127);
	}
	else
	{
		stopMotor(Middle1);
		stopMotor(Middle2);
	}
	if(vexRT[Btn8R])
	{
		motor[ScissorLiftLeft] = 127;
		motor[ScissorLiftRight] = 127;
	}
	else{
		motor[ScissorLiftLeft] = 0;
		motor[ScissorLiftRight] = 0;


	if(vexRT[Btn8L])
	{
		motor[ScissorLiftLeft] = -127;
		motor[ScissorLiftRight] = -127;
	}
	else{
		motor[ScissorLiftLeft] = 0;
		motor[ScissorLiftRight] = 0;
}
}
}
}

Pictures of our robot have been attached.
IMG_2839.JPG
IMG_2837.JPG
IMG_2838.JPG

Where is your ending bracket of the else? Use the fix formatting button and you will see it indented properly.

Also you set the motors up top from the VexRT and then override it with the else conditions down below. That can cause chatter.

	if(vexRT[Btn8R])
	{
		motor[ScissorLiftLeft] = 127;
		motor[ScissorLiftRight] = 127;
	}
	else{
		motor[ScissorLiftLeft] = 0;
		motor[ScissorLiftRight] = 0;
// need a } here or else it nests with the next set of statements.....

Also, there technically isn’t a 5th and 6th joystick channel. If you wanted to have your lift controlled by a joystick you would need a partner joystick(technically you could use channel 4 but that would mess up really bad because you’re using channel 3 for the drive, I think). Apart from that if you just use the buttons for the lift then you can delete these two lines of code:

motor [ScissorLiftRight]=vexRT[Ch5];
motor [ScissorLiftLeft]=vexRT[Ch6];

Hope you figure it all out and I hope this was at least semi helpful :slight_smile:

Combine your two if/else statements for the lift to a single if/else if/else statement like so:

if(vexRT[Btn8R])
	{
		motor[ScissorLiftLeft] = 127;
		motor[ScissorLiftRight] = 127;
	}
	else if(vexRT[Btn8L])
	{
		motor[ScissorLiftLeft] = -127;
		motor[ScissorLiftRight] = -127;
	}
	else{
		motor[ScissorLiftLeft] = 0;
		motor[ScissorLiftRight] = 0;
	}

your code would turn the motors off each time you turned it on.

Thank you Joseph W(182 C), CyberHawks7983, and Team80_Giraffes for the helpful advice!! I combined all three of your code suggestions and our scissor lift chatters no more. Thanks again, this was a huge help!