Flourish Legend Teaches You the Control Software of CNC System and its Working Process

Control software is a special software compiled to complete various functions of a specific CNC (or MNC) system, also known as system software (or system program). Because the function settings and control schemes of CNC (or MNC) systems are different, the various system software vary greatly in structure and scale. The design of the system program has the most direct relationship with the realization of various functions and its future expansion, and it is the key and the most workload part in the development of the whole CNC (or MNC) system.

As mentioned earlier, the system software is generally composed of input, decoding, data processing (pre-computation), interpolation operation, speed control, output control, management program and diagnostic program. To be introduced below.

1. Input

In the CNC system, the part program is generally input through the tape reader, tape drive, disk and keyboard, and most of the input is interrupted. There are corresponding interrupt service routines in the system program, such as in the tape reader.

Interrupt service routine and keyboard interrupt service routine, etc. When the tape reader reads a character into the interface, it sends an interrupt to the host, and the interrupt service program sends the character into the memory. Similarly, every time a key is pressed, it means that an interrupt is applied to the host, and a keyboard service program is called out to process the corresponding keyboard command.

The part program input from the reader and keyboard usually enters the part program memory after passing through the buffer. The size of the part program memory is determined by the system designer. Generally, there are several Kbytes, and many part programs can be stored. For example, the part program memory of the 7360 system is 5K, which can store more than 20 part programs.

The keyboard interrupt service program is responsible for storing the characters entered on the keyboard into the MDI buffer, and pressing a key is to apply for an interrupt to the host.


2. Decoding

As can be seen from the previous discussion, the data segment has been sent to the part program memory through the work of the input system. The next step is to translate the input part program data segment into a language that the system can recognize by the decoding program. A data segment needs to go through the following steps from input to transmission to the interpolation working register:

In principle and in essence, software decoding is the same as hardware decoding. For an 8-unit tape program, one character occupies 8 bits. In a 16-bit word buffer, two characters can be stored in one word. If the data segment is long, it will take up more words. The decoding program compares each character with the corresponding number in order, and if they are equal, it means that the character has been input. It is as if in the hardware decoding circuit, only one corresponding AND gate is opened when a code is input. The difference is that the decoding program works serially, that is, they are compared one by one until they are equal. The hardware decoding circuit works in parallel, so the speed is faster. Taking the ISO code as an example, M is

, ie M is octal

, S is

, T is

, F is

, ..., therefore, when judging whether M, S, T or F words have been programmed into the data segment, the input characters can be compared with these octal numbers, if they are equal, then the corresponding characters have been input, Immediately set up the corresponding signs.

The processing after a certain character is input includes:

(1) Create a format flag. If it is a bit format, the number of bits in the format word occupied by each character is different.

(2) According to the different input characters, determine the corresponding address for storing the value. For example, the value of the M code is stored in 1000H, the value of the S code is stored in 1002H, ...; in some systems, all special address codes (such as N, X, Y, G, M, F, etc.) are stored in the storage area. There is a displacement amount, and the first address of the area is added to the displacement amount corresponding to the address code to obtain the area where the address code is stored.

(3) Determine the number of times to call the "digital conversion program". There are always numbers following a code, such as M02, S11, X1000000,…. The value of the M code is up to 2 digits, the maximum value of the Yes code is 2 digits (or 3 digits), the value of the X code is up to 7 digits, etc. Every system is different. But for a specific system, there is a specified value. If a certain code has a value of at most 2 digits, it only needs to call the digit conversion procedure twice. The so-called digital conversion is to convert the input characters (such as ASCII codes) into binary codes and store them in memory.

Combining processor programs for different characters requires an information table. Each character in the table has a corresponding column. The contents of the column include the address offset, the number of bits in the format flag word, and the number of times to call the digital conversion program. After one arithmetic and logical operation, the decoding work can be completed. While decoding, the system will check the syntax of the part program, such as whether the number of input digits is greater than the allowable value, whether the address code with a negative sign is not allowed to have a negative sign, etc.

The decoding result is stored in the specified storage area, and the place where the decoding result is stored is called the decoding result memory. The decoding result memory stores the values of each code (binary) in a specified order and includes a program format flag unit, in which a certain bit is 1, which means that the specified code (such as F, S, M... ...) have been programmed. For the convenience of use, sometimes a flag word is established separately for each value or several values of G code and M code. For example, create a flag word for G00, G01, G02, G03 related to the interpolation mode. When the flag word is 0, it means that G00 has been programmed, and when it is 1, it means that G01 has been programmed....

3. Precalculation

In order to reduce the burden of interpolation work and improve the real-time processing capability of the system, data preprocessing is often performed before interpolation operations, such as determining the arc plane and calculating tool radius compensation. When the digital integration method is used, the processing of left-shift normalization and the calculation of the number of integration times can be performed in advance, so that the most direct and convenient form of data can be provided to the interpolation operation.

Data preprocessing is precalculation, which usually includes tool length compensation, tool radius compensation calculation, quadrant and feed direction judgment, feed speed conversion and machine tool auxiliary function judgment, etc. In the second chapter, the calculation method of tool radius compensation has been introduced. The following only describes the speed calculation and control.

The control method of feed speed is related to the interpolation algorithm adopted by the system, and also varies with different servo systems. In the open-loop system, the reference pulse interpolation method is often used. The movement speed control of the coordinate axis is realized by controlling the frequency of the interpolation operation, and then controlling the frequency of output pulses to the stepping motor. The speed calculation method is based on Program the F value to determine this frequency value. Usually there are two kinds of program delay method and interrupt method.

(1) Program delay method. The program delay method is also called the program timing method. This method first calculates the time interval between two interpolation operations according to the feed frequency required by the system, and uses the CPU to execute the delay subroutine to control the time between two interpolations. The feed speed can be changed by changing the cycle times of the delay subroutine.

(2) Interrupt method. The interrupt method or clock interrupt method refers to sending an interrupt request to the CPU every specified time, performing an interpolation operation in the interrupt service program and sending a feed pulse. Therefore, changing the frequency of the interrupt request signal is equivalent to changing the feed rate. The interrupt request signal can be generated by the pulse signal set by the F command, or by the programmable counter/timer. If Z80CTC is used as a timer, the time constant is set by the program, and an interrupt request signal is sent to the CPU every time the timer arrives, and the frequency of the interrupt request pulse signal can be changed by changing the time constant. Therefore, the key to feed speed calculation and control is how to specify the time constant of CTC. In the semi-closed-loop and closed-loop systems, the idea of time division is adopted, and the contour curve is divided into sampling periods according to the programmed feed rate F value, that is, the feed amount of the iteration period - the method of contour step. The task of speed calculation is: when linear interpolation, calculate the step length of the sampling period of each coordinate axis; when interpolating circular arc, calculate the step size distribution coefficient (sometimes called angular step ). In addition, in the feed speed control, there is generally a process of speed up, constant speed (uniform speed) and speed down to adapt to the working state of the servo system and ensure the stability of the work. This content will be introduced in detail in Chapter 5.

4. Interpolation calculation

Interpolation calculation is one of the most important calculation tasks in CNC system. In traditional NC devices, hardware circuits (interpolators) are used to implement interpolation of various trajectories. In order to calculate the desired interpolated trajectory in a software system, these digital circuits must be simulated by the computer's program. The problem with using software to simulate hardware circuits is that a system with three or more axes linked has three or more hardware circuits (such as a digital integrator for each axis), and the computer uses several instructions to realize the interpolation work. of. However, it takes a certain amount of time for the computer to execute each instruction, and the calculation speed of some small or microcomputers can hardly meet the requirements of NC machine tools for feed speed and division frequency. Therefore, in the actual CNC system, the method of combining coarse and fine interpolation is often used, that is, the interpolation function is divided into two parts: software interpolation and hardware interpolation. The computer control software divides the tool trajectory into several segments, while the hardware The circuit then "densifies" the data between the start point and the end point of the segment, so that the tool trajectory is within the allowable error, that is, the software realizes the initial interpolation, and the hardware realizes the fine interpolation. The following takes the three-coordinate linear interpolation as an example to illustrate.

5. Output

The function of the output program is:

(1) Perform servo control. as above.

(2) When the direction of the feed pulse changes, backlash compensation must be performed. If a certain axis moves from positive to negative, it will output Q positive pulses before the reverse; on the contrary, if it changes from negative to positive, it will output Q negative pulses before the reverse (Q is the backlash value, which can be preset by the program).

(3) Perform lead screw pitch compensation. When the system has an absolute zero point, the software can display the absolute coordinate value of the tool at any position. If the accuracy of each point of the machine tool is measured in advance, the error curve is made, and then the correction amount of each point is made into a table and stored in the memory of the numerical control system. In this way, the numerical control system can automatically compensate the coordinate positions of each point during operation, thereby improving the accuracy of the machine tool.

(4) Output of auxiliary functions such as M, S, and T. In some program segments, it is necessary to start the spindle of the machine tool, change the spindle speed, change the tool, etc., so M, S, and T codes must be output. Most of these codes are for on and off control, and are executed by the machine power. But which auxiliary functions are executed after the interpolation output, and which auxiliary functions must be executed before the interpolation output, need to be pre-confirmed before software design.

6. Management and diagnosis software

The management software in the general CNC (MNC) system involves only two items, namely CPU management and external device management. Since the processing of CNC machine tools is based on a single part, a part program can be divided into several program segments. The execution of each program segment is further divided into steps such as data analysis, calculation, tool movement control, and other action control. Usually, there is a sequential relationship between these processing steps, so the actual process is the repeated execution of these predetermined steps. In an actual system, usually a main program is used to string together the entire custom CNC machining processing process. After the main control program analyzes and judges the input data, it transfers to the corresponding subroutine for processing, and then returns to the data analysis, judgment, and processing after processing. operation... When the main control program is idle (such as delay), the CPU can be arranged to execute a preventive diagnostic program, or to preprocess the input data of the program segment that has not been executed.

In the CNC system, the interrupt processing part is the key point, and the workload is relatively large. Because most of the control steps with strong real-time characteristics, such as interpolation operation, speed control, fault handling, etc., must be completed by interrupt processing. Some machine tools divide stroke overtravel and alarm, reader request, interpolation, etc. into multi-level interrupts, and determine the order of responses according to their priorities. Some machine tools only have one level of interrupt, and only when interrupt requests exist at the same time, the method of hardware queuing or software query is used to set a sequence. For single-CPU numerical control system, there are two common software structures, namely front-end and background-type and interrupt-type. In the CNC system with the front and rear structure, the entire control software is divided into the foreground program and the background program. The foreground program is a real-time interrupt service program, which undertakes almost all real-time functions, such as interpolation, position control, machine tool-related logic and monitoring, etc. The background program refers to the program that realizes input, decoding, data processing and management functions, also known as the background program. The background program is a cyclic operation program. During its operation, the front-end real-time interrupt program is continuously inserted to cooperate with the background program. Work together to complete the processing tasks of the parts.

The characteristic of the interrupt structure is that, in addition to the initialization program, all the various task modules in the system software are respectively arranged in different levels of interrupt service routines. The whole software is a big interrupt system. Its management function is mainly solved through the mutual communication between interrupt programs at all levels. It is also one of the characteristics of CNC and MNC systems to be able to easily set various diagnostic programs. With a relatively complete diagnostic program can prevent the occurrence or expansion of faults. After a fault occurs, the type and location of the fault can be quickly identified to reduce the downtime of the fault. The situation of setting up diagnostic programs for various CNC (MNC) systems is also very different. The diagnostic program can include checking and diagnosing during system operation; it can also be used as a service program to diagnose before the system is running or after a fault shutdown to find the fault location. The CNC systems of some foreign companies can also perform communication (overseas) diagnosis, and the communication diagnosis center instructs the system or the operator to perform some trial runs to find hidden troubles or fault locations.

(1) Diagnostics in operation. Common NC systems already include the seeds of diagnosis during operation, such as horizontal and vertical (horizontal and vertical) parity checks when tape is input, synchronization hole loss checks, and illegal command code checks. In addition, there are measures such as overtravel alarm. It is more convenient to do these jobs in CNC and MNC systems. Moreover, it is also possible to use the typewriter to indicate the results of various project diagnoses and the fault locations represented by unified numbers. Generally speaking, the program for diagnosis during operation is relatively scattered, and is often included in the branch of the main control program and interrupt processing program. Common means are:

① Use code and check memory: This method can only check those invariable areas in the program, and it must be done after restoring the initial state of the system program.

② Format check: This method is generally used in tape input to check the part processing source program, including parity check, illegal command code (command code not used in this system), data overrun, etc.

③ Two-way transmission data verification: This method is commonly used in indirect CNC systems or group control systems. Manual data entry can also be validated using this method.

④ List verification: use the equipped printing device to print the program list and some intermediate data, and comprehensively diagnose the faults of the host computer, interface and software.

(2) Shutdown diagnosis. Shutdown diagnosis refers to the use of computer for diagnosis before the system starts to run, or after the system stops running in case of failure (including the precursor of failure). It generally uses software control for staged operation, such as transmitting data or simulating a single control action. Check the function of the hardware circuit item by item, and selectively find the fault location. This diagnostic program can be separated from the running system program, and then input into the computer when diagnosis is required. When necessary, part of the system program can also be washed out and loaded into the memory.

(3) Communication diagnosis. In communication diagnosis, the user communicates with the communication diagnosis center through the telephone line, and the computer in the center sends a diagnosis program to the user's computer. The program instructs the CNC system to perform certain operations, collects data, and analyzes the status of the system. Compare the system state with the stored expected working state and some limit parameters to determine whether the system's working state is normal, the location of the fault and the trend of the fault. It can be seen that communication diagnosis can be used not only as a tool for diagnosing abnormal conditions, but also as a means of preventive maintenance. Because the transoceanic telephone system can be used between the user and the communication diagnosis center, it is also called overseas diagnosis.

Recommended Machining Materials and Parts

Company Materials NEWS
Machining Services Related Articles