Sign in to follow this  
Followers 0
Artz

Hold a "For instruction" for X time

6 posts in this topic

I want to use a For instruction on a rung that changes variables during a specific time. Doesn't matter if it's by ST or LADDER.

Something like:
 

For i := 0 to 5 Do

Variable1 := Struct[i].variable1
Variable2 := Struct[i].variable2
VariableX := Struct[i].variableX
...

TON_instance(IN:=True, PT:=variable_in_seconds, Q=>TimeUp);

<HOLD FOR UNTIL TimeUp := True>

End_For;

 

Share this post


Link to post
Share on other sites
For i := 0 to 5 Do

Variable1 := Struct[i].variable1
Variable2 := Struct[i].variable2
VariableX := Struct[i].variableX
...

TON_instance(IN:=True, PT:=variable_in_seconds, Q=>TimeUp);


; use loop to wait...
REPEAT
 ; do nothing... just wait
UNTIL TimeUp

End_For;

Share this post


Link to post
Share on other sites

Will try that thank you! Does that somehow interrupts the rest of the program or it's totally safe?

Share this post


Link to post
Share on other sites

I would recommend this:

5aa7dff3608c3_TimedForLoop.jpg.a84257d77

Once the ConditionForRunningLoop turns on, the For Loop will run for 5 seconds and then stop.

 

 

Share this post


Link to post
Share on other sites

Careful doing a loop in text.  That loop will in sturctured text will run an infinite number of times and crash the PLC on a watchdog timer.  

ST doesn't process like ladder where it reads it once and moves on.  It's there at the point in the code forever... then crash.

Mr. Walsh has the correct idea...

Share this post


Link to post
Share on other sites

Yup, thank you for the responses, i'm going to try "Michael Wash" method since "panic mode" one did not work as intended.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0