home *** CD-ROM | disk | FTP | other *** search
/ The Final Windows Shareware CD / _.img / winshare / vb / pidvbx / readme.txt < prev   
Text File  |  1993-12-02  |  21KB  |  505 lines

  1. ----------------------------------------------------------------
  2.  
  3.                         PID Controller VBX Control  
  4.  
  5.               Copyright 1993 Northeast Data Corp.
  6.  
  7.                      All Rights Reserved
  8.  
  9.  
  10.       THIS IS THE DEMONSTRATION VERSION OF THE CONTROL
  11.  
  12.       The control functions in the same manner as the
  13.       commercial version, except that a registration
  14.       dialog box appears each time the control is
  15.       accessed. To eliminate this nuisance, register the
  16.       control with Northeast Data Corp.
  17.  
  18.  
  19. ----------------------------------------------------------------
  20.  
  21.  
  22.    Release 1.0
  23.  
  24.    August 1993
  25.  
  26.  
  27. This document describes the PID Controller Custom VBX Control. 
  28.  
  29.  
  30.                CONTENTS
  31.  
  32. 1. Product Description
  33. 2. Legal Information
  34. 3. Installation
  35. 4. Usage
  36. 5. Support
  37.  
  38.  
  39. ----------------------------------------------------------------
  40.  
  41. 1. Product Description
  42.  
  43. The PID Controller VBX Control is a Microsoft Windows DLL designed and 
  44. implemented in compliance with Microsoft standards for
  45. interfacing with Visual Basic.
  46.  
  47.  
  48.  
  49. The control functions like a standard Proportional-Integral-Derivative
  50. controller used in industrial plants. It can be used for modeling 
  51. chemical processing equipment and other kinds of plant installations that
  52. use closed-loop feedback control. See appendix A for a simple introduction
  53. to process control.
  54.  
  55. To the application programmer, the interface to the slider is similar
  56. to the other MS Windows controls, with a few special messages added for
  57. performing operations specific to the PID control.
  58.  
  59. Being a VBX control, the programmer can add the PID Control to the 
  60. tool palette in Visual Basic. This allows use of the control in Visual
  61. Basic forms. Since Visual C++ supports use of VBX controls, the slider
  62. control can also be used in the Visual C++ environment.
  63.  
  64. Use of the PID Controller in a finished VB or Visual C++ application 
  65. requires the PID Control DLL (pid.vbx) to be installed with the application.
  66. This is true of all custom controls written for MS Windows.
  67.  
  68. There are properties available that allow the programmer to control
  69. the behavior and appearance of the Control.
  70.  
  71. All communication between the PID Control and the application is 
  72. performed using the standard Windows message mechanism for controls. 
  73. Design of the PID Control message mechanism allows the application to
  74. continuously monitor the settings of the control.
  75.  
  76. -------------------------------------------------------------------
  77.  
  78. 2. Legal Information
  79.  
  80. The purchaser of the PID Control is allowed to use it and
  81. distribute it in applications without paying any royalty, and without
  82. printing or displaying a copyright notice for the control. This only
  83. includes distribution of the PID Control DLL (PID.VBX). It does 
  84. not include distribution of documentation that comes with the 
  85. Control. 
  86.  
  87. The purchaser of the PID Control may distribute the control DLL with
  88. applications that are networked (multiple users accessing the DLL from
  89. a file server) without paying any license fees to Northeast Data Corp.
  90.  
  91.  
  92. -------------------------------------------------------------------
  93.  
  94. 3. Installation
  95.  
  96. Create a "PID" directory on your hard disk and copy all files from
  97. the distribution disk to the directory. You should copy the pid.vbx
  98. file to your Windows\System directory.
  99.  
  100. Start Visual Basic or the Visual C++ App Studio applications and use
  101. the custom control installation function to install the pid.vbx
  102. control.
  103.  
  104.  
  105. -------------------------------------------------------------------
  106.  
  107. 4. Usage
  108.  
  109.  
  110. PROPERTIES
  111. ----------
  112.  
  113.    Action    - Stop, Run, Reset. Reset causes all values stored in the
  114.                controller to be reset to their controller startup
  115.                settings. 
  116.  
  117.    BackColor - Sets the background color.
  118.  
  119.    DragIcon  - Name of the icon that will appear when the control is dragged.
  120.  
  121.    DragMode  - Normal or automatic.
  122.  
  123.    Gain      - The sensitivity of the controller. This value is multiplied
  124.                times the difference between the setpoint and measured value,
  125.                then divided by difference between the maximum and minimum
  126.                control values (the range of the controller). The value is
  127.                expressed as a percentage, so 100 will cause a 50% output
  128.                when the difference between measured value and setpoint
  129.                is 1 half of the span of the controller (100 degrees).
  130.   
  131.    Height    - Height of control.
  132.  
  133.    Index     - Index of control.
  134.  
  135.    Left      - Left position.
  136.    
  137.    Measured  - Position of the measured value arrow.
  138.  
  139.    Mode      - Manual or Automatic. If set to automatic, the controller
  140.                calculates and sets the output value based on the measured
  141.                value and setpoint. If set to manual, the controller does
  142.                not adjust the output, but allows you to set it manually.
  143.                Setting the mode to manual also allows you to write your
  144.                own algorithms for controlling the output based on the
  145.                measured value and setpoint.
  146.  
  147.    MVColor   - Color of the measured value arrow.
  148.  
  149.    MVTickColor - Color of the tick marks on the measured value scale.
  150.  
  151.    Name      - Standard property for the name of the control.
  152.  
  153.    OPColor   - Color of the output arrow.
  154.  
  155.    OPMode    - Normal or Reverse. In reverse mode the output is set
  156.                to 100% when the measured value is greater than the
  157.                setpoint. In normal mode, the output is zero when the
  158.                measured value is over the setpoint. This is useful for
  159.                controlled devices that work in opposite fashions. For
  160.                example, some pneumatic valves are closed at 100% output
  161.                and wide open at 0% output. Other valves are the opposite
  162.                of this.
  163.  
  164.    OPTickColor - Color of the tick marks on the output scale.
  165.  
  166.    Output    - Position of the output arrow on the output scale. This
  167.                can only be set if the Mode property is set to Manual.
  168.  
  169.    Poll      - Controller update period (in seconds). This value should
  170.                be set to something reasonable (a few seconds). Setting it
  171.                too low will cause the control to take large amount of CPU
  172.                time.
  173.  
  174.    Preact    - This value determines how many minutes the controller
  175.                "looks ahead" to determine how the output should be adjusted.
  176.                The calculation is done by extrapolating from the previous
  177.                measured value to determine what the value will be at the
  178.                specified lead time. This setting affects the ability of 
  179.                the controller to respond ahead of time to rapid changes in
  180.                the measured value.
  181.  
  182.    Reset     - The number of times per minute that the normal output 
  183.                calculated based on the Gain is reapplied to the output.
  184.                This setting affects the ability of the controller to correct
  185.                for a continuous offset between the setpoint and measured
  186.                value. 
  187.  
  188.    SetPoint  - Current setpoint position. This must be a value between
  189.                or including the current minimum and maximum values of
  190.                the controller.
  191.  
  192.    SPColor   - Color of the setpoint arrow.
  193.  
  194.    SPMax     - Maximum control value. This must be greater than the
  195.                minimum value. This established the maximum value for
  196.                the setpoint and measured values.
  197.  
  198.    SPMin     - Minimum control value. This must be less than the maximum
  199.                value. This establishes the minimum value for the setpoint
  200.                and measured values of the controller.
  201.  
  202.    SPTickColor - Color of the tick marks on the setpoint scale.
  203.  
  204.    TabIndex  - Control tab order.
  205.  
  206.    TabStop   - If this is turned on (1 instead of 0), the PID controller can
  207.                be activated by tabbing to it with the TAB key.
  208.  
  209.    Tag       - Control tag.
  210.  
  211.    Top       - Top of control window.
  212.  
  213.    Visible   - Visible/Invisible attribute.
  214.  
  215.    Width     - Width of control.
  216.  
  217.    
  218. EVENTS
  219. ------
  220.  
  221. These events work the same way as for other VBX controls.
  222.  
  223.    DblClick 
  224.    DragDrop  
  225.    DragOver
  226.    GotFocus
  227.    KeyDown
  228.    KeyUp
  229.    LostFocus
  230.    Measured
  231.    Output
  232.    Setpoint
  233.  
  234. In order to update values in your application based on the current
  235. position of the PID control, you should handle the Output and Setpoint
  236. events. The measured value event is not usually needed, since it is
  237. your application that sets the measured value based on the controller
  238. output. The setpoint event will occur when the user drags the setpoint
  239. arrow in the controller. 
  240.  
  241.  
  242.  
  243. -----------------------------------------------------------------------
  244.  
  245. 5. Support
  246.  
  247. You don't get any until you register.
  248.  
  249.  
  250.  
  251. APPENDIX A  - Process Control Overview
  252.  
  253. There are many books available on process control theory. You can find
  254. them at any good technical library. Process control is a complex field
  255. of study - far too broad to cover in detail in this document. The 
  256. following covers some of the basics to get you started. A lot can be
  257. learned just by "playing" with the PID VBX control. It is possible to 
  258. connect your PC to laboratory equipment through a special analog adapter
  259. and perform real process control, using the PID control in Visual Basic
  260. or Visual C++ to perform the control calculations and output.
  261.  
  262. Process control is divided into two broad categories; "Open Loop" and
  263. "Closed Loop". Open loop controllers send an output signal (air pressure
  264. or electrical) to a pneumatic valve or electronic solenoid. The level of
  265. the output signal is adjusted with no knowledge of conditions at the 
  266. point of control. For example, a steam valve could be set to 50% of it's
  267. travel. The kettle of water being heated is at some unknown temperature
  268. and heats up as steam is fed to it. The temperature of the water rises
  269. continuously to some point of equilibrium. No change occurs to the steam
  270. valve setting unless the operator manually adjusts the output to the valve.
  271. This type of control is manual.
  272.  
  273. Closed loop control is a technique for automatically adjusting valve or
  274. other component settings based on the measured value of the material being
  275. controlled. For example, placing a thermocouple in the kettle of water
  276. and feeding the measured temperature back to the controller allows the
  277. controller to determine a new setting for the steam valve.
  278.  
  279. In closed loop control, the tricky part is coming up with an algorithm
  280. that determines the best setting for the valve or other device based on
  281. the measured input. It's tricky because of the large number of physical
  282. characteristics of the plant that affect the behavior of the measured
  283. feedback signal and the signal going out to the valve. Various things 
  284. cause time delays in the sensing of input values and adjustment of 
  285. output devices. Since there are usually more complex things to control
  286. than a kettle of water, the nature of the fluid or whatever is being
  287. controlled various widely. For example, typical chemical reactions
  288. cause enormous perturbations in the stability of the system (the extreme
  289. case being an explosion). Modern control theory attempts to quantify
  290. all these factors and produce optimum control algorithms.
  291.  
  292.  
  293. PROPORTIONAL CONTROL
  294. ====================
  295.  
  296. The simplest form of closed-loop control is "Proportional". The output
  297. signal is determined by the difference between the setpoint and the
  298. measured value in relation to the range of the controller. A multiplier
  299. (called the "Gain") is used to determine the new output value. The output
  300. is calculated as:
  301.  
  302.       setpoint - measured value
  303.       ------------------------- * (gain/100)
  304.       max output - min output
  305.  
  306. A gain of 100% means, for example, a setpoint of 75 degrees and a current
  307. water temperature of 50 degrees results in an output of 25% (where the
  308. output ranges from zero to 100% of the valve range). A gain of 2 would
  309. cause an output of 50%. This assumes the span of the controller (range
  310. of measured value and setpoint) is 100.
  311.  
  312. This type of control is adequate for some systems. Industrial controls
  313. implement this type of control (as well as all those described in this
  314. document) by pneumatic elements using air pressure or by electrical
  315. components using electrical sensors and solenoids. The PID VBX control
  316. implements control by running a timer that periodically reads properties
  317. set by the application (the key one being the measured value). The
  318. timer period can be set using the "Poll" property.
  319.  
  320.  
  321. RESET CONTROL (Integral)
  322. =============
  323.  
  324. Then things get a little trickier. What if 25% output is not enough to
  325. heat the water (or whatever) above 50 degrees? The controller is now at
  326. equilibrium; no further changes in water temperature will occur. The system
  327. operates at a steady offset between the setpoint and the measured value.
  328. Usually, this is not quite what is desired. The operator can correct the
  329. condition by manually setting the setpoint to 100 degrees, hoping that the
  330. controller will settle down with an offset of 25 degrees, leaving the
  331. water temperature at the desired 75 degrees. Depending on the system
  332. behavior, this may not happen. The operator may have to "play" with 
  333. the setpoint to find the setting that works.
  334.  
  335. The next type of control operation attempts to correct this problem. It
  336. does, in effect, what the operator would have to do manually. That is,
  337. it resets the effective setpoint when it sees that the measured value
  338. does not come up to the setpoint over some period of time. This element
  339. of control operation is called, appropriately "Automatic Reset", or just
  340. "Reset". The numeric value for the reset is the number of times per 
  341. minute that the controller adds the output calculated from the simple
  342. gain to the current output value. The output is adjusted rather than
  343. the setpoint - the effect is the same, and is preferable to putting the
  344. setpoint to a location that looks strange to the operator.
  345.  
  346. The effect of reset is to, over time, eliminate the offset between the
  347. setpoint and the measured value. The disadvantage to this technique is
  348. that reset tends to desensify the controller. That is, once the setpoint
  349. has been reached, the reset may have driven the output so high that the
  350. measured value "overshoots" the setpoint. Also, if the controller is
  351. left in operation (doing calculations) while active components of the
  352. system are turned off, the reset component will build up a large output
  353. value. When the components are turned on, the controller massively
  354. overshoots the setpoint. For example, if a manual steam valve is turned
  355. off while the controller is running, reset will eventually drive the
  356. output to 100% because the measured value never comes up to the setpoint
  357. (no steam available). When the manual valve is opened, the reset component
  358. takes no effect until the measured value has reached the setpoint. By
  359. the time the controller has determined there is no continuing offset, the
  360. measured value has overshot the setpoint by a large value. This
  361. phenomenon is sometimes called "Reset Windup".
  362.  
  363. This problem can be overcome to some extent by providing a switch to
  364. turn the controller on and off. While the system is not being used, the
  365. controller is turned off. These prevents the reset component from building
  366. up incorrect output values. The VBX control contains an Action property for 
  367. turning the controller on and off and for resetting it, which zeroes out 
  368. all retained calculations.
  369.  
  370. Reset control action is also known as "Integral" control, since controller 
  371. output is determined by integrating offsets over a period of time.
  372.  
  373.  
  374. DERIVATIVE CONTROL  (Preact)
  375. ==================
  376.  
  377. Many systems have lengthy delays between the sensing of temperatures or other
  378. parameters and transmission of these to the controller. There can also be
  379. extensive delays in the transmission and use of output signals from the
  380. controller. The effect of these problems is that the new adjustment at the
  381. point of control is incorrect by the time it arrives. This problem is
  382. evident in all controls by observing a phenomenon known as "Cycling", where
  383. the measured value repeatedly overshoots and undershoots the setpoint. A
  384. controller operating in this condition is said to be "hunting". 
  385.  
  386. There are also process events that "surprise" the controller. A chemical
  387. reaction typically produces these at the time the chemicals begin to
  388. react. Sensitive proportional control can somewhat compensate for this
  389. problem, but Reset control tends to make things worse if the reaction
  390. occurs when the measured value is below the setpoint, since Reset will
  391. continue to boost the output until the measured value is above the setpoint.
  392.  
  393. Derivative control looks at the difference between the previous measured
  394. value and the current one. It calculates a counter-output to be applied 
  395. to the proportional output. In effect, it guesses what the next measured 
  396. value will be based on the slope (hence the term "Derivative") of the 
  397. measured value and generates an output to "get ahead" of the process.
  398.  
  399. Derivative control is also known as "Preact". The numeric value for the
  400. preact is the number of minutes to look ahead to calculate the output. For
  401. example:
  402.  
  403.    If the previous measured value was 45 degrees and occured 10 seconds ago
  404.  
  405.    If the current measured value was 50 degrees and the Preact value is .5
  406.  
  407. The rate of change in measured value is 30 degrees per minute.
  408. The preact value indicates we should use the measured value .5 minutes
  409. in the future. Based on the rate of change, the measured value will be 
  410. 65 degrees in .5 minutes ( 50 (current value) + 30 (deg/min ) / .5 (min) ).
  411.  
  412. The preact component will calculate an output based on 65 degrees, 
  413. whereas the proportional component will base its calculation on 50 degrees.
  414.  
  415. The outputs calculated by proportional, integral, and derivative components
  416. are added together to form the new output value.
  417.  
  418.  
  419. TUNING
  420. ======
  421.  
  422. The business of setting optimum values for Gain, Reset, and Preact is
  423. known as "Tuning" the controller. This is typically done through trial
  424. and error. Although there are many algorithms used for calculating these
  425. settings, many process systems are so complex that the trial-and-error
  426. technique is the most effective.
  427.  
  428. Controllers can become more complex by "cascading" them. In this 
  429. configuration, the output from one controller is used to set the setpoint
  430. of another controller. Two controllers cascaded is the norm, but there is
  431. no technical limit. Tuning these types of controllers is usually done by
  432. tuning the controller closest to the process (called the "slave") first,
  433. and tuning the "master".
  434.  
  435.  
  436.  
  437. APPENDIX B - Example Visual Basic Application
  438. ==========
  439.  
  440. The application provided with the PID control is a simple example of
  441. controlling a kettle of water (or whatever). The application sets the
  442. measured value based on the output of the control and the current 
  443. temperature of the water.
  444.  
  445. Edit boxes let you play with the Gain, Reset, and Preact. Buttons let
  446. you stop, start, and reset the controller. 
  447.  
  448. Three graph controls are used to chart the setpoint, measured value, and
  449. output. 
  450.  
  451. The game here is to try your hand at tuning the controller. You can test
  452. your skill by making controller settings and adjustments to the setpoint.
  453. The goal is to tune the controller for optimum measured value control.
  454. You need to minimize cycling, offsets, and overshoots.
  455.  
  456. You can change the behavior of the system by modifying the algorithms
  457. for calculation of the measured value. You may want to add an "Explosion"
  458. button or something like that to give a sudden burst in measured value
  459. to see how your controller responds.
  460.  
  461. If you have better ideas for controlling a process, set the mode of the
  462. controller to "Manual" and write your own subroutine for calculating the
  463. output based on the measured value and setpoint. This, in effect, lets
  464. you design your own industrial controller. You can add all kinds of
  465. logic for dealing with special behavior of your process. For example,
  466. you may know that your chemical reaction "takes off" at exactly 14
  467. minutes after the temperature reaches a setpoint of 67 degrees. Your
  468. algorithm could make adjustments to setpoint, set the controller and
  469. let your algorithm "take over", or make adjustments to the gain, reset,
  470. and preact. This is pretty cool, since many industrial controllers
  471. don't have nearly this much flexibility.
  472.  
  473. It's also fun to hook up the MCI control and play wave files for special
  474. effects when certain things happen in the controlled process.
  475.  
  476.  
  477. Enjoy.
  478.  
  479.  
  480.  
  481.       
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.