Drive motors go by themselves

So, when we start our competition program, our drive motors go very slowly all by themselves. I believe that it is caused by the joysticks not being perfectly centered. does anyone know how to fix this? Is there any way to tune a joystick’s sensitivity?

Thanks!
373A

you could have your code ignore joystick inputs below a certain value like:

if(abs(Controller1.Axis3.postition()) > [insert value here]) {
     leftMotor.spin(...);
}
1 Like

I tried the example that kevjar gave and it still moved forward without any user input on the joysticks. No matter what values that I inserted. What should I do?

can we see your code? there may be some other part that is making your motors spin

PS: make sure to use [code] and [/cod] around segments of code (i had so spell it wrong otherwise it disappears)

Comment out the section off your code that controls the drive in order to see if it really is your joystick. then run it. If it is the joysticks, then your motors will not move, If the motors continue to move, it is an issue elsewhere.

image

We also did what Cadaver_42 said. We committed the drive section and tried to drive it and nothing happened. It is a joystick issue.

Its generally bad practice to nest those if statements.
this is what I use for tank drive but it can be adapted for arcade.

 if(abs(Controller1.Axis3.value())  > 5 && abs(Controller1.Axis2.value()) > 5) {

  leftDrive.spin(directionType::fwd,Controller1.Axis3.value(),velocityUnits::pct);
        rightDrive.spin(directionType::fwd,Controller1.Axis2.value(),velocityUnits::pct);

        }

Also, why is your arm motor controlled by 2 axes?

1 Like

Ok, we tried that also, there was no change. we are amateur coders and I just changed the arm motor to only be on one axis.
image
Also, thanks for all your help!

Have you tried switching controllers. It could be a controller malfunction and not just a joystick issue, although I have never heard of that before.

We just tried a brand new controller right out of the box. and guess what? It still didn’t work!! Koby is really mad because it isn’t working. So, we don’t know what to do except to leave it possessed.

you need to stop the motors if the values from the controller are small. The code you have will stop sending new values to the motors but they will just continue to run at whatever that last value you sent to them.

5 Likes

Wouldn’t stopping motors at no input be better than stopping based on controller value? Or is there something I’m missing…

Well see when I posted my deadzone code I left out the else statement after it where I tell the motors to stop with my preferred brake type. Probably should have mentioned that my bad.

3 Likes

I wrote this, and it doesn’t like the else statement. Any suggestions?

image

1 Like

conditional expressions take this form

if( condition == true ) {
  // code
}
else {
  // more code
}

you are missing the brace before the else statement

5 Likes

Thanks sooo much! It is finally working. you all are the best!!!