Design of Servo System Based on DeviceNet Protocol

Publisher:RadiantSerenityLatest update time:2014-03-05 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  introduction

  DeviceNet is an industrial standard open network based on fieldbus technology, providing connections between simple low-level industrial devices and high-level devices such as computers and PLCs. DeviceNet uses the international standard Control Area Network (CAN) protocol, has public technical specifications and inexpensive communication components, making it much less expensive to develop than other fieldbuses. DeviceNet uses bus power supply, provides intrinsically safe technology, and is widely used in various high-reliability applications.

  This paper mainly studies the software and hardware design of the servo system based on DeviceNet. Through CAN bus, single chip microcomputer and high-performance motor controller ADMC401 for data transmission and control, the performance of the servo motor is more stable and can be better and more flexibly applied to the CNC system.

  Implementation of CAN bus and DeviceNet protocol

  CAN bus protocol and 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-channel wiring. In the automotive electronics industry, CAN is used to connect engine control units, sensors, anti-skid systems, etc., with a transmission speed of up to 1Mbps. At the same time, CAN can be installed in the electronic control system of the truck body, such as the headlight group, electrical windows, etc., to replace wiring wiring devices. Due to the use of many new technologies and unique designs, the CAN bus has outstanding reliability, real-time and flexibility in data communication compared to general communication buses. Its characteristics are summarized as follows [1]:

  l CAN works in multi-master mode, any node on the network can actively send information to other nodes on the network at any time, regardless of master or slave;

  l Based on the message identifier, the nodes on CAN are divided into different priorities to meet different real-time requirements. The data with high priority can be transmitted within 134us at the fastest;

  l CAN uses non-destructive bus arbitration technology. When multiple nodes send information to the bus at the same time and a conflict occurs, the node with a lower priority will actively quit sending, while the node with the highest priority can continue to transmit data without being affected, thus greatly saving the bus conflict arbitration time. Especially when the network load is heavy, the network will not be paralyzed (which is possible with Ethernet).

  DeviceNet protocol and features

  DeviceNet was developed by Allen Bredly in the United States in 1994. It is a fieldbus based on CAN that realizes low-cost and high-performance network interconnection of industrial equipment. The DeviceNet protocol is specially customized for factory automation control. It plays a very important role in the United States and Asia. In Europe, more and more system solutions are implemented using DeviceNet.

  The DeviceNet specification was approved as a Chinese national standard by the National Standardization Administration in December 2002 and was implemented in April 2003. The DeviceNet protocol is applicable to the lowest level fieldbus, such as: process sensors, actuators, valve groups, motor starters, bar code readers, variable frequency drives, panel displays, operator interfaces and other control unit networks. Devices that can be connected via DeviceNet include a variety of semiconductor products ranging from simple light barriers to complex vacuum pumps. DeviceNet is also a serial communication link that can reduce expensive hard wiring. The direct interconnectivity provided by DeviceNet not only improves communication between devices, but also provides quite important device-level diagnostic functions, which are difficult to achieve through hard-wired I/O interfaces. DeviceNet has many characteristics [2]:

  l DeviceNet is a communication network between PLC and field equipment based on CAN technology. It can connect switches, variable frequency speed control equipment, solid-state overload protection devices, barcode readers, I/O and human-machine interfaces, etc. The transmission rate is 125~500kbps;

  The communication model used by DeviceNet is: message producer and message consumer. The traditional communication technology used in message transmission is to specify the data source and target address. The model used by DeviceNet is more effective. It allows the control data to reach each unit of the control at the same time, and can more effectively utilize the bandwidth of the network. The data sent by the message producer at one time can be used by multiple message consumers, thereby transmitting data more effectively;

  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 and multiple priorities. When working, the devices on the bus monitor the messages on the network, and when the device recognizes the correct identifier, it will accept the message;

  Each device on DeviceNet can be connected or disconnected at any time without affecting the normal operation of other devices. The true openness makes system expansion and modification very convenient.

  Control system configuration

  In order to achieve fast real-time control of the servo system, the system adopts a single-chip microcomputer + DSP dual CPU structure in design. The system control tasks are divided during the design: DSP completes the servo control tasks with high real-time requirements, and the 8-bit single-chip microcomputer 89C51 with FLASH structure completes the management tasks with relatively low real-time requirements. The communication between the single-chip microcomputer and DSP adopts parallel data mode and is implemented by FPGA. At the same time, FPGA also needs to complete external I/O signal management, position pulse command signal processing and counting, fault signal processing and other functions. 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]. The following are explained separately. [page]

  

Servo control system structure

 

  DeviceNet communication interface

  In the DeviceNet interface circuit designed in this paper, AT89C51ED2 is used as the node microprocessor. In the CAN bus communication interface, SJA1000 is used as the CAN communication controller and 82C250 is used as the CAN bus driver.

  Figure 2 is the schematic diagram of the DeviceNet interface circuit. As can be seen from Figure 2, the circuit is mainly composed of four parts: microcontroller 89C51, independent CAN communication controller SJA1000, CAN bus transceiver 82C250 and high-speed photocoupler 6N137. The microprocessor 89C51 is responsible for the initialization of SJA1000 and realizes communication tasks such as data reception and transmission by controlling SJA1000.

  

DeviceNet interface circuit schematic diagram

 

  In order to enhance the anti-interference ability of CAN bus nodes, TX0 and RXO of SJA1000 are not directly connected to TXD and RXD of 82C250, but connected to 82C250 through high-speed optical coupler 6N137, so that the electrical isolation between CAN nodes on the bus is well achieved, thereby protecting the system circuit and bus signal transmission. In terms of overall performance, the system design has good versatility and practicality.

  The microcontroller AT89C51ED2 is used to implement the application layer protocol of communication. It has rich memory resources, 4 8-bit I/O ports, 3 16-bit timers/counters, 256 bytes of temporary RAM, 9 interrupt sources, 4 priorities, and 2K EEPROM space. The system does not need to expand the external program memory to meet the capacity requirements of the DeviceNet protocol program. And it can work and run in ×2 mode (6 clocks/machine cycle). The design in this article is in ×2 mode. The microcontroller communicates with the host computer by accessing the registers of SJA1000. The receiving register and sending register of the CAN controller SJA1000 are used to temporarily store the received and sent data. The microcontroller sends data by setting the command register of SJA1000 to send the command bit. The receiving data is realized by interrupt mode. The INT pin of SJA1000 is connected to the INT1 pin of AT89C51ED2, so that the microcontroller can respond to the interrupt request of CAN in real time. The sampling period of 2ms is generated by the timer interrupt of AT89C51ED2.

  Motor control part

  The servo motor control circuit uses the high-performance motor controller ADMC401, which is a high-end product among the DSP chips launched by Analog Devices (ADI). ADMC401 is a high-performance digital signal processor for motor control. It uses ADSP-2171 as the core and is 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, 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.

  ADMC401 provides 2K×24-bit internal program RAM, 2K×24-bit internal program ROM and 1K×16-bit internal data RAM; the contents of program and data RAM can be loaded from external ROM via its serial port in synchronous or asynchronous mode. In order to meet the needs of actual projects, ADMC401 also provides external memory expansion capability. Users can directly address up to 14K×24-bit program memory and 13K×16-bit data memory outside the chip [4]. ADMC401 is the core of the entire servo system. It has 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, various fault protection processing, etc.

  System software design

  Host computer software design

  The host computer is the core of the whole system, connected to the CAN bus through the CAN interface card, responsible for system management, motion planning and communication functions. The host PC software design includes three parts: network management, parameter management, and status management.

  l Network management sets the CAN interface card working baud rate and local node address, initializes the CAN controller SJA1000, and various DeviceNet object classes, and checks whether duplicate node addresses are set in this network. Because the PC's CAN card initialization involves the connection between the CAN card and the PC, it is necessary to configure the various registers of the CAN communication adapter card, set the interrupt vector, communication baud rate, filter receiving code, interrupt mask word and other parameters, and prepare for normal communication. In addition, this part also needs to complete the function of scanning nodes in the network and establishing connections with slave nodes. DeviceNet is a connection-oriented network. Two nodes must first establish a connection before they can communicate. In this design, only slave devices in group 2 are used to establish connections, and the connection is established by "assigning predefined master/slave connection groups." [page]

  l Parameter management completes the reading and modification of each parameter word or control word of the servo system. These parameters include the internal parameters Kp, Ki, Kd, ​​etc. of the servo motor and the parameters for the radar system: radar fan scanning center angle, fan scanning range, fan scanning speed, handwheel and antenna speed ratio in handwheel mode, and operation mode selection (parameter No. 26, where 0 is handwheel mode, 1 is uniform scanning mode, 2 is fan scanning mode, and 4 is receiving stop mode). In general, the reading and writing operations of each control word parameter are similar to the reading and writing operations of each parameter. In this design, in order to simplify the software design, we can complete the reading and writing operations of 16 control words by reading and writing parameter No. 31. The implementation process is as follows: Parameter No. 31 is the control word parameter, which is an integer composed of 16 control words in the order of STA-15 to STA-0. In this way, the reading and writing operations of the control word parameter are completed at the same time as the reading and writing operations of the 16 control words.

  l State management can reflect the current motion state of the servo motor, such as actual position, speed command, torque feedback, speed feedback, command deviation, etc. This provides us with an intuitive and convenient platform to observe the current state of the servo motor.

  Lower computer software design

  The microcontroller of the lower computer communication part completes the automatic control of the I/O data process, including the unpacking and sending of input and output data, the packaging and uploading, as well as the fault event recording and alarming. The communication card uses the timed interrupt method to frequently exchange the data of each communication buffer with the control card node of the CAN bus to ensure the real-time performance of the system I/O data and shorten the response time of the entire system. Figure 3 shows the program flowchart.

  

 

  After the lower computer is initialized, it enters the waiting interrupt state. The communication process of the lower computer is realized by the single-chip microcomputer accessing the CAN controller register. The single-chip microcomputer accesses the register of the CAN controller as the external memory of the single-chip microcomputer. The address of each register is the sum of the first address of SJA1000 and the internal relative address of SJA1000. The single-chip microcomputer receives data in an interrupt manner. The CAN controller SJA1000 receives the data from the upper computer and when there is free space in the receive buffer, the received data is placed in the receive buffer of SJA1000 in sequence. This is done automatically by hardware. When the clear command is called to clear the data in the receive register, the FIFO receive buffer will fill the data into the cleared receive register and answer an interrupt signal at the same time. The single-chip microcomputer uses this interrupt signal as the external receive interrupt of the single-chip microcomputer. After the single-chip microcomputer responds to the receive interrupt, it reads the receive buffer data in the CAN controller and saves it, and then clears the receive register of the CAN controller.

  When designing the system software, the development tool uses Borland C++ language. Borland C++ is a visual, object-oriented C++ programming language rapid development tool with simple, intuitive and powerful features. In the Borland C++ integrated development environment, the communication program of the PC can be easily written.

  With PC A as the host, servo drive and PC B as two nodes in the network, after setting the host node address and communication baud rate, scan the network to establish a connection, and two online nodes can be correctly scanned. Figure 4 shows the reading of various parameter values ​​of the servo drive.

  

 

  Conclusion

  The actual operation results show that this system has the characteristics of high reliability, good real-time performance, and easy maintenance, and meets the design requirements.

Reference address:Design of Servo System Based on DeviceNet Protocol

Previous article:Easy programming for wireless remote control
Next article:VB Hall sensor performance test system

Latest Microcontroller 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号