Hi Tim.
Not quite correct.
What i'd like, is when you place the FB in prog, i choose a block NTC10k, and name this RT401.
What i'm trying to do, is to get the name RT401 automaticly into the FB, so i can put this into the string i pass in a struct.
So in var in POU, i saw this a place i could do this, RT401: NTC10k(Tag:='RT401'), but i can't get this to work.
I shurly must have had something like this in FB:
FUNCTION_BLOCK NTC10k String TAG
But it's here where I'm stuck...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see, you want to initialize the FB.
To be able to initialise it like you described, you need to add the FB_Init method to your FB.
(right click on the FB, select add object --> method).
Then press the arrow down, to select the FB_Init (overwrite default implementation).
In the VAR_INPUT section of this method, add the variable --> Tag : STRING;
Then in the code section of this method add:
THIS^.Tag := Tag; // copy initial value to local variable in FB
Search Google if you want to know more about FB_Init.
Waht im trying to do here is to automatically tag each sensors, valves and so on. There is a preatty nasty tag system i working on.
"_320" is not alloved. I can have a tag "+4f=320.004-RT001V"
In codesys I want to build the FB in folders.
-4f
|
--320
|
--001
This is the system structure.
Inside here is all of the sensors and so on. But with Codesys, I cannot tag this like this.
So what I'm trying to do now is to Make a folder for the building "4f" and one for the system "320", and a POU _001.
Is there a way in init to get folder names?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
inside the fb, use the reflection-attribute and get the instancename includibg whole path.when im right, the applicationname will also reflected, if yes. you have to trim it.
Hi all.
I have a FB written in ST.
What i'm trying to do, is to pass data to structure. In structure i want to add a tag with systemnumber and sensorname.
'320.001-RT401'
In pou i use this RT401: NTC10k;, and tried this RT401: NTC10k(Tag:='RT401');
Anyone done this?
Really not clear what you are trying to do, but isn't a Struct enough?
So add an object of the type DUT to the Application.
Then create a structure
Then in you application add an instance of this Structure
or use it like this
Hi Tim.
Not quite correct.
What i'd like, is when you place the FB in prog, i choose a block NTC10k, and name this RT401.
What i'm trying to do, is to get the name RT401 automaticly into the FB, so i can put this into the string i pass in a struct.
So in var in POU, i saw this a place i could do this, RT401: NTC10k(Tag:='RT401'), but i can't get this to work.
I shurly must have had something like this in FB:
FUNCTION_BLOCK NTC10k String TAG
But it's here where I'm stuck...
I see, you want to initialize the FB.
To be able to initialise it like you described, you need to add the FB_Init method to your FB.
(right click on the FB, select add object --> method).
Then press the arrow down, to select the FB_Init (overwrite default implementation).
In the VAR_INPUT section of this method, add the variable --> Tag : STRING;
Then in the code section of this method add:
THIS^.Tag := Tag; // copy initial value to local variable in FB
Search Google if you want to know more about FB_Init.
PS, reflection + instance path, is also an option if you want to get the full name of the instance (path) of the Function Block.
See: https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html
Thank you so much. This worked.
Waht im trying to do here is to automatically tag each sensors, valves and so on. There is a preatty nasty tag system i working on.
"_320" is not alloved. I can have a tag "+4f=320.004-RT001V"
In codesys I want to build the FB in folders.
-4f
|
--320
|
--001
This is the system structure.
Inside here is all of the sensors and so on. But with Codesys, I cannot tag this like this.
So what I'm trying to do now is to Make a folder for the building "4f" and one for the system "320", and a POU _001.
Is there a way in init to get folder names?
inside the fb, use the reflection-attribute and get the instancename includibg whole path.when im right, the applicationname will also reflected, if yes. you have to trim it.
https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html