Function block - variable number of inputs
-
Hi,
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.Kind regards,
Tom -
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login