Codesys: Instantiate a VAR_IN_OUT inside the FB?

theColonel26

Lifetime Supporting Member
Join Date
Feb 2014
Location
West Michigan
Posts
785
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 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
157
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
6
Views
314
Hello, I have a requirement to manage the text alignment dynamically. So, for example: 1. English Texts should be displayed from Left in...
Replies
0
Views
98
Hello, I am new to Codesys, and am trying to learn about it for a project we're developing. I've got a couple questions, but first a little...
Replies
1
Views
167
Hi everyone, as this is my first experience with Rockwell Software i would like to know what's the best way to make Enumerations?
Replies
10
Views
522
Back
Top Bottom