Announcement

Collapse
No announcement yet.

Can only run 1 Neverest motor at a time + squealing

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

  • Can only run 1 Neverest motor at a time + squealing

    I have a super simple teleop program that was working fine one second and then the next it totally went kaput. The program:

    package com.qualcomm.ftcrobotcontroller.opmodes;

    import com.qualcomm.robotcore.eventloop.opmode.OpMode;
    import com.qualcomm.robotcore.hardware.DcMotor;

    /**
    * Created by aldas_000 on 9/13/2015.
    */
    public class TeleOp extends OpMode {

    DcMotor leftArm;
    DcMotor rightArm;

    DcMotor leftDrive;
    DcMotor rightDrive;



    @Override
    public void init() {

    //Gets references for motors from hardware map
    leftArm = hardwareMap.dcMotor.get("left_arm");
    rightArm = hardwareMap.dcMotor.get("right_arm");

    leftDrive = hardwareMap.dcMotor.get("left_drive");
    rightDrive = hardwareMap.dcMotor.get("right_drive");


    //Reverse the right motor arm, left drive
    rightArm.setDirection(DcMotor.Direction.REVERSE);
    leftDrive.setDirection(DcMotor.Direction.REVERSE);
    }

    double speed;

    @Override
    public void loop() {


    telemetry.addData("Chosen Speed: ", speed);


    //Get the values from the gamepads.
    //Note: pushing the stick all the way up returns -1,
    //so we need to reverse the values.
    float stickL1 = gamepad1.left_stick_y;
    float stickR1 = gamepad1.right_stick_y;

    float stickL2 = -gamepad2.left_stick_y;
    float stickR2 = -gamepad2.right_stick_y;

    //set the power of the motor with the gamepad values
    leftArm.setPower(stickL2);
    rightArm.setPower(stickR2);



    //Code for speed control
    // Choosing a speed with a button (x,a,b,y)
    if (gamepad1.x) {
    speed = 0.10;
    } else if (gamepad1.a) {
    speed = 0.30;
    } else if (gamepad1.b) {
    speed = 0.50;
    } else if (gamepad1.y) {
    speed = 1;
    }
    //Code for moving left drive wheel with given speed chosen below below
    if (stickL1 < 0) {
    leftDrive.setPower(-speed);
    } else if (stickL1 > 0) {
    leftDrive.setPower(speed);
    } else {
    leftDrive.setPower(0);
    }
    //Code for moving right drive wheel with given speed chosen below
    if (stickR1 < 0) {
    rightDrive.setPower(-speed);
    } else if (stickR1 > 0) {
    rightDrive.setPower(speed);
    } else {
    rightDrive.setPower(0);
    }
    }
    }

    When I first started it, it ran bad; the motors winned like they were trying to carry a ton. Then I moved it and ran it like normal where the robot actually moved. Then I went and cleaned the code a bit to ready it for something I want to add. Prior, I was pasting a bunch of stuff in there to get something else to work, so I thought it was an issue with that. Cleaned it out, no fix. So I flipped it on it's back like a turtle and ran the program and saw that I can only run one motor at a time. It's tank drive, so that won't do. You run one motor, then engage the second, and it takes a while for it to kick in but all in all the limit is one motor (this happens on all speeds, it happens on max speed and almost no speed).
    At first I thought that maybe it was too heavy, for whatever reason, so I ran the arm that is carrying almost no wight and what it used to be able to launch with the force of a thousand suns, now can't even get it to twitch, just a high pitched squeal. If the motors are in the air, totally without resistance, they run, though it seems like a steady build up to power and not the instant jolt it had before.

    Is it something with my code? Battery? I don't get any errors and it worked before. I ran an autonomous and I get the same result, I ran a program made by someone else and I get the same result, so I'm most certain it's something on my end. But I don't see why 4 motors that haven't been used in 4 days would suddenly break. Hopefully it's a programming thing.

  • #2
    Did you test the motor by giving direct 12 V power?

    -Nano Ninjas

    Comment


    • #3
      From looking at your code I don't really see a cause, however I do have some suggestions... more on that later. Have you tried using Tetrix motors? I've had a similar problem in the past with a different motor controller completely unrelated to FIRST competitions, and the way that I fixed it was by setting the speed to .9 instead of 1; however, I doubt that will be the solution. Have you tried a different motor controller? Or a different type of motor controller?

      Anyway, some things that I noticed about your code that I would recommend changing:

      Instead of setting the speed to a static value you should multiply the joystick input by it so that way the set speed is the max speed, but not the only speed. For example,

      Code:
      leftDrive.setPower(stickL1*speed);
      rightDrive.setPower(stickR1*speed);
      Also, you might want to make an input threshold by making sure the absolute value of the joystick input is higher than a certain number, For example,

      Code:
      double threshold = 0.1;
      if (Math.abs(stickL1) > threshold) {
          leftDrive.setPower(stickL1*speed);
      } else {
          leftDrive.setPower(0);
      }
      
      if (Math.abs(stickR1) > threshold) {
          rightDrive.setPower(stickR1*speed);
      } else {
          rightDrive.setPower(0);
      }
      The threshold thing might explain the whining but if your experiencing the same issues with other people's code then it is most likely a hardware issue.

      Comment


      • #4
        Originally posted by nanoninjas View Post
        Did you test the motor by giving direct 12 V power?

        -Nano Ninjas
        No, I've never heard of that. What do you mean?

        Comment


        • #5
          Originally posted by FTC_Team5648 View Post
          From looking at your code I don't really see a cause, however I do have some suggestions... more on that later. Have you tried using Tetrix motors? I've had a similar problem in the past with a different motor controller completely unrelated to FIRST competitions, and the way that I fixed it was by setting the speed to .9 instead of 1; however, I doubt that will be the solution. Have you tried a different motor controller? Or a different type of motor controller?

          Anyway, some things that I noticed about your code that I would recommend changing:

          Instead of setting the speed to a static value you should multiply the joystick input by it so that way the set speed is the max speed, but not the only speed. For example,

          Code:
          leftDrive.setPower(stickL1*speed);
          rightDrive.setPower(stickR1*speed);
          Also, you might want to make an input threshold by making sure the absolute value of the joystick input is higher than a certain number, For example,

          Code:
          double threshold = 0.1;
          if (Math.abs(stickL1) > threshold) {
              leftDrive.setPower(stickL1*speed);
          } else {
              leftDrive.setPower(0);
          }
          
          if (Math.abs(stickR1) > threshold) {
              rightDrive.setPower(stickR1*speed);
          } else {
              rightDrive.setPower(0);
          }
          The threshold thing might explain the whining but if your experiencing the same issues with other people's code then it is most likely a hardware issue.
          Have not used Tetrix motors, all I have are the Neverest motors. I also only have the HiTechnic motor controllers. I can try the .9 thing when I get home and get back to you. Why the threshold? I never occured to me that a static value would be so bad. We used it last year in RobotC and, as the driver, I've learned to rely heavily on variable speed for different tasks. Is there a way to incorperate variable speeds with this threshold idea?

          Comment


          • #6
            Originally posted by nanoninjas View Post
            Did you test the motor by giving direct 12 V power?

            -Nano Ninjas
            Do you mean plugging the motor directly into the 12v battery? No I haven't tried that, but it's a good idea. Will test it out when I get home.

            Comment


            • #7
              In the first code example you have it set up such that your motor powers can lurch between zero, or +speed or -speed. And with the joystick near center and probably simple noise moving it ever so slightly between a stick value of -0.0something and +0.0something, you code is dutifully slamming the motor power between +/- speed with a few zero powers in between. Probably this is loud... ???

              Comment


              • #8
                Originally posted by zain View Post
                In the first code example you have it set up such that your motor powers can lurch between zero, or +speed or -speed. And with the joystick near center and probably simple noise moving it ever so slightly between a stick value of -0.0something and +0.0something, you code is dutifully slamming the motor power between +/- speed with a few zero powers in between. Probably this is loud... ???
                Oh okay, I see what you mean. I believe the motors didn't whine while the joysticks were at rest, but this is something I should fix as general good practice.
                With the updated SDK, everything seems to work fine. I haven't ran the program that I made, the one pasted in the original post, but I modified a pre made program (the PushBotSquare) to run with my setup and it ran without any whining; it was as lively as I could ask for.

                Comment


                • #9
                  Great to see that it got resolved. Good luck for the season.
                  - 9774 Nano Ninjas

                  Comment


                  • #10
                    Originally posted by ftcbisonb View Post
                    Have not used Tetrix motors, all I have are the Neverest motors. I also only have the HiTechnic motor controllers. I can try the .9 thing when I get home and get back to you. Why the threshold? I never occured to me that a static value would be so bad. We used it last year in RobotC and, as the driver, I've learned to rely heavily on variable speed for different tasks. Is there a way to incorperate variable speeds with this threshold idea?
                    The threshold is to make sure that the motors are stopped when you let off the joysticks, because they may not always be 0 when you let go. Also, variable speed is great, I use it all the time with our non-ftc robot. My point was the way you implemented it gets rid of the speed control you have with joysticks. My example works with your speed control but retains the ability to control the speed by gauging how much you push on the joysticks. For instance, if you set your speed to .5 and push the joystick halfway up then it would set the power to .25.

                    Comment


                    • #11
                      There's already built-in support for a threshold:

                      Code:
                      gamepad1.setJoystickDeadzone(0.5f);

                      Comment


                      • #12
                        The Gamepad constructor runs the following code:
                        this.joystickDeadzone = 0.2F;
                        so the deadzone should be plenty large by default. We used something more like .08 last year.

                        Comment

                        Working...
                        X