Table of Contents - TG Drives

Table of Contents - TG Drives Table of Contents - TG Drives

28.11.2012 Views

28 Mnemonic Operators PL2 NATIVE POSITION LANGUAGE > TRUE if shortest way from Argument1 to Argument2 is clockwise. < TRUE if shortest way from Argument1 to Argument2 is counterclockwise. >= TRUE if Argument1 equals Argument2 or if shortest way from Argument1 to Argument2 is clockwise. Shift binary Argument1 to the right by Argument2 steps. AND Bit wise AND of arguments. For IF or WAIT mnemonics: TRUE if result is non-zero. EXOR Bit-wise EXCLUSIVE OR of ARGUMENTS. NOTE: EXOR can be used to perform a NOT function using: Let R10 = Argument1 EXOR -1. MOD Take Argument1 modulo Argument2.Remainder of the division Argument1/Argument2. Example: R0 = 107 mod 10; R0 will be assigned the value 7. OR Bit wise OR of arguments. For IF or WAIT mnemonics, TRUE if result is non-zero. MNEMONIC OPERATORS Op Operator; each statement has its own supported operators (see following). IFcOp One of: = < > = IfOp One of: OR AND = = < > THEN PosOp One of: ABORT ABS INC REL ’MOD ON CLR’’MOD OFF CLR’ ’MOD ON’ ’MOD OFF’ ProfOp One of: ACC THEN Either THEN or , (comma) WcOp One of: = < > = WOp One of: OR AND = = < > (none) LetOp One of: EXOR OR AND > |< |> MOD / * - + MULDIV DIVMUL User's Manual 5.1 Inmotion Technologies AB Doc. No.9032 0027 01 (B), Rev. 11.07.2001

PL2 NATIVE POSITION LANGUAGE SCALING MNEMONIC OPERATORS Compiler Extensions The operation uses full 64-bit precision in the multiplication and division. In the case of an overflow in the result will be ±MAXINT. (2147483647) DIVMUL LET = DIVMUL Arg1= 65536*Arg2 Arg3 MULDIV LET = MULDIV Arg1= Arg2*Arg3 65536 Internal calculations are made with 64 bit arithmetic. The user must handle overflow. Example usage of the MULDIV and DIVMUL operators: ; Assume a 4 pole motor ; If we want to convert one motor revolution into a ; position of 1000 ; calculate the conversion factor r100 = 1000 DIVMUL Motor.PPR r200 = rd1.pos MULDIV r100 disp r200 COMPILER EXTENSIONS [ ] Angle brackets are meta symbols implying that text is optional. addr_of @ An address of operator can be used to obtain the line number for the start of a profile or Program. The ’@’ symbol designates the address of an operator. Example: [Let] R10 = @Profile ;Ex 1. Profile Acc @Profile ;Ex 2 Vector.CycInt = @MyTimProg ;Ex 3. Ex1. Load R10 with the line number where the profile ”Profile” is defined. Ex2. Start the profile ”Profile”. Ex3. Load the vector for cyclic interrupts to point to the interrupt routine ”MyTimProg”. cond_expr A conditional expression used with conditional compilation directives using the form: .if const_expr cond_operator const_expr. const A constant value of type LConst or Sconst const_expr Any expression which result in a constant value. Constant expressions consist of VSymbols, Operator[s] and const. Parentheses can be used to alter the normal operator precedence and associatively rules. .define FOO = 10 / 2 + 1 ; Evaluates to 6 .define BAR = 10 / (2 + 1) ; Evaluates to 3 dyn_expr A dynamic expression which is evaluated during run time. The DMC 2 has the capability of embedding dynamic expressions in its instruction set. Dynamic expression consists of const_expr, User's Manual 5.1 Inmotion Technologies AB Doc. No.9032 0027 01 (B), Rev. 11.07.2001 29

PL2 NATIVE POSITION LANGUAGE<br />

SCALING MNEMONIC OPERATORS<br />

Compiler Extensions<br />

The operation uses full 64-bit precision in the multiplication and division. In the<br />

case <strong>of</strong> an overflow in the result will be ±MAXINT. (2147483647)<br />

DIVMUL LET = DIVMUL <br />

Arg1= 65536*Arg2<br />

Arg3<br />

MULDIV LET = MULDIV <br />

Arg1= Arg2*Arg3<br />

65536<br />

Internal calculations are made with 64 bit arithmetic. The user must handle<br />

overflow.<br />

Example usage <strong>of</strong> the MULDIV and DIVMUL operators:<br />

; Assume a 4 pole motor<br />

; If we want to convert one motor revolution into a<br />

; position <strong>of</strong> 1000<br />

; calculate the conversion factor<br />

r100 = 1000 DIVMUL Motor.PPR<br />

<br />

r200 = rd1.pos MULDIV r100<br />

disp r200<br />

COMPILER EXTENSIONS<br />

[ ] Angle brackets are meta symbols implying that text is optional.<br />

addr_<strong>of</strong> @ An address <strong>of</strong> operator can be used to obtain the line number<br />

for the start <strong>of</strong> a pr<strong>of</strong>ile or Program. The ’@’ symbol<br />

designates the address <strong>of</strong> an operator. Example:<br />

[Let] R10 = @Pr<strong>of</strong>ile ;Ex 1.<br />

Pr<strong>of</strong>ile Acc @Pr<strong>of</strong>ile ;Ex 2<br />

Vector.CycInt = @MyTimProg ;Ex 3.<br />

Ex1. Load R10 with the line number where the pr<strong>of</strong>ile ”Pr<strong>of</strong>ile”<br />

is defined.<br />

Ex2. Start the pr<strong>of</strong>ile ”Pr<strong>of</strong>ile”.<br />

Ex3. Load the vector for cyclic interrupts to point to the<br />

interrupt routine ”MyTimProg”.<br />

cond_expr A conditional expression used with conditional compilation<br />

directives using the form:<br />

.if const_expr cond_operator const_expr.<br />

const A constant value <strong>of</strong> type LConst or Sconst<br />

const_expr Any expression which result in a constant value. Constant<br />

expressions consist <strong>of</strong> VSymbols, Operator[s] and const.<br />

Parentheses can be used to alter the normal operator<br />

precedence and associatively rules.<br />

.define FOO = 10 / 2 + 1 ; Evaluates to 6<br />

.define BAR = 10 / (2 + 1) ; Evaluates to 3<br />

dyn_expr A dynamic expression which is evaluated during run time. The<br />

DMC 2 has the capability <strong>of</strong> embedding dynamic expressions in<br />

its instruction set. Dynamic expression consists <strong>of</strong> const_expr,<br />

User's Manual 5.1 Inmotion Technologies AB<br />

Doc. No.9032 0027 01 (B), Rev. 11.07.2001<br />

29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!