FB_SoEWrite

FB_SoEWrite 1:

With the FB_SoEWrite function block a parameter can be written.

FB_SoEWrite 2: Inputs

VAR_INPUT
    NetId    : T_AmsNetID := '';
    Idn      : WORD;
    Element  : BYTE;
    SrcBuf   : PVOID;
    BufLen   : UDINT;
    Execute  : BOOL;
    Timeout  : TIME := DEFAULT_ADS_TIMEOUT;
    Password : ST_SoE_String;
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 + 47" for S-0-0047, see AX5000 Idn description.

Element

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;

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; 

SrcBuf

PVOID

ADR() of the variable containing the value to be written.

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.

Password

ST_SoE_String

Password as Sercos string. Currently not used. The password must be written with FB_SoEWritePassword.

FB_SoEWrite 3:

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

FB_SoEWrite 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_SoEWrite 5: Outputs

VAR_OUTPUT
    Busy        : BOOL;
    Error       : BOOL;
    AdsErrId    : UINT;
    SercosErrId : UINT;
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

UDINT

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

Sample

fbWrite    : FB_SoEWrite;
Idn        : WORD;
Write      : BOOL;
WriteValue : UINT;
Password   : ST_SoE_String;
(* NcAxis *)
Axis       : AXIS_REF; 

IF Write THEN
 Idn := S_0_IDNs + 33;
 fbWrite(
    Axis     := Axis,
    Idn      := Idn,
    Element  := 16#40,
    pSrcBuf  := ADR(WriteValue),
    BufLen   := SIZEOF(WriteValue),
    Password := Password,
    Execute  := TRUE,
    Timeout  := DEFAULT_ADS_TIMEOUT,
 );
 IF NOT fbWrite.Busy THEN
    fbWrite(Axis := Axis, Execute := FALSE);
    Write := 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_SoEWrite 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_SoEWrite 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