Basic Programming Model
- Updated2025-10-10
- 2 minute(s) read
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.
- Device-specific objects
- Bus-wide objects
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
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.