ct8356

How to use a timer inside a function block?

5 posts in this topic

I created a timer inside a function block, as you would inside a normal section. (I gave it number 0001 and put a #20 inside). I then created a contact inside the function block, typing in t1 (which usually works in a normal section), however, in the FB it does not recognise it (the contact label remains red). What do I need to do to make it work? I am using the CJ2M controller.

Share this post


Link to post
Share on other sites
You have to create a timer variable with a name. You have to do this for every memory address inside a function block. Just like you cannot use D0 directly inside a MOV instruction inside a function block (You would have to create a variable name and then use AT functionality to do so). Then use the name for the timer number and the timer contacts, like this:
1 person likes this

Share this post


Link to post
Share on other sites

Hello @Michael Walsh.. I am trying to put a timer inside function block and I have attached the code with this post. I don't think the program is scanning or going into the FB when I simulate. I tried google to check for the AT functionality that you mentioned, but no luck. Can you pls help?

Regards,

P23

2.JPG

1.JPG

Share this post


Link to post
Share on other sites

Looking at your code, your coffee_stop bit will only turn off for 1 scan.  It will then immediately turn back on and the timer will start timing again.  The problem is not the timer in side the FB, but the code as written.

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