PID not going backwards correctly and it stalls when hitting objects

Hello people on the Vex Forum,

Recently I’ve had problems using PID. (The PID is in block code)

First, the motors are going forward instead of backwards when trying to use a negative velocity for the two motor groups. (One group is on the left side, the other to the right side)

Secondly, the PID just “stalls” itself when in contact with another object (like a robot) which is a problem since an autonomous can’t just randomly stop when another robot is trying to grab the same goal as you.

Thank you! :slight_smile:

By the way here’s the code (Sorry if you see repeating code its just the way I screenshot all the parts came out a bit weird)

PID :





Screenshot 2022-04-14 9.42.19 AM

Autonomous Beta :

Screenshot 2022-04-14 10.23.14 AM

1 Like

So to start off you can’t do negative velocity, just change the way the motors spin all together. Secondly, is your wheels spinning out or does it just stall? A little bit more explanation would be helpful.

The wheels of the robot stop, then when the object is out of the way it continues moving normally.

Also my team will test not using negative velocity. Thank you for the feedback!

What does your drivetrain look like? My idea of why its not working is maybe there isn’t enough torque to move the object. That and maybe you set a motor time out by accident and that could be a reason its not working.

I’m fairly certain you can; otherwise how would joystick programming work? Do you know anyone that does

while (true):
  if (joystick value < 0):
    spin motor (joystick value*-1, reverse)
  else:
    spin motor (joystick value, forward)

I think you should avoid ever in PID explicitly spinning your motors reverse and just do negative velocity. I’m not sure what spinning them reverse does, but I’m guessing it just does velocity * -1. So if you spin motor(-100, reverse), my hypothesis is that it will go forward 100, but I’m not sure. Could be your problem? Stalls would just seem to be lack of power.

4 Likes