PMAC Product Guide To write to the array, M-Variables must be used. An M-Variable defined to the corresponding P-Variable address will allow changing any P-Variable and therefore the contents of the array. Example: Values 31 to 40 will be assigned to variables P1 through P10 M34->L:$1001 ; Address location of P1 M35->Y:$BC22,0,16 ; Definition word of M34 OPEN PLC 15 CLEAR P100=31 WHILE (P100!>40) ; From 31 to 40 M34=P100 ; Value is written to the array P100=P100+1 ; Next value M35=M35+1 ; Next Array position (next P-variable) ENDWHILE DISABLEPLC15 ; This PLC runs only once CLOSE ENA PLC15 ; Enable the PLC.
Make sure I5 is either 2 or 3 P1..10 ; List the values of P1 to P10 The same concept applies for Q-Variables and M-Variables arrays although the address range for them is different. Operators PMAC operators work like those in any computer language: they combine values to produce new values. PMAC uses the four standard arithmetic operators: +, -, *, and /. The standard algebraic precedence rules are used: multiply and divide are executed before add and subtract, operations of equal precedence are executed left to right, and operations inside parentheses are executed first.
PMAC also has the % modulo operator which produces the resulting remainder when the value in front of the operator is divided by the value after the operator. Values may be integer or floating point. This operator is useful particularly for dealing with counters and timers that roll over. When the modulo operation is done by a positive value X, the results can range from 0 to X (not including X itself). When the modulo operation is done by a negative value -X, the results can range from -X to X (not including X itself). This negative modulo operation is useful when a register can roll over in either direction. PMAC has three logical operators that do bit-by-bit operations:
& (bit-by-bit AND), | (bit-by-bit OR), and ^ (bit-by- bit EXCLUSIVE OR). If floating-point numbers are used, the operation works on the fractional as well as the integer bits. & has the same precedence as * and / ; | and ^ have the same precedence as + and -. Use of parentheses can override these default precedence. Functions These perform mathematical operations on constants or expressions to yield new values. The general format is: {function name} ({expression}) The available functions are SIN , COS , TAN , ASIN , ACOS , ATAN , ATAN2 , SQRT , LN , EXP , ABS , and INT . Whether the units for the trigonometric functions are degrees or radians is controlled by the global I- Variable I15.
Programming PMAC 49