IOL_IdentificationAndDiagnosis

IOL_IdentificationAndDiagnosis 1:

Function block for identification and diagnosis of an IO-Link device. This function block is implemented by the Common IO-Link Profile. The ApplicationSpecificTag, the FunctionTag and the LocationTag of an IO-Link device can be written. The function classes and ProfileIDs of a device can be read. Additionally the function block gives a diagnosis on the state of a device and its identification, which can include the Vendor Name, Vendor ID, Device Name, and Device ID.

IOL_IdentificationAndDiagnosis 2: Inputs

Name

Type

Description

Execute

BOOL

A trigger causes the function selected with the Function variable to be executed:

MasterAoENetid

T_AmsNetid

AMS NETID of the IO-Link master

IolPort

E_IolPort

IO-Link port of the IO-Link device

Func

E_IolIad_Function

This variable selects the functionality to be triggered by a request:

0 = no_func

A request is neglected, no function is executed

1 = rd_all

A request starts the read-back of the current identification

and diagnostic parameter values from the device.

2 = rd_diag

A request starts reading back the current diagnostic parameter values by reading DeviceStatus and DetailedDeviceStatus from the device.

3 = wr_ ident

A request causes a previously created value for ApplicationSpecificTagIn, LocationTagIn and FunctionTagIn to be written to the device.

BackupEnable

BOOL

This variable configures the behavior of the FB in case of the requested function wr_ident.

"true" = enabled

The backup mechanism is triggered by the FB.

"false" = disabled

The backup mechanism is not triggered by the FB.

ApplicationSpecificIN

String(32)

Parameters of the IO-Link device

FunctionTagIN

String(32)

Parameters of the IO-Link device

LoactionTagIN

String(32)

Parameters of the IO-Link device

IOL_IdentificationAndDiagnosis 3:Outputs

Name

Type

Description

Done

BOOL

The signal is set when the FB has completed a requested operation.

Busy

BOOL

The signal is set when the FB executes a requested operation.

Error

BOOL

The signal is set when an error occurred during the execution of a requested operation.

AdsError

E_ADSErr

ADS error code

IoLError

E_IolError

IO-Link error

State

E_IolIad_State

The value represents the current status of the FB operation and the executed functions. The content is system specific and contains the status information.

ProfileIDList

ARRAY [0..31] of E_IolProfileIdentifier

List of ProfileIDs supported by the device

FunctionClassIDList

ARRAY [0..31] of E_IolProfileIdentifier

List of FunctionClassIDs supported by the device

IdentificationObjects

ST_IolIdentificationObjects

Structured list of identification objects, for more details.

DeviceOK

BOOL

The signal is set if no further diagnostic information is available, it is false if further information is available at DeviceStatus and DetailedDeviceStatus.

DeviceStatus

E_IolDeviceStatus

Status of the IO-Link device

DetailedDeviceStatus

T_IolDetailedDeviceStatus

ARRAY [0..63] of ST_DetailedDeviceStatusEntry

Example

The following function block is part of the IoLink sample project. For more information, see the chapter Samples.

FUNCTION_BLOCK FB_Sample_06_IdentificationAndDiagnosis
VAR_INPUT
    sApplicationTagIn       : STRING(32) := '';
    sFunctionTagIn          : STRING(32) := '';
    sLocationTagIn          : STRING(32) := '';
    bExecute                : BOOL;
END_VAR
VAR_OUTPUT
    bBusy                   : BOOL := FALSE;
    bDone                   : BOOL := FALSE;
    bError                  : BOOL := FALSE;
    
    sIolError               : STRING;
    sAdsError               : STRING;
    aProfileIDList          : ARRAY [0..31] OF E_IolProfileIdentifier;
    aFunctionClassIDList    : ARRAY[0..31] OF E_IolProfileIdentifier;
    stIDentObjects          : ST_IolIdentificationObjects;
    bDeviceOK               : BOOL;
    nDeviceStatus           : E_IolDeviceStatus;
    DetailedDeviceStatus    : T_IolDetailedDeviceStatus;
END_VAR
VAR
    bExecuteOld             : BOOL;
    nState                  : INT := 0;
    IolDiagAndIdent         : IOL_IdentificationAndDiagnosis;
END_VAR
////
// Execute/Busy State Machine
//
IF bExecute AND NOT bExecuteOld AND NOT bBusy THEN
    bBusy := TRUE;
    nState := 10;    // START
ELSIF NOT bExecute THEN
    bBusy := FALSE;
    bError := FALSE;
    bDone := FALSE;
    sIolError:='';
    sADSError:='';
END_IF
bExecuteOld := bExecute;
    

CASE nState OF
    
// IDLE
0:;

// START
10:
    IolDiagAndIdent(Execute := FALSE);
    
    IolDiagAndIdent.MasterAoeNetId := F_CreateAmsNetId(GVL_IO.sTerm2AmsNetId);
    IolDiagAndIdent.IolPort := E_iolport.Port4;
    IolDiagAndIdent.Funct := E_IolIad_Function.ReadAll;
    IolDiagAndIdent.ApplicationSpecificTagIn := sApplicationTagIn;
    IolDiagAndIdent.FunctionTagIn := sFunctionTagIn;
    IolDiagAndIdent.LocationTagIn := sLocationTagIn;
    
    IolDiagAndIdent.Execute := TRUE;
    nState := 20; // WAIT FOR DONE
    
// WAIT FOR DONE
20:
    IF NOT IOlDiagAndIdent.Busy AND NOT IOlDiagAndIdent.Error THEN
        nState := 30; // DONE
    END_IF

// DONE
30:
    aProfileIDList := IolDiagAndIdent.ProfileIDList;
    aFunctionClassIDList := IolDiagAndIdent.FunctionClassIDList;
    stIDentObjects := IolDiagAndIdent.IdentificationObjects;
    bDeviceOK := IolDiagAndIdent.DeviceOK;
    nDeviceStatus := IolDiagAndIdent.DeviceStatus;
    DetailedDeviceStatus := IolDiagAndIdent.DetailedDeviceStatus;
    
    IolDiagAndIdent.Execute := FALSE;
    nState := 0; // INIT

END_CASE


////
// call FBs
//
IolDiagAndIdent();

////
// Error Handling
//
IF NOT bError AND bBusy THEN
    IF IolDiagAndIdent.Error THEN
        nState := 0;
        bBusy := FALSE;
        bError := TRUE;
        sIolError := F_IolGetIolErrorTxt(ioldiagandIdent.IolError);
        sAdsError := F_IolGetadsErrorTxt(ioldiagandident.AdsError);
    END_IF
END_IF

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.25

Tc3_IoLink from v3.3.4.0