Jump to content

How to use a timer inside a function block?


Recommended Posts

Posted
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.

Posted
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:
  • Like 1
Posted

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

Posted

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.

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
×
×
  • Create New...