FB_MDP_ScanModules
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 a device to be searched for a specific IPC diagnostics module.
A selection can be made if the module type is present more than once. For the selected module type the dynamic module ID is determined by the function block.
This is an important part of the MDP addressing, which is represented in the structure ST_MDP_Addr.
VAR_INPUT
VAR_INPUT
bExecute : BOOL;
nModuleType : WORD; (* 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. *)
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.
nModuleType: At this input is the IPC diagnostics module type is specified. The possible types are listed in the enumeration E_MDP_ModuleType. (general information on IPC diagnostics module types.)
iModIdx: If several instances of an IPC diagnostics module exist, a selection can be made by means of the input iModIdx (0,...,n).
In the case of uncertainty concerning the selection: information about which module is explicitly concerned can be queried via the function block FB_MDP_ReadModuleHeader after scanning.
tTimeout: Specifies a maximum length of time 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 Scan was successfull or not *)
nErrID : UDINT;
nDynModuleId : BYTE; (* Dynamic Module 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.
nDynModuleId: This output indicates the dynamic Module ID determined for the selected module.
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 |