FB_SoEWrite
With the FB_SoEWrite function block a parameter can be written.
Inputs
VAR_INPUT
sNetId : T_AmsNetId := '';
nIdn : WORD;
nElement : BYTE;
pSrcBuf : PVOID;
cbBufLen : UDINT;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
sPassword : ST_SoE_String;
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetId | String, which contains the AMS Network ID of the PC (type: T_AmsNetId). |
nIdn | WORD | Parameter number to which FB_SoERead refers, e.g. "S_0_IDN + 47" for S-0-0047. |
nElement | BYTE | Specifies which part of the parameter should be accessed, e.g. 16#40 is the value (Value) of the parameter. Usually there is only write access to the value, other components of the parameter are read-only. EC_SOE_ELEMENT_DATASTATE :BYTE :=16#01; |
pSrcBuf | PVOID | ADR() of the variable containing the value to be written. |
cbBufLen | UDINT | SIZEOF() of the variable containing the value to be written. |
bExecute | BOOL | The function block is enabled via a positive edge at this input. |
tTimeout | TIME | Maximum time allowed for the execution of the function block. |
sPassword | ST_SoE_String | Password as sercos string. Currently not used. The password must be written with FB_SoEWritePassword. |
Inputs/outputs
VAR_IN_OUT
Axis : NCTOPLC_AXIS_REF;(* reference to NC axis *)
END_VAR
Name | Type | Description |
---|---|---|
Axis | Axis data structure of the type NCTOPLC_AXIS_REF |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
iAdsErrId : UINT;
iSercosErrId : UINT;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | This output is set when the function block is activated, and remains set until a feedback is received. |
bError | BOOL | This output is set after the bBusy output has been reset when an error occurs in the transmission of the command. |
iAdsErrId | UINT | Returns the ADS error code of the last executed command when the bError output is set. |
iSercosErrId | UINT | In the case of a set bError output returns the Sercos error of the last executed command. |
Sample
fbWrite : FB_SoEWrite;
bWrite : BOOL;
nIdn : WORD;
iWriteValue : UINT;
sPassword : ST_SoE_String;
(* NcAxis *)
NcToPlc AT %I* : NCTOPLC_AXLESTRUCT;
IF bWrite THEN
nIdn := S_0_IDN + 33;
fbWrite(
Axis := NcToPlc,
nIdn := nIdn,
nElement := 16#40,
pSrcBuf := ADR(iWriteValue),
cbBufLen := SIZEOF(iWriteValue),
sPassword := sPassword,
bExecute := TRUE,
tTimeout := DEFAULT_ADS_TIMEOUT,
);
IF NOT fbWrite.bBusy THEN
fbWrite(Axis := NcToPlc, bExecute := FALSE);
bWrite := FALSE;
END_IF
END_IF