Pointer

martin3885

Member
Join Date
Aug 2005
Location
Saarland
Posts
144
Hi,
I have just noticed a curious thing. ie. I have DB11 of UDT11 type.
Then I define a pointer as an input variable in FC20.
So, now if I give only DB11 to this variable I will see that in Byte2(memory area) is 11 DB nummer. But if instead of db11 I put there DB11.[UDT name] DB nummer(11) will be in Byte 0. Why is it so?
 
If you put DB+UDT as the parameter, this is a DB pointer with the DB number followed by the Area pointer. Bytes 0,1 give the DB number and bytes 2,3,4,5 give the area pointer.

If you put the DB only as the parameter, this is not a DB pointer but a shortened version of an any pointer for blocks and in this case it appears that bytes 0,1=0, and bytes 2,3,4,5= block number.
 
Hi,
I don't know how to post whole code, but here are the most important things:
Eingabe_Bereich, Temp_Bereich, Ziel_Bereich are Pointers

CALL FC 20
Eingabe_Bereich:=PEW128
Temp_Bereich :=P#DB11.DBX0.0 BYTE 30
Ziel_Bereich :="Daten".Out
ret :=DB1.DBW2
NOP 0

L P##Temp_Bereich //Pointer
LAR1
L P##pointer_temp_bereich //ANY
LAR2
L B#16#10 //10 fuer S7
T B [AR2,P#0.0]
L B#16#2 //Datentyp 2Hex=Byte
T B [AR2,P#1.0]
L W#16#20
T W [AR2,P#2.0]
L W [AR1,P#0.0]
T W [AR2,P#4.0]
T #Quell_DB_Nr
T MW 50


L D [AR1,P#2.0]
T D [AR2,P#6.0]
T #Zeiger_Quell_Adresse
T MD 52
 
SimonGoldsworthy said:
If you put the DB only as the parameter, this is not a DB pointer but a shortened version of an any pointer for blocks and in this case it appears that bytes 0,1=0, and bytes 2,3,4,5= block number.

So, it means, that a pointer can automaticly be an ANY pointer?
What were the dfference if I had a variable of a type ANY instead of pointer?
 
Are you sure Temp_Bereich is POINTER type really? Step marks it red if ANY value is assigned to input of POINTER type.
 

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
534
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,617
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,346
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,818
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,932
Back
Top Bottom