VEX V5 Coding/ Building

I am in a rookie team and we are having a couple of problems regarding v5 text code.

When programming the arms of our robot, we had some trouble making the motors stop moving suddenly in one place. When we program our arms to go up, the weight of the arms make the arms fall right back down.

Is there any way to fix this through the design of the robot or through coding?

One way is to set your motor brake type to hold in your code. Motor.brake(brakeType::hold);

2 Likes

Hold causes overheating use brake and it will stay where it was last moved to

2 Likes

Not if you rubber band correctly. There are very few cases where you should use brake over hold.

2 Likes

If they over heat just spray dry ice on them

A lot of great posts here but to add more detail you can use the motor hold which will stop the motors and have them hold their position even if gravity or some other force tries to move them.

Sample code:

controller Controller1;
motor LLift = motor(PORT1, false);
motor RLift = motor(PORT2, true);


void usercontrol(void) {
  // User control code here, inside the loop
  while (1) {
    if(Controller1.ButtonR1.pressing()){
      RLift.spin(directionType::fwd, 70,velocityUnits::pct);
      LLift.spin(directionType::fwd, 70,velocityUnits::pct);;
    } else if(Controller1.ButtonR2.pressing()){
      RLift.spin(directionType::rev, 70,velocityUnits::pct);
      LLift.spin(directionType::rev, 70,velocityUnits::pct);
    } else {
      //The brake mode can be set to coast, brake, or hold. 
      RLift.stop(brakeType::hold);
      LLift.stop(brakeType::hold);
    }
    
    //Add your other driver code here

    wait(20, msec); 

  }
}

This does cause a problem if the motors are working hard to keep the lift in the same position - they tend to overheat and will eventually stall.

Best practice is to use rubber bands or some other counter-weight to put the least amount of load on the motors. You want the arms to naturally stay in their position while the motors are not running. To solve that problem do a search on rubber bands.


This second article is a favorite but the photos are missing.

7 Likes

Would I be allowed to have code like this in the driver control period?

Are teams allowed to have any type of code regarding speed/motion in the driver control period?

Yes and of course. It’s all part of the design.

2 Likes

image

1 Like