Research and Design of Embedded Serial Device Server on the DNC System

2013-12-07 07:33QUBaojunGUOChao
机床与液压 2013年1期
关键词:山东理工大学多任务内核

QU Baojun,GUO Chao

School of Mechanical Engineering, Shandong University of Technology, Zibo 255049, China

ResearchandDesignofEmbeddedSerialDeviceServerontheDNCSystem

QU Baojun*,GUO Chao

SchoolofMechanicalEngineering,ShandongUniversityofTechnology,Zibo255049,China

ThispaperdiscussedthesoftwareandhardwaredesignmethodsofEmbeddedSerialDeviceServerontheDNCSystem,andpresentedasortofruletotransmissionlineforNCprogramadaptedtoDNCsysteminthefaceofasetofquestionsaboutNCmachiningadoptedwithgeneralserialdeviceserver.IthasbeenresearchedindetailsaboutthearchitectureandkerneloftheEmbeddedSerialDeviceServerandputforwardthedetailmethodofachievingmultitaskkernel.

serialdeviceserver,DNCsystem,μC/OS-II,ethernet

With the development of computer technology, modern communication technology and advanced manufacturing technology, the DNC (distributed numerical control ) has become a typical form of workshop information integration, which uses a computer or network to achieve the integrated control on multiple CNC machine tools, including NC program transfer, machine condition monitoring, tool management, and production scheduling[1-3].

Serial device server is a protocol converter for RS232/RS485 and TCP/IP, which provides transparent data transfer between RS232/RS485 and the network. This paper mainly researched and developed the embedded serial device server dedicated to the DNC system.

1.The transmission mechanism of the serial server

DNC system can accomplish the transmission of manufacturing data and monitoring of machine condition, while the computer is the storage system of the manufacturing data and status information. Under the actual production conditions, the computer generally does not need real-time control on the CNC machine tool, just needs to monitor the running state of the machine tool. Only in the condition that the NC program is being transmitted while the workpiece is being machined, the DNC system is particularly strict with the real-time control. Thus, it requires the serial port server which connects to the CNC machine tools to maintain a certain amount of data buffering constantly. In the long workpiece process, whether the data can be received timely by machine or not relates to the amount of data buffering. If the data can not be received continuously, it will result in data underrun; If the amount of data buffering is too small, the data received will be lost, resulting in data overload. Therefore, only when the receiving speed and the sending speed of the serial server match, the data buffering can be maintained at a reasonable level. The mechanism of the data transmission is to establish reasonable rules for sending and receiving data, so as to control the amount of data buffering.

Therefore, as shown in Fig.1, the process that the NC program is sent to the CNC machine by DNC server can be divided into two stages.

First is that the NC program is sent from the DNC server to the serial device server, and then we must consider how to match the data transmission speed. The solution is to provide a data buffer queue in the serial server to decide whether to send the requested information by determining the size of the data queue. In accordance with the requirements of the NC machining, the maximum data buffering can be set to 10 KB. However, the agreed value of the data buffering is set to 5 KB. When the queue size is less than 5 KB, it will request the network to continue to send data.

Fig.1 The transmission procedure of the NC program sending line

Second is that the NC program is sent from the serial device server to the CNC machine, and then we must guarantee that the CNC machine can correctly receive data. The solution is to adopt handshake protocol for serial transmission between the serial device server and CNC machine.

When using the remote control to achieve that the CNC machines send the NC program containing command information to the DNC server, TCP is a reliable stream end-to-end protocol, and the network bandwidth is up to 10/100 Mbps, so the timeliness and definiteness of the NC program can be satisfied, and therefore the NC program can be transmitted directly. There is no need for data buffering. And M30 can be adopted as the end instruction of the program, indicating the end of a CNC file transmission.

2.The hardware structure of the serial device server

The essence of the serial device server is a converter of TCP/IP and RS232[4], its internal structure is shown in Fig.2. It accesses to the workshop LAN upward, adopting RJ-45 connector form, whose communication medium is a non-shielded twisted pair. It connects to the CNC machine having the RS232 serial port downward and serial device server can be installed as a part of the CNC machine on the CNC machine.

The serial server CPU adopts processor LPC2210, which is based on 16/32 bit ARM7TDMI RISC core. Then it uses LPC2210 and the network physical layer chip RTL8201BL as the core to complete the peripheral hardware circuit design work, which is used as a basis to select the hardware development platform.

LPC2210 itself doesn’t own FLASH, the system selects the 4Mbit FLASH (SST39VF160) to save the TCP/IP protocol stack and other programs, and selects the 16Mbit SRAM (IS61LV2561611L) as the memory to meet the requirements of the μC/OS-II embedded operating system and the memory block copy operation of the communication controller.

Fig.2 The hardware structure of the serial server

3.The software structure of the serial server

3.1.Multitaskingkerneldesignforserialservers

The serial server kernel is the key to realize DNC communication system based on Ethernet. It mainly have two functions: First, the serial server receives the NC programs sent by DNC servers from the network, meanwhile, it sends them to the CNC machine through the serial port; Second, the serial server receives the NC programs or the commands sent by the CNC machine from the serial port, meanwhile, it sends them to the DNC server over the network.

μC/OS-II is a priority-based preemptive multitasking real-time operating system. According to the requirements of the data transfer mechanism of the DNC system, this paper uses the μC/OS-II multitasking kernel to achieve the functions of the serial port server by assigning them to five tasks[5].

Among them, task 1 is used to receive data from the network; Task 2 is used to receive data from the CNC machine; Task 3 is used to send data to the network; Task 4 is used to send data to the CNC machine, and when the data transfer is completed, it will send a confirmation message to the task 5. Finally, task 5 judges whether confirmation message is received or not; If received, it requests the network to continue to send data. When the NC program is being transmitted when the workpiece is being machined, the requirements for real-time are strict. Therefore, as to the task priority, task 4 is set as the highest level, followed by task 1.

Shared variables and non-reentrant functions exist in each task, so semaphores in the μC/OS-II needs to be used to control the right of use of the shared resources, to mark the occurrence of a time, and to make the behaviors of the two tasks synchronous. Through the use of semaphores to promise multi-tasks to run, only the task having applied to the semaphore can run. When the serial server is multitasking running, semaphores used by it are as follows:

OS_EVENT *SerialRecvFlag;

/*Semaphore marking serial data is readable.*/

OS_EVENT *NetSendFlag;

/*Semaphore marking network can send data.*/

OS_EVENT *ShareVarbFlag;

/*Semaphore marking shared variables can be used.*/

OS_EVENT *ReqireSendFlag;

/*Semaphore marking request for sending data is available.*/

There are three steps in implementing the semaphores:

1.OSSemCreate(); /*Initialization*/

2.OSSemPend(); /*Waiting for signal*/

3.OSSemPost(); /*Sending signal*/

3.2.Thedesignofnetworkcommunicationprogramforserialserver

As the server-side of TCP/IP, serial server achieves the network connection with the DNC server. Through DNC server polling the serial port server, the NC programs or commands are transmitted between the client and the serial port server up and down. The data buffering adopts data queue to balance the problems of transmission speed matching between the serial server and the CNC machine. The correlation functions are as follows:

#define UART1_SEND_QUEUE_LENGTH 1024*10

/*The maximum data buffering is 10K*/

uint8 UART1SendBuf[(UART1_SEND_QUEUE_LENGTH + sizeof(int)-1)/ sizeof(int)];

QueueCreate((void*)UART1SendBuf,sizeof(UART1SendBuf), NULL, NULL)/*Creating a queue*/

QueueWrite((void *)UART1SendBuf, tempdata[i]);

/*Sending data into the queue*/

QueueRead(&temp,UART1SendBuf);

/*Acquiring data in the queue*/

The network communication program mainly completes the two tasks of receiving and outputting network data. The flow chart of the task of receiving network data is shown in Fig.3, the serial server receives data from the network, then processes data separately depending on the type of data.

3.3.Serialportcommunicationprogramdesignforserialserver

The serial communication of serial port server achieves the communication between the serial port server and the CNC machine, which completes the two tasks of receiving and outputting data of the serial port. Although there are many types of CNC machines, most of them support communication protocols of XON/XOFF and RTS/CTS, and serial device server supports these two communication protocols as well. The choices of the parameters related to communication, such as baud rate, parity, data bit and stop bit, are initialized in the network communication program.

Fig.3 The data flow diagram of the receiving network

4.Conclusions

This article developed a single serial port server based on the embedded system, which connects with the CNC machine FANUC0i downward, the DNC system upward. Through a series of tests, the result shown the rationality and applicability of the dedicated serial port server in the DNC system, especially in the demanding real-time process that the NC program is being transmitted as the workpiece is being machined, the machine downtime caused by data underload or overload doesn’t occur. However, in a long process, because the transmission speed does not match, the universal serial device server previously used often leads to the machine abnormity, and sometimes results in the automatic reset of the serial device server. So this article proves that the dedicated serial device server has a good real-time, stability and robustness.

[1] ZHANG Xumei,LIU Fei. Research of the workshop operation mode based on the integrated DNC technology[J]. Chinese Mechanical Engineering,1999,10(3):97-101.

[2] XIONG Bin. Theoretical discussion of the agile DNC system[J].Computer Integrated Manufacturing System,1999,5(6):1-6,25.

[3] Wainwright C R,Harrison D K,Leonard R.CAD/CAM and DNC links as a strategy formanufacture: implications for CAPM[J].Computing & Control Engineering Journal,1992(3):82-87.

[4] YAN Weiguo,WANG Minjie,WANG Minrui. Research of the Ethernet communication technology based on Ethernet and TCP/IP[J]. Journal of Da Lian University of Technology,2003,43(1):77-81.

[5] Jean J. Labrosse. μC/OS-II-Open source real-time embedded operating system[M].Bei Jing:China electric power press,2001.

DNC系统嵌入式串口服务器的研究与开发

曲宝军*,郭 超

山东理工大学 机械工程学院,山东 淄博 255049

针对当前使用的通用串口服务器在数控加工中出现的一些问题,提出了适用于DNC系统的数据传输机制,并论述了一种专用于DNC系统的嵌入式串口服务器的软、硬件设计方法。研究了串口服务器的体系结构以及内核设计,提出了多任务内核的具体实现方法。

串口服务器;DNC系统;μC/OS-II;以太网

TP23

2013-01-09

*QU Baojun. E-mail:qbj22@sina.com

10.3969/j.issn.1001-3881.2013.06.007

猜你喜欢
山东理工大学多任务内核
山东理工大学
山东理工大学
强化『高新』内核 打造农业『硅谷』
基于中心化自动加权多任务学习的早期轻度认知障碍诊断
山东理工大学
基于嵌入式Linux内核的自恢复设计
Linux内核mmap保护机制研究
山东理工大学
基于判别性局部联合稀疏模型的多任务跟踪
微生物内核 生态型农资