timboekhorst Posted August 2, 2023 Report Share Posted August 2, 2023 Controller: US7-B5-T24, Unilogic When the PackML states "Execute," "Completing," and "Completed" are active, the function EM10 M1100 is invoked. Inside the function M1100, there is a TA timer (stage timer) that becomes active during specific steps in the program. When the PackML states are not true (not in "Execute," "Completing," or "Completed" states), the timer inside the function stops. However, the problem arises when one of these conditions becomes true again, as the timer appears to have jumped ahead, as if it had never stopped in the first place. Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted August 2, 2023 MVP 2023 Report Share Posted August 2, 2023 Let us know if "Stage Timer" is a local or a global variable. Putting a timer inside a UDFB is not recommended as the local variables are created and destroyed with the function call. I don't know what's going on in your case. Is "Stage Timer" used anywhere else? I would roll my own global accumulator using an Add block and a system time variable as a pulse. If this function is called in many places you'll have to add code to load and unload the value of the time accumulator in your function. Joe T. Link to comment Share on other sites More sharing options...
timboekhorst Posted August 2, 2023 Author Report Share Posted August 2, 2023 The TA Stage Timer is an Input Variable in the UDFB, which is linked to a Global Variable. The reason to make it globally is indeed to preserve its value. The Stage Timer is only used in this function. Example situation: Step 1: PackML State Execute: Func call M1100: Timer starts counting down (preset 00:30:00:000). Step 2: PackML State Hold: Func M1100 is not active anymore. Looking at a global variable list the timer is stopped (example time: 00:28:21:532). Step 3: PackML State Execute active again after two minutes, meaning Func M1100 is also active. The timer jumps to 00:26:21:532) and continues counting down. Any ideas? Link to comment Share on other sites More sharing options...
ORSO2001 Posted August 3, 2023 Report Share Posted August 3, 2023 hi timboekhorst, seems strange...or better I never had problem with timers like you described...in my opinion you have to perform some debugs like: check if the "current" variable of your timer is call somewhere in the program insert one or more "activation counter" in the same row where your UDFB is called...to be sure that BITs command are not flikering for some reasons. Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 3, 2023 Report Share Posted August 3, 2023 I tested it and you are right. In my opinion, this is a bug . @Saragani Can you check it? I haven´t used TA in UDFB before, only TD or counters in ms, the last method to be able to pass "timers" to the UDFB when input parameter is a struct. If possible, call the functions without conditions. Link to comment Share on other sites More sharing options...
ORSO2001 Posted August 3, 2023 Report Share Posted August 3, 2023 I also did a test...with USP-070-x10/x08 and Unilogic App 1.33.348 and when i use a timer inside a UDFB it works as described by timboekhorst. then i downgrade at version 1.26.90 and the problem still be present...also if the timer is managed as FunctionIn variable, so inside the UDFB i have a local timer, the counter still count...and every timer works in the same way...for example the TON doesn't restart when the RLO is off...with the timer in the main function block all seems works fine. hope that is helpful for the debug... Link to comment Share on other sites More sharing options...
timboekhorst Posted August 9, 2023 Author Report Share Posted August 9, 2023 Thank you all for your input. How about retaining (in a different variable) the final timer output (TIMER.Current) when transitioning from the state? Then, when the state resumes, reinserting it into the timer (TIMER.Current)? Link to comment Share on other sites More sharing options...
Saragani Posted August 9, 2023 Report Share Posted August 9, 2023 I'm sorry, bug I'm not seeing the attached images, so I don't know what it's about. As far as I remember, Timers must be ran on the main Routine. Link to comment Share on other sites More sharing options...
timboekhorst Posted August 9, 2023 Author Report Share Posted August 9, 2023 @Saragani Please see links: (edited by Aus so links work) https://i.ibb.co/1KJvrrc/Knipsel1.png https://i.ibb.co/hMQwVfj/Knipsel2.png Link to comment Share on other sites More sharing options...
timboekhorst Posted August 9, 2023 Author Report Share Posted August 9, 2023 @Saragani Thank you for your suggestion. Implementing the timer function within the MAIN function did indeed accomplish the task effectively. While I tend to lean towards keeping the conditions and timer within the actual function for structural reasons, for now it does the job. Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted August 9, 2023 MVP 2023 Report Share Posted August 9, 2023 2 hours ago, timboekhorst said: Please see links: 1) https://i.ibb.co/1KJvrrc/Knipsel1.png & 2) https://i.ibb.co/hMQwVfj/Knipsel2.png These links don't work. Shall I delete the post? Joe Tauser Link to comment Share on other sites More sharing options...
MVP 2023 Ausman Posted August 9, 2023 MVP 2023 Report Share Posted August 9, 2023 8 hours ago, Joe Tauser said: These links don't work. Shall I delete the post? The "g" in png was not being automatically included in clicking the links. I've now edited the originals so that they work ok. 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