CNC system massive NC program interpretation implementation method (2)
In the concrete interpreter implementation, consider the actual pointer of the program and the program logic pointer at the top and bottom of the page. When the actual pointer of the program and the program logic pointer are at the top, the next position of the program logic pointer may be at the end of the previous logical page, and the actual pointer of the program may be retired to the end of the physical page. When the actual pointer of the program and the program logic pointer are at the end of the page, the next position of the program logic pointer may be in the next logical header. The actual pointer of the program may move from the end of the physical page to the top of the physical page. For these two cases, two processing functions are designed: Previous page next page
Struct PageProgPtr TreatOfFrameEnd(struct PageProgPtr);
Struct PageProgPtr TreatOfFrameStart(struct PageProgPtr);
This processing guarantees the accuracy of the actual pointer of the program in the physical page and the logical point of the program logic pointer in the extended memory.
Since the actual pointer of the program changes only in the physical page during program interpretation, and the program logic pointer moves in the logical page of the extended memory, the actual pointer of the program and the program logic pointer must be considered together in the design of the interpreter. The interpreter performs the interpretation task of the extended memory NC program by interpreting the contents of the physical page in the high-end memory.
The interpreter interprets the data obtained by the NC program and sends it to a ring buffer queue. When the buffer queue is filled, the interpretation task stops. When the interpolator takes the data from the interpreter and makes the empty cell in the slow queue, the interpreter is activated again by task scheduling, so that the interpreter and the interpolator can work together.
3 About NC programs and NC programs compatible with high-level language BASIC
In the general NC code interpreter, only the NC program of the ISO code can be interpreted, and some NC statements with high-level language features such as DO-WHILE statements, IF statements, GOTO statements, and the like are not supported. There are two methods for interpreting NC statements with high-level language features: The first method is to interpret the NC program of ISO code and the NC program written in a high-level language by two interpreters; the second method is to do A compatible universal interpreter that handles both programs. The first method is simple in thinking, and the interpreter programming is easy. Because the NC program of the ISO code and the NC program written in a high-level language can only be written separately, the processing ability of the NC program is not strong; the second method interpreter programming is difficult, but The interpretation function of the program is strong. In the ISO code program, some high-level language features such as DO-WHILE statement can be used, so that the processing function of the NC program written by the user can be very strong.
In the interpreter of the Huazhong I type CNC system, the second method is adopted, which is compatible with a large number of NC programs and NC programs written in a high-level language to ensure that some high-level languages ​​can be added to a large number of NC programs. Features, which require high-level language processing such as high-level language expression calculations, subroutine calls, and program jumps.
In the basic program-based NC program interpreter, the processing of subroutine labels and jump labels for NC programs written in a high-level language BASIC is generally performed by scanning the entire program to form a subroutine table and a label table, and then each encounter When the NC calls a subroutine or executes a jump program, the table is used to find the address of the subroutine or the destination address of the jump. This not only wastes memory, but also affects the execution speed of the interpretation task. If there are a lot of NC labels, it will take up more basic memory, and the speed of the interpreter is very slow. Especially the huge NC programs generated by CAD/CAM, basically each line has N labels, which is more likely to occur. problem. Due to the use of extended memory, not only the general hand-programmed short NC program is processed, but also a large number of NC programs are processed. Direct addressing is used, and each time a subroutine and jump program instruction is encountered, the label is compared. Find the destination address to execute, which not only saves the basic memory of the system, but also improves the processing speed of the system and the stability of the CNC operation. Solve this problem with 2 functions:
Struct PageProgPtr Find_Nlabel(struct PageProgPtr);
Struct PageProgPtr Find_Ocode(struct PageProgPtr);