Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 10 PID Loops

10.2 Creating a new PID loop

Scroll Prev Top Next More

To create a PID loop, click on PID: in the workspace.  This will display the PID summary view which will list any PID loops and their current status.  Click Add.  Enter a name for the loop.  The PID view will appear.  This allows you to set all the parameters of the PID, do autotuning, and set an event to execute with each PID loop iteration.  

PID parameters:

Process Variable: an expression that when evaluated is used in the loop.  This should be a singular value, i.e. PV[0]  DAQFactory automatically does a 4 point weighted average to reduce the effects of noise.  You can add to this by doing a mean: Mean(PV[0,9])

Set Point: an expression that when evaluated is used as the target for the process variable.  This should also be a singular value.  If you want this adjustable from a screen, use a variable, v channel or test channel.

Output Channel: a channel or variable name to set the result of the PID.

P, I and D: These take numeric values for the three parameters that make up a PID loop. I and D are in minutes.  A value of 0 for I and/or D disables this part of the calculation, even though the I term is used in the denominator.

PID Type: There are two PID algorithms available.  The standard algorithm applies the Gain to all three parts of the calculation, thus Out = P * (e + i/I - D*dPV).  The alternate, "separate" algorithm, keeps the gain solely in its own section, thus Out = P*e + i/I + D*dPV.  This is a less standard algorithm, but tends to be much easier to tune because each term is independent.

SP Range: holds the possible range of set points and is used to help scale the output of the PID calculation.

Out Range: limits the output to a certain range of values

Loop Interval: how often the PID is calculated and the output channel is set.  This should not be below 0.01 without a multi-processor system.  Smaller values use up larger amounts of processor time.

Integral Limit: limits the accumulated integral to +/- this amount.  This is an easy way to avoid integral wind-up.  

Reverse Acting: if checked, then a negative output results in a positive moving process variable.

Reset on SP change: if checked, then the accumulated integral and internal process variable and derivative smoothing is reset whenever the set point changes.

Reset on Start: if checked, then the accumulated integral and internal process variable and derivative smoothing is reset whenever a loop is restarted.  Otherwise, the integral will continue to accumulate while the PID is stopped.  The integral will not start to accumulate until the PID is started for the first time.

Running a PID Loop:

Once the PID is set up you can start and stop loops the same way you would start/stop a sequence.  This includes component actions and sequence commands.  The Settings tab of the PID View has some useful diagnostic information for a running sequence.  To the right of the process variable, set point, and output channel fields numbers will appear showing the current value for each of these terms.  The process variable is smoothed, so the value displayed will not be the exact current value of your expression, but it will be the value fed into the PID calculation.  To the right of the P, I, and D terms numbers will appear showing the current effect related to the term.  For P, this displays P*e, for I, P*i/I or i/I depending on the PID type, for D either P*D*dPV or D*dPV.  Unless you have an PID event returning a different value, the sum of these three terms will equal the output value.  Finally to the right of the integral limit field, a number will appear showing the current accumulated integral.  This is useful to determine an appropriate integral limit.

In addition, a graph of the process variable, set point and output is displayed along the right.  This is a standard DAQFactory graph, so you can double click on it to change graph scaling and other parameters.

Note: Unlike sequences, you do not need to stop and restart your PID loop every time you change a parameter.  The option will apply immediately to a running PID loop.

Example:  As an example, we will create a simulation temperature system and use a PID loop to control it.

1. Create a new sequence, call it whatever you would like.  To create a sequence, right click on SEQUENCES: in the workspace and select Add Sequence.  Enter a name for the sequence and the sequence view will appear.  Enter the following text into the sequence:

 

global PV = 1

global Out = 0

global SP = 50

while(1)   

  PV += Out - 0.25

  delay(1)

endwhile

The first three lines initialize the three variables we are going to use in our simulation.  The rest does the actual simulation, increasing the process variable (PV) by the output of the PID loop, but also subtracting 0.25 from it every loop to simulate cooling.  Click Apply & Compile to save your changes.

2. Create a new PID loop, again call it whatever you would like.  Only three parameters need to be set:

Process Variable: PV

Set Point: SP

Output Channel: Out

3. Click Apply to save your changes.

4. Start your sequence.  To do this, click on the + sign next to SEQUENCES: to expand the tree, then right click on your sequence and select Begin Sequence.

5. Start your PID loop.  To see a different way to start loops, click on PID: in the workspace to display the PID summary view, then click Begin to start the highlighted PID loop in the view.  There will be only one and it should be highlighted.

6. At this point, both your sequence and PID loop will be running.  Go to the PID view for your PID loop by clicking on the PID loop name in the workspace.  You may need to expand the PID tree by clicking the + next to PID:.  Next, click on the Graph page to display a graph of our three parameters.

7. Depending on how long it took for you to get between step 5 and step 6, the system may have stabilized already.  So, to create a disturbance we need to change the set point.  To do this, go to the Command / Alert window and type: SP = 20 and hit Enter.  This will change the set point to 20 and the graph should show the change.  The blue trace is your set point, the red trace is the output from the PID loop, and the green trace is the process variable.

At this point feel free to play around a little with some of the parameters.  You do not have to stop the loop to adjust the parameters.  Remember though that the simulation is very basic, so autotuning will not really work on it.  As you gain experience with sequences, you may want to play with the simulation and try and improve it.