CANopen Instance Definition
CANopen definition block defines a CANopen communication instance.
Block ID
CANopen Instance Definition
Library
motohawk_canopen_lib
Description

In order for the CANopen library to be used, the user's MotoHawk security token will need to have the proper license added to it. For instructions on how to accomplish this, please see the instructions for adding the MotoHawk CANopen Library license.
A user can check whether their MotoHawk security token has the needed product license at the Matlab command line by executing the motohawk_canopen_check_license command. A returned value of 1 means the MotoHawk CANopen library is licensed, while a returned value of 0 means it is not.
Node ID of the instance is supplied by input port. It must be within the range of 1 - 127.
Number of possible CANopen instance definitions is not limited. There could be more than one CANopen instance definitions referencing a single CAN resource. It is not advised to use the same node ID on more than one instance reference the same CAN resource.
Referenced heartbeat period entry OD 0x1017 is a name of an object dictionary entry. It is required that it's data type is UNSIGNED16 and access type allow reading. It describes how often the CANopen instance sends heartbeat messages. Period is defined in milliseconds.
Referenced SYNC COB-ID entry OD 0x1005 is a name of an object dictionary entry. It is required that it's data type is UNSIGNED32 and access type allow reading. It defines CAN ID of SYNC messages that the CANopen instance will respond to. Note that in order to support the range of CAN ID's for a SYNC message, the range of possible values, 0 to the maximum defined engineered value defined in the object dictionary definition for the SYNC COB-ID is integrated into the CAN mask. As this field is optional, the uint32 max value is used when not defined and will force the CAN mask to be unrestricted (mask of 0). It is recommended to set the maximum value as low as possible to keep as many relevant bits in the CAN mask as possible to have the most efficient CANopen receive queue.
Referenced SYNC Period Entry OD 0x1006 is a name of an object dictionary entry. It is required that it's data type is UNSIGNED32 and access type allow reading. Edit field is only visible when enable sync producer checkbox is checked. It defines how often the CANopen instance sends SYNC messages. Period is defined in milliseconds.
The CANopen software stack processes all CANopen messages on the "CAN Channel" every 3 ms. It is necessary to specify a software message queue (receive queue size) that is appropriate for the baud rate and bus loading. At 100% loading the following table can be used to estimate a good value for the slot queue:
| Baud Rate | Maximum Messages per second | Recommended Queue Size |
| 250kbps | 5700 | 18 |
| 500kbps | 11400 | 35 |
| 1000kbps | 22800 | 70 |
It is necessary to define CANopen definition blocks in subsystem located in the main MotoHawk application window, where target definition and CAN definitions are. Node ID could be changed during runtime, however is is recommended to update it in an NMT event trigger block that is configured to execute on NMT reset on command. Following design could be used :

CANopen definition block is inside CANopen definition subsystem. STARTUP_EVENT trigger must be used to ensure that block is called during model initialization. Additionally it's priority must be lower than 255.
CANopen definition shouldn't be defined in different location, as it could result in incorrect behavior on start-up (boot-up message sent with incorrect Node ID).
Block Parameters
| Parameter Field | Values | Comments/Description |
|---|---|---|
| Instance Name | String | Unique name for this instance of the protocol. |
| Channel Name | String | CAN resource name that will receive requests and transmit responses. |
| Receive Queue Size | Numeric | Specifies the number of messages buffered in the CANopen slot queue. Must be within the range of 1-200. |
| Use Extended CAN IDs | Checkbox | If selected 29 bit extended CAN ID will be used, otherwise standard 11 bit will be used |
| Referenced Heartbeat Period Entry OD 0x1017 | Numeric | Name of object dictionary entry where "heartbeat period" parameter is stored. Defines how often Heartbeat is sent. |
| Referenced SYNC COB-ID Entry OD 0x1005 | String | Name of object dictionary entry where "SYNC COB-ID" is stored. Only SYNC messages with given COB-ID are processed. |
| Referenced SYNC Period Entry OD 0x1006 | String | Name of object dictionary entry where SYNC period is stored. It defines how often SYNC message is generated. Visible only when "enable sync producer" is checked. |
