FB_MDP_ReadElement
Update: Tc3_IPCDiag library The TwinCAT 3 PLC library Tc2_MDP is the predecessor to Tc3_IPCDiag. With the new Tc3_IPCDiag library the number of readable parameters has been increased and the user interface has been optimized. It is recommended to use the Tc3_IPCDiag library. |
The function block enables querying of an individual MDP element. In this way, each element from each module of the Configuration Area can be read!
Internally, the device is scanned for the selected module, and the element information is 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. *)
pDstBuf : DWORD; (* 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 positive edge on the input bExecute, if the function block is not already active.
stMDP_Addr: At this input the MDP addressing relating to the selected MDP module is specified. The structure is of type ST_MDP_Addr.
The area must be specified as Configuration Area.
The dynamic module ID is only added internally and must not be specified.
iModIdx: If a MDP module is present more than once, a selection (0,...,n) can be made by means of input iModIdx.
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: An The length of the data buffer in bytes is specified at this input.
tTimeout: Specifies a maximum time duration for the execution of the function block.
sAmsNetId: To execute the query on the local device, it is not necessary to specify this input variable. Alternatively, an empty string can be specified. To direct the query to another computer, its AMS Net Id (of type T_AmsNetId) can be specified here.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL; (* indicates if Read was successfull or not *)
nErrID : UDINT;
nCount : UDINT;
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. *)
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.
nCount: This output indicates the number of bytes read.
stMDP_DynAddr: At this output the MDP addressing relating to the selected MDP module is specified. 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 correspond to the specified type.
iModuleCount: The output iModuleCount indicates the entire number of modules on the device.
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, ARM) | Tc2_MDP |