Share this

Implementation of CANopen protocol in servo motor control system

2026-04-06 07:21:30 · · #1
Abstract : Addressing the issue that most domestic efforts focus on low-level software development above hardware, hindering the improvement of application levels, this paper develops CANopen, a high-level communication protocol for the CAN bus based on the PIC18F258 microcontroller, for servo motor control modules in industrial control. This enables the module to possess strong online controllability, scalability, and versatility. The module's operation is verified through a self-developed PC monitoring panel based on LabVIEW software. Keywords : CANopen protocol, CAN bus, servo motor control. Research on fieldbus-based network technology is a hot topic in the field of automation. The CANopen protocol is currently a standard protocol based on the CAN bus application layer, popular in Europe. For engineers, the core task of fieldbus research is the development of control nodes. This paper implements the CANopen protocol for a servo motor control module, illustrating the configuration of a control network based on the CANopen protocol. Servo motor controllers have wide applications in the field of automatic control, such as textile machinery and printing presses. To achieve ideal speed control effects, servo motor modules, in addition to meeting certain requirements in resolution, linearity, and conversion rate, should also possess good online controllability and real-time online status detection capabilities. Therefore, utilizing the CAN bus high-level communication protocol CANopen, and combining the requirements of the Shaanxi Provincial Department of Education's "Self-Adjusting and Leveling of Drawing Wire Machines" project for servo motor control module parameters, a servo motor control module with hardware reusability and software reconfigurability was developed. 1 Overview of CANopen Protocol [1-2] The CANopen protocol is a higher-level protocol defined by the CiA Association to address the incompleteness of the CAN protocol—an application layer protocol. A CANopen device module can be divided into three parts, as shown in Figure 1. The communication interface and protocol software are used to provide services for sending and receiving communication objects on the bus; communication between different CANopen devices is accomplished by exchanging communication objects, and this part directly operates on the CAN controller. The object dictionary describes all data types, communication objects, and application objects used by the device; the object dictionary is located between the communication program and the application program, and is used to provide an interface to the application program. The application program operates on the object dictionary to realize CANopen communication. It includes a functional part and a communication part. The communication part realizes CANopen communication by operating on the object dictionary; while the functional part is implemented according to the application requirements. Figure 1 CANopen device model In the CANopen network system, each node has a unique object dictionary, and the object dictionary of each node has the same structure, but the specific content depends on the different devices. It contains all the parameters describing the device and its network behavior. The CANopen protocol also defines four types of messages (communication objects) for processing information with different functions, namely management message (NMT), service data object (SDO), process data object (PDO) and predefined message or special function object. For specific CANopen protocol content, please refer to the relevant documents. 2 Hardware implementation of servo motor module The servo motor module is controlled by a PIC18F258 microcontroller with a CAN bus function module produced by Microchip with a main frequency of 40 MHz [3]. According to the requirements of the self-adjusting system of the drawing machine for the servo motor (9 V-3000 r/min, i.e. 3 mV-1 r/min), and the D/A speed control data sent from the bus with a period of 1 ms, the 12-bit AD7243 chip of ADI is used for D/A conversion. It features a 300 kHz slew rate, three selectable output voltages (0–+10 V, 0–+5 V, and -5–+5 V), and serial port communication. Figure 2 shows a simplified hardware circuit diagram. Based on system requirements, the AD7243 output voltage is set to ±5 V by connecting the ROFS pin and REFIN pin of the AD7243 chip. An OP07 operational amplifier is connected to the output of the AD7243 to adjust the output voltage to ±10 V, thereby controlling the motor's forward and reverse direction and adjusting its speed. The FDLL4148 relay in the diagram controls the motor's start and stop; the TL521 optocoupler is used as an isolator for acquiring the servo motor's status; to monitor the servo motor's operating status in real time, LEDs (green and red) are designed according to the CANopen protocol to indicate the system's current status and errors; J1 is the interface plug-in with the servo controller. Figure 2 Simplified hardware structure diagram of servo motor module In Figure 2, an adjustable potentiometer R3 for adjusting the zero output bias voltage is connected to OP07; the traditional optocoupler is replaced by an ADuM1100 high-speed digital isolator to reduce power consumption and provide accurate signals; the MCP2551 is a fault-tolerant high-speed CAN transceiver with differential transmit and receive capabilities, which can connect many nodes to the same network and deploy the network using unshielded wires, thereby reducing system costs. 3 Implementation of CANopen protocol for servo motor module (1) Implementation of CANopen protocol The servo motor module plays the role of a slave node in the CANopen network, completing specific tasks within its own scope, performing real-time data transmission, and collecting and controlling data from the underlying devices it is responsible for. Before implementing the CANopen protocol, it is necessary to understand its specific functions in the network: receiving data for controlling the servo motor (including speed control, start and stop) through the CAN bus; sampling the servo Ready signal and the current status of the motor and sending it back to the CAN bus. The core of the CANopen protocol is the object dictionary. The essence of CANopen protocol communication between various machines is to operate on the object dictionary, processing various message data through mapping relationships. Based on the function of the servo motor module and the characteristics of various CANopen protocol messages, the attributes listed in Tables 1 and 2 are defined. Tables 1 and 2 define SDO and PDO messages for reading/writing the object dictionary and transmitting real-time data, respectively. The content of the PDO message mapping parameter sub-index represents the purpose of each byte in the PDO message. For example, RxPDO message mapping parameter sub-index 0x64110110L refers to object dictionary index 0x6411 and sub-index 0x01, occupying 16 bits of data, i.e., the control motor speed data. In addition, the system also defines a receive NMT message for configuring the slave node from the master node; and a Heartbeat message, sent at a period of 5000 ms, enabling the master node to monitor the slave node status in real time and handle errors promptly. In addition to the above-mentioned messages used to implement the predefined functions of the servo motor module, status (green) and error (red) indicator lights were designed according to the indicator light specifications of the CANopen protocol. The CAN bus status register and CANopen communication status flag are checked periodically by timer, and the status of the indicator lights is set to constant, flashing and blinking, etc., so that users can intuitively judge the current status of the machine, thereby improving work efficiency. For specific CANopen protocol and indicator light specifications, please refer to the relevant documents [4]. The design of the servo motor control module is based on the modular design of the CANopen protocol object dictionary. It can be conveniently extended in terms of function. It is only necessary to modify the message mapping parameters in the object dictionary and add the corresponding functional modules. Compared with the previous CAN data transmission protocol, it greatly improves the system efficiency, saves limited hardware resources, and provides convenience for the extension of functions and applications. (2) Application flow After the servo motor module is powered on, according to the nature of the slave node in the CANopen protocol, after the system completes the initialization parameter configuration, it sends a Boot-up message to notify the master node that it has entered the preoperational state and waits for the arrival of various types of interrupts in the main loop. In the pre-operation state, the SDO message from the master node can be received to read/write the object dictionary. For example, when the DA zero-point output bias voltage cannot reach the standard value, it can be adjusted by modifying the voltage bias value in the object dictionary. The NMT message can also be received in the pre-operation state to change the node state, enter the operational state of the servo motor module to transmit PDO messages in real time, and start the normal operation of the system. Once the system enters the pre-operation state, it will send Heartbeat messages at a period of 5,000 ms to enable the master node to monitor the status of the servo motor module in real time; when the slave node has an error, the master node can take immediate measures to realize the function of real-time online monitoring. Figure 3 is the interrupt program flowchart. Figure 3 Interrupt program flowchart (3) Implementation of dynamic mailbox allocation based on PIC18F258 microcontroller The task of dynamic mailbox allocation is to realize the judgment of the function of messages in the mailbox without fixing the specific characteristics of a certain mailbox. Through dynamic mailbox allocation, system resources can be saved, software flexibility can be improved, and future system expansion can be facilitated. During system initialization, dynamic allocation of mailboxes was implemented. Specifically, the PIC18F258 microcontroller has two receive buffers and six receive filters, where receive buffer 0 corresponds to receive filters 0 and 1, and receive buffer 1 corresponds to receive filters 2, 3, 4, and 5. By defining a constant flag array _uCANRxHndls[i] (0≤i≤5), the COBID of the message to be received is defined in the receive filters sequentially. When a CAN bus receive interrupt occurs, the receive buffer that caused the interrupt is determined by Bit0 (RXB0IF, receive buffer 0 interrupt flag) and Bit1 (RXB1IF, receive buffer 1 interrupt flag) of the interrupt flag register PIR3. When receive buffer 0 is interrupted, then: _uCAN_ret = * (_uCANRxHndls + (RXB0CON & 0x01)) (1) Where: uCAN_ret is an array constant flag that identifies a message receive interruption; Bit0 of the receive buffer 0 control register (RXB0CON) is the selection bit for receive filters 0 and 1. When the receive buffer 1 is interrupted, then: _uCAN_ret=*(_uCANRxHndls+(RXB1CON & 0x07)(2) Where: Bit2~Bit0 of the receive buffer 1 control register (RXB1CON) are the selection bits of the receive filters 2, 3, 4 and 5. Through equation (1) and equation (2), the array constant flag representing a certain message interruption can be obtained, so as to realize the judgment of the received message type, complete the dynamic allocation of mailbox and the corresponding message processing. 4 Experimental verification In order to facilitate laboratory monitoring, intuitively observe the working status of the servo motor module, and judge the linear characteristics of D/A conversion, a PC monitoring panel was designed using LabView software [5], as shown in Figure 4. Figure 4 Servo motor module test panel In Figure 4, amplitude and phase are used to set the amplitude and phase of the sine wave to be sent. The sine wave data is sent in the form of occupying two bytes, and combined with the one byte occupied by relays 1 and 2 to form a 3-byte TPDO message. Optocouplers 1 and 2 represent the data status received from the RPDO message. Based on this monitoring panel, the debugging of the system is more convenient. The D/A output waveform observed on the oscilloscope is shown in Figure 5. Because the D/A output is an instantaneous waveform, only a portion of the waveform is visible on the oscilloscope. Furthermore, due to limitations of the LabVIEW software, the maximum output data period is only 1 ms. Therefore, the waveform observed on the oscilloscope exhibits a broken line, with each inflection point representing an output point. The number of inflection points, i.e., how many data points are output to represent a waveform, is determined by setting the phase value. For example, a phase of 18 in Figure 5 will output 36 points to represent one periodic waveform. Figure 5: Waveform observed on the oscilloscope. This D/A output can be sent to the servo controller to control the servo motor, a fact verified in field testing. 5. Conclusion By using the same method to develop other control nodes of the self-adjusting leveling system of the drawing machine using the CANopen protocol, a networked control system was achieved. Besides the servo motor, a complete control system should also include: a main control module (such as a DSP or microcontroller), a PLC module, and a keyboard display module. Similar to the servo motor module, each control module can be developed as a node. Each node has its own node ID. The received and transmitted data are exchanged on the bus. The draft ratio is adjusted by changing the speed of the low-speed roller controlled by the servo motor, thereby achieving self-leveling. The networking and standardization of automatic control systems is an inevitable trend in modern industrial development. Applying the CAN bus application layer protocol CANopen to this field has broad application prospects. This paper presents a standardized servo motor control module conforming to the CANopen protocol, applied to a self-leveling system of a drawing frame, giving it plug-and-play and online monitoring characteristics, enhancing the equipment's scalability, and improving data transmission reliability. This development and use based on a fieldbus application layer standard protocol has certain guiding significance for improving system efficiency, especially in the development of complex systems. References [1] Boterenbrood H. CANopen: high-level protocol for CAN-bus. 2000. [2] CiA, CANopen Communication Profile for Industrial Systems Based on CAL. 1996. [3] Liu Heping, Liu Lin, Yu Hongxin, et al. PIC18FXXX microcontroller principle and interface program design. Beijing: Beijing University of Aeronautics and Astronautics Press, 2004. [4] CiA. CANopen Indicator Specification. 2001. [5] Wang Minsheng. LABVIEW Basic Tutorial. Beijing: Electronic Industry Press, 2002. About the authors: Song Xiaomei, Associate Professor, whose main research direction is signal processing and computer communication technology. Jia Jia, Master, whose main research direction is CANopen protocol and microcontroller development and application.
Read next

CATDOLL Alisa Soft Silicone Head

You can choose the skin tone, eye color, and wig, or upgrade to implanted hair. Soft silicone heads come with a functio...

Articles 2026-02-22