FB_CMA_SourcePaired

This function block writes data from external PLC data buffers to a pair of MultiArray buffers.

It accumulates input data continuously, until the maximum size of the multi-array is reached. When these are completely filled, it is transferred to the target analysis ID.

FB_CMA_SourcePaired 1:

Synchronization of the data

The assignment of the data from the first stream to the second is direct, i.e. the first value from Stream A is related to the first value from Stream B. Measured data, e.g. position and vibration values must be synchronized in advance.

An instance of FB_CMA_Source must not be used as target for any other analysis function block. It offers only source functionality.

A time series collection can be interrupted in the event of an error. Lost signal data can lead to an unexpected result of the analysis chain, depending on the configuration of the algorithms.

Inputs and outputs

The output buffers correspond to the following definition (Shape). The variable parameters are part of the function block input stInitPars.

MultiArray in the

Element type

Dimensions

Dimensional variables

output stream A

eTypeCode

nDims

aDimSizes

output stream B

eTypeCode

nDims

aDimSizes

VAR_INPUT
    stInitParsA      : ST_MA_MultiArray_InitPars;       // init parameters for first MultiArray
    stInitParsB      : ST_MA_MultiArray_InitPars;       // init parameters for second MultiArray
    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#40US;             // 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.

Properties

The following properties can optionally be used to specify the timestamp of the input values associated with the next input call. If the properties are not set, a current timestamp and a typical time difference between two input values are automatically determined internally.
At FB_CMA_Sink, the timespan and time stamp of the input values of the analysis chain are assigned to the result of the analysis.

Name

Type

Access

Description

nTimestamp

ULINT
[T_DCTIME64; 1ns steps since 1.1.2000]

Set

Specification of the timestamp associated with the oldest value, which is transferred with the next input call.
(example: StartTimeNextLatch -CycleTime)

tSamplePeriod

LTIME

Set

Specification of the time difference between two input values.
(example: CycleTime / cOversamples).
This specification is only necessary once, as it is a constant value.

Methods

Input1D():

Writes data from external one-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.

  • 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 Input1D : HRESULT
VAR_INPUT
    pDataInA      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeA  : UDINT;                // size of data buffer in bytes
    pDataInB      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeB  : UDINT;                // size of data buffer in bytes
    eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    nWorkDimA     : UDINT;                // It designates the dimension in the first multi array being processed.
    nWorkDimB     : UDINT;                // It designates the dimension in the second multi array being processed.
    pStartIndexA  : POINTER TO UDINT;    (* optional: default:0->internally handled; It designates the index of the first MultiArray element to be copied.
                         If allocated it must point to a onedimensional array of UDINT with so many elements as dimensions of the MultiArray.
                         Upon successful completion of the copy, corresponding StartIndex is incremented by the number of copied elements. *)
    pStartIndexB  : POINTER TO UDINT;    // see pStartIndexA
    nOptionPars   : DWORD;               // option mask
END_VAR
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
  • pDataInA, pDataInB: The data buffer must contain the data from all channels.
  • eElementTypeA, eElementTypeB: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.
  • nWorkDimA, nWorkDimB: Defines the dimension in which the data are accumulated. In general the MultiArray is also one-dimensional and nWorkDimA := 0 or nWorkDimB := 0 , but the MultiArray can also have additional dimensions, which may not then be processed, however.
  • pStartIndexA, pStartIndexB: This is an optional parameter, which can be useful if the MultiArray has more than one dimension. Specifies the index of the first MultiArray element to be copied. If assigned, it must point to a one-dimensional array of UDINT that has as many elements as the MultiArray has dimensions. After a successful copy process, the corresponding Start Index is incremented by the number of copied elements.
  • bError: This output is TRUE if an error occurs.
  • hrErrorCode: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.

Input1DStd():

Writes data from external one-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.

This method uses default values for the parameters nWorkDimA := 0, nWorkDimB := 0 and pStartIndexA := 0, pStartIndexB := 0.

  • 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 Input1DStd : HRESULT
VAR_INPUT
    pDataInA      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeA  : UDINT;                // size of data buffer in bytes
    pDataInB      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeB  : UDINT;                // size of data buffer in bytes
    eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    nOptionPars   : DWORD;               // option mask
END_VAR
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
  • pDataInA, pDataInB: The data buffer must contain the data from all channels.
  • eElementTypeA, eElementTypeB: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.
  • bError: This output is TRUE if an error occurs.
  • hrErrorCode: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.

Input2D():

Writes data from external two-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.

  • 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 Input2D : HRESULT
VAR_INPUT
    pDataInA      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeA  : UDINT;                // size of data buffer in bytes
    pDataInB      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeB  : UDINT;                // size of data buffer in bytes
    eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    nWorkDimA0    : UDINT;                // It designates the first dimension in the first multi array being processed.
    nWorkDimA1    : UDINT;                // It designates the second dimension in the first multi array being processed.
    nWorkDimB0    : UDINT;                // It designates the first dimension in the second multi array being processed.
    nWorkDimB1    : UDINT;                // It designates the second dimension in the second multi array being processed.
    pStartIndexA  : POINTER TO UDINT;    (* optional: default:0->internally handled; It designates the index of the first MultiArray element to be copied.
                         If allocated it must point to a onedimensional array of UDINT with so many elements as dimensions of the MultiArray.
                         Upon successful completion of the copy, corresponding StartIndex is incremented by the number of copied elements. *)
    pStartIndexB  : POINTER TO UDINT;    // see pStartIndexA
    nOptionPars   : DWORD;               // option mask
END_VAR
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
  • pDataInA, pDataInB: The data buffer must contain the data from all channels.
  • eElementTypeA, eElementTypeB: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.
  • nWorkDimA0, nWorkDimB0: Defines the dimension that matches the number of channels. In general, the MultiArray is also two-dimensional and nWorkDimA0 := 0 or nWorkDimB0 := 0, but the MultiArray can also have additional dimensions, which may then not be processed.
    E.g: If the first index of the specified data buffer stands for the channels, but the second dimension of the MultiArray enumerates the channels, then set nWorkDimA0 := 1 or nWorkDimB0 := 1.
  • nWorkDimA1, nWorkDimB1: Defines the dimension in which the data are accumulated. In general, the MultiArray is also two-dimensional and nWorkDimA1 := 1 or nWorkDimB1 := 1, but the MultiArray can also have additional dimensions, which may then not be processed.
    E.g: If the second index of the specified data buffer stands for the collected data, but the first dimension of the MultiArray collects the data, then set nWorkDimB1 := 0 or nWorkDimB1 := 0.
  • pStartIndexA, pStartIndexB: This is an optional parameter, which can be useful if the MultiArray has more than one dimension. Specifies the index of the first MultiArray element to be copied. If assigned, it must point to a one-dimensional array of UDINT that has as many elements as the MultiArray has dimensions. After a successful copy process, the corresponding Start Index is incremented by the number of copied elements.
  • bError: This output is TRUE if an error occurs.
  • hrErrorCode: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.

Input2DStd():

Writes data from external two-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.

This method uses default values for the parameters nWorkDimA0 := 0, nWorkDimA1 := 1, nWorkDimB0 := 0, nWorkDimB1 := 1 and pStartIndexA := 0, pStartIndexB := 0.

  • 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 Input2D : HRESULT
VAR_INPUT
    pDataInA      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeA  : UDINT;                // size of data buffer in bytes
    pDataInB      : POINTER TO BYTE;      // address of data buffer (e.g. oversampling data) as one-dimensional array
    nDataInSizeB  : UDINT;                // size of data buffer in bytes
    eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
    nOptionPars   : DWORD;               // option mask
END_VAR
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
  • pDataInA, pDataInB: The data buffer must contain the data from all channels.
  • eElementTypeA, eElementTypeB: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.
  • bError: This output is TRUE if an error occurs.
  • hrErrorCode: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.
METHOD Init : HRESULT
VAR_INPUT
    stInitParsA    : ST_MA_MultiArray_InitPars;       // init parameters for first MultiArray
    stInitParsB    : ST_MA_MultiArray_InitPars;       // init parameters for second MultiArray
    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 sets that have already been added so that the current output buffer (MultiArray) can be filled from the start again. If external indices are to be used when filling (pStartIndex parameter), they must be explicitly reset.

METHOD ResetData : HRESULT
VAR_INPUT
END_VAR

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4022.25

PC or CX (x86, x64)

Tc3_CM, Tc3_CM_Base, Tc3_MultiArray