Jump to content

Recommended Posts

Posted

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;

 


Posted
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;
Posted

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...

Posted

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

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
×
×
  • Create New...