FB_MDP_ReadModule

FB_MDP_ReadModule 1:

The function block enables an MDP module to be queried.
The device is scanned internally for the selected module and the module header, and the module information are queried with the dynamic Module ID.

VAR_INPUT

VAR_INPUT
    bExecute        : BOOL;
    stMDP_Addr      : ST_MDP_Addr;            (* includes all address parameters without the Dynamic Module Id *)
    eModuleType     : E_MDP_ModuleType;      (* chosen module type out of the module type list *)
    iModIdx         : USINT;                (* chosen index(0..n) of the demanded module type. E.g. second NIC(idx 1) of three found NICs. *)
    iSubIdxCount    : USINT;
    pDstBuf         : POINTER TO BYTE;              (* Contains the address of the buffer for the received data. *)
    cbDstBufLen     : UDINT;                (* Contains the max. number of bytes to be received. *)
    tTimeout        : TIME  := DEFAULT_ADS_TIMEOUT; (* States the time before the function is cancelled. *)
    sAmsNetId       : T_AmsNetId;          (* keep empty '' for the local device *)
END_VAR

bExecute

The function block is called by a rising edge on the input bExecute, if the block is not already active.

stMDP_Addr

The MDP addressing belonging to the selected module is specified at this input. The structure is of the type ST_MDP_Addr. The dynamic Module ID is only added internally.

eModuleType

The MDP module type is specified at this input. The possible types are listed in the enumeration E_MDP_ModuleType. (General information on the module type list

iModIdx

If several instances of an MDP module exist, a selection can be made by means of the input iModIdx (0,...,n).

iSubIdxCount

The input iSubIdxCount is used to specify how many subindices of the selected Table ID are to be queried.

pDstBuf

The memory address of the data buffer is specified at this input. The received data are stored there if the query is successful.

cbDstBufLen

The length of the data buffer in bytes is specified at this input.

tTimeout

Specifies a maximum length of time for the execution of the function block.

sAmsNetId

For local access don't specify this input or allocate an empty string. For remote access to another computer specify its AMS Net Id.

VAR_OUTPUT

VAR_OUTPUT
    bBusy               : BOOL;
    bError              : BOOL;         (* indicates if Read was successfull or not *)
    nErrID              : UDINT;
    iErrPos             : USINT;
    stMDP_DynAddr       : ST_MDP_Addr;        (* includes the new dynamic module type id. *)
    iModuleTypeCount    : USINT;            (* returns the number of found modules equal the demanded module type. *)
    iModuleCount        : USINT;            (* returns the number of all detected MDP modules. *)
    stMDP_ModuleHeader  : ST_MDP_ModuleHeader;
    arrStartIdx         : ARRAY[0..255] OF UINT;    (* startindexes in bytes of each subindex element *)
END_VAR

bBusy

This output is TRUE as long as the function block is active.

bError

Becomes TRUE as soon as an error situation occurs.

nErrID

Returns an error code if the bError output is set.

iErrPos

If an error occurred and this refers to an individual element, then this output indicates the position (subindex of the element) at which an error first occurred.

stMDP_DynAddr

The MDP addressing belonging to the selected MDP module is specified at this output. The structure is of the type ST_MDP_Addr. The dynamic Module ID was added by the function block.

iModuleTypeCount

The output iModuleTypeCount indicates the number of modules that corresponds to the specified type.

iModuleCount

The output iModuleCount indicates the entire number of modules on the device.

stMDP_ModuleHeader

The header information from the read MDP module is displayed at this output in the form of the structure ST_MDP_ModuleHeader.

arrStartIdx

This array describes how the individually queried subindices have been stored in the buffer.
The array index zero indicates the position in bytes at which the data of subindex zero begins in the buffer. Subsequent subindices are handled analogously.

Requirements

Development environment

Target platform

PLC libraries to be linked

TwinCAT v2.11.0 Build >= 1541

PC or CX (x86, ARM)

TcMDP.Lib