Jump to content

Is this as expected in ladder function?


bjarni

Recommended Posts

Hello, I'm considering what is the scope of the Positive Transition Event in the program.  I thought it was supposed to stay on for one pass to the whole - but maybe that's not correct?

In this example I'm catching the 100ms frequency and I'm checking it in a function which I call twice with different parameters - but the event only stays on in the first call to the function:

image.png.e284f82f0571bb598c42935d1754e55c.png

and in this case the TestFunc is only: 

image.png.8358cb60f74575d37bf70d4761066ba0.png

(N is the "Out" parameter)

Is this as it is supposed to be?

 

Thanks, Bjarni 

 

 

 

Link to comment
Share on other sites

you are calling the same function twice...I think that, in this case, the Frequecncy.Frequency1ms is consider as a static variable in this function...then its status will be propagted in the other calls after the first call...

if you try the same but with two different function (UDFB) its will works...

Link to comment
Share on other sites

18 hours ago, ORSO2001 said:

you are calling the same function twice...I think that, in this case, the Frequecncy.Frequency1ms is consider as a static variable in this function...then its status will be propagted in the other calls after the first call...

if you try the same but with two different function (UDFB) its will works...

Yes, I know now :) - but it would be awkward to write the same function twice - just to catch this event.   Instead I made an global event or bit which is ON for one scan through the whole by putting this in the beginning in my Main:  
image.png.e7f56caa21f1dc2594fbbf41aa484619.png

Link to comment
Share on other sites

2 hours ago, bobnorway said:

a good rule is to make your pulse to a flag bit,  Px -> M123

then the flag M123 will be the same for all of your program code.

using a frequency function several places in the code could be a problem because it is asynchronous

and can change during your program execution.

👍 Exactly!

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