Design of a servo system based on the DeviceNet protocol
2026-04-06 07:20:33··#1
With the development of power electronics, control, network, and computer technologies, servo systems have gained unprecedented development opportunities. Servo systems permeate various sectors of the national economy, such as CNC machine tools, laser processing, robotics, large-scale integrated circuit manufacturing, office automation equipment, and military weapon servo systems. The development trend of servo technology itself is towards open, networked, and intelligent servo systems. DeviceNet, as an industrial standard open network based on fieldbus technology, provides connectivity between simple low-level industrial devices and high-level devices such as computers and PLCs. DeviceNet uses the international standard Controller Area Network (CAN) protocol, has open technical specifications and inexpensive communication components, resulting in significantly lower development costs than other fieldbuses. DeviceNet adopts a bus-based power supply method, providing intrinsic safety technology and is widely applicable to various high-reliability applications. This paper mainly studies the hardware and software design of a servo system based on DeviceNet. Data transmission and control are achieved through the CAN bus, a microcontroller, and the high-performance motor controller ADMC401, making the performance of the servo motor more stable and enabling better and more flexible application in CNC systems. The implementation of CAN bus and DeviceNet protocol CAN bus protocol and its characteristics Controller Area Network CAN is a serial communication protocol that can effectively support distributed real-time control with a high level of security. CAN has a wide range of applications, from high-speed networks to low-cost multi-way wiring. In the automotive electronics industry, CAN is used to connect engine control units, sensors, anti-skid systems, etc., and its transmission speed can reach 1 Mbps. At the same time, CAN can be installed in the electronic control system of the truck body, such as the headlight assembly, electric windows, etc., to replace wiring devices. Due to the adoption of many new technologies and unique designs, compared with general communication buses, CAN bus has outstanding reliability, real-time performance and flexibility in data communication. Its characteristics are summarized as follows [1]: CAN works in a multi-master mode, and any node on the network can actively send information to other nodes on the network at any time, without distinguishing between master and slave; In terms of message identifiers, nodes on CAN are divided into different priorities, which can meet different real-time requirements. Data with higher priority can be transmitted within 134us at the fastest; CAN adopts non-destructive bus arbitration technology. When multiple nodes simultaneously send information to the bus and a conflict occurs, the lower-priority node actively withdraws from transmission, while the highest-priority node can continue transmitting data unaffected, thus greatly saving bus conflict arbitration time. Especially under heavy network loads, network paralysis will not occur (unlike Ethernet). DeviceNet protocol and its characteristics: DeviceNet is a CAN-based fieldbus developed in 1994 by Allen Bredly in the United States, enabling low-cost, high-performance network interconnection of industrial equipment. The DeviceNet protocol is specifically tailored for factory automation control and plays a very important role in the United States and Asia. In Europe, an increasing number of system solutions use DeviceNet. The DeviceNet specification was approved as a Chinese national standard by the Standardization Administration of China in December 2002 and came into effect in April 2003. The DeviceNet protocol is suitable for the lowest-level fieldbus, such as: process sensors, actuators, valve assemblies, motor starters, barcode readers, frequency converters, panel displays, operator interfaces, and other control unit networks. Devices that can be connected via DeviceNet include a wide range of semiconductor products, from simple light shields to complex vacuum pumps. DeviceNet is also a serial communication link, reducing costly hardwiring. The direct interconnectivity provided by DeviceNet not only improves communication between devices, but also provides important device-level diagnostic functions, which are difficult to achieve through hard-wired I/O interfaces. DeviceNet has several features [2]: DeviceNet is a communication network between PLC and field devices based on CAN technology. It can connect switches, variable frequency speed control devices, solid-state overload protection devices, barcode readers, I/O and human-machine interfaces, etc., with a transmission rate of 125~500kbps; The communication mode used by DeviceNet is: message producer and message consumer. Traditional communication uses the technology of specifying the data source and the target address in message transmission. The model used by DeviceNet is more efficient. It can make control data arrive at each unit of control at the same time and can make more efficient use of the network bandwidth. The data sent by the message producer at one time can be used by multiple message consumers, thus transmitting data more efficiently; The communication protocol used by DeviceNet is an 11-bit identifier, that is, all I/O messages have their own 11-bit identifier ID. The identifier ID is divided into four message groups, each with different uses. The ID also provides multiple priorities. When working, the devices on the bus listen to messages on the network. When the device identifies the correct identifier, it will accept the message. Each device on the devicenet can be connected or disconnected at any time without affecting the normal operation of other devices. The true openness makes the system expansion and modification very convenient. The composition of the control system In order to realize the fast real-time control of the servo system, the system adopts a single-chip microcomputer + DSP dual-CPU structure in the design. The system control tasks are divided in the design: the DSP completes the servo control tasks with high real-time requirements, the 8-bit single-chip microcomputer 89C51 with flash structure completes the management tasks with relatively low real-time requirements, and the communication between the single-chip microcomputer and the DSP adopts the parallel data method, which is implemented by the FPGA. At the same time, the FPGA also completes the functions of external I/O signal management, position pulse command signal processing and counting, fault signal processing, etc. The structure of the servo control system is shown in Figure 1. As can be seen from Figure 1, the system mainly consists of the following parts: servo control center ADMC401; peripheral interface FPGA + single-chip microcomputer 89C51; main circuit and switching power supply circuit [3]. These are described below. [align=center]Figure 1. Structure diagram of the servo control system[/align] DeviceNet communication interface section In the DeviceNet interface circuit designed in this paper, the AT89C51ED2 is used as the microprocessor of the node. In the CAN bus communication interface, the CAN communication controller uses the SJA1000, and the CAN bus driver uses the 82C250. Figure 2 is the schematic diagram of the DeviceNet interface circuit. As can be seen from Figure 2, the circuit mainly consists of four parts: the microcontroller 89C51, the independent CAN communication controller SJA1000, the CAN bus transceiver 82C250, and the high-speed optocoupler 6N137. The microprocessor 89C51 is responsible for the initialization of the SJA1000 and realizes communication tasks such as data reception and transmission by controlling the SJA1000. [align=center]Figure 2 DeviceNet Interface Circuit Schematic[/align] To enhance the anti-interference capability of the CAN bus nodes, the TX0 and RX0 of the SJA1000 are not directly connected to the TXD and RXD of the 82C250, but are connected to the 82C250 through a high-speed optocoupler 6N137. This effectively achieves electrical isolation between the CAN nodes on the bus, thereby protecting the system circuit and the signal transmission of the bus. In terms of overall performance, the system design has good versatility and practicality. The microcontroller AT89C51ED2 is used to implement the application layer protocol for communication. It has abundant memory resources, including four 8-bit I/O ports, three 16-bit timers/counters, 256 bytes of temporary RAM, nine interrupt sources, four priorities, and 2KB of EEPROM space. The system can meet the capacity requirements of the DeviceNet protocol program without expanding the external program memory. It can also operate in ×2 mode (6 clock/machine cycles), and the design in this paper is in ×2 mode. The microcontroller communicates with the host computer by accessing the registers of the SJA1000. The SJA1000's receive and transmit registers are used to temporarily store received and transmitted data. The microcontroller sends data by setting the command bit in the SJA1000's command register. Data reception is achieved through interrupts; the SJA1000's int pin is connected to the AT89C51ED2's int1 pin, enabling the microcontroller to respond to CAN interrupt requests in real time. The 2ms sampling period is generated by the AT89C51ED2's timer interrupt. The servo motor control circuit uses the high-performance ADM401 motor controller, a high-end DSP chip from Analog Devices, Inc. (ADI). The ADM401 is a high-performance digital signal processor for motor control, based on the ADSP-2171 core and supplemented by complete motor control peripherals. These include an 8-channel 12-bit A/D conversion system, a three-phase 16-bit PWM generation unit, two auxiliary PWM outputs, and an incremental encoder interface for position feedback. In addition, the ADMC401 also includes 12 digital I/O ports, event capture units and internal timers, providing complete hardware facilities for the development of fast and high-precision motor control systems. The ADMC401 provides 2k×24-bit internal program RAM, 2k×24-bit internal program ROM and 1k×16-bit internal data RAM; the contents of the program and data RAM can be loaded from the external ROM synchronously or asynchronously through its serial port. In order to meet the needs of actual engineering, the ADMC401 also provides external memory expansion capability, and users can directly address up to 14k×24-bit external program memory and 13k×16-bit data memory [4]. The ADMC401 is the core of the entire servo system, with high-speed computing power, high sampling accuracy, strong peripheral configuration performance and functions, and can handle servo control tasks with high real-time requirements. This system uses it to realize vector transformation, current loop, speed loop, position loop control, PWM signal generation, and various fault protection processing. System Software Design The host computer software design is the core of the entire system. Connected to the CAN bus via a CAN interface card, it is responsible for system management, motion planning, and communication functions. The host PC software design includes three parts: network management, parameter management, and status management. Network management sets the CAN interface card's operating baud rate and local node address, initializes the CAN controller SJA1000 and various DeviceNet object classes, and checks for duplicate node addresses in the network. Because the PC's CAN card initialization involves communication between the CAN card and the PC, the registers of the CAN communication adapter card must be configured, setting parameters such as interrupt vectors, communication baud rates, filter receive codes, and interrupt masks to prepare for normal communication. This part also needs to scan for nodes in the network and establish connections with slave nodes. DeviceNet is a connection-oriented network; a connection must be established between two nodes before communication can occur. This design only uses group 2 slave devices to establish connections, which is accomplished by "assigning predefined master/slave connection groups". Parameter management handles the reading and modification of various parameter words or control words in the servo system. These parameters include internal servo motor parameters such as kp, ki, and kd, as well as radar system parameters: radar sector scan center angle, sector scan range, sector scan speed, the ratio of handwheel speed to antenna speed in handwheel mode, and operating mode selection (parameter 26, where 0—handwheel mode, 1—uniform speed scan mode, 2—sector scan mode, 4—receive stop mode). Generally, reading and writing control word parameters is similar to reading and writing individual parameters. In this design, to simplify the software design, we can use the reading and writing operation of parameter 31 to complete the reading and writing operation of 16 control words. The implementation process is as follows: parameter 31 is a control word parameter, which is an integer composed of 16 control words combined in the order of sta-15 to sta-0. Thus, reading and writing the control word parameter simultaneously completes the reading and writing operation of all 16 control words. State management reflects the current motion state of the servo motor, such as actual position, speed command, torque feedback, speed feedback, and command deviation. This provides us with an intuitive and convenient platform to observe the current status of the servo motor. The lower-level software design uses a microcontroller in the communication section to automatically control the I/O data process, including unpacking and sending input/output data, packaging and uploading data, as well as fault event recording and alarms. The communication card uses a timer interrupt method to frequently exchange data in their respective communication buffers with the control card node on the CAN bus, ensuring the real-time performance of the system's I/O data and shortening the overall system response time. Figure 3 shows the program flowchart. After the lower-level machine is initialized, it enters a wait-for-interrupt state. The communication process of the lower-level machine is achieved by the microcontroller accessing the CAN controller registers. The microcontroller's access to the CAN controller registers is treated as external memory access; the address of each register is the sum of the starting address of the SJA1000 and its internal relative address. The microcontroller receives data using an interrupt method. When the CAN controller SJA1000 receives data from the host computer and there is free space in the receive buffer, the received data is placed sequentially into the SJA1000's receive buffer; this is done automatically by hardware. When the clear command is invoked to clear the data in the receive register, the FIFO receive buffer will fill the cleared receive register with the data and simultaneously respond with an interrupt signal. The microcontroller treats this interrupt signal as its external receive interrupt. After responding to the receive interrupt, the microcontroller reads the data in the receive buffer of the CAN controller and saves it, then clears the receive register of the CAN controller. In designing the software for this system, the development tool used is Borland C++. Borland C++ is a visual, object-oriented C++ programming language rapid development tool, characterized by its simplicity, intuitiveness, and powerful functionality. In the Borland C++ integrated development environment, communication programs for PCs can be easily written. Using PC A as the host, and the servo drive and PC B as two nodes in the network, after setting the host node address and communication baud rate, the network is scanned to establish a connection. Both online nodes are correctly scanned, as shown in Figure 4, which reads the various parameter values of the servo drive. From the characteristics of CAN bus and DeviceNet bus, it can be seen that compared with traditional serial communication, it can reduce wiring in hardware, is easy to expand or modify the system, and is more flexible in software communication, has better real-time performance and stronger error correction capability. This shows that the motion control system based on DeviceNet bus has broad application prospects. The motion control system designed in this paper combines DeviceNet bus with servo motor drive technology to realize the full digitalization of the control system. Actual operation results show that the system has the characteristics of high reliability, good real-time performance and easy maintenance, and meets the design requirements. References [1] Rao Yuntao. Fieldbus CAN Principle and Application Technology. Beijing: Beijing University of Aeronautics and Astronautics Press, 2003 [2] DeviceNet Network Structure, Guangzhou Zhou Ligong Microcontroller Development Co., Ltd., www.zlgmcu.com [3] Li Yesong et al. Design of All-Digital AC Permanent Magnet Synchronous Motor Servo System. Power Electronics Technology, 2002, (6) [4] ADI. Single-chip, DSP-based high performance motor controller ADMC401. Analog Devices, 1999.