S7 Any (pointer) parameter in FC

USDutchman

Member
Join Date
Feb 2005
Posts
26
How can I access the data from an ANY parameter that is passed to an FC?

Input One: Source Type ANY
Input Two: Dest Type ANY

I used ANY variables before, but they were either local TEMP variables (Accesible in the Local L Memory area), or DB variables.
now I like to use them with an FC.

All I need to know is, how do I get to the 10 Bytes that make up the ANY parameter passed to the FC.
 
Is this what you mean:

You are passing a pointer into an FC. Let's call it "SamplePointer".

When you open the FC, in the declaration table it will be an input variable.

To look at the contents, code this:

L P##SamplePointer
LAR1
L W[AR1,P#0.0]
L W[AR1,P#2.0]
L W[AR1,P#4.0]
L D[AR1,P#6.0]

This will give you all of the components of the pointer.
 
Ask About Ar2 In My Content?

T #i;
A80a: L #i;
L 3;
<=I ;
JCN A809;
L #i;
ITD ;
L L#2;
+D ;
L L#8;
*D ;
TAR2 ;
+D ;
LAR1 ;
L DIB [AR1,P#64.0];
L #DB_SCALE;
T LW 56;
TAK ;
T LB 55;
TAK ;
L #ti_ADR;
L #i;
+I ;
ITD ;
L L#8;
*D ;
L LB 55;
OPN DB [LW 56];
TAK ;
LAR1 ;
TAK ;
L DBB [AR1,P#0.0];
<>I ;
JCN A80c;
SET ;
= L 30.0;
= #sb_APPL_ID_ERR;
A80c: L #i;
L 1;
+I ;
T #i;
JU A80a;
I want to change to SCL! who help me? please
order TAR2 mean what? why use AR2 at that?
 
Ask About Ar2 In My Content?

L 0;
T #i;
A80a: L #i;
L 3;
<=I ;
JCN A809;
L #i;
ITD ;
L L#2;
+D ;
L L#8;
*D ;
TAR2 ;
+D ;
LAR1 ;
L DIB [AR1,P#64.0];
L #DB_SCALE;
T LW 56;
TAK ;
T LB 55;
TAK ;
L #ti_ADR;
L #i;
+I ;
ITD ;
L L#8;
*D ;
L LB 55;
OPN DB [LW 56];
TAK ;
LAR1 ;
TAK ;
L DBB [AR1,P#0.0];
<>I ;
JCN A80c;
SET ;
= L 30.0;
= #sb_APPL_ID_ERR;
A80c: L #i;
L 1;
+I ;
T #i;
JU A80a;
I want to change to SCL! who help me? please
order TAR2 mean what? why use AR2 at that?
 
This should be in a new thread but,

The STL you have posted uses the TAR2 instruction as part of the processing to access an element of a static array.
For example, here is a small snippet of SCL

Code:
FUNCTION_BLOCK FB999

VAR_INPUT
DB_Scale:BLOCK_DB;
END_VAR

VAR_IN_OUT
sb_APPL_ID_ERR:BOOL;
END_VAR

VAR_OUTPUT
 // Output Parameters
END_VAR

VAR_TEMP
  // Temporary Variables
byData:BYTE;
END_VAR
VAR
  // Static Variables
  i:INT;
  Scale:ARRAY[1..10,1..2] OF BYTE;
END_VAR
FOR i:=0 TO 3 DO
	IF scale[1,i] <> byData THEN sb_APPL_ID_ERR:=0; END_IF;	
END_FOR;   
END_FUNCTION_BLOCK

which produces this STL:

Code:
	  SET   
	  SAVE  
	  =	 L	  1.1
	  L	 0
	  T	 #i
A7d0: L	 #i
	  L	 3
	  <=I   
	  JCN   A7d1
	  L	 #i
	  ITD   
	  L	 L#-1
	  +D	
	  L	 L#8
	  *D	
	  TAR2  
	  +D	
	  LAR1  
	  L	 DIB [AR1,P#6.0]
	  L	 #byData
	  <>I   
	  JCN   A7d2
	  CLR   
	  =	 #sb_APPL_ID_ERR
A7d2: L	 #i
	  L	 1
	  +I	
	  T	 #i
	  JU	A7d0
A7d1: CLR   
	  A	 L	  1.1
	  SAVE  
	  BE

With a bit of trial and error you may be able to reverse engineer your STL to produce the correct SCL for your block. Good luck.
 

Similar Topics

Hej All I hope some of you can help me with this issue: I want to make a function block where, the IN-Parameter of data type...
Replies
6
Views
4,964
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
556
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,635
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,392
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,823
Back
Top Bottom