String copy in Step7 SCL by SFC20 problems

Coralreef

Member
Join Date
May 2006
Location
Dk
Posts
23
Hi

Im trying to use SFC20 BLK Move in a piece of SCL code in Step7.

I need to copy/move one string[16] in a DB to another DB place !

If a block call is inserted with SFC20 in my SCL code it looks like this :

BLKMOV(SRCBLK := // IN: ANY
,DSTBLK := // OUT: ANY
); // INT

At SRCBLK i would write P#db2000.dbx220.0 BYTE 18 and at DSTBLK i would write P#db2000.dbx20.0 BYTE 18

But this dosnt work ?

I have also tryed doing the call like this :

BLK_Move_Dummy := BLKMOV(SRCBLK := P#db2000.dbx220.0 BYTE 18, DSTBLK := P#db2000.dbx20.0 BYTE 18);

Where BLK_Move_Dummy is defined as an INT for the RET_VAL !

If i do a blk mov with just INT values its all good but as soon as p# pointer for string values are added it all goes wrong. I can do the same pointer in ladder and it works
 
Here's an example copy using SFC20:

Code:
FUNCTION FC111: void
VAR_TEMP
Source,Dest:ANY;
S AT Source:STRUCT
	ID:BYTE;
	TYP:BYTE;
	NUM:INT;
	DBN:INT;
	PTR:DWORD;
	END_STRUCT;
D AT Dest:STRUCT
	ID:BYTE;
	TYP:BYTE;
	NUM:INT;
	DBN:INT;
	PTR:DWORD;
	END_STRUCT;
  iSFC20Return:INT;
END_VAR
S.ID:=16#10;
S.TYP:=16#02;
S.NUM:=18;
S.DBN:=2000;
S.PTR:=16#840006e0; //DBX220.0
D.ID:=16#10;
D.TYP:=16#02;
D.NUM:=18;
D.DBN:=2000;
D.PTR:=16#840000A0; //DBX20.0
iSFC20Return:=sfc20(srcblk:= source, dstblk:= dest);
END_FUNCTION
 
quick and dirty - take the byte address and multiply by 8 and enter the value in hex. The 84 means DBX
 
Edit - embarrassed mode on

I truely am sleeping this morning.....

Thanks for the basics !

Edit - embarrassed mode off :D
 
Guys guys ...
Strings and SCL are like fish and water.
No need to program BLKMOV (if BLKMOV is needed, the SCL compiler automatically inserts it in the generated STL code).

Code:
DATA_BLOCK Strings
    STRUCT
        line1 : STRING[20] ;
        line2 : STRING[20] ;
        manylines1 : ARRAY[1..10] OF STRING[20] ;
        manylines2 : ARRAY[1..10] OF STRING[20] ;
    END_STRUCT
BEGIN
    line1:='hello' ;
    line2:='goodbye' ;
    manylines1[1]:='1' ;
    manylines1[2]:='2' ;
    manylines1[3]:='3' ;
    manylines1[4]:='4' ;
    manylines1[5]:='5' ;
    manylines1[6]:='6' ;
    manylines1[7]:='7' ;
    manylines2[2]:='20' ;
END_DATA_BLOCK
 
FUNCTION String_manipluate : VOID
    "Strings".manylines1[2] := "Strings".line1 ;
    "Strings".line2 := "Strings".line1 ;
    "Strings".Manylines2 := "Strings".Manylines1 ;
END_FUNCTION
 

Similar Topics

Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
128
There must be a way to create a 'String Copy' function in Step7, something like: Call FCx FromStr:=SourceString ToStr:=DestString or am I...
Replies
12
Views
5,183
I feel like I'm going crazy, new to Siemens, coming from AB, and I cannot get a dang string copied in SCL. This is a S7-300, V16 PLC. I have a...
Replies
10
Views
3,488
HI Guys So i am trying to write a real SINt or DINT value into a string tag. If in string browser I write it manually, no problem. But how can I...
Replies
8
Views
5,953
I am using v14 with a 1215 dc/dc/dc. I need to copy a 50 element array of strings to another 50 element array of strings. I can work it out for...
Replies
3
Views
4,050
Back
Top Bottom