VexCode PID help

This code near the end of the PID task is the “exit” condition:

       // stop PID from controlling motors when at target
       if ((fabs(error) < deadBand) || pidAbort) {
         enableDrivePID = false;
       }

If the abort is working then the error is not smaller than deadBand. What is your value of kP? It may be too small to move the motors when the error is small that is why there is a dead band.

That seems to work, thanks. Now I’m just working on tuning.

I’ve been thinking about how the current code uses lateralMotorPower +/- turnMotorPower. I think it needs to use the arcade drive scaling methods.
I have some equations that can be found here, (the 127 is for joystick value, so that would change to 12 for voltage).
https://timeconfusing.github.io/arcade.html

Also, when using turnPID the importance of output clamp can be seen when either value exceeds the max input value for motor.spin(). Take the case where output is not clamped and the forward value reaches 18 and the turn value is 6.

leftside = 18 + 6 = 24 
rightside = 18 - 6 = 12

motor.spin() internally clamps to 12 and 12 so turning does not happen
now if the output s are clamped

leftside = 12 + 6 = 18 = motor.spin() (internal clamp) = 12
rightside = 12 - 6 = 6 = motor.spin() = 6

so turning does happen

Ok, thanks, I’ll take a look at that.

I have created a python version of a vex PID I am not sure if it will help you but a link is

https://hdprojects.dev/pid/