Mapping input/output to FB's

linnemann

Member
Join Date
Aug 2016
Location
Aars
Posts
30
Hi Guys

How do you map the inputs for your machine when using FB's?
btw I'm using Twincat 3/Codesys.

Right now I map all the input/output to global variables and use the input as input to the FB's and the FB outputs sets the global outputs in the main loop.

So ex.

Code:
bIn1 AT %I* : BOOL;
bOut1 AT %Q* : BOOL;

fbTest : FB_TEST;

and then

Code:
fbTest(bIn:=bIn1);
bOut1 := fbTest.bOut;

I have also seen people mapping the in/out directly in the FB's directly.

Code:
FUNCTION_BLOCK FB_TEST
VAR_INPUT
    bIn1 AT %I* : BOOL;
END_VAR
VAR_OUTPUT
    bOut1 AT %Q* : BOOL;
END_VAR
VAR
END_VAR

That way you need to instantiate each FB first to map input to.

I can see positive and negatives in each approach just looking for some best practice from the experts.
 
The latter looks stupid. Seems like someone is using FBs instead of PBs. Each one ends up as a unique FB but you can instantiate each one in the global scope.

If you want to be lazy and access global variables from the FB rather than passing them why not be properly lazy and just use them directly.
 
Hi

Well I'm not trying to be lazy I'm trying to make sure I can reuse the code for the different machines we have and trying to adhere to the most basic of OOP principles.
And no my FB's are not just simple on/off things there are calculation and communication and other things going on, that if I put all that in a big sequential program it will turn into spaghetti and a pain to maintain.

OOP although never (not that I've been able to find) discuss the IO mapping so that's why I'm trying to get at little input.
 

Similar Topics

Hello. I am unable to find information regarding the input mapping for the embedded inputs for the Micrologix 1100. as far as I can tell, inputs...
Replies
1
Views
1,609
When programming in RSLogix 5000, I usually map all my inputs to bits to be used in the program. Since the IO is updated separate from the...
Replies
6
Views
5,144
I have to modify a device net network by adding two nodes(VFDs) to the network.Please advice me how i can map input and output to PLC...
Replies
0
Views
1,673
Dear All, I am currently facing a simple input mapping logic issue. Basically, the input bit function well from the sensor and it trigger...
Replies
11
Views
3,513
Hi everyone, Kind of new at this, so we recently upgraded our 1769-l32e to the newer 5069-L320erm, i converted the file over and Verify the...
Replies
8
Views
398
Back
Top Bottom