Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 5

Programming in IL

Basic instructions in IL: LD (LoaD) the contents of the variable is stored in the memory. LDN (LoaDNot) the inverted status of the variable is stored in the memory. AND is a logic AND function. OR is a logic OR function. ST (STore) the result of the memory is given to the variable following the ST. S (Set) a coil is set R (Reset) a coil is reset. Example: LD Start (Loads the status of the Start button into the memory) AND Stop (performs a logical AND with the status of Stop button, and places the result in the memory) ST L_Work (Loads the result of the memory in L_Work)

DC-B/Holtmann, Martin

Programming in IL

March 8, 2013

Programming in IL
Example: LD Start AND Stop S L_Work If the Start button is released L_work will stay 1. To switch L_Work off the Reset function must be used Example: LDN Stop R L_Work

DC-B/Holtmann, Martin

Programming in IL

March 8, 2013

Programming in IL
NOTE! (*Comment*) (* is the start of a comment. *) is the end of a comment.

Operator LD ST N N

Modifiers

Meaning Loads the (negated) value of the operand into the accumulator. Stores the (negated) content of the accumulator into the operand variable. LD iVar ST iErg

Example

Sets the operand (type BOOL) to TRUE when the content of the accumulator is TRUE.

S bVar1

R AND OR XOR NOT ADD ( N,( N,( N,(

Sets the operand (type BOOL) to FALSE when the content of the accumulator is TRUE . Bitwise AND of the accumulator and the (negated) operand Bitwise OR of the accumulator and the (negated) operand Bitwise exclusive OR of the accumulator and the (negated) operand Bitwise negation of the accumulator's content Addition of accumulator and operand, result is copied to the accumulator .

R bVar1 AND bVar2 OR xVar XOR N,(bVar1,bVar2)

ADD (iVar1,iVar2)

SUB

Subtraction of accumulator and operand, result is copied to the accumulator.

SUB iVar2

MUL

Multiplication of accumulator and operand, result is copied to the accumulator.

MUL iVar2

DIV

Division of accumulator and operand, result is copied to the accumulator.

DIV 44

GT

Check if accumulator is greater than or equal to the operand, result (BOOL) is copied into the accumulator; >= GT 23

GE

Check if accumulator is greater than or equal to the operand, result (BOOL) is copied into the accumulator; >= GE iVar2

EQ

Check if accumulator is equal to the operand, result (BOOL) is copied into the accumulator; =

EQ iVar2

NE

Check if accumulator is not equal to the operand, result (BOOL) is copied into the accumulator; <>

NE iVar1

LE

Check if accumulator is less than or equal to the operand, result (BOOL) is copied into the accumulator; <=

LE 5

LT JMP CAL RET RET

( CN CN

Check if accumulator is less than operand, result (BOOL) is copied into the accumulator; < Unconditional (conditional) jump to the label (Conditional) call of a PROGRAM or FUNCTION_BLOCK (if accumulator is TRUE) Early return of the POU and jump back to the calling POU

LT cVar1 JMPN next CAL prog1 RET RETC

Conditional - if accumulator is TRUE, )early return of the POU and jump back to the calling POU

RET ) DC-B/Holtmann, Martin Programming in IL

CN

Conditional - if accumulator is FALSE )early return of the POU and jump back to the calling POU Evaluate deferred operation March 8, 2013

RETCN

Calling a function block in IL


Example of a counter
Block_5

Bij de variabelen moet de variabele Blok_5 To_Count = defined0 counter CTU Var_1 is the count pulse (CU) Var_2 is the reset puls (RESET) To count (PV) is the preset amount of counts wanted Q is the output of the counter which will go to a state of 1 when the counted pulses is equal to the To_Count Value (CV) is the amount of conted pulses

Value = 0

In the program we write, CAL Block_5 (CU:=Var_1, RESET:=Var_2, PV:= To_Count) The variables must be given a Type. Block_5 : CTU; Var_1: BOOL; Var_2: BOOL; PV: INT; LD Block_5.Q ST Lamp LD Block_5.CV ST Value Lamp: BOOL; Value: INT;
March 8, 2013 4

DC-B/Holtmann, Martin

Programming in IL

Calling a function block in IL


PROGRAM PLC_PRG VAR Block_5: CTU; Var_1: BOOL; Var_2: BOOL; To_Count: INT; Lamp: BOOL; Value: INT; END_VAR (* Programme body: *) LD 5 ST To Count Blok_5 (CU:=Var_1, RESET:=Var_2, PV:= To_Count) LD Block_5.Q ST Lamp LD Block_5.CV ST Value (* When activating the reset the CV will go to 0 and Q will go to a 0 state. *)

DC-B/Holtmann, Martin

Programming in IL

March 8, 2013

You might also like