FB_CMA_SpikeEnergySpectrum

Analysis of peak energy of high-frequency signal components

The function block FB_CMA_SpikeEnergySpectrum implements a widely used method for vibration analysis on machine elements. The method analyzes high-frequency signal components, in particular frequencies beyond the linear transmission range of an accelerometer, and is therefore very sensitive in the early detection of damage patterns.

The method is based on the evaluation of an accelerometer signal, wherein signal components are considered that are beyond the resonance frequency of the accelerometer. Accordingly, high-frequency pulse-shaped disturbances appear – e.g. arising when rolling over minor damage to the roller bearing - as modulation on a carrier signal. The carrier signal is determined by the resonance frequency of the mounted accelerometer. The spike energy method filters out the carrier signal and forms an envelope over the high-frequency pulse-shaped disturbances. Thus, they allow the damage frequencies of a component, e.g. a roller bearing, to be recognized more concisely in the spectrum.

Since the method strongly depends on the assembly, the location and the sensor type, the method is only suitable for trend monitoring, i.e. the transfer of threshold values to other measuring points is not possible.

The input data buffer of the function block FB_CMA_SpikeEnergySpectrum is first combined overlapping with the immediately preceding buffers and multiplied by a window function. The DFT coefficients are then calculated using the Goertzel algorithm. The parameter eSpectrumType defines whether the absolute magnitude or its square is calculated from the resulting complex values. If the parameter bTransformToDecibel is TRUE, the values are transformed to decibel values. These decibel values are the same for both spectral values (magnitude or its amplitude), i.e. the influence of the squaring on the power values is taken into account by a factor of two for the magnitude values when calculating the decibel values. Furthermore, scaling of the results is feasible via the parameter eScalingType, see Scaling of spectra.

Scaling

The scaling of the result values, e.g. the Acceleration Spectral Densities matches the definition of the FFT by default. This means that the influence of the window length and the window function are eliminated.
Tabulated parameters described in the section "Options for spectrum scaling " can be used for the arithmetic scaling of absolute measurements.

Memory properties

Due to the use of the Welch method, the current input data buffer, together with the last-transferred buffers, is used for the calculation. The number of buffers incorporated depends on the selected overlap (nOverlap).
The frequency analysis takes step changes in the time series into account. In order to achieve a correct result, therefore, the input data buffers used must be concatenated without gaps and without jumps.

NaN occurrence

If the input vector contains one or more NaN (Not a Number) values, the entire output sector is filled with NaN. See separate section for further information on NaN values.

FB_CMA_SpikeEnergySpectrum 1:

Handling of NaN values

If the situations described above, which lead to NaN values, cannot be ruled out or safely neglected, the application program must be able to handle these error values.

Behavior when processing multi-channel input data

When processing several channels (nChannels > 1), there is a possibility of each channel having different return values. In this case, return values can be queried separately on the function block. If the results from one or more channels are impermissible, but not all channels, the value on the function block corresponds to eCM_InfRTime_AmbiguousChannelResults. If the results of all channels are impermissible, then the value on the function block corresponds to eCM_ErrRTime_ErrornousChannelResults.

A list of return values of all channels can be queried using the method GetChannelErrors().

Sample implementation

A sample implementation showing the possible uses of the function block and its configuration is available under the following link: Spike Energy Spectrum

Inputs and outputs

The input and output buffers correspond to one of the following definitions (input / output shape). The variable parameters are part of the function block input stInitPars.

Versions

Input buffer (MultiArray input stream)
element type, number of dimensions, dimension sizes

Output buffer (MultiArray output stream)
element type, number of dimensions, dimension sizes

Standard variant
(nChannels = 1)

LREAL, 1,
nWindowLength-nOverlap

LREAL, 1,
nFFT_Length/2+1

Multichannel variant
(nChannels > 1)

LREAL, 2,
nChannels x nWindowLength-nOverlap

LREAL, 2,
nChannels x nFFT_Length/2+1

VAR_INPUT
    stInitPars       : ST_CM_SpikeEnergySpectrum_InitPars;  // init parameter
    nOwnID           : UDINT;                               // ID for this FB instance
    aDestIDs         : ARRAY[1..cCMA_MaxDest] OF UDINT;     // IDs of destinations for output
    nResultBuffers   : UDINT := 4;                          // number of MultiArrays which should be initialized for results (0 for no initialization)
    tTransferTimeout : LTIME := LTIME#500US;                // timeout checking off during access to inter-task FIFOs
END_VAR

Input parameters

The input parameters of this function block represent initialization parameters and must already be assigned in the declaration of the FB instance! (Alternatively: Init() method). They may only be assigned once. A change at runtime is not possible.

Output parameters

VAR_OUTPUT
    bError         : BOOL;                           // TRUE if an error occurs. Reset by next method call.
    hrErrorCode    : HRESULT;                        // '< 0' = error; '> 0' = info; '0' = no error/info
    ipErrorMessage : I_TcMessage := fbErrorMessage;  // Shows detailed information about occurred errors, warnings and more.
    nCntResults    : ULINT;                          // Counts outgoing results (MultiArrays were calculated and sent to transfer tray).
END_VAR
  • bError: The output is TRUE if an error occurs.
  • hrErrorCode: If an error occurs, a corresponding error code of the type HRESULT is output. Possible values are described in the List of error codes.
  • ipErrorMessage: Contains more detailed information on the current return value. Refer here to the section Error description and information. This special interface pointer is internally secured so that it is always valid/assigned.

Methods

Call():

The method is called each cycle in order to apply the algorithm to the current input data. The function block waits for input data if the method indicates neither new results nor an error. This is a regular behavior in the process of the analysis chain.

  • Return value: If an error occurs, a corresponding error code of the type HRESULT is output. Possible values are described in the List of error codes.
METHOD Call : HRESULT
VAR_OUTPUT
    bNewResult   : BOOL;       // TRUE every time when outgoing MultiArray was calculated and sent to transfer tray.
    bError       : BOOL;       // TRUE if an error occurs.
    hrErrorCode  : HRESULT;    // '< 0' = error; '> 0' = info; '0' = no error/info
END_VAR
  • bError: The output is TRUE if an error occurs.
  • hrErrorCode: If an error occurs, a corresponding error code of the type HRESULT is output. Possible values are described in the List of error codes. This output is identical to the return value of the method.
FB_CMA_SpikeEnergySpectrum 2:

If a timeout occurs or no MultiArray buffer is available for the result, then neither the input data nor the result data are lost. They are forwarded on the next call.

Configure():

By calling this method, the decay time (fDecayTime) as well as the frequency band under consideration (via fLowerFrequencyLimit, fUpperFrequencyLimit) can be adjusted at runtime. The decay time should be selected in the optimal case so that the peak energy can completely decay, i.e. fDecayTime > 1/f_fault.

The corresponding PLC array must be defined as follows: [fDecayTime, fLowerFrequencyLimit, fUpperFrequencyLimit]. The Configure() method can also be used for a new configuration with a different set of arguments.

METHOD Configure : HRESULT
VAR_INPUT
    pArg     : PVOID;    // pointer to array of arguments
    nArgSize : UDINT;    // size of arguments buffer in bytes 
END_VAR

The input buffers correspond to one of the following definitions (input shape). The variable parameters are part of the function block input stInitPars.

Versions

Input buffer (MultiArray input stream)
element type, number of dimensions, dimension sizes

Identical configuration of all channels

LREAL, 1,
3

Channel-specific configuration
(nChannels > 1)

LREAL, 2,
nChannels x 3

METHOD Init : HRESULT
VAR_INPUT
    stInitPars     : ST_CM_SpikeEnergySpectrum_InitPars;  // init parameter
    nOwnID         : UDINT;                               // ID for this FB instance
    aDestIDs       : ARRAY[1..cCMA_MaxDest] OF UDINT;     // IDs of destinations for output
    nResultBuffers : UDINT := 4;                          // number of MultiArrays which should be initialized for results (0 for no initialization)
END_VAR

Init():

This method is not usually necessary in a Condition Monitoring application. It offers an alternative to the function block initialization. The Init() method may only be called during the initialization phase of the PLC. It cannot be used at runtime. You are referred to the use of an FB_init method or the attribute 'call_after_init' (see TwinCAT PLC reference). In addition, this facilitates the function block encapsulation.

The input parameters of the function block instance may not be assigned in the declaration if the initialization is to take place using the Init() method.

  • Return value: If an error occurs, a corresponding error code of the type HRESULT is output. Possible values are described in the List of error codes.

ResetData():

The method deletes all data records that have already been added, see Memory property of the function block. If the Call() method is called again after a ResetData(), the internal memory must be replenished in order to calculate a valid result.

  • Return value: If an error occurs, a corresponding error code of the type HRESULT is output. Possible values are described in the List of error codes.
METHOD ResetData : HRESULT
VAR_INPUT
END_VAR

PassInputs():

As long as an FB_CMA_Source instance is called and signal data are thus transferred to a target block, all further function blocks of the analysis chain have to be called cyclically as explained in the API PLC Reference.
Sometimes it is useful not to execute an algorithm for a certain time. For example, some algorithms should be executed only after prior training or configuration. The function block must be called cyclically, but it is sufficient for the data arriving at the function block to be forwarded in the communication ring. This is done using the PassInputs() method in place of the Call() method. The algorithm itself is not called here, and accordingly no result is calculated and no output buffer generated.

  • Return value: If an error occurs, a corresponding error code of the type HRESULT is output. Possible values are described in the List of error codes.
METHOD PassInputs : HRESULT
VAR_INPUT
END_VAR

GetChannelErrors():

The method enables the querying of a list of the channel-specific return values when processing several channels (nChannels > 1). A call is useful in the case that the return value of the function block corresponds to one of the values eCM_InfRTime_AmbiguousChannelResults or eCM_ErrRTime_ErrornousChannelResults.

  • Return value: Information on the reading process of the list of error codes. The value is set to TRUE if the query was successful, otherwise to FALSE.

    METHOD GetChannelErrors : BOOL
VAR_IN_OUT
    aChannelErrors : ARRAY[*] OF HRESULT;
END_VAR
  • aChannelErrors: Error list of the type HRESULT of the length nChannels.

Similar function blocks

The function block FB_CMA_PowerCepstrum calculates the power cepstrum of a real-valued input signal.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4022.25

PC or CX (x86, x64)

Tc3_CM, Tc3_CM_Base