question about some code

Tommycai

Member
Join Date
Aug 2011
Location
KY
Posts
120
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.
 
That one is hard to follow, but it sounds like he wants to increment db5.dbw0 and then put the result in db5.dbw2

but I can't tell for sure.
 
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.
 
Last edited:
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

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...
Replies
6
Views
1,336
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...
Replies
2
Views
1,589
Can a low voltage electrical panel be designed to be opened without powering it off first without violating any electrical codes? Panel will...
Replies
3
Views
1,940
Hi I have a question about a gray code absolute 8 bit encoder. The encoder is connected to 8 inputs on an Allen Bradley PLC. if you turn the...
Replies
6
Views
2,262
Hello Guys, First off Happy Holidays! (edit: I am using Rslogix5000 not 500. sorry!) I am a beginner programmer trying to sort out some code...
Replies
1
Views
1,591
Back
Top Bottom