FC parameters - different behaviour reported

L D[AR2P#0.0]

Lifetime Supporting Member
Join Date
Nov 2006
Location
UK
Posts
6,693
The following code snippet was recently posted by Amr Hassan with a query about why the two calls sometimes behaved differently.

Code:
opn db1

Call fc1
input1: dbx0.0
input2: dbx0.1

call fc1
input1: db1.dbx0.0
input2 : db1.dbx0.1
There is a fundamental difference between these two calls that may not give the results expected, but, they will always give predictable results.

input1 and input2 are boolean parameters

Method 1 passes DBX0.0 (and DBX0.1) as the actual parameters. This means that when the parameter is referenced inside the FC, DBX0.0 is accessed in the global Data block that is open prior to executing the instruction.

Code:
A input1

Executes essentially as follows:

Code:
LAR1 P#DBX0.0
A [AR1,P#0.0]

Method 2 however, cannot pass the fully addressed variable DB1.DBX0.0 as a parameter, so the editor assigns the value of DB1.DBX0.0 to a local temp and passes the local temp as a parameter.
This means that when the parameter is referenced inside the FC, the code uses the value of DB1.DBX0.0 assigned to the local variable before the call is executed. In this case it does not matter which global data block is open when the input parameter is accessed, or if the value of DB1.DBX0.0 is modified in between calling the block and executing the parameter access inside the FC.

Code:
A input1

Executes essentially as follows (i've chosen L20.0 as an example local temp address). The V area is the temp local data area of the calling block.

Code:
//before the call to the FC
OPN DB1
A DBX0.0
= L20.0
//then in the FC
LAR1 P#20.0
A V[AR1,P#0.0]
 

Similar Topics

I am looking for the best way to store and recall parameters for several hundred different jobs for a machine control. Each job will only have...
Replies
15
Views
6,801
I need to call a IO LINK functional block multiple times by triggereing the REQ bit. But every call I want to pass different parameters like...
Replies
15
Views
8,665
Hi, In our two similar machines we are using two VFD's for same application. Those are Hitachi and Omron, these two VFD ratings are same i'e. 1.5...
Replies
15
Views
6,229
Hi everyone, i have an issue with saving a changed value in an AOI, I am using L84E, Everytime i try to save my work to SD card, the program lost...
Replies
1
Views
90
I'm using FactoryTalk ME version 13. I'm aware how to pass a parameter file once, but I was wondering if it is possible to do it twice...
Replies
4
Views
154
Back
Top Bottom