Twincat v3

plclearner123

Member
Join Date
Apr 2014
Location
stuttgart
Posts
3
Hi,
I am working on a ST code aiming to implement timer functionality inside a function block. I am facing the following problems:
-During the execution, in the Main program a function block(FB) is called and inside the FB another function block (TMR) is called. The timer (TON) is defined inside TMR.
-I observed that when TMR is called from FB,even though the TON.IN is set to true and the PT value is passed, the timer does not start counting(for the required preset time).
The same TMR when called in the Main program yields the required results.
-To better understand the reason behind this, I defined a count variable when the main function calls the timer and when the FB calls the timer.
-While in the case of FB call the count variable stops at 1, in the case of Main program call the count variable keeps incrementing.

NOTE:
The FB is called in the main program based on an IF condition.
I have attached screen shots of the call made from FB and main program, the definition of TMR and the debugging operation.

variable definition TMR function block.png mainprogram.png Timerblock (FB call).jpg FBcall.jpg Timerblock (mainprogram call).jpg
 
oke some basics:
if you call a timer you will set the starttime and the runningtime, you can see this time on the rightlower (EP?) variable running.
so now the timer is running.
however your main program is back on the same line in about 2 ms.
at that time the timer is called again and the runningtime is set to the value you give it.
so only once call the start of a timer, and you are allowed to get the Q value multiple times.
example an eggtimer, if you call it it will be set to 4 minutes, afterwards you only look at if it is expired, if you call it again it will be reset.
and i like my eggs with easter nice and soft.
a better way vfor us when you export only the blocks needed and put them here as a txt file or just inside the message.
 
hi shooter,
I have typed the ST in text and attached it here.
Hope this is better than the pictures. Also I tried to implement the ladder diagram of TMR in ST to be able to copy in text.

regards :)
 
in main program tmr2 is not declared
in tmr epsilon is not declared etc.
avoid to have straight values inside a program, they can not be changed simply, so please have them declared.
please export your program (so i can put it direct in codesys.
 

Similar Topics

Hi! I am trying to run the 'SimpleSample' (https://infosys.beckhoff.com/content/1033/TF5100_TC3_NC_I/Resources/3438746891/.zip ) to understand the...
Replies
2
Views
96
I am developing a library in twincat and one of the function uses IID_ITcVnAccess_TcVnPoint2_DINT and the definition of this type is defined in...
Replies
0
Views
68
Sorry if this has been asked before, and apologies if this seems like a trivial issue, but I am new to Beckhoff and have been banging my head...
Replies
2
Views
141
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
948
I am trying to communicate between a 1769-L16 and a beckhoff EL6652 EtherNet/IP-Master. I need 8 INT and 2 REALS. When I generate the eds file, in...
Replies
1
Views
161
Back
Top Bottom