National Instruments 371685C-01 用户手册

下载
页码 39
Chapter 3
Using the PID Control Toolkit
3-4
ni.com
Using the PID Library
The following sections describe how to use the PID Library to implement a control strategy.
PID Controller
The PID controller requires several inputs, including SP, PID gains, timer interval (in case the 
internal timer is not used), PV, and output range. PID gains include proportional gain, integral 
time, and derivative time. The following steps provide an overview of typical PID controller 
use.
1.
Provide the PID gains to 
PidCreate
 to create a PID controller. 
PidCreate
 returns a 
handle that you can use to identify the PID controller in subsequent function calls.
2.
Use 
PidSetAttribute
 to set the PID controller attributes such as SP, time interval, 
minimum and maximum controller output values, and so on.
3.
Provide the PV to the controller in a loop and use 
PidNextOutput
 to obtain the 
controller output, which is again applied on the system.
4.
Once the control loop ends, call 
PidDiscard
 to discard the PID controller and free its 
resources.
You can call 
PidSetAttribute
 with the 
pidAttrOutputMin
 and 
pidAttrOutputMax
 
attributes to specify the range of the controller output. The default range is –100 to 100, which 
corresponds to values specified in terms of percentage of full scale. However, you can change 
this range so that the controller gain relates engineering units to engineering units instead of 
percentage to percentage. The PID controller coerces the controller output to the specified 
range. In addition, the PID controller implements integrator anti-windup when the controller 
output is saturated at the specified minimum or maximum values. Refer to Chapter 2, 
for more information about anti-windup.
PID Algorithms
The PID controller can use the following types of PID algorithms to determine the controller 
output.
Fast PID algorithm (
pidFastPidAlgorithm
)
Precise PID algorithm (
pidPrecisePidAlgorithm
)
Use the 
pidAttrAlgorithm
 attribute, which you can set using 
PidSetAttribute
to specify the algorithm to use. 
pidFastPidAlgorithm
 is the default value.