Announcement

Collapse
No announcement yet.

Hold a motor in place.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hold a motor in place.


    We are trying to extend the arm and then put a hold/Brake on a motor. What is the best way to stop the motor so it hold and our arm can stay at a position.

    Please help.
    Thanks
    FTC Coach.. - Green Mustaches.


    The code which is not working for us as we tried is below.

    if Gamepad.x /* then move down */
    Flipmotor.setpower(1)

    else if Gamepad.B /* then move up */
    flipmotor.setpower(-1)
    else
    /* hold the arm at down position */

    flipmotor.setTargetPosition(flipmotor.getCurrentPo sition());
    flipmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION) ;
    flipmotor.setPower(0.1);

  • #2
    At the end of your first pass you put the motor in Run to Position Mode and then never change modes. After that you're only changing the max power that the motor will see if it is away from the TargetPosition. Since it is already at the TargetPosition it will only apply enough power in the right direction to hold the current position.

    You'll want to change the runMode to Run Using Encoder as the first statement following the X and B buttons. I'd guess you'll probably find you want less than 1, -1 for the button powers, and more than 0.1 for the Run to Position power.

    Switching modes used to take time, I don't believe that is true anymore, but it would be interesting to see if you have some lag.

    Comment


    • #3
      Your pseudo code looks somewhat reasonable (assuming that's what you are actually doing).
      I notice that your never switch the code away from RUN_TO_POSITION when you press a button.
      The real code would be more helpful.

      You say your code is not working. That could mean a million things.
      What is it doing that makes you say "it's not working". Is it not moving, is it not holding, is it spinning madly?

      We need more details, and actual code



      Comment

      Working...
      X