IOF_SER_IDN_Read
The function block "IOF_SER_IDN_Read" allows to read an S- or P-Parameter from a SERCOS drive. The data type and size are determined automatically by reading the parameter attribute. Internally, an instance of the ADSREAD function block is called.
VAR_INPUT
VAR_INPUT
sNetId : T_AmsNetId;
nIDN : UINT;
bExecute : BOOL;
nPort : UINT;
nMode : DINT;
nAttrib : DWORD;
cbLen : UDINT;
dwDestAddr : DWORD;
tTimeout : TIME;
END_VAR
sNetId: It is possible here to provide the AmsNetId of the TwinCAT computer on which the ADS command is to be executed. If it is to be run on the local computer, an empty string can be entered.
nIDN: The nIDN variable is used to specify the SERCOS parameter which has to be read. For standard S-Parameters nIDN has to be between 0 and 32767, for manufacturer specific P-Parameters nIDN has to be between 32768 and 65535.
bExecute: The function block is activated by a positive edge at this input.
nPort: The port number nPort is specified by the TwinCAT System Manager during the hardware configuration.
nAttrib: Attribute of the parameter, if known. If nAttrib = 0 then IOF_SER_IDN_Write reads the parameter attribute from the drive, before it writes the parameter value to the drive.
cbLen: Maximum length of data buffer.
dwDestAddr: Address of data buffer.
nMode: The mode nMode determines which data of the parameter nIDN should be read.
nMode = 0: Value
nMode = 2: Name
nMode = 3: Attribute (is always read to determine data type and size, unless nAttrib is <> 0)
nMode = 4: Unit (not available for all parameters)
nMode = 5: Minimum (not available for all parameters)
nMode = 6: Maximum (not available for all parameters)
tTimeout: States the length of the timeout that may not be exceeded by execution of the ADS command.
VAR_OUTPUT
VAR_OUTPUT
cbRead : UDINT;
nAttribRd : DWORD;
sAttrib : ST_SercosParamAttrib;
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
cbRead: Number of bytes read and copied to dwDestAddr.
nAttribRd: contains the attribute of the parameter and can be used if saved as attribute (nAttrib) for the next parameter access with read or write
sAttrib: contains the attribute of the parameter split to separate bits in to the structure ST_SercosParamAttrib
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.
nErrId: Supplies the ADS error number or function block specific error code when the bError output is set.
Function block specific error codes | Description |
---|---|
0x1003 | Wrong parameter mode |
0x1004 | Data parameter wrong value size |
Requirements
Development environment | Target system type | IO hardware | PLC libraries to include |
---|---|---|---|
TwinCAT v2.8.0 Build > 735 | PC (i386) | Sercans SCS-P ISA; Sercans SCS-P PCI; | TcIoFunctions.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically ) |