11-17-2016 01:45 PM
I have a program running in scan mode on a cRIO 9074 with the clock at 10ms.
My producer (timed) look executes every 20 clock cycles (so 200ms).
I believe that typically, PID controls are placed within the producer loop but the Setpoint is typically a shared variable with RT FIFO enabled or similar in the consumer loop.
I have a couple somewhat complex sub vi's that include PID controls but also have "local" controls that I can change while the main program is running if I care to--such as the values for P, I and D or the hi/lo limits.
Will having these controls in the sub vi, and by extension in the Producer Loop affect performance? If so, what's the recommended way to prevent this?
11-17-2016 02:02 PM
Hi NXTenergy,
A good rule of thumb is not to use any controls or indicators inside the timed loop (I’m assuming you are using timed loop). Controls and indicators setup additional background processes to show you values on the front panel which introduces jitter.
Some of the recommended ways to get values in/out of a timed loop (deterministic) are
RT Fifos
Local Variables (be careful how you use them so you don’t create race conditions)
Global variables (be careful how you use them so you don’t create race conditions)
Singe element Shared Variable (SV) with RT fifo enabled
And few others. Check out cRIO developers guide page 29
I hope this helps
11-17-2016 02:35 PM
Thanks Miro,
I'm specifically interested in the knowing
1) whether placing the PID loops in sub vi's within the Producer Loop will be a problem
2) if the controls within the sub vi's will cause jitter (I'm guessing they would from what you said)
3) what the best way to pass variables to those sub vi's is. If it's the same as passing control values to anything else in the Producer Loop that's fine.
Thanks!
11-17-2016 02:50 PM
@NXTenergy wrote:My producer (timed) look executes every 20 clock cycles (so 200ms).
At a 200ms control rate, I would not be worried about any jitter from having controls in your timed loop. In fact, I would also have the outputs in this loop. 200ms is a VERY long time. I currently see no reason to complicate your code by using a Producer/Consumer for the PID control.
11-17-2016 03:11 PM
Crossrulz,
If I could follow up with this quickly, at what scan rate should I start worrying about jitter?