Announcement

Collapse
No announcement yet.

Encoders

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

  • Encoders

    How do I use encoders now to tell the motors what to do, I hope it isn't the code "NxtEncoderOp"

  • #2
    Use the .setTargetPosition() method on a Motor object once you've set it to RUN_USING_ENCODERS mode.
    See here for an example of how to do that.
    By the way, can you please post questions like this about the SDK in the main "FTC Technology" forum?

    ~liam

    Comment


    • #3
      Originally posted by archimedespi View Post
      Use the .setTargetPosition() method on a Motor object once you've set it to RUN_USING_ENCODERS mode.
      See here for an example of how to do that.

      Thanks, and I'm sure I don't have anymore questions...

      Comment


      • #4
        And how do you know when the motor has reached the target position?

        Comment


        • #5
          Originally posted by dburnette View Post
          And how do you know when the motor has reached the target position?
          Call the isBusy() method for any given motor.

          Comment


          • #6
            Originally posted by skatefriday View Post
            Call the isBusy() method for any given motor.
            Except that I can't get the isBusy() function to return a valid value, so don't "assume" that it's working.

            No official word on this yet.

            Phil.

            Comment


            • #7
              Originally posted by archimedespi View Post
              Use the .setTargetPosition() method on a Motor object once you've set it to RUN_USING_ENCODERS mode.
              See here for an example of how to do that.
              By the way, can you please post questions like this about the SDK in the main "FTC Technology" forum?

              ~liam
              I think this isn't quite right.

              RUN_USING_ENCODERS tells the motor controller to use the onboard PID control loop to run at a constant speed. You would use .setPower after this command, and it will run until you give a different .setPower command.

              RUN_TO_POSITION is the runMode that you would use with .setTargetPosition.

              An alternative to isbusy which the example programs use is to read the encoders to see when you have reached your target position. This would be redundant as you could have just used one of the other two runModes, except that the delay time of reading the encoders means that you can't stop the motors in time.

              Comment


              • #8
                I want to do something like this:

                switch (currentState) {
                ...
                case START_ARM_MOVEMENT:
                motor.setTargetPosition(1440*4); // 4 complete rotations of the motor shaft cause the "arm" to be lifted to the correct height
                currentState = WAIT_FOR_ARM_TO_MOVE;
                break;
                case WAIT_FOR_ARM_TO_MOVE:
                if (! motor.isBusy()) currentState = NEXT_STEP_IN_AUTONOMOUS;
                break;
                ...

                }

                So I need to know if "isBusy()" is going to be TRUE immediately after setTargetPosition and remain TRUE until the PID controller has settled on the target position.
                If isBusy() is not reliable, then I'll dump the whole idea of using the PID controller built in and just watch the encoder count (and scale the motor power so that it slows down as it approaches the desired count).

                Comment


                • #9
                  isBusy() does work like that, yet. It flips back and forth, right now, it should be corrected in the next release.

                  Comment


                  • #10
                    When is the next release due out?

                    Comment


                    • #11
                      I would plan on it being out on the 26th, but do a happy dance if it comes out around the 19th

                      Comment

                      Working...
                      X