PID Only One Side Turning

When turning with PID code during auton only one side will spin. I can get both sides to spin, but then it won’t stop until I exit the code. Please help a brother out.

Would it be possible to provide your code?
Note: You can just copy and paste your code, surrounding the entirety of it with [code] and [/code]

Code 4

That’s what I have so far. I followed your tutorial to gain a base understanding and all the pseudo code are my attempts to fix the problem.

So, take a look at the last three lines of your CallDrivePID function:

return 1;

A ‘return’ is the very last thing a function will ever see once it executes. Any code after that effectively does not exist. Now, that being said, I don’t know what those two lines after the return are supposed to do; they don’t look like legal commands (stop() doesn’t look to take any arguments?). Once your code meets the condition to exit the loop, you may need to just have a set of explicit motor stop commands before exiting via a return.

Now, as a separate issue, I question the operation of the loop working fully properly by using global variables that the program is supposed to pick up by looping through. I would highly recommend moving your three values that you’re setting (resetDrivesensors, TurnkP, desiredvalue) into parameters to pass in directly. You may get some rather unexpected behavior otherwise. In this case, it looks like you’re trying to command driving a certain distance, waiting a certain amount of time (one second? hard to tell with the sleep command if this is msec or usec as a parameter), and then issuing it new command targets. A PID shouldn’t be time constrained, unless you want to give it an overall max time to reach something before it times out, but then that really starts to indicate your PID values need tuned (or mechanicals) if you’re not reaching your targets in the time you want.


Stop has three different modes, coast, brake, and hold (with the default being brake I believe). Coast makes the motor spin freely, brake makes the motor lock up, and hold actively tries to hold the position it was in

If you are ever not sure if it is a legal command, you can always check the vex api


The stop(hold)’s were just something I saw suggested on a form with a similar problem to mine. Also what exactly do you mean by putting them in separate parameters I am new to PID.