Skip to main content

CO_MasterControlStatus

CO_MasterControlStatus monitors CANopen master status while Execute is TRUE. It can disable CANopen communication through DisableComm and send a Network Management (NMT) command on a rising edge of SendNMT.

Ladder Representation

CO_MasterControlStatus ladder representation

Block Structure

Variable TypeNameData TypeDescription
VAR_INPUTExecuteBOOLEnables block execution.
VAR_INPUTDisableCommBOOLDisables CANopen communication.
VAR_INPUTSendNMTBOOLTriggers the sending of a network management command.
VAR_INPUTNMTCommandBYTENetwork management command code to send.
VAR_INPUTNodeIDBYTE USINTSlave address used by the block.
VAR_OUTPUTDoneBOOLIndicates that the block completed successfully.
VAR_OUTPUTCommDisabledBOOLIndicates that communication is disabled.
VAR_OUTPUTBusPowerOffBOOLIndicates a CAN interface power supply failure.
VAR_OUTPUTBusOffBOOLIndicates a BusOff error in the CAN interface.
VAR_OUTPUTNMTCmdFeedbackBOOLIndicates that the master sent the NMT command.
VAR_OUTPUTErrorCtrlFailureBOOLIndicates a node guarding or heartbeat error.
VAR_OUTPUTInitFailureBOOLIndicates an initialization error.
VAR_OUTPUTInitFinishedBOOLIndicates that the slave initialization procedure finished.

Operation

While Execute is TRUE, the block updates its outputs according to the master status and the input requests. When Execute is FALSE, the inputs are ignored and the outputs are reset. Done is TRUE when Execute is TRUE and the block has completed execution.

When DisableComm is TRUE, CANopen communication is disabled and the master status counters and markers are reset.

A rising edge on SendNMT sends the NMT command selected in NMTCommand to the slave address configured in NodeID.

Each status output is TRUE when the CANopen master status matches the condition described by that output.

Execution Flowchart

CO_MasterControlStatus execution flowchart

Structured Text Example

The following Structured Text code shows a typical block execution.

Structured Text
VAR
DISABLE, SEND_COMM, STATUS_DISABLED, STATUS_POWEROFF,
STATUS_BUSOFF, STATUS_FB, STATUS_ERROR, STATUS_FAILURE,
STATUS_FINISHED: BOOL;
COMM, NODEID: BYTE;
END_VAR

DO1 := FB_CO_MasterControlStatus(
Execute:=DI1,
DisableComm:=DISABLE,
SendNMT:=SEND_COMM,
NMTCommand:=COMM,
NodeID:=NODEID,
CommDisabled=>STATUS_DISABLED,
BusPowerOff=>STATUS_POWEROFF,
BusOff=>STATUS_BUSOFF,
NMTCmdFeedback=>STATUS_FB,
ErrorCtrlFailure=>STATUS_ERROR,
InitFailure=>STATUS_FAILURE,
InitFinished=>STATUS_FINISHED);