Artz Posted March 13, 2018 Report Posted March 13, 2018 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;
panic mode Posted March 13, 2018 Report Posted March 13, 2018 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;
Artz Posted March 13, 2018 Author Report Posted March 13, 2018 Will try that thank you! Does that somehow interrupts the rest of the program or it's totally safe?
Michael Walsh Posted March 13, 2018 Report Posted March 13, 2018 I would recommend this: Once the ConditionForRunningLoop turns on, the For Loop will run for 5 seconds and then stop.
Crossbow Posted March 13, 2018 Report Posted March 13, 2018 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...
Artz Posted March 14, 2018 Author Report Posted March 14, 2018 Yup, thank you for the responses, i'm going to try "Michael Wash" method since "panic mode" one did not work as intended.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now