PPCL Programs
This section discusses the following topics:
After you complete the process of planning the PPCL program, you can start writing program code for each of the modes by entering the PPCL program lines into the Program Editor. Start with one mode, and code the solution.
Keep in mind that multiple PPCL programs can be run in a single field panel. This allows you to reduce the size of a large program by dividing it into smaller modules of program functionality. You can then run a separate program for each module. Each program in the field panel will have its own set of line numbers, resident points, and local variables.
For more information on the program language and PPCL syntax, see the Powers Process Control Language User’s Manual (125-1896).
When you save the program, the Program Editor compiles the program statements into an executable control program. During compilation, the compiler automatically checks each PPCL statement for correct syntax. If the compiler finds an error, an error message displays in the Output section, and the program changes are not saved. To locate the error in the program code, double-click on the error. The cursor moves to the start of the program line where the error occurred. You can then make any necessary changes to correct the error.
Before saving the program, you can compile the entire program to check for correct syntax. You can also compile just one program line in order to check its syntax without having to compile the entire program.
Common Compiler Errors
The common compiler errors are described below.
- backwards GOTO found. With the exception of the last GOTO in the program, there was a GOTO found that refers to an earlier line number.
- error found in conditional portion of IF statement. A condition represented in an IF statement is improperly constructed. Examine and restructure the program line.
- GOTO or GOSUB line # is not an integer. A GOTO or GOSUB statement must transfer program control to a valid line number that is an integer from 1 to 32,767.
- GOTO references a non-existent statement. A GOTO statement is referencing a line number that doesn't exist.
- invalid SAMPLE statement. The program line has an improperly used or constructed SAMPLE statement.
- invalid statement type found in optab.
- invalid use of statement in nested function. Improper nesting of a controller or IF statement. Examine and restructure the program line.
- leading parenthesis not found on control statement. The parenthesis at the beginning of the expression in the control statement is missing.
- leading parenthesis not found on IF statement. The parenthesis at the beginning of the expression in the IF statement is missing.
- mismatched parenthesis. The number of opening parentheses is not equal to the number of closing parentheses in the program line.
- more than 16 operands needed. Too many operands in the statement. A total of 16 operands can be used in one PPCL statement. Each additional point reference or value constant adds one operand.
- more than 32 operators needed. Too many operators in the statement. A total of 32 operators can be used in one PPCL statement. An expression adds one operator for each arithmetic operator, relational operator, logical operator, point reference, and value constant.
- not enough operands for operation. A statement cannot be executed because an operand is missing. For example, a value may be missing from a calculation.
- not enough operands in repeat operation.
- numeric constant out of range for function. The value of a constant in the program line is outside the permissible value.
- out of range. 0 < line # < 32767. A program line was entered with an invalid line number. Each program statement must begin with a unique line number that is an integer from 1 to 32,767.
- point in another panel. PPCL statement references points in a field panel other than the one the program is saved in.
- syntax error in OIP statement, parenthesis or quotes. The program line has an improperly constructed OIP statement.
- syntax error in sample statement, parenthesis. The program line has an improperly constructed OIP statement.
- unknown error. A program line was not accepted but the field panel cannot determine the specific problem. Examine the line and, if necessary, re-enter the line.
- unknown operand type encountered. The compiler does not recognize an operand in the program line. Verify that the name of the operand is typed correctly.
When you create a new program or make changes to an existing program in the PPCL Editor and successfully compile and save the program, changes are automatically downloaded to the field panel.
How long it takes to download a program depends on the number of statements in the program.
If program changes are made at the field panel, the changes are automatically uploaded to the management station when the program is saved at the field panel. You do not need to coldstart the field panel in order for program changes to take effect.
Before enabling program statements, test the program code to verify that the program works properly under a variety of operating conditions. Tests should be developed in which you test individual modes or small sections of code, one at a time, until the entire program is tested.
When a program is tested, the data used should adequately test all conditions that the program may encounter. Test conditions not only include testing the range at which an input responds, but also testing values outside the range of response. If an input is defined to accept values from 50 degrees Fahrenheit to 70 degrees Fahrenheit, use an input value of 40 degrees Fahrenheit to find out how the system responds. If the program turns a point ON, find out what happens when you turn it OFF. Test how your program will react if a sensor or fan motor would fail.
When you use values that are not expected to be encountered by the program, you discover how the program processes errors. The precautions you take in programming and testing can save you downtime when the system encounters unusual operating conditions.
When you modify PPCL code, you should clear trace bits from the previous PPCL code to ensure that the program runs properly. Clearing trace bits helps you to follow the flow of PPCL execution. With trace bits cleared and PPCL code displayed, you can determine if certain statements are being executed or bypassed. This is a useful tool for debugging PPCL code. For the procedure, see Clearing Trace Bits.
After you have written and tested a program, the final step is to create program documentation. You should include documentation that details the functions and the equipment controlled by the program. Below are examples of program documentation.
- Comment lines within the program code
- Flowcharts, decision tables, and pseudocode that show a sequence of operation
- Printout of the PPCL program (you must copy and paste the program to any text editor and then print)