Changing motor speed during Autonomous

Just changed over to VexCode in the last month and I noticed that during my autonomous mode (first 15 seconds of the match) I had to set the motor speed. Unlike VexCodingStudio, you were able to adjust how fast you wanted your motors to go during a certain action of the robot. For example, we have a tray bot so during autonomous mode the robot drives up to the cubes at a speed of 45 while its picking up cubes. Once it’s done we can reverse the drive motors at 100 pct so we can get into position to stack 7 cubes in the corner. When my team moved to VexCode, we had to set the motors in the beginning of the autonomous section so now we were only able to do 5 cubes.

So is there a way to go around this? Please help…!!!

So you want Set velocity?

Example-

RightIntake.setVelocity(100, velocityUnits::pct);

This means your intake will run at 100 speed.

So when you want to change speeds during auton, just make another one right above that command that will change and tune the speed.

So like this

IntakeMotor.setVelocity(100,velocityUnits::pct);

IntakeMotor.spinFor(2.4,turns);

IntakeMotor.setVelocity(50,velocityUnits::pct);

IntakeMotor.spinFor(4,turns);

2 Likes

That is what I use to do with the older VexCodingStudio, but with the newer VEXcode I had to start the autonomous section with something like this,

int LeftFrontMotorSpeedPct…

Sorry but I forgot exactly how it goes since my laptop is at school and it’s closed down for awhile…

you don’t have to start with that. the set velocity still works.

Here is yours

int LeftMotorSpeedPCT=100;

Like that?

:+1:

Yes that is correct. So I set all my drive motors before autonomous starts.

In the void yes. to set speed.

void usercontrol(void) {
  

  int LISpeedPCT=100;
  int RISpeedPCT=100;
  int ArmSpeedPCT=100;
  int TiltSpeedPCT=70;

This is my driver pct. it should work for auton. I never tested but they are the same.

Thanks! Hopefully I am able to pick up robot next week and try it.

No problem. Good luck on further comps and seasons

The other option is to set the speed when you call the motor to spin. Then you can vary your speed at each move.

  motor leftDrive = motor(PORT1);
  motor rightDrive = motor(PORT2);
  
  void autonomous(void) {

      //Move foward at 50% speed for one second then stop.
      leftDrive.spin(directionType::fwd, 50, velocityUnits::pct);
      rightDrive.spin(directionType::fwd, 50, velocityUnits::pct);
      wait(1000, msec);
      leftDrive.stop();
      rightDrive.stop();
  }
2 Likes

You just have to program that specific motor to go a specific speed.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.