S7 Clearing multiple registers

snydl0ga

Member
Join Date
Apr 2005
Location
Tennessee
Posts
21
I have the need to clear several consecutive registers at the same time. I can't seem to find a function that will do that. I found the Move Block and the Fill but they move or fill from one group to another.

I need to do something like this:

Clear registers DB100.DBW100 through DB100.DBW200.

Maybe I didn't look hard enough...???

Lance
 
Hello snydl0ga;
I am the first to agree that the solution I have used to do what you need to do is not the most elegant, but it works. I create a dummy DB, with an array of words (or bytes) initialized to 0. This is what I use as a Source (Bval parameter) for SFC21("Fill"). This allows me to initialize my Destination (Blk parameter)to 0. Just make the source as large as needed to cover all the registers of your destination (100 words in your example).
Hope this helps,
Daniel Chartier
 
Hi,
Try this:
write zero to MD204

L 0
T MB10

CALL "FILL"
SRCBLK :=P#M10.0 BYTE 1
RET_VAL:=MW22
BLK :=P#M204.0 BYTE 4




You could probably use a Temp variable instead of "M"
addressing. Just change to your DB start address and area length, ie P#DB100.DBW100 WORD 100 in BLK

I think this should work ok

Steve
 
Last edited:
For the area length in the example "FILL" would be a waste of time as i could

L 0
T MD204



but you get the idea(i hope)

All the best

Steve
 
"clear" is a temporary int, "return" is a temporary word. Note that in the following code the number of words cleared in DB100 is hard coded in the fill block parameters. If there is any chance that the area may change in size you could use pointers to the start and end of your data area and then contruct the anypointer for the block fill. The code would then need a re-compile to work with a different length of data area, instead of having to search and manually update the lengths.

L 0
T #clear
CALL SFC 21
BVAL :=#clear
RET_VAL:=#Return
BLK :=P#DB100.DBX 100.0 INT 101
 
dchartier said:
I create a dummy DB, with an array of words (or bytes) initialized to 0. This is what I use as a Source (Bval parameter) for SFC21("Fill").
All you need is just one byte initialized to 0 and you can clear as large area as S7 can handle with SFC21.
 
i did yhis before using this function from the ti library

A M 37.0
JCN M027
CALL FC 88
IN0 :=DB2.DBW0
IN1 :=B#16#4
IN2 :=B#16#4
RET_VAL:=MW40
M027: NOP 0
 

Similar Topics

I'm online with a 90-30 using PAC ME 9.8 No one has gotten online with this PLC for many years and the the I/O fault table has a total of 1209...
Replies
6
Views
2,999
Using an L81 - I have the arrangement below that will try the Ethernet Radio first and if that fails use the Cellular Radio. The Failover works...
Replies
16
Views
3,374
Since this is the most helpful place on earth for us programmers, I'm back with another one. Using Logix v32 I've got an array with 100 elements...
Replies
9
Views
2,979
Hey guys, I'm still pretty new to PLC's in general. For a program on RSLogix 500 with a micro1400 and pvp400, we are currently logging data for...
Replies
9
Views
2,807
I am currently working in RSLogix 5000. I have a large data structure with the following general structure: UDT[0] Dataset1 Min Max Avg Data[90]...
Replies
14
Views
4,376
Back
Top Bottom