(ST) Embedded function calls

automationMan

Member
Join Date
Mar 2015
Location
Baltimore
Posts
2
Is this possible? I'll use this scenario as an example.

I have a function block that represents the behavior of an I/O card, say a 2 channel thermocouple card, and it has read, write, and configure behavior. so I have a separate read function block and a write function block, etc. Almost any card I use Analog Input cards, outputs cards, etc will use the read, write, configure fb's. So my question is, I want to 'read a value from the thermocouple 2 card',

I would call
<code>
thermo2.read(word);
</code>

is this possible?
 
I don't think the IEC61131 has this, but Beckhoff TwinCAT has a feature called "actions". Each action is a subroutine associated with a POU or an FB and shares the local variables.

So if you have an FB 'Thermo2', you can put all your code that handles reading data inot an action called 'Read' and later call 'Thermo2.Read' elsewhere in the program.

PS Compare this to 'methods' in Visual Basic.
 
The IEC standards are vague and loose, so every platform's implementation of ST is different in capability. However, it is pretty standard to allow function block instances to be part of a structure, so you could have a structure named 'thermo2' and that structure could contain a function block instance named 'read' and you would call it exactly as you have it in your first post.
 
Automation Studio 3.X and above also provides a great ST implementation that I much prefer to Codesys 3 (I've never tried TwinCat 3, but hear good things).

Rockwell's Studio 5000 is the worst I've ever encountered, but there are probably even worse out there. I'd be surprised if you could do what you are trying to do with a Rockwell system.
 
actions are part of the SFC language but they can be implemented in ST.
Shooter and Nettogisen sum things up pretty well.

capinwinky said:
The IEC standards are vague and loose, so every platform's implementation of ST is different in capability. However, it is pretty standard to allow function block instances to be part of a structure, so you could have a structure named 'thermo2' and that structure could contain a function block instance named 'read' and you would call it exactly as you have it in your first post.
errr.
IEC 61161-3 is not a standard, it is a specification.
The IEC specification is pretty specific on how things must work. It isn't specific on how the compiler writer implements the specification.

Allow FB instances inside a structure is something that Siemens does because all the data is in a data block some place. The IEC specification doesn't mention data blocks.

There are a couple extensions that make sense. It is easy to implement a UNION. It wouldn't be too hard to allow one to declare an array of FB instances. True object oriented features would be a lot of work to implement and probably wouldn't get used by most programmers.

I am still working on my ST compiler off and on. I am actually working on function block instances. I am allocating the static memory for each instance within the static data are of the parent function block or program. Functions cannot have function blocks as they have no static data.
 
actions are part of the SFC language but they can be implemented in ST.
Shooter and Nettogisen sum things up pretty well.

capinwinky said:
The IEC standards are vague and loose, so every platform's implementation of ST is different in capability. However, it is pretty standard to allow function block instances to be part of a structure, so you could have a structure named 'thermo2' and that structure could contain a function block instance named 'read' and you would call it exactly as you have it in your first post.
errr.
IEC 61161-3 is not a standard, it is a specification.
The IEC specification is pretty specific on how things must work. It isn't specific on how the compiler writer implements the specification.

Allow FB instances inside a structure is something that Siemens does because all the data is in a data block some place. The IEC specification doesn't mention data blocks.

There are a couple extensions that make sense. It is easy to implement a UNION. It wouldn't be too hard to allow one to declare an array of FB instances. True object oriented features would be a lot of work to implement and probably wouldn't get used by most programmers.

I am still working on my ST compiler off and on. I am actually working on function block instances. I am allocating the static memory for each instance within the static data are of the parent function block or program. Functions cannot have function blocks as they have no static data.
 

Similar Topics

Hi, I'm getting a bunch of these warnings when I build the program in Connected Components Workbench. The program is legacy code. The program...
Replies
5
Views
2,367
Hello everyone! This is my first time posting, though I have been to this site a few times hunting for some random problem like we all do. I...
Replies
4
Views
173
Hi Guys, I have a 1769-L24-QBFCB1 that has the OK light flashing on the embedded counter module. The manual states it is a resettable fault, but...
Replies
0
Views
104
I am using Allen Bradley PLC for Ethernet/IP communication. I send any explicit msg request (Get attribute or Set attribute), I observed packet...
Replies
0
Views
70
Hi everyone, this is my first time trying to setup encoder counts and track the traveled distance and speed i am using L27ERM QBFC1B processor...
Replies
12
Views
385
Back
Top Bottom