FB_Dpv1WritePNET

FB_Dpv1WritePNET 1:

The function block FB_Dpv1WritePNET writes one or more parameters of a Sinamics Profidrive via DPV1 (Profidrive Specification 3.1) via Profinet. The DPV1 write telegram must be created with F_CreateDpv1WriteReqPkgPNET before a rising edge is present at bExecute. The DPV1 answer telegram must be evaluated with F_SplitDpv1WriteResPkgPNET after bBusy indicates a falling edge.

The execution of this function block requires some time, depending on the number of parameters to be read. The function block sends the DPV1 telegram and polls for an answer telegram.

FB_Dpv1WritePNET 2: Inputs

VAR_INPUT
    bExecute        : BOOL;(* drive access info *)
    aNetId          : T_AmsNetId; (* NetID of Profibus Master EL6631 *)
    iProfinetPort   : UINT; (* Port of ProfiDrive *)
    iDriveId        : USINT; (* 0..255 possible *)
    pDpv1ReqData    : POINTER TO ARRAY [1..iMAX_DPV1_SIZE_PNET_REQ] OF BYTE;
    iDpv1ReqDataLen : UDINT;
    pDpv1ResData    : POINTER TO ARRAY [1..iMAX_DPV1_SIZE_PNET_RES] OF BYTE;
    iDpv1ResDataLen : UDINT;
    tTmOut          : TIME;
END_VAR

Name

Type

Description

bExecute

BOOL

The function block is enabled by a positive edge at this input.

aNetId

T_AmsNetID

The network address of the Profibus master device (see ADS tab of the Profibus master device in the I/O configuration in the TwinCAT system)

iProfinetPort

UINT

The Profinet port number of the drive. This is an address for several axes, specified in the TwinCAT system in the I/O configuration.

iDriveID

USINT

The ID is 1 for the ControllerUnit, 2 for the drive object A, 3 for the drive object B of a double/triple drive. The drive ID is set in the starter software. 1..16 is possible.

pDpv1ReqData

POINTER TO ARRAY

Pointer to an array of 240 bytes containing the DPV1 write telegram. This telegram must be created by the function F_CreateDpv1WriteReqPkg before the DPV1 Read is activated via bExecute.

iDv1ReqDataLen

UDINT

Maximum length of the DPV1 data buffer (240 bytes).

pDpv1ResData

POINTER TO ARRAY

Pointer to an array of 240 bytes containing the DPV1 write answer telegram. This telegram must be evaluated by the function F_SplitDpv1WriteResPkg after a negative edge appears on bBusy.

iDpv1ResDataLen

UDINT

Maximum length of the DPV1 response data buffer (240 bytes).

tTmOut

TIME

Maximum time allowed for the execution of the command.

FB_Dpv1WritePNET 3: Inputs/outputs

VAR_OUTPUT
    iRequestRef : USINT; (* 1..127; 0: reserved *)
END_VAR

Name

Type

Description

iRefRequest

USINT

Reference that is automatically incremented with each telegram. The reference is required for the allocation of the responses to the write/read requests.

FB_Dpv1WritePNET 4: Outputs

VAR_OUTPUT
    bBusy        : BOOL;
    bError       : BOOL;
    bErrorValues : BOOL;
    iErrId       : UDINT;
    iErrorClass  : BYTE;
    iErrorCode   : BYTE;
END_VAR

Name

Type

Description

bBusy

BOOL

This output goes TRUE as soon as the function block is activated via bExecute and remains TRUE as long as the function block has not received a response.

bError

BOOL

In case of errors this output goes TRUE and bBusy goes FALSE.

bErrorValues

BOOL

TRUE if the DPV1 Write was unsuccessful or only partly successful. The error causes are returned via the error ID (as well as Class and Code).

iErrId

UDINT

Returns the ADS error number or function-block-specific error numbers if bError = TRUE.

iErrClass

BYTE

Profidrive error class

iErrCode

BYTE

Profidrive error code

Function-block-specific error codes

Description

0x2

Incorrect response reference

0x3

DPV1 Read faulty or partially faulty

0x4

Incorrect response ID

other error IDs

See ADS error codes

Error classes

Description

Error code

0x0 - 0x9

Reserved

-

0xA

Application errors

0x0: read error
0x1: write error 0x2: module error
0x3 - 0x7: reserved
0x8: version conflict
0x9: not supported
0xA - 0xF: user-dependent

0xB

Access errors

0x0: invalid index (no data block DB47, parameter access is not supported)
0x1: write length error
0x2: invalid slot
0x3: type conflict
0x4: invalid range
0x5: state conflict (access to DB47 temporarily not possible due to internal process states)
0x6: access denied
0x7: invalid range (write error in DB47 header) 0x8: invalid parameter
0x9: invalid type
0xA - 0xF: user-dependent

0xC

Resource errors

0x0: read conflict
0x1: write conflict
0x2: resource busy
0x3: resource not accessible 0x4 - 0x7: reserved
0x8 - 0xF: user-dependent

0xD - 0xF

User-defined errors

-

Requirements

Development environment

Target platform

IO hardware

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86)

Beckhoff EL6632

Tc2_IoFunctions (IO)