plc code question from a novice

I don't see "loop:" listed as a opcode.
 
Can someone explain  the code Flow. (when you break out of the loop and where it goes)
 
Thanks again!
 
Just continue asking questions in ONE thread please.  Loop is a label.  It is used with branch and goto.
 
start  -----------power on starts here
   set var1 0 ---
   set op1 0---does all this
 
loop:  
    tsteq op1 1--if true 
    callsub estop -- jumps to here 
   tsteq op2 1
   set op 3 1
  goto loop--does not go to start but goes to loop
                 ---take goto loop out and op1 0 then 
                   program will goto start
end
 
estop:   
     goto loop--goes to loop not start
                          until op1 0
ret
 
hope this helps
 
If you are not sure how each command works, you can start writing a simple program, in different part, you can
 
SET  VAR8  line-number
DELAY  80000
 
In that way, you can see from browser screen where your PLC code is now.  I use 8000 because browser auto refresh is set to 5 seconds.  Once you change the GENERAL tab auto polling on, it will keep refresh the screen.
 
Could you possible implement the "set var8 line number....delay 8000"  in some simple code (turning op1 on - off, etc..) so that I could follow the code.
Sorry for being so novice, but I will learn!
Thanks for the support!
 
Because everyone debug with different method, we probably won't make that the only way to debug.  Besides, VAR8 is one of eight important storage, if we make that only for debug, many advanced users will not be able to use that for other purposes.  Besides, type those lines and experiment with different VARs are a good leaning process.
 
Learning WC PLC is not that hard.  Starting from something simple is a good start.  Because VARs are displayed on the screen, users can easily see value in different process, that is very helpful for debugging your code.
 
Debugging that way is sort of tedious, especially if you are just starting and only have a short program.  You end up with more debugging code lines than actual code lines. 
 
In general, lines are executed in order one line after another until it reaches an instruction that tells it to go somewhere else.  A LABEL is just a placeholder for a branch/goto and will execute as a NOP (do nothing).  A GOTO will jump to the specified LABEL.  END is the same as GOTO START.  CALLSUB is like a combination of a GOTO and a LABEL since it first jumps to a label and then when RET is called jumps back to the line after the CALLSUB.
 
Once you understand that flow, you can look at the conditional operators that begin with TST. 
 
Why don't you post the code you are looking at and your thought process including where you get stuck?
 
How can I add additional TTL ports (op2, op3, op4) with different times, to the code?
 
LOOP:
   TSTGE CH 4 VAR1
    TSTGT CH 21  
    SET VAR1 0  
    TSTEQ VAR1 OP8
    GOTO LOOP
    SET OP8 VAR1
    TSTEQ VAR1 1
    EMAIL  EM1
    TSTEQ VAR1 0
    EMAIL EM2
 
Credit goes to rossw for the code example!
 
Well you can duplicate that code multiple times into subroutines, replacing loop with unique labels and replacing GOTO with RET and also adding a RET at the end of course.  Then you can call all of your subroutines in order from the main program section (between START and END) using CALLSUB with the unique labels.
 
But that may sound like gibberish to you until you have achieved a fundamental understanding of the instruction codes.
 
Back
Top