Dear all,
I have tried to initialize my variables ( init: BOOL := 1; ).
This works the first time I run the program.
If I stop the program and run it again (or if I build again, login and start the program) its not initialized again.
How can I fix this ?
I would like to initialize my variable everytime I start the program.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
Only a hot Reset or a cold Reset intialize variables.
When you build your program, login and start it, it's like a Reset.
I think you have to write a small program to initialize your variables each time you simply run the program.
For exemple :
(GVL declaration)
VAR
xInitialisation_OK :BOOL; (This variable is FALSE each time your PLC start)
END_VAR
(Begin of your program)
IF NOT xInitialisation_OK then (IF xInitialisation_OK is FALSE, it's the first cycle of scrutation)
xvariable1:= ... ; (write the initial value you want )
xvariable2:=... ;
..........
xInitialisation_OK :=TRUE; (Initialization is finish)
END_IF
You can also write this program in a "StartDone" System Event.
BR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear all,
I have tried to initialize my variables ( init: BOOL := 1; ).
This works the first time I run the program.
If I stop the program and run it again (or if I build again, login and start the program) its not initialized again.
How can I fix this ?
I would like to initialize my variable everytime I start the program.
Hello
Only a hot Reset or a cold Reset intialize variables.
When you build your program, login and start it, it's like a Reset.
I think you have to write a small program to initialize your variables each time you simply run the program.
For exemple :
(GVL declaration)
VAR
xInitialisation_OK :BOOL; (This variable is FALSE each time your PLC start)
END_VAR
(Begin of your program)
IF NOT xInitialisation_OK then (IF xInitialisation_OK is FALSE, it's the first cycle of scrutation)
xvariable1:= ... ; (write the initial value you want )
xvariable2:=... ;
..........
xInitialisation_OK :=TRUE; (Initialization is finish)
END_IF
You can also write this program in a "StartDone" System Event.
BR
Thank you !
I have fixed it with the StartDone Event.
Thanks for the reply..
Grz
Thomas