News:

  • June 30, 2026, 12:36:58 AM

Login with username, password and session length

Author Topic: GOTO LABEL VS JMP STAGE  (Read 7834 times)

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
GOTO LABEL VS JMP STAGE
« on: February 09, 2015, 01:23:57 PM »
If you have a GOTO - Label 1 and in the rungs after Label 1, there is a GOTO - Label 2 and in the rungs after Label 2 there is a GOTO - label 3, etc.
is it all done in one scan or would it take 3 scans. The same question for JMP Stage.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: GOTO LABEL VS JMP STAGE
« Reply #1 on: February 09, 2015, 02:23:00 PM »
GOTOs are different than JMPs.  Forward GOTOs will always execute in-line when enabled and will set the PLC CPU's program pointer to the LABEL address, and just keep on executing from there.  Backward GOTOs behave similar to how FOR/NEXT, WHILE/WEND, REPEAT/UNTIL backwards looping works, by analyzing the current .TimeSlice and behaving based on those rules.  So it may immediately jump to the LABEL, or it may wait until the next PLC scan do start executing from that LABEL.  Look up .TimeSlice in the Help Search to learn more about backward GOTOs.

JMPs are a different beast altogether.  They just ENABLE/DISABLE stages.  No actual "logic jumping" occurs.  When you JMP to S10 from S0, S0 becomes DISabled, and S10 becomes ENabled.  That means that whenever S10's logic is hit (if it is "below" S0, then on THAT PLC scan, if "above" S0, then on the NEXT PLC scan), it will run.  Since S0 is now DISabled, S0 will NOT run on the NEXT scan.

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
Re: GOTO LABEL VS JMP STAGE
« Reply #2 on: February 10, 2015, 08:04:39 AM »
Thanks for your help Franji1