FB_SoERead

FB_SoERead 1:

With the FB_SoERead function block a parameter can be read.

By default, attributes and values are read in parallel.

Should the call generate an ADS error on a third-party device, the lack of support for this faster parameter access method may be the cause.

In this case, the FB_SoESetDataAccessMode function block can be used to switch to the slower sequential access method, if required.

FB_SoERead 2: Inputs

VAR_INPUT
    NetId    : T_AmsNetID := '';
    Idn      : WORD;
    Element  : BYTE; 
    pDstBuf  : PVOID;
    BufLen   : UDINT;
    Execute  : BOOL;
    Timeout  : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

Name

Type

Description

NetId

T_AmsNetID

String which contains the AMS Network ID of the PC (type: T_AmsNetId).

Idn

WORD

Parameter number that FB_SoERead refers to, e.g. "S_0_IDNs + 33" for S-0-0033

Element

BYTE

Specifies which part of the parameter should be accessed, e.g. 16#40 is the value (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; 

pDstBuf

PVOID

ADR() of the variables that the value should be read to.

BufLen

UDINT

SIZEOF() of the variables that the value should be read to.

Execute

BOOL

The function block is enabled via a positive edge at this input.

Timeout

TIME

Maximum time allowed for the execution of the function block.

FB_SoERead 3:

The Idns can be taken from the corresponding drive documentation. For the AX5000 from Beckhoff see AX5000 Idn description.

FB_SoERead 4: Inputs/outputs

VAR_IN_OUT
   Axis : AXIS_REF;
END_VAR

Name

Type

Description

Axis

AXIS_REF

Axis data structure that unambiguously addresses an axis in the system. Among other parameters it contains the current axis status, including position, velocity or error state.

FB_SoERead 5: Outputs

VAR_OUTPUT
    Busy        : BOOL;
    Error       : BOOL;
    AdsErrId    : UINT;
    SercosErrId : UINT;
    Attribute   : DWORD;
END_VAR

Name

Type

Description

Busy

BOOL

This output is set when the function block is activated, and remains set until a feedback is received.

Error

BOOL

This output is set after the Busy output has been reset when an error occurs in the transmission of the command.

AdsErrId

UINT

In the case of a set Error output returns the ADS error code of the last executed command.

SercosErrId

UINT

In the case of a set Error output returns the Sercos error of the last executed command.

Attributes

DWORD

Returns the attributes of the Sercos parameter.

Sample

fbRead    : FB_SoERead;
Read      : BOOL;
Idn       : WORD;
ReadValue : UINT;
(* NcAxis *)
Axis : AXIS_REF; 

IF Read THEN
 Idn := S_0_IDNs + 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 

Parameter access

Note that for some parameters, the additional items of information "ActualLength" & "MaxLength" are necessary for the parameter access.

In order to determine the parameters for which this is necessary, the attributes can be displayed in the parameter list of the Drive Manager via the context menu of the header.

FB_SoERead 6:

If the fifth place from the right contains the value 4, 5, 6 or 7, then the additional items of information are also transmitted.

FB_SoERead 7:

The structure to read out the serial number (S-0-0432) then looks like this:

TYPE ST_SerialNumber:
STRUCT
    ActualLength : UINT;
    MaxLength    : UINT;
    SerialNumber : T_MaxString;
END_STRUCT
END_TYPE