FB_SoEWrite_ByDriveRef

FB_SoEWrite_ByDriveRef 1:

The function block FB_SoeWrite_ByRef can be used to write drive parameters by means of the “Servo drive profile over EtherCAT (SoE)” protocol. To this end the slave must have a mailbox and support the SoE protocol. The drive parameter to be written is specified with the parameters nIdn (identification number), nElement and stDriveRef.

The global variable bSeqReadDrvAttrAndValue := TRUE from the Tc2_EtherCAT library can be used to enforce sequential access to attribute and value. The default value of this variable is FALSE. Devices of the AX5xxx series enable parallel and sequential access to attribute and value. For third-party devices it may be necessary to separate access to attribute and value, which overall slows down access by several cycles.

FB_SoEWrite_ByDriveRef 2: Inputs

VAR_INPUT
    stDriveRef : ST_DriveRef; (* contains sNetID of EcMaster, nSlaveAddr of EcDrive, nDriveNo of EcDrive, either preset or read from NC *)
    nIdn       : WORD; (* SoE IDN: e.g. "S_0_IDN + 1" for S-0-0001 or "P_0_IDN + 23" for P-0-0023*)
    nElement   : BYTE; (* SoE element.*)
    pSrcBuf    : PVOID; (* Contains the address of the buffer containing the data to be send. *)
    cbBufLen   : UDINT; (* Contains the max. number of bytes to be received. *)
    bExecute   : BOOL; (* Function block execution is triggered by a rising edge at this input.*)
    tTimeout   : TIME := DEFAULT_ADS_TIMEOUT;(* States the time before the function is cancelled. *)
END_VAR

Name

Type

Description

stDriveRef

ST_DriveRef

The reference to the drive can be linked directly to the PLC in the System Manager. To this end an instance of ST_PlcDriveRef must be used and the NetID of the Byte array converted to a string.

nIdn

WORD

Identification number of the parameter to be read

nElement

BYTE

Element number of the parameter to be read
(See nElement)

pSrcBuf

 

Address (pointer) to the send buffer

cbBufLen

 

Maximum available buffer size (in bytes) for the data to be read

bExecute

BOOL

The function block is activated by a positive edge at this input.

tTimeout

TIME

Maximum time allowed for the execution of the function block.

nElement

Element number of the parameter to be read. The following values are permitted:

Value

Description

0x01

Data status

0x02

Name (read only)

0x04

Attribute

0x08

Unit

0x10

Minimum

0x20

Maximum

0x40

Value

0x80

Default

FB_SoEWrite_ByDriveRef 3: 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

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

iSercos
ErrId

UINT

Returns the Sercos error of the last executed command when the bError output is set.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_EtherCAT