CNC technology is undoubtedly the most important technical basis in modern advanced manufacturing technology. In a sense, the level of numerical control technology has become one of the important indicators to measure the manufacturing level of a country. Due to technical monopoly and exclusive market, the CNC systems produced by various manufacturers are mostly closed in the architecture, and cannot be extended with high software. In recent years, many CNC software developers at home and abroad have repeatedly researched and developed the same or similar CNC systems, repeatedly designing several basic modules, resulting in huge waste of manpower, material resources and financial resources, and due to the lack of uniform standards, different Software developed by CNC software developers cannot replace each other, lack of compatibility, hinder the upgrading of CNC software, and hinder the ability of CNC machine tool manufacturers to respond quickly to the market and users. Through the analysis of the software system architecture of the numerical control system, we envisage that if the same or similar parts of the numerical control system software are made into software ICs (SIC) similar to hardware electronic chips [1, 2], each software chip has High degree of functional independence, portability, ease of assembly, and ease of expansion. In this way, when we build a new CNC system, we only need to take out the required chips from the chip library and combine them, and if necessary, expand them so that the CNC system can be reused without having to develop the entire software system from scratch. In this way, the closed design of the current CNC system can be changed, which lays a good foundation for adapting the production organization mode of the future workshop-oriented tasks and orders, and makes the integration of the underlying production control system more simple and effective, thereby greatly improving the productivity of the numerical control software and Can be used to reduce production costs and development cycles. This is an inevitable way to enhance the rapid response of the CNC system to the market and promote the rapid and efficient development of the CNC industry.
1 Division of CNC system software chip
Reasonable chip division is the first step in developing software chips. Each chip in the CNC system software chip library is opened in an interface manner. Through the prompts of interface parameters and interface information, the user can grasp the start, end and operation of the chip. The inside of different chips is black box package, the external interface is open, and on this basis, the new system is built. Therefore, how to define a reasonable CNC system software chip, the external interface of the chip is easy to standardize and standardize, and the internal black box encapsulation is easy, which is a key step for us to develop the CNC system software chip library.
At present, although the numerical control system varies from the design method of the system to the implementation of the system, the basic principles and the composition of the software are similar. On the basis of careful and comprehensive analysis of the existing CNC system [3] and user requirements, at the same time, based on summarizing the common features of the existing system control structure, and based on appropriate classification and abstraction, The numerical control system is divided into the following basic functional modules.
(1) Human-computer interaction interface module This module mainly completes the modification and setting of system parameters before and during system operation, such as setting system working mode (automatic, manual, jog, etc.), graphic display mode, system initial setting. Set, coordinate offset setting, editing of G code program, etc.
(2) The part code interpretation module is responsible for grammar checking the user-written part program according to the user's system configuration and the grammar rules of the part program, and interpreting and decoding, and separating and extracting various information given in the source code instruction. , into various states and data, providing intermediate code for the grammatically correct part program for the preprocessor chip.
(3) The tool compensation pre-processing module is responsible for pre-processing and pre-interpolation of the interpreted data.
(4) The trajectory interpolation module is responsible for the control of acceleration and deceleration, interpolation, and end point discrimination, and outputs the feed amount after the trajectory calculation to the position controller.
(5) The axis servo control module controls the machine tool actuator to move according to the path and speed specified by the NC command by the fine interpolation correction with the help of the information obtained from the I/O and the interpolation operation.
(6) The I/O module is responsible for the input and output of the controller (including the input of the machine detection signal and the position and related feedback information, the output of the control command, etc.).
The above modules are interoperable, portable and extensible, and thus can be used as the basic chip of the numerical control software chip library.
2 CNC system software chip construction and working principle
The concept of software chip is a milestone in the development of software reuse. The development of software chips is the use of object-oriented technology to make some common modules in a particular class into independent reusable object classes. Because object-oriented has valuable features such as encapsulation, classification, message response and inheritance, the coupling degree between the software chip and other parts of the system is reduced as much as possible, which provides a guarantee for the development and use of the software chip. At the same time, since the chips are implemented by encapsulating more mature technologies, they are verified in practice, that is, a mature chip has already reduced the error rate to the lowest point, so it can be constructed by using a numerical control software chip. The new CNC system guarantees the system's reliability to the greatest extent possible. The software chip is built by encapsulating the body part of the function module in a black box, so that the input interface and the output interface are as simple and standardized as possible. Because the object-oriented features and encapsulation of C++ language are better [4], VC is used as the programming environment to construct the chip ontology in this system. The entire chip is created based on a static library, and finally a Lib library file is generated. All functional implementations are encapsulated in Lib library files. When the user uses it, it is not necessary to know how the functions inside the chip (such as initialization, error information processing, data separation) are implemented. Just add the corresponding .Lib file and .H file to their own system, and then follow the chip instructions. The proposed interface requirements can be invoked through the interface parameters. Interface parameters and methods are defined in the Lib file as the user can interact with the chip through the outside world. Just as the user uses the functions inside the chip through the pins of the hardware IC.
The following is an example of a part program interpretation chip, and briefly describes the construction process of the CNC system software chip.
First, analyze the ontology function of the chip and define the appropriate interface. In general, a complete part NC machining program consists of several blocks, one block consists of several code words, and ends with ";". Each code word consists of a character and a number of characters separated by a space character.
According to the top-down principle, this part can be divided into the following parts:
(1) lexical check to spell and digitize the data of the source program;
(2) Grammar check Checks the format of the G code and other function codes in the program segment, such as the compatibility check of the G code;
(3) Semantic check checks for context-sensitive errors, such as I, J, K, and R cannot appear in the same line of code;
(4) Decoding The information of the program segment is extracted, and the corresponding state quantity and data amount are stored in the output buffer.
On the basis of comprehensive consideration of the internal logic relationship of the numerical control system interpreter and the motion control of the numerical control system, the input port data of the interpretation chip is defined as a line of numerical control code segments (char* LineStr) input in the form of a string; the output port data definition It is a structure that contains various amounts of information.
Output data structure:
Typedef struct{
Int Gp01; ∥1 group G code
......
Int Gp15; ∥ 15 groups of G code
Int N, ∥ block number
G, ∥ preparation function
M, ∥ accessibility
P, Q, L, D, H; ∥ other parameter characters
Long T; ∥ cutter selection
Double F;
Double S; ∥ spindle speed
Double D; ∥ tool radius
Double X,Y,Z,A,B,C,I,J,K,R,U,V,W; ∥size word
......
BOOL bLastCmnd; last line indicator
}NCcode
To interpret and decode a line of code, declare an instance first:
CCode code; //CCode is the class generated by the Lib file.
Then call its member function,
code.InterCode(char* LineStr)
Complete the lexical, grammatical, semantic checking, and data separation of the code segments in LineStr. During the interpretation process, if there is a syntax or semantic error in the code segment, InterCode will give a corresponding prompt and return to the edit state to re-edit.
Similarly, if you want to initialize the flag bits in the structure, you can do so by calling code.FlagINI(). At the same time, you can end the operation of the entire chip by assigning values ​​to the code.ENDED variable externally.
The various status and data information after the completion of the interpretation is stored in the previously defined data structure. Users only need to follow the general structure of the reading method to obtain the corresponding data, such as NCcode.G; NCcode.M, can also use the entire data structure as the entry point of the next chip, to achieve data transfer between the chip and the chip.
In order to prevent the outside world from operating on the data structure when the chip is being decoded, an error is generated. The chip uses the critical section method, that is, when the method InterCode() is called, it uses the CcriticalSection member function Lock to perform locking processing, and rejects the external access to the updated data, so as to avoid the error that new and old data are read at the same time. . After the explanation is completed, Unlock is used to unlock the data, so that the user can access the updated data.
3 Inter-chip synchronization and coordination
When several chips form a practical system, the synchronization problem between chips becomes extraordinarily important, especially for systems such as CNC systems that require higher real-time performance. When using a software chip to build a CNC system, each chip with specific functions, such as decoding, interpolation, etc., is a separate thread. The communication between threads and threads is implemented by means of event objects. This system is developed in the VC environment, so it can be completed by using the CEvent class and its member functions in the MFC library. Each event object can have two states: a signal state and a non-signal state. Events can monitor whether a thread is placed in a signal state and thereby decide to run the appropriate thread at the appropriate time. Another reason for using event objects for thread communication is that the declaration of an event object is as easy as declaring a global variable. For example, CEvent InterCodedStart; after the event object is created, it is in a non-signal state. If the event object is in the signal state, just call the event object's member function SetEvent(), ie InterCodeStart.SetEvent();
After executing the above statement, the event object InterCodeStart is in the signal state. Whether the thread monitoring event is in a signal state can be implemented using the following Windows API functions.
::WaitForSingleObject(InterCodeStart.mhObject, 0); In this case, if the function returns a value of WAITOBJECT0, the event has been placed in the signal state, otherwise the event is still in a non-signal state. Through these messages and methods, we can realize the communication between the threads of the system, and can also "glue" several chips into an organic practical system through the communication control between these event objects.
4 Conclusion
This system is all developed in the VC environment under Windows NT, so it utilizes many basic classes in MFC, which greatly enhances the flexibility of the entire system and enhances the functions of the entire system. For example, the editor of the NC code is created based on the CEditView class, so when used, it can take advantage of some editing functions of the CEditView class itself, such as New, Open, Save, Copy, Cut, Paste, etc. Editing and management has become as easy and convenient as file management under Windows. At the same time, the use of various controls in VC not only increases the ease of operation of the system control, but also makes the control interface beautiful and friendly. These are the places that deserve further exploration. The idea of ​​using reusable component technology to develop software chips and using it to construct a new numerical control system has been used in the research of the National Natural Science Foundation of China, "High-tech CNC system software chip library and its operating environment", and achieved good results. The effect not only achieves the open design and resource reuse of the numerical control system well, but also is developed based on the general environment such as Windows NT and IPC. It has a good upgrade to the numerical control system and timely response to the market. Development prospects.
About the author: Zuo Jing female, born in 1972. Master of Science in Numerical Control Research Institute, School of Mechanical Science and Engineering, Huazhong University of Science and Technology (Wuhan 430074). The main research directions are numerical control technology, intelligent control system and virtual manufacturing.
Wei Renxuan Lu Xinping Chen Youping Zhou Zude Wuhan 430074 Huazhong University of Science and Technology
Author: Zuo Jinghua University of Science and Technology (Wuhan 430074)
Wei Renxuan Lu Xinping Chen Youping Zhou Zude Wuhan 430074 Huazhong University of Science and Technology
references
1 Wang Fuqing. Object-Oriented Programming. Beijing: Peking University Press, 1992: 56-57, 88-107, 142-159
2 Lenz ManFred. IEEE SOFTWARE, 1987, 4(4): 34-42
3 Bi Chengen. Modern CNC Machine Tools. Beijing: Mechanical Industry Press, 1991: 1~50
4 Kate Gregory, Kangbo Studio Translation. Visual C++ 5 Development User Manual. Beijing: Mechanical Industry Press, 1998: 543~563
Weather Resistant Powder Coating,Automotive Powder Coating,Powder Coating
Color Powder Coating Co., Ltd. , http://www.jhcolorpowdercoating.com