Worldwide Technical Support and Product Information
ni.com
National Instruments Corporate Headquarters
11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100
Worldwide Offices
Australia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599,
Canada 800 433 3488, China 86 21 5050 9800, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00,
Finland 358 (0) 9 725 72511, France 01 57 66 24 24, Germany 49 89 7413130, India 91 80 41190000,
Israel 972 3 6393737, Italy 39 02 41309277, Japan 0120-527196, Korea 82 02 3451 3400,
Lebanon 961 (0) 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793, Netherlands 31 (0) 348 433 466,
New Zealand 0800 553 322, Norway 47 (0) 66 90 76 60, Poland 48 22 3390150, Portugal 351 210 311 210,
Russia 7 495 783 6851, Singapore 1800 226 5886, Slovenia 386 3 425 42 00, South Africa 27 0 11 805 8197,
Spain 34 91 640 0085, Sweden 46 (0) 8 587 895 00, Switzerland 41 56 2005151, Taiwan 886 02 2377 2222,
Thailand 662 278 6777, Turkey 90 212 279 3031, United Kingdom 44 (0) 1635 523545
For further support information, refer to the Technical Support and Professional Services appendix. To comment
on National Instruments documentation, refer to the National Instruments Web site at
the info code
The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects
in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National
Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives
notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be
uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before any
equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are covered by
warranty.
National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical accuracy. In
the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent editions of this document
without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected. In no event shall National
Instruments be liable for any damages arising out of or related to this document or the information contained in it.
E
XCEPTASSPECIFIEDHEREIN, NATIONAL INSTRUMENTSMAKESNOWARRANTIES, EXPRESSORIMPLIED, ANDSPECIFICALLYDISCLAIMSANYWARRANTYOF
MERCHANTABILITYORFITNESSFORAPARTICULARPURPOSE. CUSTOMER’SRIGHTTORECOVERDAMAGESCAUSEDBYFAULTORNEGLIGENCEONTHEPARTOF NATIONAL
I
NSTRUMENTSSHALLBELIMITEDTOTHEAMOUNTTHERETOFOREPAIDBYTHECUSTOMER. NATIONAL INSTRUMENTSWILLNOTBELIABLEFORDAMAGESRESULTING
FROMLOSSOFDATA, PROFITS, USEOFPRODUCTS, ORINCIDENTALORCONSEQUENTIALDAMAGES, EVENIFADVISEDOFTHEPOSSIBILITYTHEREOF. This limitation of
the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including negligence. Any action against
National Instruments must be brought within one year after the cause of action accrues. National Instruments shall not be liable for any delay in
performance due to causes beyond its reasonable control. The warranty provided herein does not cover damages, defects, malfunctions, or service
failures caused by owner’s failure to follow the National Instruments installation, operation, or maintenance instructions; owner’s modification of the
product; owner’s abuse, misuse, or negligent acts; and power failure or surges, fire, flood, accident, actions of third parties, or other events outside
reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying,
recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National
Instruments Corporation.
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other
intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only
to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.
Trademarks
National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section
on ni.com/legal for more information about National Instruments trademarks.
The mark LabWindows is used under a license from Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation in the United
States and other countries. Other product and company names mentioned herein are trademarks or trade names of their respective companies.
Patents
For patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software, the patents.txt file
on your media, or ni.com/patents.
WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS
(1) NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OF
RELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS IN
ANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANT
INJURY TO A HUMAN.
(2) IN ANY APPLICATION, INCLUDING THE ABOVE, RELIABILITY OF OPERATION OF THE SOFTWARE PRODUCTS CAN BE
IMPAIRED BY ADVERSE FACTORS, INCLUDING BUT NOT LIMITED TO FLUCTUATIONS IN ELECTRICAL POWER SUPPLY,
COMPUTER HARDWARE MALFUNCTIONS, COMPUTER OPERATING SYSTEM SOFTWARE FITNESS, FITNESS OF COMPILERS
AND DEVELOPMENT SOFTWARE USED TO DEVELOP AN APPLICATION, INSTALLATION ERRORS, SOFTWARE AND HARDWARE
COMPATIBILITY PROBLEMS, MALFUNCTIONS OR FAILURES OF ELECTRONIC MONITORING OR CONTROL DEVICES,
TRANSIENT FAILURES OF ELECTRONIC SYSTEMS (HARDWARE AND/OR SOFTWARE), UNANTICIPATED USES OR MISUSES, OR
ERRORS ON THE PART OF THE USER OR APPLICATIONS DESIGNER (ADVERSE FACTORS SUCH AS THESE ARE HEREAFTER
COLLECTIVELY TERMED “SYSTEM FAILURES”). ANY APPLICATION WHERE A SYSTEM FAILURE WOULD CREATE A RISK OF
HARM TO PROPERTY OR PERSONS (INCLUDING THE RISK OF BODILY INJURY AND DEATH) SHOULD NOT BE RELIANT SOLELY
UPON ONE FORM OF ELECTRONIC SYSTEM DUE TO THE RISK OF SYSTEM FAILURE. TO AVOID DAMAGE, INJURY, OR DEATH,
THE USER OR APPLICATION DESIGNER MUST TAKE REASONABLY PRUDENT STEPS TO PROTECT AGAINST SYSTEM FAILURES,
INCLUDING BUT NOT LIMITED TO BACK-UP OR SHUT DOWN MECHANISMS. BECAUSE EACH END-USER SYSTEM IS
CUSTOMIZED AND DIFFERS FROM NATIONAL INSTRUMENTS' TESTING PLATFORMS AND BECAUSE A USER OR APPLICATION
DESIGNER MAY USE NATIONAL INSTRUMENTS PRODUCTS IN COMBINATION WITH OTHER PRODUCTS IN A MANNER NOT
EVALUATED OR CONTEMPLATED BY NATIONAL INSTRUMENTS, THE USER OR APPLICATION DESIGNER IS ULTIMATELY
RESPONSIBLE FOR VERIFYING AND VALIDATING THE SUITABILITY OF NATIONAL INSTRUMENTS PRODUCTS WHENEVER
NATIONAL INSTRUMENTS PRODUCTS ARE INCORPORATED IN A SYSTEM OR APPLICATION, INCLUDING, WITHOUT
LIMITATION, THE APPROPRIATE DESIGN, PROCESS AND SAFETY LEVEL OF SUCH SYSTEM OR APPLICATION.
Converting between Percentage of Full Scale and Engineering Units ...........3-9
Using PID on Real-Time (RT) Targets........................................................... 3-10
Using PID with DAQ Devices ........................................................................ 3-10
Appendix A
References
Appendix B
Technical Support and Professional Services
Glossary
Index
LabWindows/CVI PID Control Toolkit User Manualvini.com
About This Manual
The LabWindows/CVI PID Control Toolkit User Manual describes the PID
Control Toolkit for LabWindows
features, functions, and operation of the toolkit. To use this manual, you
need a basic understanding of process control strategies and algorithms.
™
/CVI™. The manual describes the
Conventions
The following conventions appear in this manual:
»The » symbol leads you through nested menu items and dialog box options
to a final action. The sequence File»Page Setup»Options directs you to
pull down the File menu, select the Page Setup item, and select Options
from the last dialog box.
This icon denotes a note, which alerts you to important information.
boldBold text denotes items that you must select or click in the software, such
as menu items and dialog box options. Bold text also denotes parameter
names.
italicItalic text denotes variables, emphasis, a cross-reference, or an introduction
to a key concept. Italic text also denotes text that is a placeholder for a word
or value that you must supply.
monospaceText in this font denotes text or characters that you should enter from the
keyboard, sections of code, programming examples, and syntax examples.
This font is also used for the proper names of disk drives, paths, directories,
programs, subprograms, subroutines, device names, functions, operations,
variables, filenames, and extensions.
Related Documentation
The following documents contain information that you may find helpful as
you read this manual:
•LabWindows/CVI PID Control Toolkit Help
•LabWindows/CVI Help
•NI-DAQmx Help
•Traditional NI-DAQ (Legacy) C Function Reference Help
This chapter describes how to install the toolkit and describes
Proportional-Integral-Derivative (PID) control applications.
System Requirements
Your computer must meet the following minimum system requirements to run the PID
Control Toolkit:
•LabWindows/CVI 7.x or later
•Windows Vista/XP/2000
Installation Instructions
If you already have an earlier version of the PID Control Toolkit installed on your computer,
you must uninstall it before installing this version of the PID Control Toolkit.
1
Note When you install the PID Control Toolkit, your user account must have
administrator privileges.
Complete the following steps to install the PID Control Toolkit:
1.Insert the PID Control Toolkit CD into the CD drive. If the CD does not run
automatically, open Windows Explorer, right-click the CD drive icon, and select
AutoPlay.
2.On installation startup, the National Instruments PID Control Toolkit screen appears.
Click InstallToolkit.
3.In the User Information panel, enter your name and organization and the serial number
found on your Certificate of Ownership card. LabWindows/CVI uses this serial number
when you run the NI Activation Wizard.
4.Follow the instructions on the screen. When the PID Control Toolkit has been
successfully installed, click Finish.
The first time you launch LabWindows/CVI after installing the PID Control Toolkit, you are
prompted to activate the toolkit. Complete the following steps to activate the PID Control
Toolkit.
1.Click ActivateProducts.
2.Select the Automatically activate through a secure Internet connection option and
click Next. Your computer must be connected to the Internet for this option to work.
If you do not have Internet access on your computer, refer to the LabWindows/CVI ReleaseNotes.
3.Enter the serial number with the number found on your Certificate of Ownership card.
Click Next.
4.Fill in the necessary information and click Next.
5.Check the option if you would like to receive a confirmation email of your activation and
click Next.
6.After a brief moment, you should receive a message indicating whether the PID Control
Toolkit has been activated or not. Click Next.
Note If your activation was not successful, you can update the serial number, get help
from National Instruments, or evaluate the toolkit.
7.Continue to follow the instructions on the screen.
8.When you successfully activate, click Finish. LabWindows/CVI displays a window
indicating when this license expires.
For more information about activation, refer to the LabWindows/CVI Release Notes.
PID Control Toolkit Applications
The PID Control Toolkit contains functions you can use to develop LabWindows/CVI control
applications. For more information about the types of applications you can develop, refer to
the example programs that are installed with the toolkit.
LabWindows/CVI PID Control Toolkit User Manual1-2ni.com
PID Control
Currently, the PID algorithm is the most common control algorithm used in industry. Often,
PID is used to control processes that include heating and cooling systems, fluid level
monitoring, flow control, and pressure control. When using PID control, you must specify a
process variable and a setpoint. The process variable is the system parameter you want to
control, such as temperature, pressure, or flow rate. The setpoint is the desired value for the
parameter you are controlling. A PID controller determines a controller output value, such as
the heater power or valve position. When applied to the system, the controller output value
drives the process variable toward the setpoint value.
You can use the PID Control Toolkit functions with National Instruments hardware to develop
LabWindows/CVI control applications. Use I/O hardware, such as DAQ devices, FieldPoint
I/O modules, or GPIB boards, to connect your PC to the system you want to control. You can
use the LabWindows/CVI I/O functions with the PID Control Toolkit to develop a control
application or modify the examples provided with the toolkit.
Using the PID Control Toolkit functions, you can develop the following control applications
based on PID controllers:
•Proportional (P), proportional-integral (PI), proportional-derivative (PD), and
proportional-integral-derivative (PID) algorithms
•Gain-scheduled PID
•PID autotuning
•Precise PID
•Lead-lag compensation
•Setpoint profile generation
•Multiloop cascade control
•Feedforward control
•Override (minimum/maximum selector) control
•Ratio/bias control
Chapter 1Overview of the PID Control Toolkit
Refer to the LabWindows/CVI PID Control Toolkit Help, which you can access by selecting
Start»All Programs»National Instruments»PID Control Toolkit for CVI»LabWindows
CVI PID Help, for more information about the functions.
This chapter explains the fast PID, precise PID, and autotuning algorithms.
The PID Algorithm
The PID controller compares the setpoint (SP) to the process variable (PV) to obtain the error
(e), as follows:
2
e = SP – PV
Then the PID controller calculates the controller action, u(t), as follows. In this equation, K
is the controller gain.
⎛⎞
ut()K
If the error and the controller output have the same range, –100% to 100%, controller gain is
the reciprocal of proportional band. T
time, and T
represents the proportional action.
The following formula represents the integral action.
The following formula represents the derivative action.
is the derivative time in minutes, also called the rate time. The following formula
d
⎜⎟
=
c
⎜⎟
⎝⎠
is the integral time in minutes, also called the reset
Implementing the PID Algorithm with the PID Functions
This section describes how the PID Control Toolkit functions implement the fast (positional)
PID algorithm. The fast PID algorithm is the default algorithm used in the PID Control
Toolkit.
Error Calculation
The following formula represents the current error used in calculating proportional, integral,
and derivative action, where PV
is the filtered process variable.
f
e( k) = (SP PV
)–
f
Proportional Action
Proportional action is the controller gain times the error, as shown in the following formula:
u
k()= Kc* ek()()
P
Trapezoidal Integration
Trapezoidal integration is used to avoid sharp changes in integral action when there is a
sudden change in the PV or SP. Use nonlinear adjustment of the integral action to counteract
overshoot. The following formula represents the trapezoidal integration action.
k
K
------
u
k()=
I
T
c
∑
i
i 1=
ei() ei 1–()+
----------------------------------
2
tΔ
Partial Derivative Action
Because of abrupt changes in the SP, apply derivative action to only the PV, not to the error
(e), to avoid derivative kick. The following formula represents the partial derivative action.
T
d
uDk() = Kc
-----
Δt
PV
k()PVfk 1–()–()–
f
Controller Output
Controller output is the summation of the proportional, integral, and derivative action,
as shown in the following formula:
uk() u
LabWindows/CVI PID Control Toolkit User Manual2-2ni.com
k() uIk() u+Dk()+=
P
Chapter 2PID Algorithms
Output Limiting
The actual controller output is limited to the range specified for control output, as follows:
if uk() u
then uk() u
max
=≥
max
and
if uk() u
then uk() u
min
=≤
min
The following formula shows the practical model of the PID controller.
ut()K
SP PV–()
c
t
1
----
+=
(SP PV)dt T
∫
T
i
0
dPV
f
------------
––
d
dt
The PID functions use an integral sum correction algorithm that facilitates anti-windup and
bumpless manual-to-automatic transfers. Windup occurs at the upper limit of the controller
output, for example, 100%. When the error (e) decreases, the controller output decreases,
moving out of the windup area. The integral sum correction algorithm prevents abrupt
controller output changes when you switch from manual to automatic mode or change any
other parameters.
The default ranges for the SP, PV, and output parameters correspond to percentage values;
however, you can use actual engineering units. If you use engineering units, you must adjust
the corresponding ranges accordingly. The T
and Td parameters are specified in minutes.
i
In manual mode, you can change the manual input to increase or decrease the output.
All the PID control functions are reentrant. Multiple calls from high-level functions use
separate and distinct data.
Note As a general rule, manually drive the PV until it meets or comes close to the SP
before you perform the manual-to-automatic transfer.
Gain Scheduling
Gain scheduling refers to a system in which you change controller parameters based on
measured operating conditions. For example, the scheduling variable can be the SP, the PV,
a controller output, or an external signal. For historical reasons, the term gain scheduling is
used even if other parameters, such as the derivative time or integral time parameters, change.
Gain scheduling effectively controls a system whose dynamics change with the operating
conditions.