PROGRAM CONTROL INSTRUCTIONS Instruction Function Description MCR Disable all the rungs in a section of logic JMP, LBL Jump over a section of logic that does not always need to be execu
Trang 1DAY 2
SESSION 3
LADDER LOGIC PROGRAMMING – CONTROL
INSTRUCTIONS
Trang 2PROGRAM CONTROL
INSTRUCTIONS
Instruction Function (Description)
MCR Disable all the rungs in a section of logic
JMP, LBL Jump over a section of logic that does not always need
to be executed JSR, SBR, RET Jump to a separate routine, pass data to the routine,
execute the routine, and return results.
TND Mark a temporary end that halts routine execution.
AFI Disable a rung.
SFR* Reset a sequential function chart (SFC)
Trang 3MCR – MASTER CONTROL RESET
• The MCR instruction, used in pairs, creates a program zone that can
disable all rungs within the MCR instructions.
• When the MCR zone is enabled, the rungs in the MCR zone are scanned
for normal true or false conditions
• When disabled, the controller still scans rungs within an MCR zone, but
scan time is reduced because all the outputs in the zone are disabled.
• When the MCR zone is disabled, the rung-condition-in is false for all the
instructions inside of the MCR zone.
• When you program an MCR zone, note that:
• User must end the zone with an unconditional MCR instruction.
• User cannot nest one MCR zone within another.
• Do not jump into an MCR zone If the zone is false, jumping into the zone
activates the zone from the point to which user jumped to the end of the zone.
• If an MCR zone continues to the end of the routine, user do not have to
program an MCR instruction to end the zone.
Trang 4SAMPLE PROGRAM OF MCR
Trang 5JMP – JUMP DAN LBL – LABEL
• The JMP and LBL instructions skip portions of ladder logic.
• When enabled, the JMP instruction skips to the referenced LBL instruction and
the controller continues executing from there
• When disabled, the JMP instruction does not affect ladder execution.
Trang 6JSR – JUMP TO SUBROUTINE, SBR
– SUBROUTINE, AND RET - RETURN
• The JSR instruction jumps execution to a different routine
• The SBR instruction passes data to and executes a routine
• The RET instruction returns the results.
• The JSR instruction initiates the execution of the specified
routine, which is referred to as a subroutine:
• The subroutine executes one time
• After the subroutine executes, logic execution returns to the
routine that contains the JSR instruction
Trang 7SAMPLE PROGRAM
s c a n
s c a n
Program constant and value are saved in logical address that passed to SBR instruction when JMP being executed to subroutine file
Next, when subroutine finish,
parameter value return to JSR by
RET instructions
Trang 8SUBROUTINE WHICH CONNECTED
There are no restrictions, other than controller memory, on the
number of nested routines user can have, or the number of
parameters user pass or return.
JSR SBR
JSR
RET
SBR
JSR
RET
SBR
RET
Main Program
U:2
U:3 U:4 U:5
Trang 9TND – TEMPORARY END
• The TND instruction acts as a boundary.
• When enabled, the TND instruction lets the controller execute
logic only up to this instruction.
• When enabled, the TND instruction acts as the end of the
routine
• When the controller scans a TND instruction, the controller
moves to the end of the current routine
• If the TND instruction is in a subroutine, control returns to the
calling routine
• If the TND instruction is in a main routine, control returns to
the next program within the current task.
Trang 10SAMPLE PROGRAM OF TND
This rung will be act as
END instruction in the end
of program
If I:000/5 goes true, then
TND will be enable and will
be cause the rest rungs will
not be scanned.
Trang 11AFI – ALWAYS FALSE
• The AFI instruction sets its rung-condition-out to false.
• Use the AFI instruction to temporarily disable a rung while you
are debugging a program.
• When enabled, the AFI disables all the instructions on this
rung.
Trang 12SAMPLE PROGRAM
Always false
Trang 13EOT - END OF TRANSITION
• The EOT instruction returns a Boolean state to an SFC
instruction.
• Because the EOT instruction returns a Boolean state, multiple
SFC routines can share the same routine that contains the
EOT instruction
• If the calling routine is not a transition, the EOT instruction
acts as a TND instruction.
• Sample Program of :
Trang 14UID – USER INTERRUPT DISABLE
The UID instruction and the UIE instruction work together to
prevent a small number of critical rungs from being interrupted
by other tasks.
Sample Program of UID :
Interruptible program
Uninterruptable program
Trang 15SESSION 4
LADDER LOGIC PROGRAMMING – MATH
INSTRUCTIONS