Implementation of CANopen Communication Protocol Based on DSP

Publisher:创新思绪Latest update time:2011-02-15 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

CANopen is an open, standardized application layer protocol that has been widely used in various control systems. With the support of the CANopen protocol, devices from different CAN manufacturers can communicate in real time through the bus.

This paper uses the CANopen communication protocol to achieve communication between the CAN bus digital signal processor (DSP) system and the host computer CAN card for the self-developed fully digital motor servo drive system, and verifies the reliability of information transmission through test experiments, ensuring the speed, accuracy and real-time performance of motor control in the fully digital networked servo drive system.

2 Basic principles of communication system implementation

2.1 CAN controller module of LF240x series DSP

The CAN controller module of the LF240x series DSP is a complete CAN controller. It has the following features [6]:

(1) Fully supports CAN2.0B protocol;

(2) The object has 6 mailboxes for receiving and sending information, and its data length is 0 to 8 bytes;

(3) Programmable interrupt configuration, bit timer and CAN bus wake-up function;

(4) When an error occurs in the transmission or the arbitration loses data, the CAN controller has an automatic retransmission function;

(5) Bus error self-diagnosis function;

(6) Supports self-test mode.

2.2 CANopen protocol

The CANopen protocol uses the CAN chip as the hardware basis and effectively utilizes the simple communication function area provided by the CAN chip to implement the complex application layer protocol requirements of the industrial control network. The following aspects should be noted in the application:

2.2.1 Object Dictionary OD

OD is the core concept of the CANopen protocol [1]. It is an ordered group of objects. Each object is addressed with a 16-bit index value and an 8-bit sub-index. Each node in the CANopen network has an OD, which contains all the parameters describing the device and its network behavior.

2.2.2 CANopen Identifier

CANopen defines a mandatory default identifier (COB-ID) allocation table. It is based on an 11-bit CAN-ID, including a 4-bit function segment (Function Code) and a 7-bit address segment (Node-ID), as shown in Figure 1. Reference [1] gives the CANopen predefined master/slave connection set CAN identifier allocation.



2.2.3 CANopen communication mechanism

The CANopen communication model defines four messages (communication objects) [1]:

1) Management message NMT (Network Management)

is used by the master node in the network to monitor and manage the slave node. This message does not require a response. The NMT message format is shown in Table 1.



2) Service Data Object SDO (Service Data Object)

SDO accesses the OD of a device by using an index and a sub-index. The protocol belongs to the confirmed service type. Depending on the length of the transmitted data, there are two transmission mechanisms: accelerated transmission (up to 4 bytes) and segmented transmission (greater than 4 bytes). The send and reply messages always contain 8 bytes of information, and the basic structure is shown in Table 2:


3) Process Data Object PDO (Process Data Object)

is used to transmit real-time data in normal network operation. Each PDO is described by 2 objects in OD: PDO communication parameters and PDO mapping parameters. Here is an example to illustrate the use of PDO. Assuming that the second send PDO mapping is shown in Table 3, if this message is sent, it consists of 3 bytes, and the message structure is shown in Table 4.


4) Predefined message or special function message

Three specific objects for synchronization, emergency indication and time stamp are defined. Used to cooperate with the above three communication mechanisms.

3 Software and hardware design of system communication

3.1 CAN bus hardware design

Since the TMS320LF2407A chip has a built-in CAN bus controller module, the circuit design of the CAN bus becomes very simple. Just connect the CANTX and CANRX pins of the TMS320LF2407A to the TXD and RXD pins of the CAN transceiver PCA82C250. A suitable terminal resistor is required to connect the CAN buses. In order to further improve the anti-interference ability of the system, an optoelectronic isolation device 6N137 can be added between the controller and the transmission medium. The circuit schematic is shown in Figure 2.



3.2 Establishment of CANopen protocol object dictionary OD

This servo drive communication supports CANopen communication sub-protocol (DS301) and drive device sub-protocol and motion control command (DSP-402). During the development process, according to the specific requirements of the application, the device types such as digital input/output modules, motors and drive devices, controllers, encoders and their corresponding functions are described in the device description protocol. The established OD is divided into three parts:

1) Communication protocol object (Index 0x1000-0x1AFF)

defines the device type, error register, manufacturer-specified status register, COB-ID synchronization information, communication cycle, synchronization CAN information window, as well as device name, software and hardware version number, etc. In addition, the communication parameters of SDO and the communication and mapping parameters of PDO are also defined in this part. Fixed PDO mapping is used in this design, and dynamic mapping is not allowed.

2) Standard device sub-protocol object (Index 0x6000-0x65FF)

defines three types of information: the first type is the relevant device parameters of the motor and driver, such as type, manufacturer information, classification number, etc.; the second type is command words and status words; the third type is the relevant parameters of position and speed.

3) Manufacturer-specified protocol object (0x2000-0x20FF)

flexibly defines the variables used according to the manufacturer's requirements. The use of this part enables the CANopen protocol to ensure both the versatility of the device and the good expansibility of the system.

3.3 Design and implementation of communication program

Software design is carried out for the communication between TMS320LF2407A with CAN controller and PC CAN card.

Mailbox 2 of the CAN controller of TMS320LF2407A is configured as receiving mode, and mailbox 3 is configured as sending mode. Both use the standard information frame format (11Bit ID). The query mode is used for sending information, the interrupt mode is used for receiving information, and mailbox 2 uses low interrupt priority. The information transmission baud rate is set to 500Kbps.

The process of controlling the device using the CANopen protocol can be understood as the process of reading and writing the data dictionary using SDO. When detecting the status of the device object or querying the current information of the device, SDO can be used to read the objects in the data dictionary; to issue control commands to the device, SDO can be used to write data to the corresponding data dictionary object. When receiving the information frame, its command byte (byte0) must be read out first to determine the next step of read and write command processing.

The receiving and sending of information frames are both done in a buffer. During the read operation, the length of the sent information frame is 4 bytes, and the response information frame is agreed to be 8 bytes; during the write operation, the length of the sent information frame is agreed to be 8 bytes, and the response information frame is 4 bytes.

Use different sending mailboxes to send information frames with different data lengths. In this program design, mailbox 4 is used to send information frames with a length of 4 bytes, and mailbox 5 is used to send information frames with a length of 8 bytes. This method can improve the efficiency of information transmission. The software design flow chart is shown in Figure 3.



4 Test results

In order to test the communication between the CAN bus DSP system and the PC CAN card, a friendly human-machine interface was written using VC++ (see Figure 4). When conducting a communication test, first select the communication port, set the communication baud rate, ID mask bit, information frame format and the format of the transmitted data (decimal or hexadecimal). It is particularly important to note that the communication baud rate set on the PC side must be consistent with the communication baud rate on the DSP side. Then open the CAN bus port, select the function segment and address segment for sending SDO, fill in the information frame length (in bytes) and content, and then conduct a communication test.



For example, to set the expected value of the motor wheel speed at address 1 to 0x3E8, the index of the expected value of the motor wheel speed in OD is 0x606B, and the startup domain download protocol is used to accelerate the transmission. Then set the address segment to 1, the information frame length to 8, and the information frame content to 2B 6B 60 00 E8 03 00 00. After the transmission is successful, the response information frame content returned is: ID=581, LENTH=4, DATA=60 6B 60 0 0 0 0, indicating that the write operation is correct (see Figure 4).

To read the expected value of the motor wheel speed at address 1, that is, read the object 0x606B in OD, use the startup domain upload protocol, and the server responds using the accelerated transmission method. Then set the address segment to 1, the information frame length to 4, the information frame content to 40 6B 60 00 00 00 00 00, and the response information frame content returned after successful transmission is: ID=581, LENTH=8, DATA=4B 6B 60 0 E8 03 0 0, indicating that the reading operation is correct (see Figure 4).

5 Conclusion

This paper uses the CANoen protocol to realize the communication between the CAN bus DSP system and the host computer CAN, realizes the digitization and modularization of the control system, and maintains the scalability of the system, laying a solid foundation for improving the intelligent level of the servo drive system. (Author: Ma Yange Jia Kai Xu Fang Microcomputer Information)

Reference address:Implementation of CANopen Communication Protocol Based on DSP

Previous article:Design of intelligent power amplifier switching power supply based on DSP
Next article:Digital control system of brushless DC motor for energy storage flywheel based on DSP

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号