S7-300 Add Integer

johnparker

Member
Join Date
Sep 2006
Location
Bristol
Posts
2
Hi all

This should be an easy one !

I need to increment a value in a data block by 1 each time a flag is high.
If i set up an ADD_I with the data address at IN1 and 1 at IN2 it should add 1 to the value when EN is enabled by the flag. Trouble is, it adds 1 to it on every scan of the program while EN is high.
How can i make it just count once each time the flag goes high.

I could use a counter but i need to count up into the 100,000s and the counter only counts to 999

Thanks in advance for any help
 
If your counts exceed 32k then you will need to use a double word:
Paste the following code into a blank network in stl mode and it will display in ladder (assuming the jump label is not duplicated elsewhere of course)

Code:
	  A	 M	  0.0
	  FP	M	  0.1
	  JNB   _00b
	  L	 MD   100
	  L	 1
	  +D	
	  T	 MD   100
_00b: NOP   0
 
Simon, you need to use L#1. Otherwise MD100 will flip over at 65535.

Edit: Never mind. You can use an INT if you explicitoly use the +D instruction. I usually use STL and write it like this:

L MD 100
+ L#100
T MD100

If I do this:

L MD 100
+ 100
T MD100

it will flip at 65535.
 
Last edited:

Similar Topics

Hi , Anybody can guide me how to add E300 motor overload relay to Rslogix 5000 product catalog? I downloaded EDS file from rockwell website and...
Replies
2
Views
4,544
How to add two bytes Num1 : BYTE; Num2 : BYTE; Num2 := Num2 + Num1; is not working? Why I would like to increase Num2 by 1 every time in a loop
Replies
8
Views
3,173
Hi all, I recently upgraded my TIA portal V11 to V12. In V11 when you add a DB, you can choose choose between standard or compatible with S7-300...
Replies
3
Views
4,256
Hi friends, Help me to convert from STL to LADD below the statement, O "M 1226.5" M226.5 -- step 5 length of hood O "M 1226.6" M226.6 -- step 6...
Replies
4
Views
4,075
Hi friends, We have a simatic field PG which we use for the s7-300 PLC's, In my program some network they write in statement list, So how to...
Replies
2
Views
3,307
Back
Top Bottom