Well Test - SCADAPack 47xi
For this demo, the automation piece is a Remote Connect project. The project has a single task which runs at 200 ms with two structured text programs in that task. The entire project is available for download from the Well Test - Downloads section. The project sections are described in detail below.

Remote Connect Logic
Remote Connect Objects
The project includes Remote Connect objects for each PLC Shift app, plus control, configuration and status objects. Each type of object is organized into its own object browser.
-
The WT_CFG group holds tags for uploading a new well configuration to the app.
-
The WT_CNTRL group holds tags to control the Well Test application, including tags to start and stop tests, switch between manual and auto modes, and select the well on test.
-
The WT_STATUS group holds tags that show the status of the Well Test application.
-
GF01, LF01, and WT01 are groups created from objects that are imported from PLC Shift Manager. Each group has objects for one app. Many objects are including in the export, but only a subset of objects are used in the logic.

Object and Browser Configuration
Well Test Configuration
The 'WellTest' structured text program contains five hard coded well configurations. This makes it easy to test the program, and to get started, but it is not useful for a real application. In a real well testing application, it's important to be able to load well configurations from an external source, like SCADA or a local HMI.
Use the tags in this section to load a new configuration into the program. First set the configuration to update using the 'WellTest_cfg_CfgToUpdate' tag. Internally, the program has an array of 32 well configurations allocated, so this number must be between 1 and 32. Next, set the configuration values as needed. Finally, set the 'WellTest_Cfg_UpdateCfg' tag to true. When the ST program sees this value as true, it will move the configuration values from the objects into the group in the right structures in the internal array.

Configuration Objects
Well Test Control
Use tags in this group to control the well test application.
-
The 'WellTest_Control_ManualAutoMode' tag is used to choose between Manual and Auto modes. 0 = Manual mode and 1 = Auto mode. In Manual mode, the well on test is selected by the user and well tests are started manually. In automatic mode, the program will cycle through all the configured wells automatically, and put the next well on test when the current test is complete.

Control Objects
-
The 'WellTest_Control_WellOnTestIn' tag is used to select the well on test. This is only needed in Manual mode.
-
The 'WellTest_Control_StartTest' tag is used to start a well test when in Manual mode.
-
The 'WellTest_Control_StopTest' tag is used to stop a test when in Manual mode. Note that a stop command will always take priority over a start command if both are set at the same time.
Well Test Status
Use tags in these groups to see that status of the well test application. Note that each flow run provides comprehensive status information and this group only shows a small subset of the available information. For example, previous tests results are not shown, even though they are available from the flow computers in the form of batch history tags.Status Objects
Logic
The MAST task is set to execute every 200ms and contains two programs. Programs are divided into Program Units so that local variables from each program aren't mixed together. Each program does read and write to global variables from Remote Connect, however.
Simulate Inputs
The 'SimulateInputs' program is used to simulate inputs to the flow computers so that real IO is not required to start. This program should be deleted in a real system.
Well Test
The 'WellTest' program is the main program for this demo. This is where we actually control the well test. This program has a few different sections, which are explained at a high level below.
Well Configurations
At the bottom of WellTest there is a large chunk of code that defines configurations for 5 different wells. These are populated into the 'WellConfigurations' variable when the 'LoadConfigurations' variable is set. Note that the configuration for well 3, at index 2, has an invalid gas composition. The sum of the hexanes+ components is out of range for AGA 8 1994. This is used to show what happens when the configuration of a flow run fails validation.
The configuration for well 3, at index 2, is purposefully invalid.
|
When a well test is started, we take the well on test variable from the 'WellTest_Control_WellOnTestIn' tag, which ranges from 1 to 5, subtract 1, to get a number from 0 to 4, and then use that number as an index for the 'WellConfigurations' array to retrieve the configuration for the well on test.
Adding more wells can be done by increasing the size of the 'WellConfigurations' array. This is configured to hold 32 well configurations, but we have only populated 5.
Main State Machine
The bulk of the work for the program is done in the main state machine. This is a large IF THEN ELSE structure that moves between the various states as defined in the 'TestStates' enumeration. The code and the state transitions are well documented, so we won't get into the details here.
Additional Code
Outside of the main state machine, there are various small chunks of helper code.
-
Get Inputs. This code maps external tags into internal variables.
-
Connection State. This code checks that the applications execution counts are always changing. When the counts are changing we can be sure that PLC Shift apps are working and connected to the PLC.
-
Write Outputs. This code moves internal variables to external tags.
-
Copy Configs. This code moves configuration values from external tags into the internal configuration array.
-
Alarms Active. This code determines whether any flow computer alarms and active and if alarms are active, the HMI is updated.