ANY data typ

martin3885

Member
Join Date
Aug 2005
Location
Saarland
Posts
144
Hi,
I try to work with ANY data type. I read in Step7's help about it, but there is no example how to use it. Yesterdy I found this thread. RolfB has placed there an example with ANY data type.

FUNCTION FC 15 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
in_PDatabase : ANY ; // Sample P#DB15.dbx0 Byte 1
in_iBitoffset : INT ;
END_VAR
VAR_OUTPUT
out_Result : BOOL ;
END_VAR
VAR_TEMP
P : STRUCT
Kenn : BYTE ;
Typ : BYTE ;
lenght : WORD ;
DBnum : WORD ;
Bereich : DWORD ;
END_STRUCT ;
END_VAR
BEGIN
NETWORK
TITLE =Copy Pointer in local structure
L P##in_PDatabase; // Any-Pointer
LAR1 ;
L B [AR1,P#0.0]; // ID S7
T #P.Kenn;
L B [AR1,P#1.0]; // Data Typ
T #P.Typ;
L W [AR1,P#2.0]; // Lenght
T #P.lenght;
L W [AR1,P#4.0]; // DBno
T #P.DBnum;
L D [AR1,P#6.0]; // Area
T #P.Bereich;
AUF DB [#P.DBnum]; // open Datablock
//************************************************
//add Bitoffset to pointer
//************************************************
LAR1 #P.Bereich; // Area --> AR1
L #in_iBitoffset; // INT add Bit Offset
+AR1 ; // to -> ar1
U DBX [AR1,P#0.0]; // Sample ?=1
= #out_Result; // Test if function work

END_FUNCTION

Do I always need such a "P" structure?

What if I want to point to FB and not DB?

I would be thakfull if someone could show me another example with variable of ANY data type, thus I could compare them and see how does ANY data type works.
 
If I do Help on STL from the block editor (using english) and find topics related to any, I get the following:

Example of the Data Type ANY from the topic ANY_PTR. This shows a coding example using any pointers.
 
thanks, I found it.
Simon, maybe you will know this, no, you know everything, so you must know also this:).
In my book there is that ANY-Pointer cannot be used in AWL(STL), because it has 80 bits and it is longer than accumulator.

But in Fact we do use ANY-Pointer in STL.

So, how should I understand it?
 
Last edited:
I refer to my Hans Berger book for information on any pointers etc. I'm sure it must exist elsewhere in the Siemens documentation but as I have Berger thats where I always look. From the content of your posts, I strongly recommend you obtain a copy....(do a search on this site and you will find the ISBN)

Just for info, I have created an FC that will return the individual components of an any pointer, see below. For example, you can call FC3 and specify FC3 as the parameter for pAny, this will show you how Step 7 has coded this as an any pointer.

Code:
 FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1 


VAR_INPUT
  pAny : ANY ;  
END_VAR
VAR_OUTPUT
  byId : BYTE ; 
  byType : BYTE ;   
  iSize : INT ; 
  iDBNumber : INT ; 
  dwPointer : DWORD ;   
END_VAR
BEGIN
NETWORK
TITLE =get individual components of an any pointer

	  L	 P##pAny; 
	  LAR1  ; 
	  L	 B [AR1,P#0.0]; 
	  T	 #byId; 
	  L	 B [AR1,P#1.0]; 
	  T	 #byType; 
	  L	 W [AR1,P#2.0]; 
	  T	 #iSize; 
	  L	 W [AR1,P#4.0]; 
	  T	 #iDBNumber; 
	  L	 D [AR1,P#6.0]; 
	  T	 #dwPointer; 
END_FUNCTION
 
Please excuse my ignorance,but why would you want to call a FC as a Parameter for a any Pointer?

Is there a Practical application or example for this to help me understand? I've seen it applied as follows call FC [FC_NO] but nothing more complicated.

Thanks again.
 
Thanks!

jacekd,

thats perfect, Now the small problem of understanding it all! Also thanks for the interesting alternative to the #LOOP_COUNTER in the other thread!

Regards

Sorry for hijacking the thread!
 

Similar Topics

Hello I have a s7-1200 and I would like to read the tags present in this controller with my controllogix controller. The two controllers don't use...
Replies
5
Views
102
Hi folks, I'm not as accustom with Siemens & WinCC, however I've been asked to increase the amount of data an existing application is logging...
Replies
2
Views
65
Has anyone migrated Proficy Historian data to a new server? I followed the guide to move all the data over, but when I run the utility, it stops...
Replies
0
Views
46
I cannot add SLC500 analog input tag (I: 8.3) to EZSeries Touch Panel Editor (V 5.3). I used all the listed tag datatype but it all says "Invalid...
Replies
10
Views
257
Hi, Wy we log data in PLC using DLG instruction, when we have option to log data in HMI
Replies
1
Views
80
Back
Top Bottom