Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Structured text Programming

2016-04-29
2016-07-20
  • ricardorbinar - 2016-04-29

    Hi, Im new in Structured Text Programming, and Im looking for a JUMP command. What is the code for jump in ST?

     
  • ndzied1 - 2016-04-29

    I don't know if there is a jump and if there is I don't think I would ever use it.

    Within a single POU the way to conditionally run code is to put it into a IF/END_IF block.
    If you want to call another POU as a subroutine then you put the name followed by parenthesis:
    OTHERPOU( parameters);

    PLCs work best when there is a clear line of code execution and Jumps disrupt that.

     
  • jzhvymetal - 2016-04-30

    ricardorbinar,

    All machine programing is based on states. The easiest way to create a state machine in ST is using a case statement. Please understand the example below is only an example to show how you can expand on the idea. The example does not jump states but that is easy to do by changing the step to a different number.

    VAR
       Step:   INT;
       Delay:   TON;
       Enable:   BOOL;
       OUTPUT:   BOOL;
    END_VAR
    CASE Step OF
    0:   (* Wait / Disable*)
       IF Enable THEN
          Step:=10;
       END_IF
    10:     (* TURN ON OUTPUT DELAY 10s)
       OUTPUT:=TRUE;
       Delay(IN:=TRUE, PT:=T#10s);
       IF Delay.Q THEN
          Delay(IN:=FALSE, PT:=T#10s);
          Step:=20;
       END_IF
    20:     (* TURN OFF OUTPUT DELAY 10s)
       OUTPUT:=FALSE;
       Delay(IN:=TRUE, PT:=T#10s);
       IF Delay.Q THEN
          Delay(IN:=FALSE, PT:=T#10s);
          Step:=0;
       END_IF   
    END_CASE
    
     
  • PJE - 2016-05-01

    ricardorbinar hat geschrieben:
    Hi, Im new in Structured Text Programming, and Im looking for a JUMP command. What is the code for jump in ST?

    IF NOT(Jump Condition) THEN

    END_IF

    This is not how I typically program. I tend to implement SFC type code using a state variable and a CASE statement.

    PJE

    Sent from my SM-G900V using Tapatalk

     
  • Anonymous - 2016-05-01

    Originally created by: scott_cunningham

    JUMP is not directly supported in ST. You have RETURN available like in LD, but you have to use IF statements or other techniques. Note that the just released programming guidelines from the PLCopen group recommend not using JUMPs and RETURNS for debugging reasons. I agree and suggest to avoid JUMPS. There are times I like to use returns (at the beginning of a POU - IF NOT Enabled THEN RETURN).

     
  • mkeller - 2016-05-02

    Hi ricardorbinar.

    ricardorbinar hat geschrieben:
    Hi, Im new in Structured Text Programming, and Im looking for a JUMP command. What is the code for jump in ST?

    Look for JMP in the CODESYS online help. Be careful not to build an endless loop!

    BR
    Martin

     

Log in to post a comment.