FB_SoERead

FB_SoERead 1:

The functionblock  FB_SoERead  can be used to read a parameter. 

VAR_INPUT

VAR_INPUT
    sNetId     : T_AmsNetId := '';
    nIdn       : WORD;
    nElement   : BYTE; 
    pDstBuf    : 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 + 33" for executing a S-0-0033 command

nElement: 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.

cbBufLen:The maximum available buffer size for the data to be read, 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.

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

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

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;
    dwAttribute   : DWORD;
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.

dwAttribute: Supplies the Sercos parameter attribute.

Sample

fbRead : FB_SoERead;
bRead  : BOOL;
iReadValue : UINT;

(* NcAxis *)
stNcToPlc AT %I* : NCTOPLC_AXLESTRUCT;
IF bRead THEN
    nIdn := S_0_IDN + 33;
    fbRead(
        Axis     := stNcToPlc,
        nIdn     := nIdn,
        nElement := 16#40,
        pDstBuf  := ADR(iReadValue),
        cbBufLen := SIZEOF(iReadValue),
        bExecute := TRUE,
        tTimeout := DEFAULT_ADS_TIMEOUT,
    );
    IF NOT fbRead.bBusy THEN
        fbRead(Axis := stNcToPlc, bExecute := FALSE);
        bRead := FALSE;
    END_IF
END_IF