CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Fri Sep 21, 2018 8:43 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: TON ST Simulation
PostPosted: Thu Mar 08, 2018 4:32 am 
Offline

Joined: Fri Dec 08, 2017 7:25 am
Posts: 5
Hello Team,

Ran into quite a baffling situation.
I am able to easily setup and run a TON timer when using the CFC style of graphic code...
However, I find in certain setups the ST version doesn't function

Is this a limitation of the software? Or a Bug? Or is there something I am missing?
(I am running the code in Simulation, as I have no machine to deploy to at this time.
Both run under the Main task in a PRG POU)

ST Attempt 1 (Simple works correctly)
Code:
VAR
   TON_1 : TON;   
   TimeOut  : BOOL;
   ValueIN : BOOl;
END_VAR

TON_1( IN:= ValueIN, PT:= T#5S);
TimeOut := TON_1.Q;


ST Attempt 2 (Complex, doesn't work)
Code:
VAR
   TON_2 : TON;
   ValueIN : BOOL := TRUE;
   OUT : BOOL;
   Delay : TIME := T#5S;
   

END_VAR



TON_2.PT := Delay;
TON_2.IN := ValueIN;

OUT := TON_2.Q;



TON_2.ET doesn't count up at all, despite TON_2.IN Being TRUE.
I decided to place the TON_2.PT in an init IF statement so it only runs once, and still nothing happened with the timer.

I am curious why this is the case?


Top
   
 Post subject: Re: TON ST Simulation
PostPosted: Thu Mar 08, 2018 6:49 am 
Offline

Joined: Fri Feb 07, 2014 7:21 am
Posts: 81
Hi,
you never call the instance of the timer(you just set the Inputs of the instance)
TON_2();

Regards
plcmax


Top
   
 Post subject: Re: TON ST Simulation
PostPosted: Fri Mar 09, 2018 5:11 am 
Offline

Joined: Fri Dec 08, 2017 7:25 am
Posts: 5
Ah, That makes sense now.
Did some testing with your suggestion.

I now understand that the internal variables are only updated during a call of TON_1().
However, after the first call, the actual timer continues on without the need of TON_1 being called.

So correct me if I am wrong,
but I understand that you only need to call TON_1() twice for a single use of the TON?
Once to start the timer.
Once to update the variables AFTER PT has expired.
However in practice this isn't possible, which is why we check each loop of the program (or use an internal for/while loop) to continuously update the internal variables.


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: learnetk and 2 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