This sample project deals with the programming interface of the CANopen master and CANopen slave communication stack.
The project contains examples for SDO, NMT, diagnostics, and the dynamic configuration of communication parameters
(baud rate, network ID, node ID), and many more.
This sample project contains different examples for using the programming interface of the CANopen master
and CANopen slave stack. Topics that are handled include the following:
The project includes a CANopen master and a CANopen slave stack that communicate with each other via CANbus.
Two interconnected CAN interfaces are needed for commissioning the project.
It is easiest to implement this with CODESYS Control Win V3 and a PEAK PCAN-USB Pro or two PEAK PCAN USB adapters.
For this to work, the runtime system component "CmpPCANBasicDrv" must be entered in the configuration file.
For more information, refer to the CODESYS online help.
The project can also be operated on any controller with two CAN interfaces by means of an update device of the PLC.
The project is divided into three areas:
ChangeBaudrate: Dynamic change of baud rate in runtime mode by means of reconfigure
EnableDisableCANbus: Dynamic activation and deactivation of a CANbus in runtime mode by means of reconfigure
GetCANbus: Generic search of an engineered CANbus instance by means of the device diagnosis library
ReceiveEMCYFromAllDevicesExample: Reception of emergency messages by means of
ReceiveEMCYFromOneDeviceExample: Reception of emergency messages for a specific device by means of
GetCANopenKernelStateExample: Detection of the CANopen kernel state by means of
GetStateExample: Detection of the CANopen state of a slave by means of
GetCANopenManagerNodeIDExample: Detection of the CANopenManager node ID by means of
NMT_Example: Sending of NMT requests by means of
SDO (Acyclic data transfer)
ExpeditedReadExample: Reading of an object <= 4 bytes via SDO (expedited transfer) by means of
ExpeditedWriteExample: Writing of an object <= 4 bytes via SDO (expedited transfer) by means of
SegmentedAndBlockReadExample: Reading of an object of any length via SDO (segmented or block transfer) via
SegmentedAndBlockWriteExample: Writing if an object of any length via SDO (segmented or block transfer) via
General API functions
CANopenManagerAPI: Demonstrates the use of all methods and properties of the
CANopenManagerEventHandler: Exemplary implementation of a CANopen event handler
CANopenRemoteDeviceAPI: Demonstrates the use of all methods and properties of a
GetLocalDeviceInfoExample: Demonstrates the reading of the CANopen state as well as the node ID
ChangeNodeIDExample: Change of the node ID in runtime mode
NMTExample: Change of the local CANopen state
ReadObjectExample1: Reading of an object from the local object directory
ReadObjectExample2: Alternative example of
WriteObjectExample1: Writing an object to the object directory
WriteObjectExample2: Alternative example of
CountObjects: Traversing of the complete object directory by means of
GetPDOInfo: Additional example of traversing the object directory
ObjectDictionaryEventHandler: Exemplary implementation of an object directory event handler
|System requirements and restrictions||Info|
|Programming System||CODESYS Development System Version 126.96.36.199 or higher|
|Runtime System||CODESYS Control Version 188.8.131.52|
|Required Accessories||Two CAN interfaces from the company PEAK-System Technik GmbH (e.g.two PCAN-USB or one PCAN-USB Pro)|