siemens s7-400 DB zeroing

merlinknight

Member
Join Date
Feb 2005
Posts
7
How would i go about resetting any bit that is set in a Db. I am in need of resetting bits that were set after a system failure. All of the bits that need to be reset are in the same data block.

Merlin
 
Maybe I'm missing something here, but what's the problem with:

L 0
T DBx.DBXm.n (or DBBm, DBWm DBDm)

for larger areas use the SFC21 FILL command.

The only problem with this technique is that if you're normally using Symbolic Addressing, this reset will not show up where you expect it in X-Ref. I do all my resets in one FC which is called at the start of a run (and on Power On, Restart etc.) and this is the only place that I address what are normally individual BOOLS as a group, so if I find something getting reset unexpectedly, I know where to go looking. I also arrange my memory use so as to group similar or related variables with the same reset requirements wordwise or DWORD-wise together. For example, all my Merker for edge-detection or one-time Flags for Job 51 Screen-Jumps in ProTool are each grouped together in one word. This makes for easy initialisation and for example with Job 51, I have at the moment 8 different places which can cause a jump to a fault screen and can clear all of these with one function when leaving the fault screen.
 
Oops, thanks, yes of course, for the Bit you need to use the Reset command. I had my own Reset FC in mind where I'm doing most of it it in WORD or DWORD chunks, although even there I'm resetting a lot of variables individually so that the Symbolic Names allow them to be more easily identified, needless to say I am using the "R" command there! :oops:
 
They are all together.
There are 96 bytes in the DB. Everything is a bit config.
Yes, just need to set everything to zero after a crash with a touch button on the screen. I am still new to siemens and any help would greatly be appreciated.

Thank You very much,
Merlin Knight
 
Last edited:
Hello Merlinknight;You could try this bit of code (in STL, easily translated to LAD if you prefer):


L 0
T MB10 //make sure you have a 0 value to write to your DB

A "Reset_Btn" //when the operator presses the reset button on the HMI on the HMI screen

CALL "FILL" //SFC 21 from the standard functions library

SRCBLK :=P#M10.0 BYTE 1 //your initial 0 value

RET_VAL:=MW12 //just a placeholder where you can see errors


BLK :=P#DB10.DBX0.0 BYTE 96 // the destination area you want to overwrite with 0

Hope this helps,

Daniel Chartier
 
I had a PM from Merlin on this, but in the mean time I see Daniel's beaten me to it.

I don't think there's anything to add to his explanation except perhaps that SFC21 is to be found in the "System Function Blocks" folder.

By the way, if you put the Load/Transfer command in one network and the CALL FILL in a second network and add a

NOP 0

command as the last line in each network, then you can switch back forth in View between STL and Ladder as you please.

If you prefer to enter it directly in ladder and you're unsure how, come back again and we'll sort that out too.
 
Last edited:
Thank you all for the help.

Thanks RMA for looking further into this.

Thanks again, i will try this when i get finished with this other job.

Merlin Knight
 
I assumed Daniel meant creating a Reset Button on a ProTool screen to initiate the Reset program.

If the "A" was meant to be an AND command, then perhaps he made things a bit too compact if you try and read it literally because the CALL command is not RLO dependant. In that case it would have perhaps been better to do it like this:

AN "Reset_Btn" //If Bit indicating "Do Reset" not set, exit
JC Exit
CALL "FILL"
SRCBLK :=P#M10.0 BYTE 1
RET_VAL:=MW12
BLK :=P#DB10.DBX0.0 BYTE 96

CLR
= "Reset_Btn" //Clear "Do Reset" Bit afterwards
Exit: NOP 0
 

Similar Topics

Hi, Yesterday, I was at a customer site. I made one little change. Changed a dummy bool output to an actual output. I didn't add any tags, or...
Replies
15
Views
328
Hi everyone, I'm working on a project where I need to exchange data between a Siemens S7-1200 PLC and an Allen-Bradley MicroLogix 1400 PLC. The...
Replies
8
Views
651
Good Afternoon. I am having a problem going online with S7-400. Attached is the error that I am getting. I have looked at the help file but the...
Replies
7
Views
1,775
I can't replace cpu S400 416-3XR05-0AB0 BY 416-3ER05-0AB0 in PCS7 Project when using replace object to keep the original configuration in the...
Replies
4
Views
1,504
I have a project where I've decided to put in a facility to change the PLC time and date through the HMI, as there's no network connection at the...
Replies
3
Views
1,900
Back
Top Bottom