Codesys: Instantiate a VAR_IN_OUT inside the FB?

theColonel26

Lifetime Supporting Member
Join Date
Feb 2014
Location
West Michigan
Posts
786
Is it possible to instantiate a VAR_IN_OUT inside the FB?


The VAR_IN_OUT in question is function block that I call inside another function block, but I want to be able to access it outside of the parent FB.



I want to beable to do something like the following at a program level.
Code:
FB_A_Instance1.FB_Child.Setpoint := 123.56;

or am I just going to have to create an instance of FB_Child outside the FB_A and then pass it into FB_A?
 
Is it possible to instantiate a VAR_IN_OUT inside the FB?


The VAR_IN_OUT in question is function block that I call inside another function block, but I want to be able to access it outside of the parent FB.



I want to beable to do something like the following at a program level.
Code:
FB_A_Instance1.FB_Child.Setpoint := 123.56;
or am I just going to have to create an instance of FB_Child outside the FB_A and then pass it into FB_A?


In the Siemens world, we call that a multi-instance FB, where an instance of FB_Child is declared as a STAT of FB_A. Inside FB_a you would access it as #FB_Child_Instance.Setpoint, but you would also have to actually call FB_Child_Instance as an FB somewhere in FB_A.



I would assume Codesys allows that as well, but I have no experience there.
 
Pointer

Myabe you can create an input as a pointer to lreal

VAR_INPUT
i_plrSetpoint : POINTER TO LREAL;
END_VAR


in the program you call it like this:
IF i_plrSetpoint^>100 THEN
;
END_IF

Hope this helps



Is it possible to instantiate a VAR_IN_OUT inside the FB?


The VAR_IN_OUT in question is function block that I call inside another function block, but I want to be able to access it outside of the parent FB.



I want to beable to do something like the following at a program level.
Code:
FB_A_Instance1.FB_Child.Setpoint := 123.56;

or am I just going to have to create an instance of FB_Child outside the FB_A and then pass it into FB_A?
 

Similar Topics

Hello, I would like to execute code saved in initialization FB on the first start of the PLC. It is basically something like OB100 in the Siemens...
Replies
2
Views
30
Hi! What is the way to convert the code from the Codesys code to the Tia Portal? Regards, WK
Replies
0
Views
43
Hello to all, can you please provide an example of obtaining a current working directory as a string in CodeSys? For example, during starting the...
Replies
7
Views
231
Hello to all, I'm just starting with using CodeSys. Immediately, I have noticed that Codesys doesn't use data blocks like for example S7 does...
Replies
11
Views
234
Hello, I am using a Hitachi Micro EHV+ for a small project, and I wanted to have a Web visu, done with Codesys V3.5 SP13 Patch 2. I test the...
Replies
7
Views
454
Back
Top Bottom