Toggling PID Control


I was attempting to create an encoder brake on my robot’s drive for when, and I was having trouble with how to turn off built-in PID within the program. Is there a way I can “toggle” the built-in PID control within the program? Below is the general idea for how my code looks now. Also, I am using 3 IME’s on our mecanum base, so how should I go about programming the non-IME motor? Should I slave the non-IME motor to an IME motor or do I need another IME? If anyone has a better way to program an encoder brake, please feel free to tell me. Thanks in advance for the help!

while(true) {
    moveMotorTarget(backRight, 0, 90, true)
    moveMotorTarget(frontLeft, 0, 90, true)
    moveMotorTarget(backLeft, 0, 90, true)

nMotorPIDSpeedCtrl[port1]=RegIdle; // turn off PID

nMotorPIDSpeedCtrl[port1]=RegSpeed; // turn on PID

You can look a little bit at this thread for some explanation

I would suggest putting a 4th IME on the system. With mecanum wheels you don’t strictly want 1 motor “following” another. Slaving would cause strange behavior like not being able to strafe or having to toggle PID and the motor slave to strafe.

This was exactly what I was looking for, thank you! Also, could I use 3 IME’s and use the mecanum drive as a tank drive for all autonomous movements, like in programming skills and autonomous?