Announcement

Collapse
No announcement yet.

Continuous Servo Help

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

  • Continuous Servo Help

    we are going to use a micro scale continuous rotation servo for our robot. I can get the servo to begin rotation and change direction with the bumper buttons, but I want it to stop when the buttons are no longer pressed. I don't know how to get it to stop when I want it to.

    Here is my code and I have a feeling that I need to put something in the else statement. I just don't know what.

    Code:
    package com.qualcomm.ftcrobotcontroller.opmodes;
    import com.qualcomm.robotcore.util.Range;
    import com.qualcomm.robotcore.eventloop.opmode.OpMode;
    import com.qualcomm.robotcore.hardware.Servo;
    /* Created by wyatt.ross on 9/22/2015.
    */
    public class cont_servo_test extends OpMode {
    Servo servoswitch;
    boolean pressleft;

    public cont_servo_test() {
    }
    @Override
    public void init() {
    pressleft = gamepad2.left_bumper;
    servoswitch = hardwareMap.servo.get("switch");

    }

    @Override
    public void loop() {
    if (gamepad2.left_bumper) {
    servoswitch.setPosition(0.00);

    }
    else if(gamepad2.right_bumper) {
    servoswitch.setPosition(1.00);
    }
    else {
    servoswitch.setPosition(0.50);

    }




    }
    }

  • #2
    That code looks good to me.

    I'm wondering if the servo is slightly out of calibration.

    Does it keep moving at full speed when you request 0.5, of does it seem slower?
    Does it always revert back to one direction, or does it keep moving in the same direction as the last requested motion?

    Either of these could indicate that you need to find the exact "center Stop" value of the servo.

    eg: it may be 0.45 instead of 0.5. You may need ome trial and error, or perhaps connect a joystick and vary the input

    Phil.

    Comment


    • #3
      FWIW our CR servos "roll" a little at the 0.5 notional "center" point too. I have not gotten my oscilloscope out of storage yet, but I mean to have the kids measure what value really gets a solid 1.5mS pulse width out of the servo control module and what the end point values correspond to (0.0 and 1.)

      to that end, does anybody know a way to set the "gain" between the 0.0 to 1.0 the kids use in servoname.setPosition() and the actual pulse widths that get sent out? It obviously matters for some position (not CR) servos that nominally go 180 degrees.

      - Z

      Comment

      Working...
      X