FB_SoEWrite

FB_SoEWrite 1:

The functionblock FB_SoEWrite can be used to write a parameter.

VAR_INPUT

VAR_INPUT
    sNetId     : T_AmsNetId := '';
    nIdn       : WORD;
    nElement   : BYTE;
    pSrcBuf    : DWORD;
    cbBufLen   : UDINT;
    bExecute   : BOOL;
    tTimeout   : TIME := DEFAULT_ADS_TIMEOUT;
    sPassword  : ST_SoE_String;
END_VAR

sNetId: A string containing the AMS network identifier of the PC.

nIdn: Parameter number for the command, i.e. "S_0_IDN + 47" for executing a S-0-0047 command

nElement: Shows on which parameter part is to be read, e.g. 16#40 is the value of the parameter. Most times only write access on this value is possible, other parameter parts are write-protected.

    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 send.

cbBufLen:The maximum available buffer size for the data to be written, in bytes.

bExecute: The block is activated by a rising edge at this input.

tTimeout: Maximum time allowed for the execution of the function block.

sPassword: contains the password as Sercos-String. Not yet used. The password has to be written with FB_SoEWritePassword.

VAR_IN_OUT

VAR_IN_OUT
    Axis : NCTOPLC_AXLESTRUCT;(* reference to NC axis *)
END_VAR

Axis: Axis structure.

VAR_OUTPUT

VAR_OUTPUT
    bBusy         : BOOL;
    bError        : BOOL;
    iAdsErrId     : UINT;
    iSercosErrId  : UINT;
END_VAR

bBusy: This output is set when the function block is activated, and remains set until an acknowledgement is received.

bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.

iAdsErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.

iSercosErrId: Supplies the Sercos error code associated with the most recently executed command if the bError output is set.

Sample

fbWrite : FB_SoEWrite;
bWrite  : BOOL;
iWriteValue : UINT;
sPassword   : ST_SoE_String;

(* NcAxis *)
stNcToPlc AT %I* : NCTOPLC_AXLESTRUCT;
IF bWrite THEN
    nIdn := S_0_IDN + 33;
    fbWrite(
        Axis      := stNcToPlc,
        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 := stNcToPlc, bExecute := FALSE);
        bWrite := FALSE;
    END_IF
END_IF