Siemens S7: How to: Multi instance offset in SCL

inalvor1

Member
Join Date
Apr 2012
Location
Malmö
Posts
27
Greetings,

I'm trying to do this, in SCL:

Code:
TAR2  
AD    DW#16#FFFFFF
L     P##Input_ANY
+D
LAR1
I just can't seem to find a similar function for SCL. Don't you still need the offset depending on which multi instance you are using?

I guess I don't need to put it in AR1, but I still need it for BLKMOV, I think.


What I've seen so far, AR1 & AR2 can't be accessed in SCL, which confuses me. Since it will be compiled to STL anyways.
 
Last edited:
You need to describe the functionality you require. Showing the functionality in SCL that will not compile may help.
 
You need to describe the functionality you require. Showing the functionality in SCL that will not compile may help.

Ah, thanks for feedback.

Functionality:
I have an FB with an Input variable that is of the ANY type.
(Input_Variable)

To transfer the data area of this pointer to the temp area in the block, I use SFC20.
Code:
T_RET_VAL:= BLKMOV(SRCBLK := Input_Variable, DSTBLK := SEND_BUFFER);
In this case the "SEND_BUFFER" is just an array of 512 bytes.

But what if I have to use two or more of this FB multi instanced? If it was STL I'd have to use something like the code I posted in message one. Otherwise the BLKMOV would move the wrong data after multi instance 1.
Edit: Id have to use that code, before building the ANY pointer for DSTBLK

It's not that I can't compile, it's just that I cannot see how you are supposed to get this offset in SCL.
Edit: With "this offset" I mean, the offset in the DI from 0 to the start of the multi instance data.
 
Last edited:
Here's some example code along the lines of your description - I've tested this and the correct data ends up in second instance.

Code:
FUNCTION_BLOCK FB100
VAR_INPUT
Input_Variable:ANY;
end_var    
VAR_TEMP
T_RET_VAL:INT;
END_VAR
VAR
Send_Buffer:ARRAY[1..16] OF int;
END_VAR
T_RET_VAL:= SFC20(SRCBLK := Input_Variable, DSTBLK := SEND_BUFFER);
END_FUNCTION_BLOCK


FUNCTION_BLOCK FB101
VAR_TEMP
iIndex:INT;
END_VAR
VAR
Buffer1:ARRAY[1..16] OF int;
Buffer2:ARRAY[1..16] OF int;
X1:fb100;
X2:fb100;
END_VAR
FOR iIndex:=1 TO 16 DO
 Buffer1[iIndex]:=iIndex;
 Buffer2[iIndex]:=iIndex+100;   
END_FOR;    
X1(Input_variable:=Buffer1);
X2(Input_variable:=Buffer2);
END_FUNCTION_BLOCK
 

Similar Topics

What determines if a FB can be used as a multi instance? According to Berger "Prerequisite is that both the calling function block and the called...
Replies
10
Views
5,831
Hi Every one I want to hookup the 10 numbers S7 300 PLC CPU on MPI Network . CPU,s are running on 10 different machines with 12 " HMI on each on...
Replies
5
Views
2,108
I added a fault to the HMI and when I went to download it, it told me the OS needed to be updated. So I updated the OS and transferred the program...
Replies
2
Views
1,942
Please help me. The DB9 on my USB/PPI converter was dammaged. I need to know the wire color to pin, with this i can install a new DB9. Thanks
Replies
0
Views
1,587
Hi Friends I’ am new here, so bare whit me. I have a problem regarding communication from Siemens S7-222 thru the PPI/USB cable. what I want...
Replies
0
Views
3,638
Back
Top Bottom