Totalising

shaunn

Member
Join Date
Sep 2005
Location
Orapa
Posts
39
Hi All,

I am programming a Siemens S7-400 with Step 7 in STL. I am trying to totalise a counter that wraps-around.

In other words, I want to start counting (totalising) some start value of a counter and when the counter reaches a maximum value (normal word, 16 bits = 65536)I want to somehow store the old value and then continue totalising, even though the counter has reset to zero. (The counter will probably reset many times but I want the totaliser to continue to increment until I give the totaliser a reset trigger.) The totaliser will probably be stored in a double word to cater for it's large size.

Any help will be greatly appreciated.

Regards,
Shaun Nel.
 
Here's my implementation:

iCurrentCount is the value read from your counter
iLastCount is a static variable in FB
iPulseA is a static variable
dwTotalPulses is an in/out dword variable

Code:
	  L	 #iLastCountA				//get last count (from last cycle)
	  L	 #iCurrentCountA			 //and current count
	  T	 #iLastCountA				//save last count (ready for next cycle)
	  TAK   
	  -D								//Calc (Current-Last) counter wrapped around ?
	  JPZ   NWP0						//if so then negative answer
	  L	 L#65536					 //so adjust
	  +D	
NWP0: T	 #iPulsesA				   //and then update pulse count
	  L	  #dwTotalPulses			 //get current total
	  +D
	  T	  #dwTotalPulses			 //and update with pulses this scan
 

Similar Topics

Good day, How does a control system totalise your milliamp signal? Milliamp represents a flow from 0-60 t/h.
Replies
21
Views
3,761
Hi All, Rockwell Compact Logix processor. I'm using an Add function that I trigger by a using an XIC instruction followed by a ONS. The add...
Replies
6
Views
2,107
Hi All, I am programming a Siemens S7-400 with Step 7 in STL. I am trying to totalise a counter that wraps-around. In other words, I want to...
Replies
0
Views
1,554
Back
Top Bottom