Hi,
I am new to CXA_EtherCATMaster library and i have the similiar issue, the CytroPac when it power on it is in Safe-OP mode and need to switch to INIT -> OP mode for it to be operational.
I tried following your code:
Declaration:
PROGRAM PLC_PRG
VAR
//CytroPac EtherCAT Switch State OP -> INIT -> OP
fbECATMasterGetBusState: IL_ECATMasterGetBusState;
eActBusState: IL_ECAT_STATE;
fbECATMasterSetBusState: IL_ECATMasterSetBusState;
fbIL_ECATRemoteSlaveGetDevState1: IL_ECATRemoteSlaveGetDevState;
eActDevState1: IL_ECAT_STATE;
fbIL_ECATRemoteSlaveGetDevState2: IL_ECATRemoteSlaveGetDevState;
eActDevState2: IL_ECAT_STATE;
fbIL_ECATRemoteSlaveGetDevState3: IL_ECATRemoteSlaveGetDevState;
eActDevState3: IL_ECAT_STATE;
fbIL_ECATRemoteSlaveSetDevState1: IL_ECATRemoteSlaveSetDevState;
fbIL_ECATRemoteSlaveSetDevState2: IL_ECATRemoteSlaveSetDevState;
fbIL_ECATRemoteSlaveSetDevState3: IL_ECATRemoteSlaveSetDevState;
strMasterName: STRING := 'ethercatmaster';
iSetMaster: INT;
bExecute: BOOL;
END_VAR
Implementation:
//CytroPac EtherCAT Switch State OP -> INIT -> OP
fbECATMasterSetBusState.Execute := bExecute;
fbECATMasterSetBusState.MasterName := ADR(strMasterName);
CASE iSetMaster OF
0: //Automatically Start every slave in OP mode
IF NOT (eActDevState1 = ECAT_STATE_OP AND eActDevState2 = ECAT_STATE_OP) AND eActDevState3 = ECAT_STATE_OP THEN
fbECATMasterSetBusState.NewBusState := IL_ECAT_STATE.ECAT_STATE_INIT;
ELSIF eActBusState = ECAT_STATE_INIT THEN
fbECATMasterSetBusState.NewBusState := IL_ECAT_STATE.ECAT_STATE_OP;
END_IF
1:
fbECATMasterSetBusState.NewBusState := IL_ECAT_STATE.ECAT_STATE_INIT;
2:
fbECATMasterSetBusState.NewBusState := IL_ECAT_STATE.ECAT_STATE_PREOP;
3:
fbECATMasterSetBusState.NewBusState := IL_ECAT_STATE.ECAT_STATE_SAFEOP;
4:
fbECATMasterSetBusState.NewBusState := IL_ECAT_STATE.ECAT_STATE_OP;
END_CASE
fbECATMasterSetBusState();
IF fbECATMasterSetBusState.Done THEN
; // Master reached operational state
END_IF
IF TRUE = fbECATMasterSetBusState.Error THEN
; // Error handling
END_IF
When i write iSetMaster = 1 (Switch EtherCAT Master State INIT), my ctrlX EtherCAT Master state remain OP.
does anyone have a code example for switching between EtherCAT state? i have seen this example but i do not understand how the switching works.
Warmest regards,
... View more