Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 15 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
15
Dung lượng
144,92 KB
Nội dung
DAY SESSION 7-1 LADDER LOGIC PROGRAMMING – CONTROL INSTRUCTIONS Ladder Logic Programming – Control Instructions – 10 December 2010 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) UIE*, UID* Disable user tasks EOT End a transition for a sequential function chart Ladder Logic Programming – Control Instructions – 10 December 2010 7-2 PROGRAM CONTROL INSTRUCTIONS MCR – 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: 7-3 • 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 not have to program an MCR instruction to end the zone Ladder Logic Programming – Control Instructions – 10 December 2010 7-4 SAMPLE PROGRAM OF MCR Ladder Logic Programming – Control Instructions – 10 December 2010 JMP – 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 7-5 • Ladder Logic Programming – Control Instructions – 10 December 2010 JSR – 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: 7-6 • The subroutine executes one time • After the subroutine executes, logic execution returns to the routine that contains the JSR instruction Ladder Logic Programming – Control Instructions – 10 December 2010 SAMPLE PROGRAM 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 Ladder Logic Programming – Control Instructions s c a n 7-7 s c a n – 10 December 2010 SUBROUTINE 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 Main Program JSR U:2 SBR SBR U:3 JSR U:4 U:5 JSR RET RET 7-8 RET SBR Ladder Logic Programming – Control Instructions – 10 December 2010 TND – 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 7-9 • If the TND instruction is in a main routine, control returns to the next program within the current task Ladder Logic Programming – Control Instructions – 10 December 2010 7-10 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 Scan Scan SAMPLE PROGRAM OF TND Ladder Logic Programming – Control Instructions – 10 December 2010 AFI – 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 7-11 • When enabled, the AFI disables all the instructions on this rung Ladder Logic Programming – Control Instructions – 10 December 2010 Scan SAMPLE PROGRAM 7-12 Always false Ladder Logic Programming – Control Instructions – 10 December 2010 EOT - 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 7-13 • Sample Program of : Ladder Logic Programming – Control Instructions – 10 December 2010 UID – 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 Interruptible program Ladder Logic Programming – Control Instructions – 10 December 2010 7-14 Uninterruptable program NEXT SESSION 7-15 LADDER LOGIC PROGRAMMING – MATH INSTRUCTIONS Ladder Logic Programming – Control Instructions – 10 December 2010 ... not have to program an MCR instruction to end the zone Ladder Logic Programming – Control Instructions – 10 December 2010 7-4 SAMPLE PROGRAM OF MCR Ladder Logic Programming – Control Instructions. .. Sample Program of UID : Interruptible program Interruptible program Ladder Logic Programming – Control Instructions – 10 December 2010 7-14 Uninterruptable program NEXT SESSION 7-15 LADDER LOGIC PROGRAMMING. .. chart Ladder Logic Programming – Control Instructions – 10 December 2010 7-2 PROGRAM CONTROL INSTRUCTIONS MCR – MASTER CONTROL RESET • The MCR instruction, used in pairs, creates a program zone that