Intake coding issue

We have an issue with our intake code. For some reason, when the intake code to run the intakes slowly back (buttons R2 and B) if we have just ran the intakes quickly (button L1 and L2) the intakes will jolt for a split second at that speed.

For example, if we just pressed L1 and ran the intakes full speed inward, and then press R2 to run them out slowly, they will jolt at 100 percent inward for a split second, then rotate out slowly like they are supposed to.

As a result, we have dropped a lot of stacks in practice. Any ideas?

Code

if(Controller1.ButtonL1.pressing())
{
intake.setVelocity(100, percent);
intake.spin(forward);
}
else if(Controller1.ButtonL2.pressing())
{
intake.setVelocity(100, percent);
intake.spin(reverse);
}
else if(Controller1.ButtonR2.pressing())
{
intake.setVelocity(10, percent);
intake.spin(reverse);
}
else if(Controller2.ButtonB.pressing())
{
intake.setVelocity(10, percent);
intake.spin(reverse);
drive.setDriveVelocity(10, percent);
drive.drive(reverse);
}

I had the same problem with it earlier in the season, but sadly none of my programs to work. I will see if I can figure something out

Maybe you could try putting in wait codes in between? (vexcode isnt pulling up for me right now)

/*----------------------------------------------------------------------------*/ /* */ /* Module: main.cpp */ /* Author: C:\Users\Synergy */ /* Created: Tue Nov 05 2019 */ /* Description: V5 project */ /* */ /*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// intake motor 1
// Controller1 controller
// Controller2 controller
// Drivetrain drivetrain 2, 3
// ---- END VEXCODE CONFIGURED DEVICES ----

#include “vex.h”

using namespace vex;

int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
void usercontrol(void);
// User control code here, inside the loop
while (1) {
// This is the main execution loop for the user control program.
// Each time through the loop your program should update motor + servo
// values based on feedback from the joysticks.

// ........................................................................
// int main() {

// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
int armSpeedPCT = 100;
int ClawSpeedPCT = 100;
int slowClawSpeedPCT = 10;
int chuteSpeedPCT = 100;
//Create an infinite loop so that the program can pull remote control values every iteration.
//This loop causes the program to run forever.
while(1) {
//Drive Control
//Normal intake Control
if(Controller1.ButtonL1.pressing()) { //If the L1 button is pressed…
//…Spin the intake forward.
intake.spin(vex::directionType::fwd, ClawSpeedPCT, vex::velocityUnits::pct);
}
else if(Controller1.ButtonL2.pressing()) { //If the L2 button is pressed…
//…Spin the intake backward.
intake.spin(vex::directionType::rev, ClawSpeedPCT, vex::velocityUnits::pct);
}
else { //If the L1 or L2 button are not pressed…
//…Stop the intake.
intake.stop(vex::brakeType::brake);
}
//Slow intake Control
if(Controller1.ButtonR1.pressing()) { //If the R1 button is pressed…
//…Spin the intake forward.
intake.spin(vex::directionType::fwd, slowClawSpeedPCT, vex::velocityUnits::pct);
}
else if(Controller1.ButtonR2.pressing()) { //If the R2 button is pressed…
//…Spin the intake backward.
intake.spin(vex::directionType::rev, slowClawSpeedPCT, vex::velocityUnits::pct);
}
else { //If the R1 or R2 button are not pressed…
//…Stop the intake.
intake.stop(vex::brakeType::brake);
}
//Controller 2 intake Control
if (Controller2.ButtonB.pressing()) { //If the R2 button is pressed…
//…Spin the intake backward.
intake.spin(vex::directionType::rev, slowClawSpeedPCT, vex::velocityUnits::pct, Drivetrain.setDriveVelocity(10, percent),
Drivetrain.drive(rev);
}
else if ( //If the B button is not pressed…
//…Stop the intake.
intake.stop(vex::brakeType::brake);

I suppose the issue is that i’m setting the velocity then spinning instead of using just .spin. I’ll try it out tonight.

@7686B, please, wrap your code into [code] ... [/code] tags. It will be much easier to read.

@Robo_Chickens in your original post you didn’t include the else statement that stops your intake motor.

How do you stop it?
Do you use .stop() function or set velocity to 0?
Can you try both ways and let us know if it helps?

1 Like

Right now we are using .stop()
I will try it your way when I get the chance (probably tomorrow)

See the thing is now that you pointed it out, I too have noticed this subtle yet consistent problem with out bot too. If anyone knows how to fix it, could they help? My code specifically just holds if not moved.

I believe it’s just a quirk with the hold function. All of our motors do the same thing when they go from holding to moving.

will do, i forgot and was using <(code> and </code)> by accident (ignore paranthesis)

So we ended up changing the stop mode to (brake) instead of (hold) like we had been doing, and that solved the issue. Thank you to all who helped us out.

1 Like

the issue is you have two intake stop functions at two different flows. when ButtonL1/2 is pressed the intake motor spins, then because the ButtonR1/2 is not pressed, the intake motor stops. The cycle goes on and on and the intake jolts.

1 Like