CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Aug 17, 2019 3:39 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: initialize variables
PostPosted: Wed Jan 16, 2019 1:57 pm 
Offline

Joined: Wed Jan 16, 2019 8:33 am
Posts: 2
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.


Top
   
 Post subject: Re: initialize variables
PostPosted: Wed Jan 16, 2019 11:03 pm 
Offline
Frequent User
Frequent User

Joined: Sun Apr 15, 2007 1:18 am
Posts: 163
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 :D


Top
   
 Post subject: Re: initialize variables
PostPosted: Thu Jan 17, 2019 5:31 pm 
Offline

Joined: Wed Jan 16, 2019 8:33 am
Posts: 2
Thank you !

I have fixed it with the StartDone Event.

Thanks for the reply..

Grz
Thomas


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited