Example History:  (1) Feb 17, 2015    (2) Feb 18, 2015    (3) Feb 22, 2015    (4) Feb 23, 2015    (5) Feb 25, 2015

NOTE:  All images on this page can be enlarged by clicking on them.

The PIDFF Complete PID Controller is based on a PID algorithm with parallel or mixed structure (series / parallel).  The PIDFF EFB can be used (and is recommended) for the majority of closed loop control needs and also includes a feed forward component for disturbance compensation, but use of this component is not required.  Another benefit of the PIDFF EFB is that it supports use of the AUTOTUNE Unity Pro EFB.

This project was developed to demonstrate a Level Control solution that is typical in industrial control systems.  The requirement of the Level Control is to maintain the level in a Water Storage Tank (or buffer tank) that supplies water to a system with continuous variation of water usage.  Controlling the level is accomplished by the use of a Variable Frequency Drive which will control the speed of an electric motor connected to the pump that fills the tank.

The example project also includes many features which demonstrate other capabilities of Unity Pro.  These include:
  • object oriented code by the extensive use of Unity Pro DFBs
  • various code use (FBD, LD, SFC and ST) for a variety of use cases
  • conditional execution of MAST Task Sections
  • the use of Subroutines (SR Sections)
  • complex Operator Screens using only native Unity Pro graphical objects
  • Application Diagnostics, the PAC Diagnostics Buffer/Viewer and the native ALRM_DIA DFB
  • Pump Energy Integration (TOTALIZER EFB) enabling analysis of the affect of the PID Tuning Parameters on Energy Usage

The example project was built with Unity Pro V8.0 and on a PC using 1280x720 resolution.  Using the following Unity Pro Option settings will provide the intended user experience.

The example project was built for use in the Unity Pro Simulator, but it can be adapted and run in hardware.  After downloading the application and opening it in Unity Pro, execute the following steps to run the application in the Simulator:
  • set the project to Simulator Mode (using the 'PLC' pull-down menu or the Toolbar Buttons)
  • Build the project
  • Connect the project to the Simulator
  • Download the project
  • Run the project
The application provides the user with the ability to change the dynamics of the system by setting the size of the Water Storage Tank and the Maximum System Flow by an easy to use interface located on the 'Introduction' Operator Screen.  Changes to any of these following values will most likely require re-tuning of the Level Control Loop to achieve the desired performance.
  • Tank Radius (r)
  • Tank Height (h)
  • Max. Flow (f)
The default values (r=25, h=30 & f=17,500) result in a slow system where the Water Storage Tank Level maximum change rate is slightly less than 4% per minute.

To analyze the behavior of a faster reacting system, values similar to r=5.0, h=10.0 and f=5,871 can be used.  These result in a 100% per minute maximum change rate.  With this rate (and anything greater) the system will begin to behave more like a pressure or flow control loop.

The application also includes an automated configuration for a Fast Loop, and to facilitate ease of use and demonstrations, this loop can be Auto Tuned automatically within the application.  The dynamics of the system for the Fast Loop are set to r=1.0, h=5.0 and f=500.0.  These result in a 427% per minute (or ~7% per second) maximum change rate.  This rate essentially nullifies the Tank Buffering and the loop will behave much like a liquid pressure control loop.

To run the application using the default or modified values, simply check the Checkbox 'RUN' (as shown here) on the 'PIDFF Example' Operator Screen.
The horizontal slider control (shown above, and is on both the 'PIDFF Example' and 'Introduction' Operator Screens) allows the user to change the rate of the Tank Water Usage.  There are also two additional automated methods of varying the Tank Water Usage (
on the 'PIDFF Example' Operator Screen):
  • TOD Mode (Time Of Day Mode) - this feature provides an automatic hourly change to the Tank Water Usage with the Percentage of Max Flow defined in the Variable 'TOD_WaterUsage_Table'.  The profile of the default values is shown here.  More details regarding all of the TOD Mode Options are below.

  • Process Disturbance - this feature provides an automatic Continuous Water Usage Variation with an adjustable maximum value (in percentage of the current Water Usage).  More details regarding all of the Process Disturbance Options are below.

The PIDFF Level Control code is demonstrated within the Unity Pro Project in both Function Block Diagram (FBD) and IEC Ladder Diagram (LD).  The execution of FBD or LD is mutually exclusive and which Section to execute is user select-able on the 'Introduction' Operator Screen.  Here is the FBD code.
Demonstration of Application Diagnostics is included, to enable the intended experience, use the 'Tools' pull-down menu and open the 'Diagnostic Viewer'.  Then Right-Click on any of the field column headers and select 'Diag Viewer Properties', then check the Checkbox 'Automatic opening'.

When TOD Mode is Enabled, a digital clock face is displayed (with the time starting at midnight) and the Storage Tank Water Usage rate is set according to the hour and the associated TOD_WaterUsage_Table element.  Also displayed is the Time Warp adjustments.  The Time Warp allows the user to speed up time.  Here are the relationships between the Time Warp values and the simulated time.
By setting the Time Warp Factor to '9', the entire 24 hour cycle of the TOD_WaterUsage_Table can be simulated in 24 minutes.

When TOD Mode is Enabled, the Time Warp Factor is used as the source time for cycling through the TOD_WaterUsage_Table and for the TOTALIZER EFBs used to calculate the Energy Data.

When TOD Mode is enabled the Trend Zones of the 'PIDFF Example' Operator Screen are also sped up according to the Time Warp Factor.  
The 3 Hour Trend shows 3 Hours of data when the Time Warp = '0' and 180 Hours when the Time Warp = '9'.
The Process Disturbance trend shows 2 Hours of data when the Time Warp = '0' and 120 Hours when the Time Warp = '9'.
The 10 Minute Trend shows 10 minutes of data when the Time Warp = '0' and 10 Hours when the Time Warp = '9'.

The Tank Water Usage also has a 'Mixed Mode' option (shown here).  When TOD Mode is enabled with 'Mixed Mode', the user controls the Tank Water Usage via the horizontal slider control and the TOD Time Warp Factor is applied only to the Energy Use Calculations.  This combination of settings can be used to analyze energy usage with different PID Tuning Parameters, an explanation of how to accomplish this is below under Energy Data Options.

The Process Disturbance feature consists of a Sine Wave Generator with configurable settings (shown here) for adjusting the frequency and amplitude of the generated output and an option to use one of two tables defining an automated cycling of the frequency and amplitude values.

Application of the Process Disturbance to the current value of the Tank Water Usage is controlled by the 'Enable' Checkbox and there are two modes available (Manual and Auto) that are controlled by the 'Auto' Checkbox.

Manual Mode
Adjustment of the Process Disturbance is set by...
Wave Rate
The Wave Rate sets the frequency of the sine wave generated.  Larger numbers increase the frequency.  Adjustment of the setting using the Spin Box is limited to -20 to +50.
Wave +/- %
This sets the +/- limit for the maximum applied amplitude of the Continuous Water Usage Variation.  Adjustment of the setting using the Entry Field is limited to 0.1 to 100.0 and this value is in percentage.
Continuous Water Usage Variation (max = +/- xxx.x % of Tank Water Usage)
The value (xxx.x) is the +/- percentage of the current GPM value that will be added to the GPM value used by the StorageTank_Model DFB's Drain_Rate_gpm input.  Adjust of the setting using the Entry Field is limited to 0.0 to 100.0 (however, do not set the value to 0.0).

Use Example
Wave +/- % = 50.0
Continuous +/- = 50.0
Current GPM = 100.0
Wave Peak Variation = 100.0 +/- (100.0 x 0.5 x 0.5) = 100.0 +/- 25.0

Automatic Mode
There are two sets of two tables that contain values for the Wave Rate and the Wave +/- %.  These are:
PD_WavePhaseTable1 and PD_WavePhaseTable2 (contain Wave Rate values)
PD_WaveAmplPhaseTable1 and PD_WaveAmplPhaseTable2 (contain Wave +/- % values)

Selection of which set of tables to use is by the 'Table 1/2' Checkbox.  The default values contained in these tables can be considered as: 'Table 1' is moderate disturbances and 'Table 2' is aggressive disturbances.

There are two Spin Boxes and indicators ('Rate Cycles' and '% Cycles') that are used configure the disturbances.  The value set for each of these is used as the preset value for a counter that counts the number of Wave Cycles that are used for each table value before the index into the associated table is incremented.  The use of Automatic Mode, these two settings combined with the values contained in the tables, can produce complex Process Disturbances as 
shown here

The use of Automatic Mode affects the Process Disturbance and current GPM in the same manner as Manual Mode and the Continuous Variation is applied the same for both Manual and Automatic modes.

The Energy Use Analysis Viewer is displayed by the Checkbox 'Show Energy Data' on the 'PIDFF Example' Operator Screen.

Energy Data is calculated, in the application, by the integration of the PIDFF Output value (assumed equal to Pump Speed) for time periods:  Hourly and Daily.
The time source for the integration periods is linked to TOD Mode; if Disabled then the time is source is the PLC RTC (PC Time if using the Unity Simulator), if Enabled then the time source is the TOD Mode Clock Face Time.  This method of Energy Use Calculation is not an absolutely accurate but, it does provide the ability to compare relative values over two time periods, and included in the Energy Use Analysis Viewer are values for the current period and periods -1 and -2.  There are two options included:  'Pause' and 'Reset' Checkboxes.

Using the TOD Mixed Mode (with a Time Warp = '9') and a Manual Mode for the Process Disturbance, the Energy Data for various PID Tuning values (and other settings like Deadband) can be compared by analyzing the Energy Hourly Data collected in 1 minute of real time execution.  Disabling the TOD Mode at the end of an Hour and the using the 'Pause' option will maintain the last two values of the Hourly data for this analysis. 

Important NOTE:  Except for the above use description, any changes to the TOD Mode or Time Warp Factor will render the Energy Use Data invalid until two complete hours or two complete 24 Hour cycles (depending on which values you wish to compare) have been completed.

The 'Introduction' Operator Screen includes two Checkboxes that cause the execution of a Subroutine (SR).  These Checkboxes are under the heading 'Prepare the Loop for:' and are identified as:  'Auto Tuning at Cold Start' and 'Auto Tuning at Warm Start'.  To understand the meaning of these two phrases, please refer to the Unity Pro Help for the AUTOTUNE EFB.  The executed SR presets several values that insure the successful execution of an Auto Tune (when the default application configuration is set).  If the Tank dimensions or Max Flow settings are modified, then the Auto Tune parameters (step_ampl, tmax and perf) and the Loop Setpoint may require different values than are set by the SR, for an Auto Tune to be successful.

At the successful completion or termination of an Auto Tune cycle, the Auto Tune Diagnostics are automatically displayed.  These are hidden/displayed by the Checkbox 'Show Diags' in the Auto Tune zone of the PIDFF Controller zone on the 'PIDFF Example' Operator Screen.

NOTE:  If the 'Show Energy Data' Checkbox is checked, then the Auto Tune Diagnostics are not visible.