User defined function in basic function block [message #1872285] |
Sun, 27 October 2024 10:37 |
Guido Piasenza Messages: 17 Registered: October 2024 |
Junior Member |
|
|
Hello experts,
I am creating a new basic function block and there's some code which is repeated in algorithms (in some cases within the same algorithm, in other cases in different algorithms).
Is there any way to create a user-defined function ? I need to pass parameters and get a return value.
Thanks,
Guido
[Updated on: Sun, 27 October 2024 10:38] Report message to a moderator
|
|
|
Re: User defined function in basic function block [message #1872294 is a reply to message #1872285] |
Sun, 27 October 2024 18:11 |
|
Hi,
you have two options:
1. IEC 61131-3 functions: for methods that you would like to use from different FBs.
2. Methods for FB local methods. You just start with Method methoName : returntype .... END_METHOD. With VAR_INPUT and VAR_OUTPUT you can define your method's interface. Furthermore methods have access to inputs, outputs and internal vars.
|
|
|
|
Re: User defined function in basic function block [message #1872312 is a reply to message #1872297] |
Mon, 28 October 2024 08:19 |
|
The algorithms tab is for entering all textual code of an FB. So there you can enter all algorithms, and methods of a single FB. Given your feedback we may need a better name for that tab. Suggestions are welcome.
In 4diac IDE currently each function is located in an own file. You can create that via New -> Type and then select Function from the template.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04090 seconds