bjarni Posted November 19, 2019 Report Share Posted November 19, 2019 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: and in this case the TestFunc is only: (N is the "Out" parameter) Is this as it is supposed to be? Thanks, Bjarni Link to comment Share on other sites More sharing options...
Saragani Posted November 20, 2019 Report Share Posted November 20, 2019 Yes. Link to comment Share on other sites More sharing options...
ORSO2001 Posted November 20, 2019 Report Share Posted November 20, 2019 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 More sharing options...
bjarni Posted November 21, 2019 Author Report Share Posted November 21, 2019 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: Link to comment Share on other sites More sharing options...
ORSO2001 Posted November 21, 2019 Report Share Posted November 21, 2019 maybe...in the main ladder...use the Frequecncy.Frequency1ms as |P| ... tu arise a "siple coil" -( )- of a global variable; pass this variable as a FunctionIn in your UDFB. Link to comment Share on other sites More sharing options...
bobnorway Posted November 25, 2019 Report Share Posted November 25, 2019 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. Link to comment Share on other sites More sharing options...
bjarni Posted November 25, 2019 Author Report Share Posted November 25, 2019 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now