SFC20 (BLKMOV) anyone help with this?

Johnny T

Member
Join Date
Jul 2003
Location
Fife, Scotland
Posts
642
I have a program that has product dependant values held within a datablock. All the values that are currently being used are held within DB100 and the different product programs are held in DB150 (for program 1), DB160 (for program 2), DB170 etc etc

If the operator selects program 1 I want to copy all of DB150 and put it into DB100.

I wrote a variable declaration table in a function that has an INT called PROG_NO.

I wanted to call SFC 20 (BLKMOV) and pass in DB[#PROG_NO] as the Source and then DB100 as the Destination but it won't let me do it.

If I just type DB150 then it accepts it but this means I'll have to call the block 20 times for 20 different programs and I don't want to do that if possible.

Is there a way to achieve this?

Also, does the BLKMOV copy all of the Source DB into the Destination DB or do you have to somehow denote the length of information to be copied? I saw an example in the 'help' file using a pointer along the line of P#0.0 BYTE 10 (do I need this format if I'm just copying an entire DB over another DB)

PS. All the datablocks are the same size.

Many thanks for your help.

Cheers

JT ;-)
 
Brilliant! Thanks for the link.

I've just been reading through the code and am I right in thinking that Simon is making the DB and Byte offset into a Cross Area Pointer and then using that pointer as the source for the DB transfer in SFC 20 ??

I haven't got S7 on this computer in order to compile the source and try the block but I'll work through it more on Monday when I can compile it.

I'm still not sure why the SFC block wouldn't accept DB[MW 20] or DB[#someVar] as the DataBlock source?

Really appreciate the link, thanks again.

JT ;-)
 
SFC20 expects ANY pointers as parameters for the block source and destination, you can't put anything else. If you want to change source/destination blocks during run time, you have to contruct the ANY pointer yourself with program statements - this is what is being done in the program.
 
I see...

Well, thanks for the explaination. I'll work through it on Monday (might need to dig out my Berger book as well).. 🍻

Cheers

JT ;-)
 
Just to explain further, here's a little example showing a call with a hardcoded ANY pointer, and another using an ANY pointer declared in the temp local data area. FC2 is a dummy function that has an input parameter of type ANY.

Code:
	 CALL FC	 2
	 Source:=P#DB1.DBX0.0 BYTE 10 //a hard coded any
	 CALL FC	 2
	 Source:=#tempAny //this variable is declared as local data

This is the code produced (the editor shows it in the form above, but I have shown the STL that is actually present). For the hard coded ANY, the editor has produced code that contructs the ANY pointer and then calls the FC with a pointer to the local data area where the any pointer has been contructed.

Code:
	 Call
	 BLD 1
	 =	 L 46.0
	 L	 W#16#1002 //this is the code produced by the editor
	 T	 LW	47	//contructing a 10 byte any pointer
	 L	 10		 
	 T	 LW	49
	 L	 1		 //using DB 1
	 T	 LW	51
	 L	 P#DBX 0.0 //with area pointer DBX0.0
	 T	 LD	53
	 UC	FC	 2
			P#L 47.0	//the editor contructed any pointer 
	 BLD 2
	 End Call

Now, for the second call using the temp variable of type ANY, this is what the editor produces:

Code:
	 Call
	 BLD 1
	 =	 L	 46.0
	 UC	FC	 2
			P#L 36.0 //this is the location of tempAny
	 BLD 2
	 End Call

This time the editor passes a pointer to tempAny - it is up to you to contruct the any pointer prior to this call.
 
Thanks for the explaination. I understand the principle of it now. With the temp local data area pointer we are just setting aside an ANY pointer 'shell'.. its up to us to then provide the necessary information to fill it.

With the hard coded ANY pointer then the information is already provided.

Thanks again ;-)

JT
 

Similar Topics

In one network SFC20(BLkMOV) is used to transfer 8 byte data from P#DB500.DBX8.0(SRC BLK) to P#DB20.DBX4.0(DST BLK). I would like to change...
Replies
2
Views
4,281
I Can't see why the first block move returns 8325 but second works. (well i can see why the second works).. What is wrong with my pointers...
Replies
2
Views
6,408
I have a very strange issue and I cannot figure out why it is not working. I read input of type pointer and store it to local temp type any. I...
Replies
4
Views
1,937
Hello everyone! I'm moving string value from DB to Q area for displaying it at WinCC. I see some value is presented in DB in Variable Table...
Replies
16
Views
5,660
Hello all, IN S7-300 Does anyone know if its possible to address sfc20 source and destination with variable addresses? ie Indirect addresses...
Replies
10
Views
2,982
Back
Top Bottom