Share this

Simplification of the extra-long control program for a full-station grinding machine

2026-04-06 03:21:13 · · #1

Abstract: This paper introduces key technologies for simplifying machining programs using macro programs, subroutines, and variable calculations during the development of motion programs for a full-station groove grinding machine. This provides guidance for machining programs on special-purpose machine tools based on CNC systems that require multiple process selections.

Keywords: multi-process program selection, macro program, subroutine, variable calculation

1. Motion control requirements for a full-station grooving grinding machine

A customer's "full-station grooving grinding machine" is equipped with a Mitsubishi M70B CNC system, with a 2-axis servo system. The servo driver is MDS-D-SVJ3-20, and the servo motor is HF204.

Figure 1. Motion control requirements for the "Full-station Slide Grinding Test Machine"

(1) It can move from the "current slide" to the "any next slide". The "any next slide" is selected by the combination keys on the operation panel.

(2) The X direction is for rapid positioning, and the Y direction is for grinding.

(3) The “running distance” and “running speed” can be set arbitrarily, and the positioning accuracy is 0.001mm .

(4) Able to arbitrarily select the "slide position";

(5) The number of grinding cycles can be set arbitrarily.

(6) It can realize functions such as jogging, handwheel, automatic one-button start and stop, emergency stop, and interruption of operation.

2. Analysis of the motion logic of the grinding process:

The motion path of the "full-station groove grinding test machine" is shown in Figure 2.

Type A products have 50 grooves. Type B products have 100 grooves. The distance between each groove is different.

Grinding process requirements: able to move from the "current groove" to the "any next groove".

Type B products have 100 grooves. If this requirement is met, there could be 100 possible motion paths to choose from at any given groove position. Therefore, the total number of possible motion paths is 100 * 100 = 10,000.

A grinding process program compiled using conventional motion programming methods, such as the basic machining program P100, consists of the following parts:

Figure 2. Basic machining procedure P100 block diagram

Basic machining program P100

(1) Current position determination program step 100.

N1 IF[#1132EQ1]GOTO1001;

...

N99 IF[#1132EQ99]GOTO1099

N100 IF[#1132EQ100]GOTO1100-

#1132 is a variable representing the current position of the worktable. It is processed and issued by the PLC program. The above program determines the current position of the worktable. The current position is in slide 1, and the program jumps to step N1001.

The current position is in slide #99. The program jumps to step N1099.

The current position is in slide 100#, the program jumps to step N1100.

The procedure for "determining the current position" has 100 steps.

(2) The current position is in any chute, which corresponds to 100 kinds of "next processing slot" selection instructions.

N1099 .IF [#1132EQ99]GOTO 2001

...

"#1132 variable" is a selection instruction, which is selected by the operation panel and then issued after processing by the PLC program. When the selection instruction is slot 99, the program jumps to step N2099.

100 slots correspond to 100 selection instructions, with a total of 10,000 judgment steps.

(3) There are 10,000 different processing procedures. Each processing procedure has 12 steps. Therefore, the length of the processing procedure is 12 * 10,000 = 120,000 steps.

Total number of machining steps

=Conditional judgment program 10100 steps + Exercise program steps 120000 steps

=131,000 steps.

The grinding process for 100 grooves could have a total of 130,000 steps. The basic machining program P100 is too long, difficult to program, and has a very low safety factor. This program is not very practical. However, it forms the basis for analyzing machining programs.

3. Simplification of the processing procedure:

3.1 Simplifying the grinding process using macro programming functionality

One of the most effective ways to simplify motion programs is to use subroutines and macros;

Any set of movements with identical actions can be programmed as a "subroutine," and any program where variables can replace specific data can be programmed as a macro program. Following this principle, careful analysis of each grinding movement reveals that the sequence of actions is identical; the grinding program is P200 .

Grinding program P200

N1 M8 ----- Turn on coolant;

N2 M3 ------ Grinding head starts rotating

N3 G90 G1Y0F2000-----Grinding back to Y0 position;

N4 M9-----Turn off coolant

N5 M5------Turn off grinding head rotation

N6 G90 G0Xx------Move to the next X position

N7 M8 ----- Turn on coolant;

N8 M3 ------ Grinding head starts rotating

N9 G90 G1YyF2000-----Grinding the next groove;

N10 M9-----Turn off coolant

N11 M5------Turn off grinding head rotation

N12 M30-----END Program ends.

It's just that in "N6 G90G0Xx------Run to the next X position" and

In the program “N9 G90 G1Yy F2000-----Grinding the next groove;”, the X-axis and Y-axis movement distances vary in different grinding processes. If we represent these X-axis and Y-axis movement distances as variables, and assign different values ​​to these variables when selecting different processes, we can program the grinding motion into a macro program. By assigning different variables to appropriate program steps and calling the macro program, the grinding action can be completed.

Based on the above scheme, a "grinding machining macro program P9200" was developed.

Grinding Process Macro Program P9200

N1 M8 ----- Turn on coolant;

N2 M3 ------ Grinding head starts rotating

N3 G90 G1Y0F2000-----Grinding back to Y0 position;

N4 M9-----Turn off coolant

N5 M5------Turn off grinding head rotation

N6 G90 G0X#1------Run to the next X position

N7 M8 ----- Turn on coolant;

N8 M3 ------ Grinding head starts rotating

N9 G90 G1Y#2 F2000-----Grinding the next groove;

N10 M9 ----- Turn off coolant

N11 M5------Turn off grinding head rotation

N12 M30-----END Program ends.

In this macro : "X-axis movement distance = #1 (variable)"

Y-axis movement distance" = #2 (variable)

In this way, the 120,000-step motion program can be simplified into 10,000 macro program call instructions. The simplified program size is only 8% of the original program size .

3.2 Program parts that cannot be simplified:

Because there are 10,000 motion steps, and the X-axis and Y-axis travel distances are different in each step, even with a simplified macro program, the variable settings cannot be simplified, so the program for setting these 10,000 variables cannot be simplified. The program must be written systematically.

3.3 Simplification of the motion process judgment condition procedure:

In the program, the variable "#1132" represents the current position of the workbench; "#1133" represents the "next instruction selection status" .

According to the programming method of the basic program P100, the program steps used for "motion process selection" reach 10100 steps, which also need to be simplified.

Taking the determination of "current position" as an example:

(1) There are 100 points in the "current position", and the conventional judgment program in the machining program has 100 steps. If a loop program is used, a variable I is used to compare from 1 to 100 in a loop to determine the "current position", and the "GOTO" instruction can be used to jump out of the loop and jump to the specified "program step". The "program step" can also be specified by a variable. Following this idea, the loop comparison macro program is compiled as follows:

P300

N1 WHILE [ILE100] DO 1

N2 #1000=I*100------(Create step number variable)

N3 IF[#1132 EQ I] GOTO#1000 -- This allows you to jump to the selected step number outside the loop.

N4 I=I+1;

N5 END 1

This simplifies the conventional 100-step comparison procedure into a 5-step loop comparison procedure.

(2) By doing the same process for the program that determines the "next instruction selection state", the conventional 10,000-step comparison program can be simplified into a 500-step loop comparison program.

In this part, the simplified program is only 5% of the original program.

The number of steps after the first simplification

1 Current position determination program = 5 steps

2. Motion flow selection and judgment procedure steps = 500 steps

3. Setting motion variables and calling macro programs: program steps = 10000 steps

4 grinding motion steps = 12 steps

Total steps = 10517 steps. After the first simplification.

The simplified program is only 8% of the "regular basic program". It can be said to be a greatly simplified machining motion program.

4. Further simplification of the processing procedure:

because

(1) Setting motion variables and calling macro programs: program steps = 10000 steps

(2) Grinding motion program steps = 12 steps

It can no longer be simplified.

The "motion flow judgment condition" can be further simplified.

The "motion process judgment condition" is actually a combination of two conditions: "current position" and "next instruction selection";

The conditions of "current position" and "next instruction selection" are actually already given in the PLC program (i.e., variables #1132 and #1132 are already determined). Thus, the problem simplifies to: given the "current position" and "next instruction selection," how to select the "sequence number of motion variable settings and macro program call"?

4.1 Setting motion variables and calling macro programs via subroutines

The "motion variable setting and macro program calling program" can be created as a separate "subroutine". This subroutine has 10,000 steps.

If its "sequence step number" is set according to a certain pattern:

"Sequence Step Number" = ("Current Position Variable" * 100) + "Next Instruction Selection Variable"

"Sequence Step Number" = (#1132 * 100) + #1133 --------- (Equation 1)

The "Motion Variable Setting and Macro Program Calling Program" on page 9100 (10000 steps in total) is as follows:

P9100

N0101 G65P9200A*B*-----------(Select slot 1 in slot 1)

N0102 G65P9200A*B*-----------(Select slot 2 in slot 1)

N0199 G65P9200A*B*-----------(Select slot 99 in slot 1)

N0200 G65P9200A*B*-----------(Select slot 100 in slot 1)

……

N0201 G65P9200A*B*-----------(Select slot 1 in slot 2)

N0202 G65P9200A*B*-----------(Select the second slot in the second slot)

N0299 G65P9200A*B*-----------(Select slot 99 in slot 2)

N0300 G65P9200A*B*-----------(Select slot 100 in slot 2)

……… . .

N9901 G65P9200A*B*-----------(Select slot 1 in slot 99)

N9902 G65P9200A*B*-----------(Select slot 2 in slot 99)

N9999 G65P9200A*B*-----------(Select slot 99 in slot 99)

N10000 G65P9200A*B*-----------(Select slot 100 in slot 99)

N10001 G65P9200A*B*-----------(Select slot 1 in slot 100)

N10002 G65P9200A*B*-----------(Select slot 2 in slot 100)

N10099 G65P9200A*B*-----------(Select slot 99 in slot 100)

N1010 0G65P9200A*B*-----------(Select slot 100 in slot 100)

Each step of the P9100 program looks similar; G65 P9200 calls the macro program P9200 instruction. The only difference is that the variables A and B are different for each macro program. A is variable #1, and B is variable #2. Aa and Bb represent the X-axis and Y-axis movement distances corresponding to different machining programs. Variables A and B must be preset for each "grinding machining program." This is why the P9100 program cannot be further simplified.

4. The "Sequence Step Number" of the 2P9100 Program

"Sequence Step Number" = (#1132 * 100) + #1133 --------- (Equation 1)

This setup is designed to retrieve relevant program steps systematically, and it's also a key factor in simplifying the program.

After completing the "Motion Variable Setting and Macro Program Calling Program" (page 9100), the remaining question is how to select the program number.

4.3 "Sequence Step Number Variable"

By setting the "sequence step number" as a variable, you can directly set a specific step of the subroutine to be called when executing the "subroutine call".

N30#1500 = (#1132 * 100) + #1133; ---- #1500 is the "sequence step number" in P9100 (the "sequence number" in P9100 has been set according to this formula).

In this process of simplifying the program, 10,000 steps were first reduced to 505 steps, and now it has been further simplified to 1 step. The program has been thoroughly simplified.

5. Main machining program

After two simplification processes and a determination of non-simplifiable procedures, the final main machining program was compiled as follows: P800

P800----Main Machining Program

N10 IF[#1133EQ0]GOTO90-----(No selection instruction judgment: If no "next position instruction" is selected, the program ends.)

N20 IF[#1133EQ#1132]GOTO90----(Same sign selection judgment--If the selected "next movement position" is the same as the "current position", the program ends.

N30 #1500 = (#1132 * 100) + #1133; ---- #1500 is the "sequence number" in the P9100 program (the "sequence number" in P9100 must be set according to this formula).

N40 M98 P9100H#1500-----Calls the H sequence segment of subroutine P9100. H----The sequence number in P9100.

N90 M30 END

Although the main program only has four steps, it includes one "subroutine" call. The "subroutine" in turn includes one "macro" call.

This program corresponds to 10,000 possible different "grinding processes," with only 10,020 steps. It achieves the most simplified grinding motion program. The main program has only 4 steps. Each step is easy to analyze, test, and troubleshoot. It is a typical method for developing machining processes using macro programming.

Read next

CATDOLL 115CM Emelie TPE

Height: 115cm Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22