The basic programming model is a general guideline for creating and executing a typical LabVIEW application for CANopen.

Creating the Application

The first step of any CANopen application is creating an interface object. An interface object corresponds to a CAN port on a CANopen board. Use the CANopen Interface Create VI to create interface objects. Use Measurement & Automation Explorer to view the mapping relationship between each interface name and specific hardware model.

To create CANopen objects for communication, pass an interface object to a proper instance of the CANopen Create VI . CANopen has two types of objects:
  • Device-specific objects
  • Bus-wide objects
Most objects are device-specific objects. The SYNC object is the only bus-wide object.

For example, to use a process data object (PDO) for a specific device, create a PDO for this device. To use a PDO for another device, create another PDO. You can create up to 355 objects, maximum.

After creating objects for communication, you can implement the algorithm of the application. For more information about creating a LabVIEW application, refer to the LabVIEW User Manual.

Starting Devices and Objects

You must start devices and objects before executing the application.

To start devices, use network management (NMT) commands. LabVIEW automatically starts all objects when you start an application.

To start objects, use the proper instance of the CANopen Start VI.

Starting Devices

To perform I/O, send a start remote node command to CANopen devices. This command switches devices into the operational state to support PDOs. Use the CANopen NMT Write VI to send this command. To start all devices on the network simultaneously, send a start remote node command with a node-ID of 0.
  • (Optional) Configuring Devices—Configure devices through SDO communication. Use the CANopen SDO Write VI or the CANopen SDO Batch Write VI to configure dictionary objects of devices.
  • (Optional) Monitoring Objects—Use the node guarding protocol or the heartbeat protocol to monitor NMT states of devices. Use the CANopen Node Guarding StartVI to read NMT states of devices. Use the CANopen Heartbeat Start VI to monitor the heartbeat transmission of devices.
  • Executing the Application

    You may execute applications after the previous steps. Devices transmit and receive PDOs during the execution. Use the CANopen RPDO Write VI to transmit data to devices. Use the CANopen TPDO Read VI to read the data that devices send.

    Stopping and Closing Objects

    LabVIEW stops and closes all objects when the application terminates. You can also manually stop and close objects before the application terminates. Use the corresponding instance of the CANopen Stop VI to stop objects, such as PDOs, heartbeat objects, and node guarding objects. Use the corresponding instance of the CANopen Close VI to close objects.

    If you close an object without stopping this object, the CANopen Close VI stops the object automatically and closes the object. If you stop an object without closing this object, LabVIEW closes this object when the application terminates.