PGM Introduction

From SysCAD Documentation

Jump to: navigation, search

Navigation: PGMs

Contents

Overview

SysCAD uses the PGM (Programmable Module) language in a number of contexts, mainly in the General Controller Model. A subset of the PGM commands can be used in the PID Controller Model and in SysCAD Trend pages.

The PGM language offers the following facilities:

  • Accessing permissible variables by name within any unit or stream on the flowsheet.
  • Modification of any permissible variables within any unit or stream.
  • Real, integer, Boolean and Bitwise arithmetic.
  • Strings and string manipulation routines.
  • Displaying of PGM local variables at run time and allowing charting of these variables.
  • Can make use of a number of supplied PGM classes, (see Classes).
  • Custom general-purpose functions and classes may be coded.

PGM code is executed once per SysCAD iteration. It allows the user to develop sophisticated programs to control the SysCAD model and to emulate real plant conditions.

Text Editor

The PGM file is a text file in a pre-defined format. It must be created using a text editor or word processor. If a word processor is used, the user must ensure that the file is converted into a text file free of control characters other than the carriage return, tab and line feed characters.

We recommend that you use Notepad++ as the text editor for control files. (Please see Using Notepad++ for more information on installing and setting up this software)

How to create and use PGM file in SysCAD

To Create a PGM file for use in a project, do the following:

  1. In a project, insert a General Controller.
  2. On the access window of the General controller, type in a name for the PGM file.
  3. Press the Edit PGM button to create the new file.

Example -- Blank file auto generated by SysCAD

;--- SysCAD General Controller (PGM) program logic file ---
;--- variable declarations --- 
if (OnInitialise)
  ;--- place logic here for execution before first iteration --- (use SetDynTag in OnInitialise)
else
  ;--- place logic here for normal execution each iteration ---
endif
$
; --- end of file ---

Template file

In build 126 and later, there is the flexibility to allow a template pgm file to be used. This template must be called template.pgm and can be placed in either the CfgFiles folder of the project or the BaseFiles folder of the SysCAD installation. A full installation of SysCAD will include a file called template.pgm in the BaseFiles folder. The user may edit this file to suit. SysCAD will look in the CfgFiles folder first for a template and then the BaseFiles folder if one is not found in the CfgFiles folder.

The same is true for include files. In this case, the template is called template.inc.pgm.

Personal tools
Document Sections