Logic and Calculation Engine

Most SCADA/HMI packages support some form of scripting or code for math and calculations but the concerns with using high level languages such as Visual Basic or proprietary language is that the user is required to have specialist programming skills. Even if these skills are available, is the code documented well and readily maintainable by others? ClearSCADA has a unique proposition in this area and offers a built-in IEC 61131-3 logic engine. This programming language is commonly found in PLC/RTU controllers and is an industry standard so it should be familiar to many engineers. ClearSCADA includes 4 out of the 5 programming styles:

Programs built on this logic engine can access real-time data points, historian, event journal and even configuration database so its application is very powerful. You might have an efficiency calculation that is part of a device template, for example a compressor or pump station. Every instance of that template would have exactly the same code so you build once, test and then deploy as many times as you like.

The Structure Text language is procedural and supports SQL queries on the ClearSCADA database. This is useful for alarm analysis such as counting the number of alarms per day per operator for regulatory compliance. Another example would be to total the production volume for a field of wells; it does not matter if you add or remove wells as the SQL query goes across the complete database (or part of database hierarchy) to provide results.

Some examples of IEC 61131-3 logic programs

LogicFBD

TYPE
  Records : STRUCT
    Total : LREAL;
  END_STRUCT;
END_TYPE

PROGRAM VMeter
  VAR_INPUT A : STRING ; END_VAR
 
  VAR
    Query AT %S(SELECT SUM(CurrentValueAsReal) AS "Total" FROM CDBPoint
      WHERE Name = 'PDay Volume')  : RESULTSET OF Records WITH_PARAMS A;
  END_VAR
 
  VAR Result AT %M(.Total Volume.CurrentValue) : LREAL; END_VAR
  Result := Query.Value.Total;
END_PROGRAM

This FBD program takes the 7 day average of production volume and sets the Low alarm limit at 10% below this value and sets the Low Low alarm limit at 20% below. This compensates for slowly degrading production of a gas well and saves the operators continually adjusting the alarm limits. You will notice that the FBD can display real-time values of the points and calculated results.  

This ST program is using an SQL query to totalise all points in the database that has the name 'PDay Volume'