steliosliv Posted November 19, 2021 Report Share Posted November 19, 2021 Hello everyone, Recently, I have started using the Unilogic program. I was familiar with TIA portal from siemens and I have some questions regarding the functions in Unilogic. 1) Is it possible to refer to the input or output of a function? For example, in TIA portal if the function is call calc the input is x and the output is y, you can use the variables directly by typing calc.x and calc.y. 2) Is there is a way to insert a contact or a series of contacts into the input of a function (as seen in the picture attached) without the need of an auxiliary coil? 3) If I call the same function multiple times is there a way to name each function call differently? For example in siemens if you called the function calc twice you could name the functions calc1 and calc2 and easily access the inputs outputs by typing calc1.input/output/local variable or calc2.input/output/local variable 4) Since you cannot insert a timer locally in a function you have to assign it globally. Let's say I want to call twice a function which uses a timer. Can I somehow use the same function in order to make two calls or I have to make two functions which are exactly the same except the timer. This is not a problem when you use the function a few times, but it is a waste of time when you have tens of calls to the same function. 5) I have read in the help file that there is a limit to the inputs/outputs of a function and that limit is 10. For the inputs this in not an obstacle since you can insert a struct as input containing as many variables as you desire. How can you overcome this problem with the outputs since you cannot assign a struct as an output in a function? If something needs further explaining please let me know. Thank you Link to comment Share on other sites More sharing options...
ORSO2001 Posted November 19, 2021 Report Share Posted November 19, 2021 hi steliosliv, i will try to anser at your questions...i hope that i will not write wrong informations: 1) no...the UNILOGIC don't manage the UDFB as an object...so doesn't expose the Inputs and Outputs as attributes. 2) no...the Input always needs a variable...could be local or global but doesn't accept the direct "power flow" of contacts. 3) no...by what is wrote at point 1...but obviously you can use the same function many times. 4) you are right...no local timer is managed by the UDFB...you have to use a different strategy...use the "millis counter"...in other thread, in this forum, I already post an example how to use millis. 5) Structs and Arrays are always passed by reference...so also if assigned as Input variable (left side of the UDFB) you can modify the value of their members inside the UDFB...so an Output of this Struct or Array is not needed. 1 Link to comment Share on other sites More sharing options...
steliosliv Posted November 22, 2021 Author Report Share Posted November 22, 2021 Hello, Thank you so much for the fast and on point answers @ORSO2001. I will definitely use the millis counter method. It is a shame that some of the things are not available in the language. But each language is different. I will get used to it and try to implement other strategies. Cheers Link to comment Share on other sites More sharing options...
curtharrington1 Posted January 11, 2022 Report Share Posted January 11, 2022 You can set an input as a timer, downside is you have to link a global timer tag to the input but it does allow you to "instantiate" the function, it would be better if we could nest structs and pass that in 1 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