event triggered analog data acquisition using the exponential moving average

8
2048 IEEE SENSORS JOURNAL, VOL. 14, NO. 6, JUNE 2014 Event Triggered Analog Data Acquisition Using the Exponential Moving Average Alan Richard Wilson Abstract— The Defence Science and Technology Organisation has developed a number of sensor interfaces and an associated versatile, low-power networked sensor design, and protocol for structural monitoring of naval vessels. A consideration for many data acquisition system such as these is the large data sets that are easily gathered. This requires large hard discs to store the data and also can strain the resources required to analyze the data. In many instances much of the data may be collected during periods of inactivity and are of no interest. This can be avoided if data logging is triggered on the detection of significant events and thus only occurs when there are data of interest. This paper considers the implementation of event triggered data acquisition based on event windows centered on an exponential moving average (EMA) formed from the incoming signal. The frequency dependence of the EMA complicates the understanding of event triggering and is thoroughly examined. Noise can result in false triggering of data logging and considerations on how to avoid this are also discussed. It is concluded that the EMA is a valuable technique that can be easily implemented within the limited computational resources of microcontrollers and is thus suitable for smart sensor interfaces. Index Terms— Sensor interfaces, data logging, event, triggered, moving average, EMA. I. I NTRODUCTION T HE development of sensor networks by the Defence Science and Technology Organisation (DSTO) was initiated to provide a capability for defence platforms to have various forms of structural, environmental and equipment monitoring. This is required for new regimes of platform management, such as condition based maintenance, monitor- ing of ageing assets and prediction of asset life, which has been covered in a number of publications [1]–[5]. For some years DSTO has also been developing sensors, sensor interface electronics, networking and communications electronics and protocols, and associated microcontroller firmware for struc- tural and environmental monitoring that addresses these requirements [6]–[10]. A system has been operational on an Armidale Class Patrol Boat (ACPB) for over 4 years and a second system has recently been deployed to another ACPB. Experience with these deployments has shown that there are often times of little activity and thus the data set is needlessly bulked out with a large number of “zeros”. The implemen- tation of event triggered data logging would eliminate the Manuscript received December 11, 2013; revised February 18, 2014; accepted February 20, 2014. Date of publication February 24, 2014; date of current version April 23, 2014. The associate editor coordinating the review of this paper and approving it for publication was Dr. M. R. Yuce. The author is with the Maritime Division, Defence Science and Tech- nology Organisation, Fishermens Bend, VIC 3207, Australia (e-mail: [email protected]). Digital Object Identifier 10.1109/JSEN.2014.2307878 collection of this null data but still ensure that all relevant data was collected. The DSTO “smart” sensor interfaces are ideally placed to perform this function since the microcontroller can analyse the data in-situ and only store data of interest. This paper first sets the scene by considering the require- ments for event triggered data logging. It then examines in detail the use of an exponential moving average (EMA) to address one particular requirement and how this affects the event triggered data logging. Discussion of the practi- cal implementation of the EMA follows, with examples on an implementation using DSTO sensor interface hardware. Finally, the effect of noise and false triggering are considered. II. EVENT TRIGGERED DATA LOGGING Event triggered data logging is useful to reduce the size of potentially large data sets and as a first processing technique to reject data of no interest, particularly if it is expected that the system under study has long quiescent periods. An interesting event is often defined as simply whether the sensor signal is above or below a certain preset value. More complex events can be based on the relative difference between two, or a num- ber of sensors, and sequences of measurements that met some criterion. The recognition of an event can be performed with dedicated hardware such as, for analog signals, monitoring the output of a voltage comparator to detect a signal above a certain level. Alternatively, software for both analog and digital signals can be implemented to monitor measurements to recognise events of interest. The software approach is more versatile however it requires extra CPU processing time and thus may limit the maximum data rate that the sensor interface can be operated at. A number of considerations must be kept in mind when implementing event triggered data logging: 1) It is often desirable to collect signals just prior to an event to obtain an understanding of the lead up to an event. This requirement is easily meet by continually storing measurements in a temporary circular memory buffer. When an event is detected these measurements, starting at the oldest, are progressively moved to per- manent storage as new measurements are made and stored in the circular buffer. Thus a pre-set number of measurements prior to an event trigger will always be recorded. 2) It is also desirable to store data for a certain time after an event has occurred so that a) any small post event information is collected and b) if events occur 1530-437X © 2014 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission. See http://www.ieee.org/publications_standards/publications/rights/index.html for more information.

Upload: alan-richard

Post on 12-Apr-2017

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

2048 IEEE SENSORS JOURNAL, VOL. 14, NO. 6, JUNE 2014

Event Triggered Analog Data Acquisition Usingthe Exponential Moving Average

Alan Richard Wilson

Abstract— The Defence Science and Technology Organisationhas developed a number of sensor interfaces and an associatedversatile, low-power networked sensor design, and protocol forstructural monitoring of naval vessels. A consideration for manydata acquisition system such as these is the large data sets thatare easily gathered. This requires large hard discs to store thedata and also can strain the resources required to analyze thedata. In many instances much of the data may be collectedduring periods of inactivity and are of no interest. This can beavoided if data logging is triggered on the detection of significantevents and thus only occurs when there are data of interest.This paper considers the implementation of event triggered dataacquisition based on event windows centered on an exponentialmoving average (EMA) formed from the incoming signal. Thefrequency dependence of the EMA complicates the understandingof event triggering and is thoroughly examined. Noise can resultin false triggering of data logging and considerations on how toavoid this are also discussed. It is concluded that the EMA isa valuable technique that can be easily implemented within thelimited computational resources of microcontrollers and is thussuitable for smart sensor interfaces.

Index Terms— Sensor interfaces, data logging, event, triggered,moving average, EMA.

I. INTRODUCTION

THE development of sensor networks by the DefenceScience and Technology Organisation (DSTO) was

initiated to provide a capability for defence platforms tohave various forms of structural, environmental and equipmentmonitoring. This is required for new regimes of platformmanagement, such as condition based maintenance, monitor-ing of ageing assets and prediction of asset life, which hasbeen covered in a number of publications [1]–[5]. For someyears DSTO has also been developing sensors, sensor interfaceelectronics, networking and communications electronics andprotocols, and associated microcontroller firmware for struc-tural and environmental monitoring that addresses theserequirements [6]–[10]. A system has been operational on anArmidale Class Patrol Boat (ACPB) for over 4 years and asecond system has recently been deployed to another ACPB.

Experience with these deployments has shown that there areoften times of little activity and thus the data set is needlesslybulked out with a large number of “zeros”. The implemen-tation of event triggered data logging would eliminate the

Manuscript received December 11, 2013; revised February 18, 2014;accepted February 20, 2014. Date of publication February 24, 2014; date ofcurrent version April 23, 2014. The associate editor coordinating the reviewof this paper and approving it for publication was Dr. M. R. Yuce.

The author is with the Maritime Division, Defence Science and Tech-nology Organisation, Fishermens Bend, VIC 3207, Australia (e-mail:[email protected]).

Digital Object Identifier 10.1109/JSEN.2014.2307878

collection of this null data but still ensure that all relevant datawas collected. The DSTO “smart” sensor interfaces are ideallyplaced to perform this function since the microcontroller cananalyse the data in-situ and only store data of interest.

This paper first sets the scene by considering the require-ments for event triggered data logging. It then examinesin detail the use of an exponential moving average (EMA)to address one particular requirement and how this affectsthe event triggered data logging. Discussion of the practi-cal implementation of the EMA follows, with examples onan implementation using DSTO sensor interface hardware.Finally, the effect of noise and false triggering are considered.

II. EVENT TRIGGERED DATA LOGGING

Event triggered data logging is useful to reduce the size ofpotentially large data sets and as a first processing technique toreject data of no interest, particularly if it is expected that thesystem under study has long quiescent periods. An interestingevent is often defined as simply whether the sensor signal isabove or below a certain preset value. More complex eventscan be based on the relative difference between two, or a num-ber of sensors, and sequences of measurements that met somecriterion. The recognition of an event can be performed withdedicated hardware such as, for analog signals, monitoringthe output of a voltage comparator to detect a signal abovea certain level. Alternatively, software for both analog anddigital signals can be implemented to monitor measurementsto recognise events of interest. The software approach is moreversatile however it requires extra CPU processing time andthus may limit the maximum data rate that the sensor interfacecan be operated at.

A number of considerations must be kept in mind whenimplementing event triggered data logging:

1) It is often desirable to collect signals just prior to anevent to obtain an understanding of the lead up to anevent. This requirement is easily meet by continuallystoring measurements in a temporary circular memorybuffer. When an event is detected these measurements,starting at the oldest, are progressively moved to per-manent storage as new measurements are made andstored in the circular buffer. Thus a pre-set number ofmeasurements prior to an event trigger will always berecorded.

2) It is also desirable to store data for a certain timeafter an event has occurred so that a) any small postevent information is collected and b) if events occur

1530-437X © 2014 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission.See http://www.ieee.org/publications_standards/publications/rights/index.html for more information.

Page 2: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

WILSON: EVENT TRIGGERED ANALOG DATA ACQUISITION 2049

rapidly, one after the other within a certain time, thenuninterrupted data between events is collected whichmay simplify later data processing. This is simply imple-mented in software by ensuring that a certain pre-setnumber of measurements are moved to permanent stor-age after the last time that a measurement met the triggercriteria.

3) Sensor outputs may slowly drift with time so it may beadvantageous to modify the trigger criteria to account forthis drift. The EMA [11], covered in more detail below,is an attractive average to use on micro-controllersbecause of its low resource requirements.

4) Sensor signals may contain spurious noise above theevent threshold and thus some filtering or other process-ing may be advantageous to avoid false triggering on thisnoise. The type of noise filtering needs to be consideredcarefully since it can impact on the event triggering andthe data logging response.

It may also be desirable for sensor interfaces to triggerother sensor interfaces for the correlation of low trigger eventsignals. This is not possible in the current DSTO networkprotocol and so the DSTO implementation relies on a timestamping approach [10] and signals large enough to indepen-dently trigger the interfaces. Pre-trigger measurement storagealso helps to achieve this.

III. THE EXPONENTIAL MOVING AVERAGE

A moving average can be used to modify the central pointof a trigger window used to detect events. The moving averageideally has a slow response time relative to the expectedsignal input, but can accommodate any longer term offsetvariation in the signal (essentially a low-pass filter). Also, forimplementation on resource constrained microcontrollers, themoving average must not require extensive computations orlarge amounts of memory. For instance, the moving windowaverage requires all data over the whole window to be stored sothat old data can be subtracted as new data is added. If 16 Bitdata were being collected at 400 Hz for 8 channels and it wasrequired to form an average over 10 s, then 64,000 Bytes ofmemory space would be required to store the data. The EMA isattractive since it does not require storing older measurementsand can have its frequency response tailored to the applicationwith no change in memory storage requirements. For the caseabove with the EMA implementation considered in Section V,the EMA only requires 32 Bytes of memory to store themoving average.

It is worthwhile exploring the properties of the EMA sincethe EMA value varies with the incoming measurements andthus the trigger window will be continually varying: the extentof this variation with both signal amplitude and frequencywill determine when the recording of measurements occurs.The following sub-section introduces the EMA and determinesthe impulse response function which is used in the next sub-section to derive the frequency response of the EMA. The finalsub-section examines the effect this has on trigger levels forincoming signals.

A. EMA and Impulse Response

The EMA can be expressed as:

A(n) = α × m(n) + A(n − 1) × (1 − α) (1)

where A(n) is the EMA for the nth measurement, m(n) is thenth measurement (corresponding to time t = n�t , �t beingthe time between measurements) and α determines the degreeof weighted decrease for successive averages with 0 < α � 1.

The ideal response of (1) can be determined by examiningthe response to the step function and then determining theimpulse response function using the convolution theorem.A unit step function input

m(n) ={

0, n ≤ 0

1, n > 0

gives an EMA of the form

A(n) = α + A(n − 1) × (1 − α), n > 0, A(0) = 0. (2)

Successive expansion of the A(n – 1), A(n – 2), . . . A(1) termsleads to two useful relationships:

A(n + 1) = α × (1 − α)n + A(n), (3)

and the power series (|α| < 1)

A(n + 1) = α ×n∑

m=0

(1 − α)m −→n→∞ 1. (4)

In (3) for a particular n = N , choosing α = β/(N+1) gives

A(N + 1) = α × (1 − β/(N + 1))N + A(N). (5)

Thus, since

limN→∞ (1 − β/(N + 1))N = e−β = e−α(N+1),

the increment from one average value to the next tendstoward αe−α(N+1). This is essentially the derivative with N ofA(N + 1) and since the integral of an exponential is anexponential, taking the integral of the derivative of A(N) [withA(0) = 0 and noting that A(n → ∞) → 1, from (4)] gives

A(N) ≈ (1 − e−αN ). (6)

Note that (6) is an exact relationship in the limit, �t → 0. Forthe EMA applied to averaging measurements in real-time thetwo relevant parameters are the time, t , of the measurementand the signal sampling frequency, φ, that relates to theaveraging frequency. In the above, N is replaced by t = N�t ,and α by φ, with φ = α /�t , giving

A(t) ≈ (1 − e−φt ). (7)

This is the response of the EMA to a step function input. Theconvolution theorem with minor rearrangement and followingLaplace transformation can be used to determine the impulseresponse function as

H (s) = φ/(s + φ) (8)

which shows that in the limit, �t → 0, the EMA is a first orderlow-pass filter with a time constant of 1/φ. This expressioncan be used with the convolution theorem to determine thefrequency response of the EMA and the relative effects of theEMA sample frequency and input signal frequency.

Page 3: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

2050 IEEE SENSORS JOURNAL, VOL. 14, NO. 6, JUNE 2014

Fig. 1. Phase lag of the EMA relative to the input signal as a function ofthe dimensionless parameter ρ = φ/ω.

B. EMA Frequency Response

The frequency response of the EMA for a unit sine wave,frequency 2π f = ω is

R(s) = φω

(s + φ)(s2 + ω2),

which is convenient to recast as

R(s) = φ/ω

φ2/ω2+1

(1

s+φ+ φ

ω

ω

(s2+ω2)− s

(s2+ω2)

). (9)

The inverse Laplace transform gives

r(t) = ρ

ρ2 + 1

(e−φt + ρ sin(ωt) − cos(ωt)

)(10)

where ρ = φ/ω is a dimensionless scaling factor of theratio between the sampling frequency, φ, and the input signalfrequency, ω.

The phase difference between the input signal and the EMAcan be determined by comparing the points where they bothhave a zero derivative (being at π /2 and tan−1(ρ), respectively)and recalling that the EMA must lag the input signal so thattan−1(ρ) is evaluated in the correct quadrant. Fig. 1 shows therelationship of the EMA phase to the input signal over a rangeof ρ values determined this way.

C. EMA Frequency Response and Trigger Levels

In the application being considered here the event triggerwindow defines a constant positive or negative excursionaround the EMA: an event is triggered whenever the inputsignal exceeds these limits. The value of the limits will varywith the incoming signal since the EMA is varying with theinput signal and thus the signal level that will trigger an eventis not simply related to the input signal level. Fig. 2 showstwo examples of how the trigger window varies with the inputsignal for a window set at 30% of a maximum unit inputsinusoidal amplitude. In this case the low frequency input, withρ = 3.2, is always just contained within the +/− 30% triggerwindow even with the maximum input signal and would nevertrigger an event. On the other hand, ρ = 0.3 easily triggers anevent and since the excursion of the EMA is only ± ∼ 0.5,signals lower than the maximum would trigger an event.

Fig. 2. Variation of a ±30% window, dash-dot lines, around the EMA, dottedline, as the input signal varies, solid line, for (a) ρ = 3.2 and (b) ρ = 0.3.In case (a) no event would be detected since the input signal is being closelytracked by the EMA and is always just within the trigger window.

To determine how low the signal can be requires a moredetailed analysis of the response of the EMA since 1) as theinput decreases the EMA decreases and 2) the phase betweenthe two changes depending on the value of ρ (standardbehaviour for a filter). This phase effect means that a simpleamplitude calculation is not sufficient to determine whether theinput signal will exceed the EMA to trigger an event. This isillustrated in Fig. 2(a) where decreasing ρ slightly will resultin triggering on the rising or falling edges, but not at the peaks.

Three different ρ regimes give a general understanding ofthe EMA response.

1. Low Frequency Response

ρ � 1, giving r(t) ≈ sin(ωt)

The EMA tracks the input (low-pass filter) and will nevertrigger an event. This would correspond to the EMAtracking a slowly varying signal such as a slowly varyingoffset due to sensor drift or other external factors such astemperature.

2. Intermediate Frequency Response

ρ ≈ 1, giving r(t) ≈ 1√2

sin(ωt − π/4)

which shows that the EMA is a sine wave that lags theinput signal by π /4. Any trigger window will be varying

Page 4: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

WILSON: EVENT TRIGGERED ANALOG DATA ACQUISITION 2051

Fig. 3. Maximum difference calculated using (11) between the EMA andthe unit input signal as a function of the dimensionless parameter ρ = φ/ω.

by a factor of ±1/√

2, a significant proportion of theinput signal’s amplitude.

3. High Frequency Response

ρ � 1, giving r(t) ≈ −ρ cos(ωt)

which is a cosine wave that lags the input signal byπ /2 with amplitude that decreases as the input signalfrequency increases relative to the EMA averaging fre-quency. As ρ decreases with increasing signal frequency,r(t) tends to 0, so the trigger window would have littlevariation.

The maximum difference between f (t) and r(t) gives theupper bound for the size of an event trigger window relative tothe maximum input signal, as a function of ρ, that will result inthe triggering of an event i.e. a trigger window larger than thisvalue will never trigger for events at the corresponding ρ ratiosince the input signal never exceeds the EMA value by morethan the trigger value. This occurs at ωt = tan−1(1/ρ), theturning point of f (t)−r(t), which is a high-pass filter (a highpass filter is equivalent to the input less the input after passingthrough a low-pass filter). Substituting this into the f (t)−r(t)gives the difference, d , following some simplification, as

dmax |t (ρ)= 1

ρ2+1

(ρ cos(tan−1(1/ρ)) + sin(tan−1(1/ρ))

)(11)

which is shown in Fig. 3. A difference close to 1 correspondsto an EMA with very little amplitude and thus very littlevariation of the trigger window. Conversely, a difference ofclose to 0 corresponds to an EMA that is tracking the inputsignal and thus the input would always be contained within atrigger window.

The actual trigger window value, Wv , that must be enteredto ensure triggering at a particular input signal level, Wl , is

Wv (φ, ω) = Wl(φ, ω) × dmax |t (t, φ, ω) (12)

where the functional dependence on φ and ω is now includedexplicitly. Note that the Wv value is less than the signal levelthat is to be detected. As an example, for ρ = 1 givingdmax|t(..) ∼ 0.7 (Fig. 3), to trigger on a signal of Wl = 0.1

of the maximum input signal the trigger window, Wv , wouldhave to be set to 0.07 of the maximum input signal. Fortheoretical considerations this is no problem however in real-world applications there is a minimum detectable signal whichdepends on parameters such as the ADC bit resolution andthe noise level. Eventually, as the desired ρ becomes larger(corresponding to lower frequency), the required window sizewould become less than the noise level and/or the single bitresolution of the ADC used and would result in continuoustriggering.

IV. IMPLICATIONS OF A FREQUENCY DEPENDENT

TRIGGER WINDOW

In practice, for structural monitoring, the interest is tocapture signals that exceed a certain level. The simplisticapproach is to set the trigger point equal to the minimum signalof interest. When using the EMA the expected maximum andminimum frequency components of the input signal must alsobe considered.

The following example is for an averaging number N = 256and a sampling rate of 100 Hz, giving φ = 100/256 =0.39 Hz. (Recall that φ has units of 1/time, φ ∼ 1/N andthe time increment for N is 1/(sample frequency). Thus φ =(sample frequency)/N .) If the lowest frequency to measure is∼0.1 Hz, (ω = 0.63) the φ/ω ratio is 0.62. From Fig. 3the maximum difference between the EMA signal and theinput signal for this ratio is ∼0.85 of the input signal andthus to ensure that an event is triggered when the input justexceeds 10 (i.e. Wl = 10 units of what is being measured) fora 0.1 Hz signal the trigger window would be set at 8.5. Higherfrequencies, such as those contained in an impulse, wouldtrigger at a lower measurement threshold with the trigger pointfor frequencies above 1 Hz (φ/ω → 0) very close to the setpoint of 8.5. Frequencies lower than 0.1 Hz would only triggerat higher input levels. For example, at 0.01 Hz (φ/ω = 6.2)Fig. 3 gives a difference of ∼0.16, thus an input of 53 wouldbe required for the difference between the EMA and the inputsignal to exceed the trigger level. This shows that the EMA isa very good average to use if impulses are to be detected butit is insensitive to low frequency variations (as expected, sinceit is meant to be averaging these out). However, in practicalimplementations, this does not place a severe restriction on theuse of the EMA since it is easy to continually record data at alow sampling rate to ensure that the low frequency regime iscaptured, and only record at a high rate when high frequencyevents are present.

V. PRACTICAL IMPLEMENTATION ON A

LOW-POWER MICROCONTROLLER

Low-power microcontrollers generally have limitedresources particularly in respect to the amount of internalmemory available and the capability and speed for performingfloating point calculations. The fastest computation speedscan be achieved using integer arithmetic and the values mustbe scaled up to ensure that fractional values, particularly αin (1), are greater than 1: the larger the scaling factor thegreater the precision since fractional values will be better

Page 5: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

2052 IEEE SENSORS JOURNAL, VOL. 14, NO. 6, JUNE 2014

Fig. 4. Calculated convergence of the EMA for K = 256 with aninput step from 0 to 2048 (corresponding to a half full-scale step for a12 Bit ADC).

represented. Multiplying all measurements by a factor ofK in (1) and allowing for truncation of all calculations tointegers gives:

R(n)= K × m(n)+ R(n − 1) −int(R(n − 1)/K ) × Kα (13)

where int(..) represents the integer part of the division andKα must be greater than 1. In practice, for best precision,K should be chosen so that Kα is an exact integer and thusthe α term is not approximated by a nearest integer. To statethis in another way, K = k/α, where k is a positive integer.For k = 1, (13) becomes:

R(n) = K × m(n) + R(n − 1) − int(R(n − 1)/K ). (14)

Computational speed is improved if K is chosen as a powerof 28 since then integer multiplication and division consistssimply of moving whole bytes up or down. It should also benoted that the use of integer arithmetic means that for a fixedinput R(n) will converge to a fixed value at some finite n,unlike the true EMA which converges but never reaches afinal value.

Selecting K = 256 is practical for implementation on amicrocontroller since all computations can be easily performedwith integers (2 Bytes) and long integers (4 Bytes). In thiscase, for a constant input m(n) = mc, R(n) converges toK 2 × mc, and provided the m(n) values are 2 byte integers,R(n) will never overflow. Another useful feature is that theaverage value for comparison with the incoming measurementsand the trigger window is simply the top 2 bytes of R(n).

There is also a practical timing consideration as demon-strated by Figs. 4 and 5. Fig. 4 shows a calculated exampleusing (14), with K = 256, of how the R(n) values convergefor a half full-scale step input (0 to 2048) for a 12 BitADC. It takes 3512 measurements for the value to reach theaverage value of 134,217,728, which equals 2048*256*256,1000 measurements to be within 2% of this value and 1175to be within 1%. Fitting a curve of the form K 2(1 −e−nα)to the results shown in Fig. 4 gives α = 1/255.5, close tothe theoretical value of 1/256. Fig. 5 shows the effect ofchanging K on the convergence of a half full-scale step inputfor 10, 12 and 14 Bit ADCs. The time is linear with K but notstrongly dependent on the Bit depth of the ADC. At 100 Hz

Fig. 5. Number of iterations to convergence related to the averaging value,K , with a half full-scale input step for 10 Bit (round), 12 Bit (square) and14 Bit (triangle) ADCs.

sampling rate the convergence shown in Fig. 4 would take35 s. However, if K was chosen as 216 it would take 256*3512measurements corresponding to nearly 2.5 hours, a long timeto achieve the EMA: any small step change in the DC levelof the input above the trigger point would result in hours ofdata being collected, even if there was no further variationin the input. The higher value for K may be appropriate forhigher sampling rates, resulting in a quicker convergence, orin situations were very low frequencies need to be recordedin the presence of very high frequencies. However, as notedat the end of Section IV, this can be achieved by continualrecording at low frequency and using the triggering to record athigh frequency. It should also be noted that if required, highervalues of K only slightly increases the memory requirementsto implement the EMA. For K = 216 and double Byte integerm(n) input, R(n) would need to be a 6 Byte long integer toavoid overflowing, giving 48 Bytes of memory for 8 channels,only 16 Bytes greater than for K = 28.

While the depth of the ADC has little effect on the conver-gence time of the EMA, it does, however, have implicationsregarding minimum window size and thus minimum triggerfrequencies for a given window size. Consider a 12 Bit ADCwith a desired range of ±2048 units. Assuming noise of 1 Bit,the minimum trigger window would be 2. Following fromthe example above (K = 256, sampling at 100 Hz and todetect 0.1 Hz signals) the minimum detectable signal is 2/0.85,rounded up to the nearest bit, giving 3. If faster events were tobe detected, say at a sampling rate of 400 Hz (ρ = 2.48), theminimum detectable signal at 0.1 Hz would increase to 2/0.37(from Fig. 3) giving 6 (rounded up). One way to reduce thispossible problem is by increasing the ADC Bit depth e.g. usinga 14 Bit ADC reduces all of these limits by a factor of 4.Another technique is to continuously record data at a lowdata rate and use event triggering to catch high rate signals.For the 100 Hz sample rate above, the data could be recordedevery 5 s (0.2 Hz) while no events were detected. Thus only720 measurements would be recorded in an hour if there wereno trigger events compared to 360 000 if it was continuouslysampled at 100 Hz. This is a reduction of 99.8% in the amountof data recorded and has the added advantage of providing acontinual “heart-beat” to indicate that the sensor is operational.

Page 6: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

WILSON: EVENT TRIGGERED ANALOG DATA ACQUISITION 2053

Fig. 6. 5 Hz sinusoidal input centred on a raw ADC value of 2050 and atrigger window of ±256, sampled at 400 Hz. There are 256 pre-trigger valuesand 1536 post trigger values. A vertical marker has been placed at the 256th

measurement.

It is also useful to include a low frequency readout of theEMA value, say whenever data is requested from the sensorinterface, so that long term changes in the baseline can beeasily tracked.

A. Example EMA Implementation on the DSTO Interface

The standard DSTO 1-8 channel ADC software has theEMA for trigger events implemented on it in C code forK = 256. Fig. 6 shows an example of triggered data collectedat a sample rate of 400 Hz. To confirm the sampling andsignal input frequency dependence of the event triggering, thesoftware was altered so that a light emitting diode (LED) onthe interface was lit when input outside the trigger windowwas detected, corresponding to a signal that triggered dataacquisition. Monitoring the LED in real-time made it easy tomeasure the effect on event triggering of the signal amplitudeand frequency. For the tests, the ADC interface was setwith a trigger level at 2% of the +/− full range of the12 Bit ADC (41 Bits in 2048, corresponding to a constantWl = 33 mV in (12), with an input range of ±1.65 V) witha sinusoidal input signal sourced from an Agilent 33220A,20 MHz Function / Arbitrary Waveform. The amplitude tojust trigger an event corresponds to Wv in (12) and thus theratio of Wv / Wl gives the maximum of the difference betweenthe input signal and EMA, from (12), which corresponds tod in (11).

The experimental results are presented in Table 1 and inFig. 7 for a range of sampling and input frequencies. Fig. 7includes a comparison with the theoretical results shown inFig. 3. The measured and theoretical results are essentiallythe same. Close examination of the higher ρ values showsthat the experimental values are consistently higher (e.g. forρ = 9.94 the calculated value is 0.100 whereas the measuredvalue is 0.106, 6% higher) which corresponds to low frequencyinput signals when the EMA is starting to track the inputmore closely. For a fixed input frequency and fixed N in (4),

TABLE I

INPUT VOLTAGE AND THE φ/ω RATIO

Fig. 7. Plot of measured Wv / Wl , as a function of the dimensionlessparameter ρ = φ/ω, for four different sampling frequencies, as indicated bythe legend, giving the maximum of the difference between the input signaland EMA. The “Theoretical” solid line is the same as that shown in Fig. 3,determined using (11).

increasing ρ (ρ = β/(N+1) / (�t .ω)) has the same affect asincreasing β in (5): the situation is moving away from thesmall value approximations used in the theoretical analysis.With increasing β and fixed N the exponent, e−β , becomesincreasingly larger than the value of (1-β/(N+1))N and thusthe increment between successive terms of the EMA forthe measurements becomes increasing less than that for thetheoretical terms. As a consequence, the measured EMA isincreasingly less than the calculated EMA as ρ increases.However, this effect is small and is “beneficial” in that thetrigger level for lower frequencies is not quite as high as thatpredicted by (11). In practice, the difference is small and thevalues given using (11) are sufficient to determine the effectof a particular trigger level and ρ combination.

VI. NOISE CONSIDERATIONS

False triggering due to noise spikes could result in excessdata collection during periods of inactivity. A simple approachto noise would be to require that the signal is above the

Page 7: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

2054 IEEE SENSORS JOURNAL, VOL. 14, NO. 6, JUNE 2014

Fig. 8. Effect of a 3 point noise filter (solid squares) on the maximumdifference between the input signal and EMA, and hence on the detection oftrigger events, compared with the theoretical results (solid line) from Fig. 7.

trigger threshold, in the same sense, for a certain number ofconsecutive measurements. This will eliminate triggering onspikes but has an impact on the trigger window now requiredto ensure triggering at a certain signal level.

To demonstrate this effect Fig. 8 was produced in thesame way as for Fig. 7, but with a noise filter that required3 consecutive points to be greater than the trigger value beforean event was recognised. Fig. 8 shows that detection of eventsis now affected at higher frequencies since it is now the mini-mum value of a number of consecutively sampled points of theinput wave that must be greater than the trigger level. Indeed,for a frequency greater than 1/4 of the sample frequency,3 consecutive points must always have one that is of theopposite sense than the other 2 (or 2 zero values) and thusno signal at this frequency would ever be detected as a triggerevent if 3 consecutive points above a threshold were required.Signal frequencies just below this would not trigger either witha finite threshold and when the frequency becomes low enoughto trigger this will not happen on all occasions since it wouldbe unlikely for the sampling to give 3 consecutive points abovethe threshold. As the signal frequency decreases this effectbecomes less since the sampling will increasingly pick offmeasurements close to each other in value at the peak of thedifference between the signal and EMA. Thus, if isolated highfrequency signal rejection is required this technique is goodgiving total rejection of all signals above a certain frequency.However, if impulse events are to be recorded then anotherapproach may be required or the signal needs to be over-sampled to ensure consistent triggering.

A. Filter for Inclusion of Impulse Events

The noise observed in the data gathered from the ACPBsconsists of random, mainly low level signal and electronicnoise plus the occasional high level spike, possibly dueto induced electrical noise from the operation of electricalmachinery. For event triggered data logging the noise associ-ated with the sensors and electronics is considered to be partof the required signal: if this noise is of the same order as thedesired trigger window then event triggered data collection isprobably not appropriate or the signal needs to be improved.The observed high level spikes on the ACPBs typically only

Fig. 9. Flow chart to avoid triggering on individual high level noise spikesin the data stream.

last for one data point. These can be rejected, for triggering,by using the procedure illustrated in Fig. 9. Essentially, point4 in the flow chart requires any high value measurements tohave been preceded by a measurement that was above thetrigger threshold. In the absence of a signal, the measurementimmediately preceding an induced spike will be below thesignal trigger threshold and the spike will be rejected. The“NO” decision for point 4 allows low level signals to beimmediately detected.

In practice, externally induced noise has been observed tohave a high level so the spike threshold will generally be wellabove the signal threshold: if the spike threshold can be setabove the maximum expected signal then this filter techniquedoes not affect signal detection. If this can not be done then itis possible that large signals (greater than the spike threshold)with high rise/fall times could still be missed. This could occuras discussed above for a signal with a frequency close to orabove 1/4 of the sample frequency. Unfortunately, this can notbe avoided. Ensuring that signals of interest have a frequencyat least 5 times lower than the sampling frequency wouldovercome this problem (and is also desirable to produce abetter sample of the waveform).

The response to impulse loads is of particular interest forthe ACPB studies. An impulse response consists of a rangeof (time damped) frequency components. Thus, even if thefirst, high frequency event was not detected, the subsequentsomewhat lower frequency components will lead to eventtriggering. The storage of pre-trigger data then ensures thatthe first high frequency components will be captured in thedata stream.

Page 8: Event Triggered Analog Data Acquisition Using the Exponential Moving Average

WILSON: EVENT TRIGGERED ANALOG DATA ACQUISITION 2055

VII. CONCLUSION

Event triggered data acquisition reduces the amount of datacollected if a system has significant quiescent periods. A trig-ger window approach has been considered here incorporatinga moving average to accommodate any long term drift in asignal’s base level. The exponential moving average (EMA)was adopted due to its low resource requirements, suitablefor implementation on a microcontroller. The variation of theEMA with the incoming signal is frequency dependent andthus the trigger level is frequency dependent, requiring smallerwindows for lower frequencies, which ultimately becomes alimitation due to the bit size of the ADC used and noise inthe measurement system. This limitation is easily overcomein practical applications by continuously collecting data at alow sample rate and using the trigger window to increasethe sample rate for higher frequencies. This still results ina significant reduction in data storage requirements if thesituation being studied has long quiescent times between burstsof activity. If random, high frequency noise spikes are an issueand result in excessive false triggering they can be eliminatedby a simple algorithm to detect and reject them.

ACKNOWLEDGMENT

The author acknowledges Tim Wilson for his initial imple-mentation of the event detection and data logging code on theDSTO 1-8 channel ADC interface.

REFERENCES

[1] W. Robinson, G. Welch, and G. O’Neill, “The need for a systemsengineering approach for measuring and predicting the degradation ofageing systems and how it can be achieved,” in Life ManagementTechniques for Aging Air Vehicles. Manchester, U.K.: RTO, Oct. 2001.

[2] G. Cooke, G. Cooke, G. Kawanishi, T. Higginbottom, P. Miller, andS. Wacksman, A Study to Determine the Annual Cost of CorrosionMaintenance for Weapons Systems in the USAF. Huachuca, AZ, USA:NCI Information Systems, Inc., Feb. 1998.

[3] S. Galea, A. Trueman, L. Davidson, P. Trathen, B. Hinton, A. Wilson,et al., “Aircraft structural diagnostic and prognostic health monitoringof corrosion prevention and control,” in Encyclopaedia for StructuralHealth Monitoring, 1st ed. New York, NY, USA: Wiley, 2009, ch. 112.

[4] R. Bartholomeus, B. Crawford, C. Davis, S. Galea, B. Hinton,G. McAdam, et al., DSTO Aircraft Structural Prognostic Health Moni-toring Program for Corrosion Prevention and Control. Perth, Australia:Australasian Corrosion Assoc. Inc., 2004.

[5] S. Freeman and J. Green, “Aluminum in the marine environment:An update,” in Proc. OCEANS MTS/IEEE Conf. Exhibit., Providence,RI, USA, Sep. 2000, pp. 1591–1595.

[6] A. R. Wilson and R. F. Muscat, “Novel thin wire paint and sealantdegradation sensor,” Sens. Actuators, A Phys., vol. 169, no. 2,pp. 301–307, 2011.

[7] R. F. Muscat, P. S. Vincent, and A. R. Wilson, “Method of manufacturingan electrical component,” Australian Patent 1 906 776, Mar. 26, 2003.

[8] A. R. Wilson, P. J. McMahon, R. F. Muscat, O. Vargas, andP. S. Vincent, “Thin metal foil sensors,” Proc. SPIE, vol. 6414,pp. 64140C-1–64140C-3, Jan. 2007.

[9] A. R. Wilson and P. S. Vincent, “Networked low power sensing: Networkinterface and main operating system,” IEEE Sensors J., vol. 10, no. 9,pp. 1495–1507, Sep. 2010.

[10] A. R. Wilson and T. E. Wilson, “High temporal accuracy for extensivesensor networks,” IEEE Sensors J., vol. 14, no. 4, pp. 1061–1063,Nov. 2013.

[11] (2013, Aug.). NIST/SEMATECH e-Handbook of Statistical Methods:EWMA Control Charts [Online]. Available: http://www.itl.nist.gov/div898/handbook/pmc/section3/pmc324.htm

Alan Richard Wilson received the B.Sc. (Hons.)and Ph.D. degrees in physics from the Universityof Melbourne, Australia, in 1976 and 1982,respectively.

From 1982 to 1985, he was a Research Fellow withthe Electron Microscope Unit, University of Sydney,and he joined the Defence Science and TechnologyOrganisation (DSTO) as a Research Scientist in1985. Most recently, he led the Platform Sensorsand Systems Group in the Maritime Division. Hiscurrent research interests include the development

of sensors and sensor systems for the monitoring of structure, environment,machinery, personnel, spaces, and other systems. He is an author of morethan 100 papers and three book chapters, and has six sensor patents. In 2008,he received both the DSTO Divisional Award for the Best Research and theDSTO Achievement Award.