No of Events in Time Window

lostcontrol

Lifetime Supporting Member
Join Date
May 2009
Location
NeverSayNever
Posts
1,070
Hi,

Have an application where we need to detect if a certain event happens more than a no of times within a time window.

What I have so far, is if the event happens, then increment a counter & start a timer.
If the counter reaches its preset before the timer completes, then the condition is captured & indicated.
If the timer times out, then reset the counter.

The issue with this method, is that if 2x events happen within the time window, then the timer should not reset, but rather start again from each occurence of the event happening. This is simply a case of resetting the event detection timer so that it starts again from its preset.

All good so far..?

Where I am geting slightly caught up, is what should I do with the counter if a 2nd event happens, but the preset time has elapsed since the first event..? :confused:
Should I then add 1 to the counter & reset the time between events timer?


Basically, we need to create a shifting window that looks for so many events within that time.
I could look at time stamps, but then that would require a lot more memory storage for the no of events required to be detected..


Current PLC is Omron, but is basic logic I think..

Cheers
 
Where I am geting slightly caught up, is what should I do with the counter if a 2nd event happens, but the preset time has elapsed since the first event..? :confused:
Should I then add 1 to the counter & reset the time between events timer?
Lost,
Follow your specifications to the letter. Logically, either way could be correct, depending on the purpose of the data. Do "they" want to record all events where the timer times out, or just the LAST series of events that occurred?

If this is for alarms or troubleshooting, then probably only the last events are needed, so you can reset the counter each time. On the other hand, if it is for a drug study or medical test, then probably all events need to be recorded.
 
Lancie,

The requirement is that if so many events happen in the defined period, then we take an action.
So, we do not need to record all of them, just capture if the preset amount happened within that window.

It is sort of like a shifting window, from the 1st event. But, if a 2nd event occurs say 2min after the first & the window is 5min, then the window reset time needs to be shifted by 2min. But then, if no more events happen within the next 3min, should I then decrease the counter by 1, therefore ignoring the very 1st event?

I feel I am almost there, just getting this last bit sorted & understood in implementation is what I need to spend the time on..
 
Maybe this might help ...

Set up an array of values of the type of the timer accumulator. The array needs to be at least as long as 'critical count' minus 1. I'm assuming a zero based array. Also have a location you can increment/decrement as a counter.

Initialization - zero the counter and the array.

The timer will time if the counter is greater than zero.


'Wait for an event' ...
While waiting, if the timer times out then go to 'Reset' (This obviously won't happen if no event has been recorded yet)
On event


  • Store timer accumulator into array[counter] (obviously if the counter is zero then this value will be zero)

  • Increment the counter - if now equal to test value then exit and perform required action. (If this changes the counter from zero to one then the timer starts.)

  • Go back to 'Wait for an event'


'Reset'

If counter > 1 then:


  • Preserve array[1] in a variable 'Reset Time'

  • Subtract 'Reset Time' from timer accumulator

  • Shift the array up (1 -> 0, 2 -> 1 etc)

  • Go through the array, subtract 'Reset Time' from each value (obviously array[0] goes to zero)
(Depending on the PLCs instruction set the last two items may be combined into one item for each move (array[1] - 'Reset Time' -> array[0] ... etc))


Decrement the counter. (If this changes the count from 1 to zero then the timer stops and is reset)

Go back to 'Wait for an event'
 
Last edited:
Thanks Bernie,

That sorta helps, I have contemplated (albeit very shortly) the array option, my reason for not pursuing this as yet, was that some of the events are >10, plus the fact that we had already implemented a structure of code for this, not that it cannot be changed mind you...

I will check memory allocations etc, & see if I can do something to what you have suggested..
 
Here's an example that I came up with for RSLogix Micro, but you may be able to re-apply to suit your needs. It works, at least as far as I understand your requirements.

Hope it helps.

Bird is the word, happy thanksgiving :ROFLMAO:

Cheers,
Dustin
 
I think I'd do it like this:

For every event, add n to a sec. counter. 'n' is the time till the event can be forgotten.
Count down every sec.
When an event causes the sec.counter to exceed an upper limit, then: alarm.

Kalle
 
Last edited:

Similar Topics

Hi- I am configuring an alarm and event server to display 1 current alarm at a time on a big display. Having a few issues The alarm doesn't...
Replies
0
Views
49
I'm using a Micro850 with a Panelview 800, programming in CCW. We'd like the customer to be able to schedule the system to startup at a certain...
Replies
5
Views
131
Hi guys, I've got problem about my Alarms services (i think), that happen after installed Visual Studio. I did a few things like, Repair : Studio...
Replies
3
Views
139
Hello, Does anyone have experience managing the FactoryTalk alarm & events SQL database from outside of FactoryTalk? Essentially I'd have tag...
Replies
3
Views
1,284
We upgraded our systems to FactoryTalk Service Platform 6.31 and ran patch roll up from Dec 22 after software updates. We have a network...
Replies
3
Views
1,454
Back
Top Bottom