|
Re: PID Velocity Control
Try to avoid global variables whenever possible, especially in LabVIEW.
In this case, they severely chop up your data flow, which makes it hard to see exactly what your order of operations is. As written, you do not guarantee the order or timing of when Cur. Rotations and Prev Rotations are read going in to the RPM calculation - You may end up with them being grabbed such that Cur is read too soon or too late, so your output can bobble between zero, expected, and multiples of expected. It could even go negative if you were attempting to update faster and you had a lot of other stuff going on.
Also, it looks like your while loop grabs the value from Cur Rotations once at the start of the owning VI, and then writes that same value to Prev Rotations every 50 milliseconds. Is this the intended behavior?
As Ether said, a feedback node or a shift register is likely what you are looking for here.
|