Step 7 writing a positive edge to a data block

Last time I saw a program that writes the help_bit and positive or negative pulse bit to a data block.

I know that in earlier days this was not working well because of opening and closing the data block during the cycle time. there fore it was necessary to write to the global memory area. id there anybody knows if there is some documentation about this topic?
 
The bit(s) need to exist in any space that it persistent. That could be M memory, a global DB or as static declaration in a FB (which would place each instance in an instance data block).

They cannot be temps.

If they are passed as parameters to a lower level block than where the persistent bits are used, the parameters cannot be inputs or outputs. They must be input/outputs.

All of this information exists one place or another, but I don't know of any one piece of documentation that puts it all together.

I hope this helps.

Michal
 
L

Luca Gallina

I've been programming S7 from its earlier days and never heard of such problem (or can't recall anything similar).

To detect the positive or negative edge you can either use old S5 method or the S7 FP/FN instructions.
The related flags can be stored either in DB or M area since old S5 days (I mean S7 does it as well).

While the auxiliary flag you will use to store the state of the input (once evaluated) MUST belong to a STATIC memory area (DBs and M flags), the result flag can be static or temporary. In the latter case you will evaluate it only AFTER being generated and WITHIN the block where you generated it.

You may even omit the result flag, e.g. you can write<pre>
A MyInput // signal to be evaluated
FP auxFlag // aux STATIC flag
JC aLabel // jump to label</pre>
About datablocks, there's no such a "close" instruction: the only thing you can do is "open" another one.

The "opening" is implicit if you use the "DBnr.DBX byte.bit" syntax, in the case the operating system will automatically "open" the DBx datablock.
If you do not state which DB you want to "open" (using instructions non including "DBnr." then the operating system will address to the currently "open" DB.

I wish it does not sound confusing ;-)
If you can post a brief sample of code I'll try to be more precise.

Kind regards
Luca Gallina
http://www.runmode.com
 
Thanks for the information,
It is clear that a programmer can use DB's for positive and negative edge's. However in the old days all this FP's and positive edges where written to global memory or set in a FB. Why should you use a DB and not Global memory?
Example:<pre>
A I0.0 // Input
FP DB1.DBX0.0 // Help membit
= DB2.DBX0.0 // pulse</pre>
Thanks for information
 
L

Luca Gallina

if your "global memory" term stands for M flags area, then using DBs or M area is up to you. There have never been limitations in that sense. You're the programmer so you decide which area you're comfortable with (or the application may benefit of).

In my s7 programs where program modularity requests the code and related variables to be confined within precise containers (typically an FB Function Block and its linked instance DB), edges evaluation are done within the Function Block and stored into static (instance DB) vars, so I have not do worry about any memory areas other than my current instance DB.

On the other hand, if you want to provide a flag which must be available to all block is your program, e.g. a 100mS clock edge or a "setpoint reached" edge, that's an information I would store into a global memory flag so that everybody can read it without accessing a specific DataBlock (which also means faster access time).

Kind regards
Luca Gallina
http://www.runmode.com
 
A

Amirreza Eghtedari

I don't know any documentation on that but your are right, It had and it also has problem yet.

Using retentive memory for storage address of an edge detection block can make problem in first scan. It's not related to data block opening and closing action. It's because of retentiveness of DBs. If you use retentive Bit Memory for storage address of an edge detection, you will again have the same problem.

If you would like to use a retentive memory for that purpose, for example static variable of instance DB, you should place a close contact of a "FirstScanOn" flag in series with all your edge detection commands.

Actually S7-300 and 400 PLCs don't have FirstScanOn flag by default and you should make it yourself.

To do that in OB100, which runs after every warm restart, set the FirstScanOn static variable of a Global DB and reset it in the last network of OB1. So it will be on only in first cycle of the program.

Hope it helps.
 
Top