Jump to content

Local Timer and Counter inside UDFB


ofer.yishai

Recommended Posts

Hi all!

I would like to place a local timer in a UDFB, but this option is not available (The timer save key is disable when it is set to local) I guess there is a reason why local timer is not possible...

The option I know is to define the timer as a Function-In , but then i have to connect a different global timer on each of the UDFB instances, and in case there are many of them we miss the concept of UDFB somehow.

So I was trying another option to count seconds on a Local Counter (Inc function to Local INT16 Tag) . The counter pulse come from a Function-In Bit (One scan every 1 second).

The problem with is the counter is not increasing if the tag is local, and it dose very well if the tag is global. This I can see with the latest Unilogic version  that support monitoring UDFB online, very helpful!

Any help regarding timing and counting within UDFB  local tags is welcome.

:) Ofer

 

Link to comment
Share on other sites

You can't use a local timer, since local tag means that it is being created on the stack when you enter the function, and deleted when you exit the function.

This means that it will not count.

The same thing happens with a local int16. Everytime you enter the function, a new int16 is being defined on the stack with a value of 0.

 

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...