S7 SFC21 "Fill" problems

CharlesM

Member
Join Date
Aug 2005
Location
Arkansas
Posts
1,129
I am trying to reset all values in DB10 to 0. I think the best way to do this is using SFC21 the fill block. I made a copy of DB10 with all 0's and called it DB13. In my fill I set BVAL to DB13.DBW0 and RET_VAL to "fill_error" and BLK to DB10.DBW0. This made DBW0 change to 0. How do I set the length of fill? I know I should be able to use a single 0 instead of DB13 but I wanted to start small.

Thanks
 
HI,
you'll need any-pointer for both parameter.
In your case you should use:
 
Call "FILL"
BVAL :=P#db13.dbx0.0 Byte 1 //pointer to 'zero-byte'
RET_VAL:=#fill_error
BLK :=P#db10.dbx0.0 Byte 20 //20?? (lenght of byte to fill)


but as you stated in your post, you don't need
to copy the Datablock and set it to zero.
Use a pointer and point to a byte that is '0'.
(e.g.P#M0.0Byte 1 ; P#db10.dbx100.0 Byte 1)

HTH
Rolf
 
You could also use the local "temp" data for this (Sorry for "stealing" your code RolfB);

Code:
L 0 	 		    // Create zero data
T #Zero  		    // Transfer to local data
Call "FILL"
BVAL :=#Zero
RET_VAL:=#fill_error
BLK :=P#db10.dbx0.0 Byte 20 //20?? (lenght of byte to fill)

Cheers
Borte
 
If you want to fill all of a DB with zeros, use the following block. You have to contruct the any pointer dynamically if you want to cater for any db of any length.

Code:
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  dbBlock : BLOCK_DB ;  
END_VAR
VAR_TEMP
  pFillDB : ANY ;   //pointer to fill DB
  byZero : BYTE ;   
  iSFC21Return : INT ;  
END_VAR
BEGIN
NETWORK
TITLE =zero all bytes in a db
	  L	 0; //zero fill byte
	  T	 #byZero; 
	  OPN   #dbBlock; 
	  L	 DBLG; //get length of DB in bytes
	  LAR1  P##pFillDB; 
	  T	 W [AR1,P#2.0]; 
	  L	 W#16#1002; //declare any pointer of type byte
	  T	 W [AR1,P#0.0]; 
	  L	 DBNO; 
	  T	 W [AR1,P#4.0]; //declare any pointer db number
	  L	 P#DBX 0.0; 
	  T	 D [AR1,P#6.0]; //declare any pointer area pointer
	  CALL "FILL" (
		   BVAL					 := #byZero,
		   RET_VAL				  := #iSFC21Return,
		   BLK					  := #pFillDB);
END_FUNCTION
 
I still have something wrong. When I enter the pointers I get and error (red)

Call "FILL"
BVAL :=P#db13.dbx0.0 Byte 1 //pointer to 'zero-byte'
RET_VAL:=#fill_error
BLK :=P#db10.dbx0.0 Byte 20 //20?? (lenght of byte to fill)

My DB's are made up of arrays of ints. Is the pointer the same for them as it is for bytes?



 
I just cut/pasted the code from your post into the block editor and it worked fine. I don't even have a DB13 in my project. Is the your post cut/pasted from the block editor ?
 

Similar Topics

Hi. I came from S7 and i have a problem trying to reset the value of some tags. In Siemens is To Easy reset a DB (With BLKMOV or FILL), in Rslogix...
Replies
4
Views
3,045
Hi' Can anyone tell me what is wrong here, I can't compile this code. FUNCTION_BLOCK FB10 VAR_INPUT Step : BOOL; END_VAR VAR //...
Replies
3
Views
3,029
Anyone tell me why this code comes up with an error, I'm trying to fill an array with a value, the array is in the stat section of the FB (60...
Replies
3
Views
3,218
Dear colleagues, hope you can help on that matter. We have a project where we need to control 3 servomotors to move a auger feeder system...
Replies
38
Views
1,170
So this is my attempt at collecting and displaying data on a Cmore panel With a DL06. Each pair in my logic is the "Time total" or the TA15 and...
Replies
4
Views
478
Back
Top Bottom