CANopen_logoThe CANopen driver (protocol stack) is a software for a microcontroller that implements the CANopen protocol based on the CAN communication interface. “Vector”, LLC implemented this driver for Texas Instruments microcontrollers based on the C28 core, for example, for TMS320F2810, TMS320F28335, i.e. Delfino, Piccolo, etc. series that have the same CAN hardware module. The driver is also implemented for Concerto Texas Instruments microcontrollers with two cores (the driver is located on the ARM core, but the parameters of the object dictionary can also be added from the C28 core software, a special data synchronization module has been made). Also, the driver is implemented for russian motorcontrol microcontroller K1921BK01T by “NIIET” company. The “Vector”, LLC driver has some extensions compared to the standard CANopen driver, however they are organized within the CANopen protocol and are “add-ons” without breaking the standard.

 

The driver supports the following standard CANopen functions:

  • Heartbeat service from the NTM service group. These are short messages sent periodically and necessary for notifying which devices are on the network.
  • Expedited SDO Service: request-response messages for accessing an object dictionary. Allow to read and write any parameters on request from the upper level environment (master).
  • PDO service that implements various types of PDO – synchronous and asynchronous. The driver supports 8 freely configurable PDOs for reception (RPDO) and 8 freely configurable PDOs for transmission (TPDO). These are the main messages for exchange between devices within the network. The master configures in each device which PDOs with which data and on which event the device will receive, which ones it will send. One PDO message contains 64 bytes of data, which are freely composed from different dictionary objects.
  • Sync time synchronization service, which synchronizes the time counters between different devices on the network. Currently, time synchronization is performed with an accuracy of 100 μs, and is implemented only in the driver for the C28 TI core. Due to this service, devices of the CANopen network can work together on one task, for example, to carry out a multi-coordinate positional movement, if the network nodes are servomotors of different axes of one machine-tool.

 

The driver supports the following extended CANopen functions implemented by “Vector”, LLC and supported by the upper-level UniCON software:

  • The ability to save/load values of parameters of the object dictionary in the non-volatile memory of the device (eeprom). This feature is available in most other implementations of the CANopen stack.
  • Providing access to the structure of the object dictionary for “downloading” the structure via the CANopen network. I.e. an upper-level device (master) can download the object dictionary of a particular device directly from the device for further interaction without knowing its composition. The function is implemented through the exchange of data through a set of “standard” dictionary objects that exist in all CANopen devices with the “Vector”, LLC implementation of the driver. In third-party implementations of CANopen for working with the device, a so-called EDS file describing the object dictionary is required. In other words, the contents of this file in the implementation of the driver by “Vector”, LLC can be downloaded over the network.
  • Extended data types that support so-called scale numbers and units. I.e. for a parameter, you can specify not only that it is, for example, signed and has length of 32 bits, but also that the value of the lower digit is 0.00125 Amperes. Together with the function of downloading the dictionary over the network, this allows the user to display the parameters not only in the form of simple numbers, but directly in volts, amperes, etc. This also allows the programmer not to try to use physical values within the program (so that the number 125, say, 12.5 A), but to implement the control system in independent relative units of measurement. This makes the control system universal in terms of scalability – the program will work equally well for a 1 kW frequency converter and a 1000 kW frequency converter.
  • Support of callback functions when accessing a parameter. The device programmer can configure the CANopen driver so that when accessing a specific dictionary object, the driver calls an arbitrary user-defined function. This is convenient for various add-ons based on the CANopen dictionary: for example, to upload device fault log values, etc. For example, the device can set the data with the alarm code in some object of the dictionary immediately after setting the cell number of the fault log in another object by the upper-level environment.
  • The function of the digital oscilloscope inside the microcontroller. To debug complex control systems, such as a vector control system, it is required to see the graphs of processes inside the control system: change of certain variables over time (for more details, see the article Debug methods for embedded microprocessor systems in power converters or similar on  Geektimes). The CANopen driver by “Vector”, LLC has an interface for a digital oscilloscope module and allows the user to select any four parameters from the object dictionary, and then sends their variable addresses into the microcontroller to the oscilloscope module (which records in arrays how these values ​​change over time). After recording waveforms using a callback function, the UniCON upper-level software downloads and displays these waveforms. It is also possible to record waveforms by a trigger. There are 32 independent triggers available for the programmer of the control system that can trigger the recording process on specific events in the control system. The user of the UniCON upper-level software has the ability to specify by what event he wants to record the waveform at the moment.
  • The function of updating the firmware via CANopen (programmer). It is implemented at the moment only for microcontrollers on the C28 TI core. It operates as a separate CANopen mini-driver (bootloader), which is transferred control to to implement the function of the microcontroller flashing. From the upper-level side, flashingis performed by the UniCON software based on the user-provided .out file with the new microcontroller firmware. This feature is not included in the basic version of the CANopen driver and is supplied separately.

 

The CANopen driver, including the oscilloscope module and the programmer module, can be quite easily integrated into the existing microcontroller software. An experienced developer can carry out this integration in one working day, even if up to this point the developer was not familiar with this driver. The driver consists of several C files (or object files, depending on the delivery contract) and several header files. The driver user (microcontroller programmer) has to include these header files, provide a call for the main driver processing function with a frequency of 1 kHz (in a timer interrupt), configure microcontroller pins (to which CAN bus is connected), enable CAN interrupt (the interrupt handler is inside driver), configure interrupt enable priorities (which interrupts can interrupt the CANopen driver handler, which can not), provide a call for the digital oscilloscope module (user should choose a sampling frequency for the digital oscilloscope by his preference) and also to make an object dictionary in the CoodEdit object dictionary editor. The user also needs to specify what actions will be performed before calling the programmer, in order to stop the device safely if it is in operation. After that he can start using the driver.