A set of functions and function blocks is available for management of CANopen devices. Such functions refer to the CANopen master configuration defined in the Fieldbus Configurator.

Sending SYNC message

The following function is used to send a SYNC broadcast message:

OK := coSync (PORT);

Arguments:

OK : BOOL; (* TRUE if successful *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

Note: You cannot send more than one SYNC message during the same PLC cycle.

Sending NMT messages

The following functions are used to send a NMT message to a CANopen slave:

OK := coNmtReset (PORT, SLV); (* reset node *)

OK := coNmtResetComm (PORT, SLV); (* reset communication *)

OK := coNmtStart (PORT, SLV); (* start node *)

OK := coNmtStop (PORT, SLV); (* stop node *)

OK := coNmtEnterPreop (PORT, SLV); (* enter peroperational *)

Arguments:

OK : BOOL; (* TRUE if successful - FALSE if busy or slave not configured *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

Note: You cannot send more than one NMT message to the same slave during the same PLC cycle.

Reading a simple parameter (SDO) - coReadParam function block

The coReadParam function block is used for sending a simple SDO message to read a parameter from a slave.

Input arguments:

EN : BOOL; (* the message is sent on a rising edge of this input *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

Param : DINT; (* SDO parameter index *)

Sub : DINT; (* SDO parameter sub-index *)

TO : TIME; (* timeout for exchange *)

Output arguments:

Ready : BOOL; (* TRUE when the block is ready - FALSE during an exchange *)

RC : DINT; (* CANopen return check *)

VAL : UDINT; (* read parameter value answered by the slave *)

Writing a simple parameter (SDO) - coWriteParam function block

The coWriteParam function block is used for sending a simple SDO message to write a parameter to a slave.

Input arguments:

EN : BOOL; (* the message is sent on a rising edge of this input *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

Param : DINT; (* SDO parameter index *)

Sub : DINT; (* SDO parameter sub-index *)

VAL : UDINT; (* parameter value *)

LEN : DINT; (* number of bytes to send - from 1 to 4 *)

TO : TIME; (* timeout for exchange *)

Output arguments:

Ready : BOOL; (* TRUE when the block is ready - FALSE during an exchange *)

RC : DINT; (* CANopen return check *)

Sending the PDO mapping (SDOs) - coSendPdoMap function block

The coSendPdoMap function block sends a sequence of SDO messages for applying the PDO mapping to a slave such as defined in the CANopen configuration.

Input arguments:

EN : BOOL; (* the message is sent on a rising edge of this input *)

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

TO : TIME; (* timeout for exchange *)

Output arguments:

Ready : BOOL; (* TRUE when the block is ready - FALSE during the exchanges *)

RC : DINT; (* CANopen return check *)

Updating a RPDO - coRpdoSendNow function

The coRpdoSendNow function triggers the emission of a RPDO configured as "On Request" in the CANopen configuration.

Input arguments:

PORT : STRING; (* Name of the CAN port as specified in the CANopen master configuration *)

SLV : DINT; (* CANopen slave number *)

RPDO : DINT; (* RPDO index (1..4) *)

Output arguments:

OK : BOOL; (* TRUE if arguments are correct *)


Created with the Personal Edition of HelpNDoc: Easily create Web Help sites