Jump to content
ofer.yishai

Local Timer and Counter inside UDFB

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

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×