EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: 5 counts in 1 hour
From: Andrew Johnson <[email protected]>
To: "Southern, Tim" <[email protected]>, "[email protected]" <[email protected]>
Date: Thu, 7 Jan 2016 11:20:55 -0600
Hi Tim,

On 01/07/2016 10:41 AM, Southern, Tim wrote:
> Problem:
> 
> We have a spark detector that will increment a counter every time a
> spark is detected.  The user requests an alarm when the counter
> increments +5 times within an hour. How can this be implemented on an IOC?

Nice little problem.

> A Solution:
> 
> I used came up with a solution using compress records. First, I created
> a 3600 element compress record using a circular buffer that records the
> value of the PV counter every second for an hour.  Next, I created two
> more compress records, one that saved the lowest value, and one that
> saved the highest value of the first record (N to 1 Low Value, N to 1
> High Value). I then created a CALC record that calculated the difference
> of the low and high values. When CALC is greater than 5 ... then alarm.
> 
> Is there a better implementation to do this? Is there anything wrong
> with this solution?

Assuming that your input is a counter that only ever increments, you
really only need the first compress record and a calc. The output from
your High Value compress will always be the same as the current spark
count $(S):FltCtr, and the first element read from the circular buffer
is the oldest value in the buffer (the one from an hour ago), which is
always the same as the output from your Low Value compress. Thus the
following is equivalent to your solution with fewer records:

> #########################################################################
> # Alarm for greater than 5 counts in 1 hour
> #########################################################################
> 
> # Circular buffer of spark counts
> record(compress,"$(S):1HrCmp"){
>  field(SCAN, "1 second")
>  field(NSAM, "3600")
>  field(N, "3600")
>  field(ALG, "Circular Buffer")
>  field(INP, "$(S):FltCtr")   # ←- Record that increments
> }
> 
> # Difference of High and Low over time of circular buffer
> # Alarms when count is greater than 5
> record(calc, "$(S):1HrCmp_diff"){
>  field(INPA, "$(S):1HrCmp CP")
>  field(INPB, "$(S):FltCtr")
>  field(CALC, "B-A")
>  field(HIGH, "5")
>  field(HSV, "MAJOR")
> }

HTH,

- Andrew

-- 
There are only two hard problems in distributed systems: 2. Exactly-once
delivery 1. Guaranteed order of messages 2. Exactly-once delivery
 -- Mathias Verraes

Replies:
Re: 5 counts in 1 hour Southern, Tim
References:
5 counts in 1 hour Southern, Tim

Navigate by Date:
Prev: RE: Pro's/Con's of LabVIEW/EPICS Mazanec Tomáš
Next: Re: areaDetector driver pixel types Phil Atkin
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: 5 counts in 1 hour Southern, Tim
Next: Re: 5 counts in 1 hour Southern, Tim
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·