Copying data in SCL

Avatar_41

Member
Join Date
Aug 2019
Location
Istanbul
Posts
96
Hello everyone, friends. I need help with something related to SCL. In a FB, I need to copy the value in the DB to the DB at another address. I want to print 35 pieces of data, increasing by 4 from the starting address, to the addresses I have previously created in the target DB. My starting address in the source starts as DB440.DBD8 and there are 35 data in the form of DB440.DBD12... The End Address ends as DB440.DBD144.
My target address starts as DB460.DBD32 and there are 35 data in the form of DB460.DBD36... The ending address ends as DB460.DBD168. I want to do these practically with programming logic and learn the logic. I need help on this. Thanks in advance. There is a photo attached.
I am using S7-300, Simatic Manager V5.6.

Source-Target Address.JPG
 
One example implementation:


Code:
FUNCTION FC99 : VOID
VAR_TEMP
iLoopCount:INT;
iSrcAddress:INT;
iDestAddress:INT;
END_VAR
FOR iLoopCount:=1 TO 35 DO
  iSrcAddress:=(iLoopCount-1) * 4 + 8; 
  iDestAddress:=(iLoopCount-1) * 4 + 32;
  DB460.DD[iDestAddress]:=DB440.DD[iSrcAddress];
END_FOR;
END_FUNCTION
 
Alternative:


Code:
TYPE UDT1
    STRUCT
    bySiem:BYTE;
    byType:BYTE;
    iCount:INT;
    iDB:int;
    dwArea:DWORD;

    END_STRUCT
END_TYPE


FUNCTION FC98 : VOID
VAR_TEMP
pSrcAddress:ANY;
mySrc AT pSrcAddress:udt1;
pDestAddress:ANY;
myDest AT pDestAddress:udt1;
iSFC20RetVal:INT;
END_VAR
 mySrc.byType:=5;
 mySrc.bySiem:=b#16#10;
 mySrc.iCount:=35;
 mySrc.iDB:=440;
 mySrc.dwArea:=DINT_TO_DWORD(8 * 8);
 mySrc.dwArea:=mySrc.dwArea OR dw#16#84000000;
 
 myDest.byType:=5;
 myDest.bySiem:=b#16#10;
 myDest.iCount:=35;
 myDest.iDB:=460;
 myDest.dwArea:=DINT_TO_DWORD(32 * 8);
 myDest.dwArea:=myDest.dwArea OR dw#16#84000000;
 
 iSFC20RetVal:=SFC20(SRCBLK:=pSrcAddress,DSTBLK:=pDestAddress);
END_FUNCTION
 

Similar Topics

I created a UDT with recipe parameters and have created several Recipe tags using that UDT as a data type, as well as an "Active_Recipe" tag. if...
Replies
1
Views
1,756
A rung is set up that goes something like this: If sysMessage > 46 ONS---> Cop SysDisp_message Destination: DatabaseMessageHold Watching it in...
Replies
4
Views
2,315
Hey guys. I have a situation where I need to compare a dynamic data value to a static value, then take the greater of the two and use that in my...
Replies
7
Views
3,952
Need a little help with a better way to copy data. I am saving data in an array and I want to move the data from the second oldest to the oldest...
Replies
5
Views
1,503
You guys have been awesome in helping me learn this plc and software stuff so I wanna poke you guys for one more question. In factorytalk studio...
Replies
4
Views
1,498
Back
Top Bottom