PPCL Guidelines
This section discusses the following topics:
- Match the PPCL program with the sequence of operation. Arrange statements in a logical order so that the program logic flows from the beginning to the end of the program.
- Use modular programming, which is a style of programming that logically organizes code into common functions, such as operational modes.
- Use comment lines to describe each block of program code. The comment lines in a program can help those unfamiliar with the program to understand what functions specific groups of statements perform.
- Use a subroutine when it is more efficient than duplicating sections of straight-line program code.
- When possible, reuse blocks of program code in other devices that require the same control. This helps reduce testing time and minimizes the number of errors in program logic. Since each point must have a unique point name, you must rename the points in the reused program code.
- Do not use a program defined in one device to control PPCL statements or points in another device.
Keep in mind the following guidelines when writing program lines.
- Each program line must begin with a unique line number. A line number can be any integer from 1 to 32,767. Program lines should be initially numbered using multiples of ten (10, 20, 30) or more. This practice provides space between program lines so that lines can be inserted without renumbering the program. You can select the Quick Numbering feature to have the Program Editor automatically number program lines using the line increment that you specify.
- All logical points used in the program must be defined in the field panel. If you enter a point name that does not reside in the field panel, the command line that contains the point will be marked with a "
U
" to indicate it is an unresolved line. - Unless directed otherwise (for example, with GOTO), program lines are executed in ascending numerical order, beginning with the lowest line number and continuing to the next higher line number. It is recommended that routing commands (such as GOTO) transfer program control to a sequentially higher line number. This practice prevents programs from being caught in endless loops.
- The first line of the program should always be executed through every pass of the program. If program execution is interrupted (for example, during a power failure), the system always resumes processing at the first line of the program.
- Time-based commands (for example, LOOP, SAMPLE, TOD, and WAIT) must be evaluated through every pass of the program for proper operation.
Program names should follow the same naming conventions as point names. This includes using a naming hierarchy that breaks the name into sections and moves from global to specific. The program name hierarchy is listed below.
- State (or other geographical location such as country, province, or city)
- Campus
- Building or Department
- Floor, Room, or Area
- Equipment (boiler chiller, air handler)
Each program has a name. Two different programs in your building system cannot have the same name, even if they reside in different field panels.
The program name can contain a maximum of 30 characters, uppercase and lowercase letters, numbers, periods and spaces. You can use any ASCII character except the following: ? * [ ] { } |.
A subroutine is a group of statements that perform a specific task more than once during each pass of the program. If the same operation is performed several times during one pass of the program, you can use a subroutine instead of writing duplicate sections of program code. Every time that particular operation is performed, control is transferred to the subroutine.
Subroutines allow for a smaller amount of program code. In addition, if you need to change the code, you can change the code at one place rather than having to search for multiple occurrences of the same code. Subroutines also help set programming standards that define where functionality is placed in the program. If you use an established block of code and you do not change the line numbers, then that subroutine will always be placed in the same location in a program.
In order to get the most use out of a subroutine, you should determine if the subroutine will be accessed enough times through one pass of the program. The following table helps you determine when it is beneficial to use a subroutine. To use the table, determine how many lines of code a subroutine will contain (excluding the RETURN statement) and how many times it will be called through one pass of the program. If the result is NO, then it is more efficient not to use a subroutine. If the result is EVEN, then there is no benefit for either method. If the result is YES, then it is more efficient to use a subroutine.
Subroutine | 1 Line | 2 Lines | 3 Lines | 4 Lines + |
1 Call | No | No | No | No |
2 Calls | No | No | Even | Yes |
3 Calls | No | No | Yes | Yes |
4 Calls + | No | Yes | Yes | Yes |
To reduce the amount of typing in the Program Editor, you can use the DEFINE command to act as a shorthand for the system name.
For the point Bld01.Ahu01.RAF, the example below uses A01 to represent the Bld01.Ahu01 part of the name in the program.
00230 DEFINE(A01,Bld01.Ahu01)
00240 IF (SECND1 .GT. 15) THEN ON ("%A01%.RAF") ELSE OFF ("%A01%.RAF")
Using the DEFINE command saves you time because you can enter fewer characters whenever you use the name of a point in a PPCL statement. When the program compiles, %A01% is substituted with the text string it represents (Bld01.Ahu01), thus forming the complete system name.
A comment line is information that is written into the program but is not interpreted as a program command. The compiler will skip over the comment line during compilation. It is recommended that you use comment lines to describe the functionality of sections of code. Comment lines are especially helpful for describing subroutines and areas of program code that are difficult to understand.
To enter a comment line in a program, enter a program line number followed by the letter C
to identify the comment and then at least one tab or space. It is recommended that you develop and use a line numbering scheme for comment lines (for example, all comment lines could be odd-numbered lines).
Example Comment Line
00035 C This section of the program handles subroutines.