Motor goes forward and reverse but ONLY at default velocity

So my middle school students designed the Crunch Bot. Its basically a Clawbot with a intake roller instead of a claw. The roller/intake paddles on the end of the arm is turned by a chain drive on a single motor. It will spin forward and reverse just fine. However, when we increase the velocity in our program to like 75% it will freak out when we try to make the motor go in reverse. The chain bounces back and forth and will not reverse at all. Any advice? It works fine going forward.

It would help if you could you post a sample of your code. What are you doing to make the motor reverse? Are you setting the velocity to a negative value or saying “yourMotor.spin(reverse)”?

Outta curiosity, you do have a small wait time in your drive code, right?

20 msecs is usually a good wait.

Edit: oops. Yes the wait time is there for a reason, and no, 20 msecs is not long enough to mess with the program. Sometimes ommitting it can cause a problem or two.

My students have the code on their laptop right now, so I cannot post atm. With that said, there is really no manual programming. We used the Robot Configuration setup to generate code for our Controller, drivetrain, arm motor and intake motor.

The only code we put in user control manually was the MOTOR.setVelocity (75, percent);

yes, the wait time is there by defualt. Could it be that the delay time is interfering with the Motor.setvelocity (75, percent) and its putting a 20ms wait in there? Again, this only happens when going in reverse.

I’m guessing it’s probably not the wait time, as it works in forward movement.

BTW, when we reverse the motor in setup, it then spins in reverse just fine but then judders when going forward.

When I remove our SetVelocity code, then it works fine both directions. So my code appears to be the problem.

I think it’s because of the motor.setVelocity command. It should automatically set the velocities by default based on joystick inputs. Try deleting that line. I’m pretty positive what is happening is that since it is a positive velocity, it will only go forward rather than backward. If you want to control the motor velocity during drive, I would recommend programming a custom drive.
To do this, just simply individually set up all of the motors in your drive and then map the velocities of the motors relative to joystick position. VEXcode V5 Pro text has an example program like this.


So if I use the velocities programmed by the joystick (controller setup) I cannot add my own manual code to make changes, like increasing velocity?

We have gone the controller setup route because the children and I are new to programming (7th graders, first time VEX)

It sound like there are conflicting commands here. It is good to manually set up all your motors individually and work with them from there. Leraning-wise, it’s a good starting point.

The statement you just added probably conflicts with the built in commands in the default code. As always, look thru that code and check for any redundancy, or two different commands directed at the same motor.

Yeah. It gets more complicated if you want to change the default drive program. Like I said in an earlier post, VEXcode V5 has example programs that you can base your program on. I would assume it would look something like this:

if (Controller1.Axis2.position(percent) >= 5){
 if(Controller1.Axis3.position(percent) >= 5){
 leftMotor.spin(fwd, 75, percent);
 rightMotor.spin(fwd, 75, percent);
 else if (Controller1.Axis3.position(percent) <= -5){
 leftMotor.spin(rev, 75, percent);
 rightMotor.spin(fwd, 75, percent);
 rightMotor.spin(fwd, 75, percent);
else if (Controller1.Axis3.position(percent) >= 5){
 leftMotor.spin(fwd, 75, percent);
else if(Controller1.Axis3.position(percent) <= -5){
 leftMotor.spin(rev, 75, percent);
1 Like

So moving forward, if students “add a controller as a device” and click on the buttons and joysticks to determine movement, they cannot write any code later in the user control? They would give up all ability to change driver control?

Would we add a controller in devices but not set up the buttons. Then configure those buttons manually in our program? Ill try to find that example program. If you know the name please let me know. We may need to learn a lot real quick.

You can set up the buttons manually, just not the joysticks.
If you don’t set up the buttons or the joysticks, then yes, you can change the joysticks.


That shouldn’t cause a problem. Can you post your controller set up?

Here is the robot config code from the controller setup. Maybe the manual code and this preconfigured code are interfering with each other?

Screenshot 2021-01-13 090648

That is probably what is happening. To fix that, just program the intake motor manually.

1 Like

Thanks for the help. It most likely is the problem, however, I dont see a set velocity in the controller setup. I just see the .spin commands.