4 posts in this topic

Hello,

 I am trying to define a struct as an input variable for a Function or Function Block.
For example the function AddDelimiter (This is a standard Sysmac function), has a input variable with the variable type Struct, an it is possible to couple a struct to this input (See picture below).

5a93d825ee135_StructAsInput.PNG.9844c9bc

If i try to make my own function block with a struct or Structure as an input data type, i get the following error (See picture below).

5a93d98250821_StructAsInputerror.thumb.P

When I try to define a struct from the data types (In this case struct: Test) it doesn't give a error.5a93da3d3ffc2_TestStructinput.PNG.459678

But when I try to couple a struct to this input, that is a layer deeper than the function block struct i get the following error (See picture below).5a93dab4cfc35_TestStructinputerror.PNG.9

How can i define a struct as an function/ function block input?

Thanks in advance.

Share this post


Link to post
Share on other sites
1 hour ago, Alex Teeuwen said:

But when I try to couple a struct to this input, that is a layer deeper than the function block struct i get the following error (See picture below).5a93dab4cfc35_TestStructinputerror.PNG.9

How can i define a struct as an function/ function block input?

Thanks in advance.

Hi, your problem here is that you are defining two different datatypes. One is Test_Struct and one is Test_Struct1.

Your FB Input (the Input_Structuur) requires Test_Struct datatype, but you give it Test.Test1 variable which has a datatype of Test_Struct1.
That's why the error pops up.

I'm just assuming here, that you are having a variable called Test whose datatype is Test_Struct, and it has a member Test1 whose datatype is Test_Struct1.
In that case you just need to put Test as the input of your FB.

 

1 hour ago, Alex Teeuwen said:

If i try to make my own function block with a struct or Structure as an input data type, i get the following error (See picture below).

5a93d98250821_StructAsInputerror.thumb.P

For a user-defined Functions / Function Blocks, you cannot use the elementary STRUCT as the datatype. This functionality is only for Omron's premade libraries. You need to specify a certain Structure name for your FB Inputs/Outputs.
Should you export this function block later on for different project, this Struct Datatype information will be carried along in the namespace of the FB.

Edited by innoaloe

Share this post


Link to post
Share on other sites

Dear Innoaloe,

 Thanks for your reply.

 I know that i coupled the wrong variable to my function block, I wanted to test if a nested struct would couple to this input, and that is not the case.
The problem is that I want to be able to couple any struct to my function block, just like the AddDelimiter function, is it possible to create a input with the data type Struct?

Thanks in advance.

Share this post


Link to post
Share on other sites

I explained in the post above already. Basically no, you can't

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now