PID turning using gyro in LabVIEW

Hi LabVIEW Helpers,

My team is having a problem when trying to tune a PID algorithm for turning the drivebase to a specified relative angle.

The following autonomous code (using only P control) will work as intended, turning the robot approximately 180 degrees and staying there until the robot is disabled:

https://onedrive.live.com/redir?resid=3826738156CBAB7D!1110&authkey=!AEIXEuv8-algkU8&v=3&ithint=photo%2CPNG

What we find strange is that any non-zero kI will cause the robot to turn toward the setpoint (as expected) and then oscillate vigorously around the setpoint for eternity. This works with kI as low as 1e-12, i.e., nothing.

We would like to use PI control for our autonomous turning VI, but are perplexed by this behavior. As we decrease kI down to zero, we expect that the program’s behavior should approach that of pure P control. Perhaps this is a floating point issue?

I remember in high school when programming in LabVIEW we ran into the same problem, but worked around it. Since we only needed to vary the robot’s heading by a few degrees in 2010, we opted to set a very high kP and only use P control. This year is different, and we would like to have a turn VI that can reliably turn the robot any amount.

Besides providing us with a solution to this specific problem, what would really help us is some very good example code for turning to a specified relative angle autonomously. Any pointers, advice, or examples are appreciated!

You actually want kI to be a larger value rather than a smaller value, e.g., try 10 or 100 instead of .1
Think of it as 1/Ti

In the toolkit the PID is in the Academic Form. So decreasing the Ti constant will increase the Ki gain.

You can verify that if you look at the labels of the three constants you’ll see they are Kp, Ti, Td.

You can transform it to the Parallel Form using the PID Structure Conversion VI.

Is it worth it to start with a non-zero kI and kP of zero, then add kP later? We have not tried that yet. However, the confusion still stands about the fact that there is such a difference between a kI of zero and a kI of 0.000000000001 (1e-12).

Ohhh I get it. Ti is proportional to 1/kI.

Edit: Thanks everyone for the quick responses!

*Here’s a slightly off-topic question related to the PNG in the OP.

Is it best to hard-code the control period (0.020 as shown in the PNG) or would it be better to leave that blank and let LabVIEW compute the actual period each iteration (especially with Teleop)? Or doesn’t it matter that much in actual practice?

You only need to specify the control period if you have sub-ms loop times.
Only in rigorous time-controlled loops of course.

The vi itself will compute the actual period using an internal 1 ms clock.