Chapter 3 Using the PID Control Toolkit
© National Instruments Corporation 3-9 LabWindows/CVI PID Control Toolkit User Manual
You can use the setpoint profiler as follows:
1. Call PidSetpointProfileCreate to create a setpoint profile. Use a pair of time and
setpoint value arrays to specify the setpoint profile with the time values in ascending
order.
2. Use PidSetSetpointProfileAttribute to set the setpoint profile attributes.
3. Use PidSetpointProfileNextSetpoint to obtain the setpoint from the profile in a
loop and provide this setpoint to the controller.
4. Once the control loop ends, call PidSetpointProfileDiscard to discard the setpoint
profile and release its resources. Also call PidDiscard to discard the PID controller.
At any time in the control loop, you can use pidSetpointProfileAttrElapsedTime
to get the elapsed time. You also can check if the profile is complete using the
pidSetpointProfileAttrProfileComplete attribute.
Using Ramp Generators
A ramp generator is a simple component that you can use to generate a ramp output. Typically,
you use a ramp generator as follows:
1. Call PidRampCreate to create a ramp generator. Specify the SP, initial output, and the
rate at which the output of the ramp changes.
2. Call PidSetRampAttribute to set the ramp generator attributes.
3. Use PidRampNextOutput to obtain the output of the ramp in a loop.
4. Call PidRampDiscard to discard the ramp generator and release its resources.
Converting between Percentage of Full Scale and Engineering Units
As described in the previous sections, the default SP, PV, and output ranges for the PID
Library functions correspond to a percentage of the full scale. Proportional gain (Kc) relates
percentage of full-scale output to percentage of full-scale input. This is the default behavior
of many PID controllers used for process control applications. To implement PID in
this way,you must scale all inputs to percentage of full scale and all controller
outputs to actual engineering units such as volts for analog output. You can use
PidConvertEGUToPercentage to convert any input from real engineering units to
percentage of full scale and PidConvertPercentageToEGU to convert the controller output
from percentage to real engineering units. PidConvertPercentageToEGU has an
additional input parameter, bCoerce. The default value of bCoerce is TRUE, which indicates
that the output is coerced to the range.
Note The PID Library functions do not use the setpoint range and output range
information to convert values to percentages in the PID algorithm. The controller gain
relates the output in engineering units to the input in engineering units. For example, a gain