pointer

SHYAMAL

Member
Join Date
Aug 2007
Location
DHAKA, BANGLADESH
Posts
53
Dear Friends,

I have written a function with two pointer parameters - one for input and other for output. Say for example #input_pointer of type pointer and #ouput_pointer of type pointer.

When I call that function from OB1 with the parameter values p#i0.0 and p#DB1.DBX0.0 respectively, it is taking the parameter values without any problem.

But in my function where I have put the codes:

L p##input_pointer
LAR1
.
.
.
.
L p##output_pointer
LAR2
.
.
.
.

I am getting the values in Acc1 16#870000A8 for input pointer
and 16#870000D8 for output pointer. But I am expecting the values - 16#81000000 and 16#84000000 respectively. Where is the actual problem? Please help to identify the problem. Hope there must be somebody who can clarify the matter.

With best regards,

Shyamal
 
In this case you are loading a pointer to a pointer.

Before calling your function, code in OB1 generates the pointers and stores them in the L area of OB1. The parameters to your FC are then assigned pointers to the L area, but are changed to the V area (local data of the calling block).

Your function needs the following to access the pointers:

Code:
L p##input_pointer
LAR1
L W[AR1,P#0.0] //fetch DB number from L area of OB1
..
L D[AR1,P#2.0] //fetch area pointer from L area of OB1
 
Here's the code presented by the editor
Code:
      CALL  FC     4
       pInput :=P#I 0.0
       pOutput:=P#DB1.DBX 0.0

Here's the actual instructions behind the code
Code:
      BLD   1
      =     L     20.0
      L     0
      T     LW    21
      L     P#I 0.0
      T     LD    23
      L     1
      T     LW    27
      L     P#DBX 0.0
      T     LD    29
      UC    FC     4
            P#L 21.0
            P#L 27.0
      BLD   2
 
Daer L D,

It is very much justified that you wants to be known to all with the name L D[AR2, P#0.0]. You are really great. I had always got very helpful informations of this type of questions from you.

I will try to understand the mechanism you described. Would you kindly help me to have any documents from which I can learn more about this mechanism.

Best Regards,

Shyamal
 
Hi there LD,

In the above post you broke this:

CALL FC 4
pInput :=P#I 0.0
pOutput:=P#DB1.DBX 0.0

into this:

BLD 1
= L 20.0
L 0
T LW 21
L P#I 0.0
T LD 23
L 1
T LW 27
L P#DBX 0.0
T LD 29
UC FC 4
P#L 21.0
P#L 27.0
BLD 2

Q1)How??
Q2)Why L 0 and and L 1 is happening??


Burger is very expensive ;-)
 
Wow that's great. Delighted.
Felt like roaming around in Egypt in search of treasure beneath Pyramids! And found it !
Now thinking how to utilize the treasure :unsure:

All thanks to you for giving detailed maps :geek:
 

Similar Topics

I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
525
I am trying to access the value of a pointer via OPC UA in Codesys. I can share it directly and in a struct but I cant access the value of it when...
Replies
5
Views
1,596
Why does my deconstruction of the input pointer only work with its own instance DB not inside the multi instance FB...See .doc The pointer at the...
Replies
8
Views
2,328
Hi All, in many library function of TiaPortal some data must be write using the pointer format........ eg.: P#DB90.DBX0.0 WORD 10 is it...
Replies
5
Views
2,817
I have a very strange issue and I cannot figure out why it is not working. I read input of type pointer and store it to local temp type any. I...
Replies
4
Views
1,922
Back
Top Bottom