FUNCTION_BLOCK FB_SoERead
The functionblock FB_SoERead can be used to read a parameter.
VAR_INPUT
VAR_INPUT
NetId : T_AmsNetId := '';
Idn : WORD;
Element : BYTE;
pDstBuf : DWORD;
BufLen : UDINT;
Execute : BOOL;
Timeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
NetId: A string containing the AMS network identifier of the PC.
Idn: Parameter number for the command, i.e. "S_0_IDN + 33" for executing a S-0-0033 command
Element: Shows on which parameter part is to be read, e.g. 16#40 is the value of the parameter.
EC_SOE_ELEMENT_DATASTATE :BYTE :=16#01;
EC_SOE_ELEMENT_NAME :BYTE :=16#02;
EC_SOE_ELEMENT_ATTRIBUTE :BYTE :=16#04;
EC_SOE_ELEMENT_UNIT :BYTE :=16#08;
EC_SOE_ELEMENT_MIN :BYTE :=16#10;
EC_SOE_ELEMENT_MAX :BYTE :=16#20;
EC_SOE_ELEMENT_VALUE :BYTE :=16#40;
EC_SOE_ELEMENT_DEFAULT :BYTE :=16#80;
pSrcBuf:Contains the address of the buffer containing the data to be read.
BufLen:The maximum available buffer size for the data to be read, in bytes.
Execute: The block is activated by a rising edge at this input.
Timeout: Maximum time allowed for the execution of the function block.
Execute: The block is activated by a rising edge at this input.
Timeout: Maximum time allowed for the execution of the function block.
VAR_IN_OUT
VAR_IN_OUT
Axis : AXIS_REF; (* Axis reference *)
END_VAR
Axis: Axis structure (see TcMC2.lib).
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
iAdsErrId : UINT;
iSercosErrId : UINT;
dwAttribute : DWORD;
END_VAR
Busy: This output is set when the function block is activated and remains set until an acknowledgement is received.
Error: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.
AdsErrId: Supplies the ADS error code associated with the most recently executed command if the Error output is set.
SercosErrId: Supplies the Sercos error code associated with the most recently executed command if the Error output is set.
Attribute: Supplies the Sercos parameter attribute.
Sample
fbRead : FB_SoERead;
Read : BOOL;
Idn : WORD;
ReadValue : UINT;
(* NcAxis *)
Axis : AXIS_REF;
IF Read THEN
Idn := S_0_IDN + 33;
fbRead(
Axis := Axis,
Idn := Idn,
Element := 16#40,
pDstBuf := ADR(ReadValue),
BufLen := SIZEOF(ReadValue),
Execute := TRUE,
Timeout := DEFAULT_ADS_TIMEOUT,
);
IF NOT fbRead.Busy THEN
fbRead(Axis := Axis,Execute := FALSE);
Read := FALSE;
END_IF
END_IF