FB_EcSetMasterState

FB_EcSetMasterState 1:

The EtherCAT Master state, assigned in the variable reqState, can be requested by the master with the functionblock FB_EcSetMasterState
The functionblock waits for the maximum tTimeout time allowed until the new state is set.

VAR_INPUT

VAR_INPUT
    sNetId      : T_AmsNetId;
    bExecute    : BOOL; 
    tTimeout    : TIME := T#10s; 
    reqState    : WORD;
END_VAR

sNetId: This is a string that contains the AMS network identifier of the EtherCAT master device.

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

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

reqState: EtherCAT state requested by the master. Possible values for reqState are:

Constant

Value

Description

EC_DEVICE_STATE_INIT

0x01

Request init state  from the master

EC_DEVICE_STATE_PREOP

0x02

Request pre-operational state  from the master

EC_DEVICE_STATE_SAFEOP

0x04

Request safe-operational state  from the master

EC_DEVICE_STATE_OP

0x08

Request operational state  from the master

VAR_OUTPUT

VAR_OUTPUT
    bBusy       : BOOL;
    bError      : BOOL;
    nErrId      : UDINT;
    currState   : WORD;
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.

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

currState: Current EtherCAT state of the master. 

Requirements

Development Environment

Target System

PLCLibraries to include

TwinCAT v2.10.0 Build > 1307 or higher

PC or CX (x86)
CX (ARM)

TcEtherCAT.Lib
( Standard.Lib; TcBase.Lib; TcSystem.Lib, TcUtilities.Lib are included automatically )