Hello,
A silly question: There any kind of task (event-based) or configuration that allows me to initialize a set of variables before any other task is launched? I need this to ensure that tasks contain their variables correctly initialized before execution. Using an additional variable to signal that they have already been initialized is ugly, I want the rest of the tasks to start only when the initialization task is finished.
Thank you in advance
Hi javierperea,
there are event tasks like cold/warm start.
Cheers
DivisionByZero
Thank you for your response, DivisionByZero, I was unwell and didn’t check your answer until today.
I’m aware of the option to associate a task with the cold/warm start event, but this is not useful for me (I believe).
I need to ensure that a specific program (which will initialize a set of variables) runs before any other program on the PLC. I can use a flag after initializing the variables and then use that flag to start the rest of the programs, but I don’t like that strategy. I was asking if there’s any mechanism in the PLC to do this automatically, meaning:
The initialization task runs, and only after this program concludes, the rest of the programs start operating
Right now, I have something like this:
InitVar program { var1 := 1; var2 := 2; … var.init := TRUE; }
Program1 {
IF (var.init = TRUE) THEN
task1_1(); … task1_N();
END_IF;
}
Program2 {
IF (var.init = TRUE) THEN
task2_1(); … task2_N();
END_IF;
}
ProgramN { …
I want the InitVar program runs before the rest of the programs, automatically. Before “Program1”, “Program2”… Starts, “InitVar program” must finish. Is this possible?
Thank you for your time.
Hi javierperea,
maybe this helps:
Execution order of tasks and programsTasks and programs of non-safety-related controllers are executed according to their priority and condition (task cycle time or user/system event). For the execution order, the following applies:
* If the condition of several tasks is fulfilled, the task with the highest priority is executed first.
* If the condition of several tasks is fulfilled and they have the same priority within the same ESM (one ESM represents one controller core), the execution order of these tasks is unpredictable.
* Tasks with the same priority on different ESMs are executed at the same time / in parallel.
* The execution order of programs that are assigned to the same task is determined by the order they are listed in the table (from top to down).
* So I think it should always be executed first when your Init program is:
of type Event: Cold/Warm start
* has the highest priority
* the topmost program instance in the topmost task
Cheers
DivisionByZero
Thank you for your prompt response, DivisionByZero. Fantastic, it seems that what you suggest works for me.
Many thanks and best regards