question about some code

I am trying to load db5.dbw0 and increment by one integer to get the value of db5.dbw2 without typing load every db.

// if bit set in step chain increase the mw200 by one integer

A "M 199.7"

// the value of db5.dbw0 should be loaded into mw200. This is trying to increase it to 1
L "MW 200"
+I
T "MW 200"
S "M 199.6"
BE

will this work or will this increase mw200 to mw202?
 
If M199.7 is True then
MW200:=M200+1;
End_If

translates as follows:

Code:
      A     M    199.7
      JCN    skp
      L     MW   200
      +     1
      T     MW   200
skp:  NOP   0

but if you want to increment DB5.DBW0 then you can use the following:

Code:
      A     M    199.7
      JCN    scp
      L     DB5.DBW    0
      +     1
      T     DB5.DBW    0
scp:  NOP   0

You haven't specified the conditions under wich M199.6 should be set.

Note that whilst M199.7 is true then the increment will take place every scan.
 
sorry for the confusion, yes I see your point on your code. I was transferring the data to MW200.0 for comparison reasons.
I'm just gonna make the DB value a shared DB I think it was instance DB.
 
There is a command called "word shift register" that will move a word in a DB down one position like a FIFO. That might help you, I am still not sure.

Then you could always use the same DB5.DBW0 for your compare. The new HMI value would come in and the first value would be shifted down to DB5.DBW2.

Doesn't matter about it being shared or instance, except you could use "DIW0" in the FB to refer to the instance DB.

S7 can do anything, 20 different ways. But you need to know exactly what you want and then get the instructions together that do what you need.

I find it is useful to study the instruction set of any PLC I use to make them part of my thought process.
 

Similar Topics

Hello everybody, maybe this is not the right place to ask this question since this forum is dedicated to PLCs. Let me ask it anyway. In our power...
7
Replies
732
Views
I am trying to connect studio5000 with a simulator (Softlogix) to a gateway that is prosoft plx32, this last one is the one that I have problem...
1
Replies
671
Views
I know most of the major players like Rockwell and Siemens have security for code that goes beyond the password protection of the controller. My...
6
Replies
2,275
Views
I'm pretty well a 100% GE/Emerson Rx3i programmer, and zero practical experience with Siemens programming. However I have just been given a PDF...
2
Replies
2,305
Views
Can a low voltage electrical panel be designed to be opened without powering it off first without violating any electrical codes? Panel will...
3
Replies
2,625
Views
Top