Function block - variable number of inputs
I would like to make a function block with a variable number of inputs.
Like with the standard AND operation for example.
Does anyone know how I can achieve this?
It doesn't matter if it has to be in ST of in FBD.
This is not a standard feature of ST or FBD but there is a small hack to achieve this. See the example below. It only works if the input variable is named "in" (the same works for output variable named "out") and the type is array.
FUNCTION InDemo : LINT VAR i : INT; END_VAR VAR_INPUT In : ARRAY[0..63] OF BOOL; END_VAR (*function block's body*) result := 0; FOR i := 0 TO 63 DO // nejaky kod IF In[i] THEN result := result + 1; END_IF; END_FOR; InDemo := result; END_FUNCTION