Combining Functions with other Functions
You can combine functions so that the outputs of one function are the inputs of another function. This allows you to create complex Logic programs where the results of one function affect the results of other functions.
In a Function Block Diagram, you can connect the output of one function to an input of another function by drawing the connection in the same way as you would connect a tag to an input.
In an ST Program, you need to declare a function and then include the second function (and its arguments) as one of the arguments for the first function. For example, to use the output of a DIV function as one of the inputs for an ADD function, you need to use this syntax:
Output := ADD (DIV (A, B), C)
Where Output is a variable defined earlier in the program, A and B are the arguments for the DIV function, and C is the second argument for the ADD function. So the ADD function uses the output of A/B as Input 1 and C as Input 2:
Example:
- Output := ADD (DIV (10, 5), 20)
In this case, ADD uses 2 as Input 1 (10/5=2) and 20 as Input 2, so the ADD function outputs 22.
The only limitation with combining inputs and outputs is that the output from one function needs to be of the data type that is required by the input of another function. So, if a function outputs a Boolean value, it can only be used as the input for a function that requires a Boolean input (unless a conversion is used).