FB_Dpv1Write
The function block "FB_Dpv1Write" writes one or multiple parameters to a Sinamics Profidrive via DPV1 (Profidrive specification 3.1). The DPV1 request telegram needs to be created with F_CreateDpv1WriteReqPkg, before the bExecute sees a rising edge. The DPV1 response telegram needs to be split with F_SplitDpv1WriteResPkg after the bBusy sends a falling edge.
The execution of this function block takes some time, depending on the amount of parameters written. The function block sends the request telegram to the drive and then polls the drive for a corresponding response telegram.
Internally instances of the ADSREAD and ADSWRITE function blocks are called.
See sample Sample04.
VAR_INPUT
VAR_INPUT
bExecute : BOOL;
aNetId : T_AmsNetId; (* NetID of Profibus Master FC310x/EL6731 *)
iProfibusSlaveAdr : USINT; (* DP address of ProfiDrive *)
iDriveId : USINT; (* 1..16 possible *)
pDpv1ReqData : POINTER TO ARRAY [1..iMAX_DPV1_SIZE] OF BYTE;
iDpv1ReqDataLen : UDINT;
pDpv1ResData : POINTER TO ARRAY [1..iMAX_DPV1_SIZE] OF BYTE;
iDpv1ResDataLen : UDINT;
tTmOut : TIME;
END_VAR
bExecute: The function block is activated by a positive edge at this input.
aNetId: Provide the AmsNetId of the Profibus Master device (see ADS-Tab of the Profibus Master device in the I/O configuration in the System Manager).
iProfibusSlaveAdr: The profibus slave DP address of the drive. This is one address for a multiple axes drive specified in the TwinCAT System Manager in the hardware configuration.
iDriveID: The drive ID is 1 for the ControllerUnit, 2 for the A drive, 3 for the B drive of double/triple drive. Drive ID is set in the Starter software. 1..16 is possible.
pDpv1ReqData: Pointer to an array of 240 bytes, which contains the DPV1 request telegram. This telegram needs to be created with F_CreateDpv1WriteReqPkg before the executing the DPV1 write.
iDv1ReqDataLen: Maximum length of the DPV1 request data buffer (240 bytes).
pDpv1ResData: Pointer to an array of 240 bytes, which contains the DPV1 response telegram after the DPV1 read. This DPV1 response telegram needs to be split with F_SplitDpv1WriteResPkg after the bBusy sends a falling edge.
iDv1ResDataLen: Maximum length of the DPV1 response data buffer (240 bytes).
tTimeout: States the length of the timeout that may not be exceeded by execution of the ADS command.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
bErrorValues : BOOL;
iErrId : UDINT;
iErrorClass : BYTE;
iErrorCode : BYTE;
END_VAR
bBusy: When the function block is activated this output is set. It remains set until and acknowledgement is received.
bError: If an ADS error should occur during the transfer of the command, then this output is set once the bBusy output is reset.
bErrorValues: Is TRUE if the DPV1 Read was not successful or partly not successful. The response telegram contains error values.
nErrId: Supplies the ADS error number or function block specific error code when the bError output is set.
nErrClass: Profidrive error class
nErrCode: Profidrive error code
VAR_IN_OUT
VAR_OUTPUT
iRequestRef : USINT; (* 1..127; 0: reserved *)
END_VAR
iRefRequest: Reference, which is increased automatically with each telegram. The reference is needed to assign the response telegram to the corresponding read/write request telegram.
Function block specific error codes | Description |
---|---|
0x2 | wrong reference response |
0x3 | DPV1 Read not successful or partly not successful |
0x4 | wrong response ID |
other error IDs | see ADS return codes |
Error classes | Description | Error code |
---|---|---|
0x0 - 0x9 | reserved | - |
0xA | Application error | 0x0: read error 0x2: module failure |
0xB | Access error | 0x0: invalid index (no datablock DB47, parameter requests are not supported 0x8: invalid parameter |
0xC | Resource error | 0x0: read constraint conflict 0x4 - 0x7: reserved |
0xD - 0xF | User defined error | - |
Requirements
Development environment | Target system type | IO hardware | PLC libraries to include |
---|---|---|---|
TwinCAT v2.10.0 Build > 1307 | PC (i386) | Beckhoff FC310x PCI, CX1500-M310, EL6731 | TcIoFunctions.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically ) |