Professional Documents
Culture Documents
77
Programming in LD
Retentive assignment
The current result can be assigned to the output
variable retentively. The output will then retain its set
or reset status.
Set
If the current result is 1, the output variable is set,
i. e. is set to 1. The 0 status of the current result has
no effect on the value of the output variable. Setting
is represented by an output symbol with an S in the
middle.
83
Graphical Programming
Languages
Jumps
The use of jump commands is a way of structuring
programs. They enable networks to be skipped
which are only processed occasionally. Jumps can
be executed depending on or irrespective of a
particular binary current result. The jump destination
is always the start of the network, i. e. the beginning
of a program sequence. A jump label must be
specified in addition to the jump symbol. The same
jump label name must be entered in the destination
network next to the network number.
84
Programming in LD
Unconditional jump
The unconditional jump JMP is executed irrespective
of the current result and is only useful in a program
section that is processed occasionally. An uncondi-
tional jump creates an independent network.
Network 0006 of the program shown contains the
02/00 AWB 2700-1306 GB
85
Graphical Programming
Languages
Conditional jump
JMPC: The conditional jump JMPC is executed if the
current result is 1. The current result 0 causes the
program directly behind the jump operation to be
processed.
JMPCN: The conditional jump JMPCN is executed if
the current result is 0. If the current result is 1, the
program is processed directly after the jump
operation. Network 0003 of the program shown on
page 84 executes a jump to network 0007 if the value
of the variable Aggregate in network 0003 is 0.
Returns
Returns enable the program execution in the current
POU to be interrupted and returned to the program
level from which the POU was invoked. Returns can
be executed dependent on or irrespective of the
current result.
Unconditional return
The unconditional return RET is executed irrespec-
tive of the current result. It is only useful in a program
section that is only processed occasionally and
which is not the last network. An unconditional return
starts a separate network.
Conditional return
RETC: The conditional return RETC is executed if the
current result is 1. If the current result is 0, the
program will be processed directly after the return
operation.
02/00 AWB 2700-1306 GB
86
Graphical Programming
Languages
Jump to a label if CR = 0
02/00 AWB 2700-1306 GB
90
Programming in FBD
91
MS_TimeRising
MS_TimeRising
On-Delay Timer, Milliseconds
Meaning of operands
Set Start condition, rising edge
347
Function Blocks
Description
Time diagram
348
Function Blocks
MS_TimeFalling
Off-Delay Timer, Milliseconds
Meaning of operands
Set Start condition, rising edge
344
MS_TimeFalling
Description
Time diagram
345
Function Blocks
S_TimeRising
On-Delay Timer, Seconds
Meaning of operands
Set Start condition, rising edge
424
S_TimeRising
Description
Time diagram
425
S_TimeFalling
S_TimeFalling
Off-Delay Timer, Seconds
Meaning of operands
Set Start condition, rising edge
421
Function Blocks
Description
Time diagram
delayed status 1.
422
TOF
TOF
Off delay
Meaning of operands
IN Start condition
Description
Time diagram
535
TON
TON
On delay
Meaning of operands
IN Start condition
Description
Time diagram
537
TP
TP
Impulse
Meaning of operands
IN Start condition
Description
Time diagram
539
TimeGenerator
TimeGenerator
Pulse generator
Meaning of operands
Set Start condition, rising edge
Time diagram
Description
A rising edge on the Set input transfers the Period
value as period duration T in milliseconds to the
timer. As long as the Set input is 1 the PulseOutput
will then supply an output pulse sequence for the
duration defined on the Period input at a pulse/pause
ratio of 1 : 1.
The period duration can be set at the Period input
06/99 AWB 2700-1306 GB
519
TimePulse
TimePulse
Time pulse
Meaning of operands
Set Start condition, rising edge
Description
Time diagram
521
TimerAlarm
PS 4-200 TimerAlarm
PS 4-300 Alarm function block Time
PS 416
TimerAlarm
BOOL EnableDisable
USINT Mode Error UINT
UINT Predivide CallUpNumber UINT
UINT SetpointValue
ANY_FUNCTION_BLOCK SubRoutine
Meaning of operands
EnableDisable Enable and disable of alarm execution
(0 = Disable, 1 = Enable)
Mode Operating mode (1 = Timer, 2 = Pulse generator)
Predivide Predivider for the counter
SetPointValue Setpoint number pulses
SubRoutine Instance name of the function block called by the
alarm
Error Error messages
CallUpNumber Number of alarm-controlled function block
invocations
Description
The input EnableDisable controls the start of the
counter. The counter is started if this input is set to 1
or TRUE and the function block instance to be called,
Predivide and SetPointValue are accepted and
temporarily saved. The value of CallUpNumber is
reset. The function block is stopped and reset if the
06/99 AWB 2700-1306 GB
523
Function Blocks
PS 4-300 _32Bit_Compare
PS 416 32-bit comparator
Meaning of operands
InputValue1 First comparison value
Description
The _32Bit_Compare function block compares
InputValue1 to InputValue2 to see whether the value
of the number InputValue1 is greater, equal or less
compared with the value of the number InputValue2.
The result of the comparison is indicated by the three
output operands as follows:
Less Equal Greater
InputValue1< InputValue2 1 0 0
InputValue1 = InputValue2 0 1 0
06/99 AWB 2700-1306 GB
216
Function Blocks
PS 4-300 _32BitCounter
PS 416 32-bit up/down counter
Meaning of operands
Forward Up counter pulse, rising edge
Description
The _32BitCounter function block is used for the
upward and downward counting of signals. Each
rising edge on the Forward input operand increments
the counter by one. A rising edge on the Backward
input operand decrements the counter by one. The
06/99 AWB 2700-1306 GB
220
_32BitCounter
VAR RETAIN
Count_parts : _32BitCounter;
END_VAR
VAR
Light_barrier : AT %I0.0.0.0.6 : BOOL;
Quantity : UDINT;
Clear : AT %I0.0.0.0.7 : BOOL;
END_VAR
END_PROGRAM
06/99 AWB 2700-1306 GB
221
CTD
CTD
Down Counter
Meaning of operands
CD Counter pulses, rising edge
PV Initial value
CV Counter status
Description
The function block CTD is used for the down
counting of impulses provided at the input operand
“CD”. The counter is set to “0” when initialised.
The value defined by the operand “PV” is loaded into
the counter as the initial value if the value of the
operand “Load” is “1”.
Each rising edge on the input “CD” is decremented,
i. e. reduced by one.
The output operand “CV” outputs the current
counter value. If the counter value is above the value
“0”, the output operand “Q” has the Boolean value
06/99 AWB 2700-1306 GB
267
Function Blocks
CTU
Up Counter
Meaning of operands
CU Counter pulses, rising edge
PV Counter limit
CV Counter status
Description
The function block CTU is used for the up counting
of impulses provided by the input operand “CU”.
The counter is set to “0” when initialised. Each rising
edge on input “CU” increments the counter, i. e.
increases its value by one.
The counter value can be cleared with the value “1”
at the operand “ReSet”.
The output operand “CV” outputs the current
counter value. If the counter value is below the limit
value “PV”, the output operand “Q” has the Boolean
value “0”. The output “Q” is set to “1” when reaching
06/99 AWB 2700-1306 GB
268