DrvPnRead
(FB)
FUNCTION_BLOCK DrvPnRead EXTENDS AbbETrig
Function block DrvPnRead reads maximum 37 parameters from the drive in a single DPV1 query. The number of parameters to be read is specified at the input Nvar.
Parameters to read from the drive are specified at the Data input. DrvPbPnPrmDpv1DataType structure must be declared to a variable and connected to Data input using ADR. This structure contains the Group, Index, which must be given to the variable. Read parameter type and values are stored in the same variable
- DrvPdPrmDpv1DataType structure has the following array elements
abyPrmGroup: Array of 37 WORD for specifying parameter Group.
abyPrmIndex: Array of 37 WORD for specifying parameter Index.
abyPrmType: Array of 37 DRV_PDRIVE_PRM_TYPE. Read parameter data type will be available here. For details refer to DRV_PDRIVE_PRM_TYPE. If a type is set here at the start, it can be compared with the type value read from the drive if the Compare input is set.
adwPrmValue: Array of 37 DWORD. Read parameter value will be available here. If a value is set at the start, it can be compared with the value read from the drive if the Compare input is set.
- Read errors
If the drive rejects to read a specific parameter, it returns the error code DRV_ERROR_PRM (16#44) in the corresponding abyPrmType element and a more specific error value in the corresponding adwPrmValue element.
The number of elements with errors from the drive are given at the output “NumPrmErrors”. The output “PrmErrCmpValues” gives an array, which contains the more specific error values in the elements (index). This can be used to quickly identify the errorneous elements.
- Compare input
As the DrvPnWrite function block does not return an error in case a parameter in the drive could not be written correctly it is recommended to verify the writing. This can be done with the call of this function block DrvPnRead if the same parameters, types and values are connected to the Data input (use the same struct as for the writing), and the input “Compare” is set to TRUE.
Then the types and values of the connected struct are copied at the rising edge of Excecute inputs and compared with the returned types and values from the drive. In case of a diffrence this is set into the corresponding element of the output array PrmErrCmpValues with the possible three error codes DRV_CMP_DIFF_TYPE, DRV_CMP_DIFF_VALUE or DRV_CMP_DIFF_TYPE_AND_VALUE.
- Mode input
Mode = 16#00 => Read direct variables and parameters via an Fxxx module, e.g. FENA-21 or FPNO-21. Group and Index have to be used as in the Data.awPrmGroup and Data.awPrmIndex array. (Number of Elements in the PN Datablock is set to 16#01)
Mode = 16#01 => Read direct variables and parameters via an Rxxx module, e.g. RETA-02 for ACS800 or DCS500. Group and Index have to be used as in the Data.awPrmGroup and Data.awPrmIndex array. (Number of Elements in the PN Datablock is set to 16#01)
Mode = 16#1x => to be used to access PROFIDrive parameters with Attribute = 16#10 (Value) and Number of Elements = x.
Mode = 16#2x => to be used to access PROFIDrive parameters with Attribute = 16#20 (Description) and Number of Elements = x. (Not supported with Fxxx or Rxxx modules)
Mode = 16#3x => to be used to access PROFIDrive parameters with Attribute = 16#30 (Text) and Number of Elements = x. (Not supported with Fxxx or Rxxx modules)
For PROFIDrive parameters using Mode = 16#1x, 16#2x or 16#3x the Number of Elements = x is used for ALL the parameters in the Data array.
Note
If multiple DrvPnRead and /or multiple DrvPnWrite Functions Blocks for the same device are enabled at the same time, it may cause a Read/ Write error.
- InOut:
Scope
Name
Type
Initial
Comment
Inherited from
Input
Execute
BOOL
FALSE
A rising edge starts the operation, the output Busy goes to TRUE. In the first cycle all other inputs are read and stored, afterwards they are ignored. A falling edge does not stop the operation. After Done = TRUE or Error = TRUE and Execute = FALSE all outputs will be reset.
AbbETrig
Output
Done
BOOL
FALSE
Operation is completed without error (while outputs Busy and Error are FALSE). This output is TRUE for at least one cycle or until Execute is set to FALSE
AbbETrig
Busy
BOOL
FALSE
Operation is running (while outputs Done and Error are FALSE)
AbbETrig
Error
BOOL
FALSE
Operation is stopped with error (while outputs Busy and Done are FALSE). This output is TRUE for at least one cycle or until Execute is set to FALSE. The output ErrorID gives more details about the error.
AbbETrig
Input
Slot
BYTE
1
2: Slot in which Profinet is configured
DevApi
DWORD
0
3: Profinet device API command - to be set to 0 for ABB drives
DevName
STRING(INT#240)
‘’
4: Profinet Name of the device, Ex: ‘abbdrive-38’
Mode
BYTE
0
5: Mode = 0: Fxxx- modules e.g. FENA-21 or FPNO-21. Mode = 1: Rxxx modules used e.g. RETA-02 (ACS800, ACS500); Other modes for Profidrive parameters see description.
MaxRetries
BYTE
4
6: Maximum numbers of retries of internal read / write telegrams if device responses with “state conflict”. Maximum: 10.
WaitTimeRetry
WORD
200
7: Waiting time [ms] before a new retry is started after response with “state confict”. 0 = Automatic calculation according to actual data size; Min: 40ms; Max: 2000ms;
Compare
BOOL
FALSE
8: Compare is performed with “abyPrmType” and “abyPrmValue” elements. Can be used to verify the before written data.
Nvar
BYTE
1
9: Number of parameters to read
Data
DWORD
10: Address of variable of “DrvPdPrmDpv1DataType”. Connect via ADR operator. For Parameter Group, Index, Type and Value
Output
ErrorID
ERROR_ID.NO_ERROR
4: Error codes
AddErrorID1
AC500_PnioCntrl.ERROR_ID
AC500_PnioCntrl.ERROR_ID.NO_ERROR
5: ErrorID output from internally called PnioCtrlRead or PnioCtrlWrite block. See enum ERROR_ID in library AC500_PnioCtrl.
AddErrorID2
UDINT
0
6: AddErrNo output number from internally called PnioCtrlRead or PnioCtrlWrite block. See library AC500_PnioCtrl.
Status
DWORD
0
7: Status output from internal called PnioCtrlRead or PnioCtrlWrite block - see Profidrive description in fieldbus module manual or AC500-V2 docu “Profinet Status” in Profinet IO library.
AddVal1
WORD
0
8: Additional Value 1 - AddVal1 output from internally called PnioCtrlRead or PnioCtrlWrite block see library AC500_PnioCtrl
AddVal2
WORD
0
9: Additional Value 2 - AddVal2 output from internally called PnioCtrlRead or PnioCtrlWrite block see library AC500_PnioCtrl
DataLen
INT
0
10: Package size of the Read response. DataLen output from the internal Read block PnioCtrlRead
NumPrmErrors
BYTE
0
11: Number of parameters that could not be read. Check abyPrmType for 16#44 (DRV_ERROR_PRM) then the abyPrmValue represents the error code.
NumPrmCmpDiff
BYTE
0
12: Number of parameters that showed diffrences in either type or value at Compare. Check PrmErrorValues[] for DRV_CMP_DIFF_TYPE, DRV_CMP_DIFF_VALUE or DRV_CMP_DIFF_TYPE_AND_VALUE.
PrmErrCmpValues
ARRAY [1..37] OF DRV_PDRIVE_PRM_REQ_ERROR
[37(DRV_NOT_USED)]
13: Error values and compare differences per parameter index
DrvPnRead.A_StartAction
(METH)DrvPnRead.B_CyclicAction
(METH)DrvPnRead.C_CleaningAction
(METH)DrvPnRead.D_ResetAction
(METH)DrvPnRead.S01_CreateRequestDataArray
(ACT)DrvPnRead.S02_CreateCompareDataArray
(ACT)DrvPnRead.S11_Sequence
(ACT)DrvPnRead.S12_CheckWriteResponse
(ACT)DrvPnRead.S13_CheckReadResponse
(ACT)DrvPnRead.S14_CheckReadResponseHeader
(ACT)DrvPnRead.S15_WriteReadValues
(ACT)DrvPnRead.S16_CompareReadValues
(ACT)DrvPnRead.S21_WriteOutputsFromWrite
(ACT)DrvPnRead.S22_WriteOutputsFromRead
(ACT)