G-Code and Toolpath Simulation – FreeCAD Path #8
Analysis and generation of the machining program
Let’s check now whether the levels in the Z axis that we specified when defining the operation match to what we get in the machining program.
Click the button Inspect the G-Code.
A window has appeared in which we can analyze the g-code.
The machining program begins with the Z5 coordinate, i.e. the Clearance Height value.
Then there is a G0 rapid move to the XY coordinates of the beginning of machining.
Then fast move, only in the Z axis, move to the Z3 coordinate, i.e. to the Safe Height value.
If you click on individual lines of the machining program, the specific part of the tool path will be highlighted.
And we will only analyze the values for the G1 move in the Z axis. The G1 means moves with work feed rate, when the tool is working in the material and we see that the machining of the material begins in the Z0 coordinate. The next coordinate is Z-0.8 and the next, the last one is Z-0.999, which is practically Z-1.
So everything agrees with what we defined when determining the parameters in this machining strategy.
Let’s check the feed values.
As you remember, for tool T11 we set the vertical feed, i.e. in the Z axis to 10, and the horizontal feed, i.e. in the XY axes to 100.
And here, in the first line with movement G1, we only have movement in the Z axis and the feed value is F10. Next we have milling in the XY axes and the feed value is F100.
And despite the fact that we set values in mm/s here, in the machining program we have generated what we wanted to achieve, i.e. values in mm/min. But are you sure? Remember that what we are looking at is only g-code analysis, the program itself has not been generated yet.
Therefore, let’s generate the program and to do this click button Post Process the selected Job. Of course, the operation must first be selected. Otherwise this button will be grayed out.
Then indicate the location where the file with the machining program will be saved and click OK.
A window appeared, this time with the part program. And as you can see at first glance, we have differences compared to what we analyzed. There is simply more information here.
At the beginning we have a comment in brackets. Here, we can delete it, change it or add our comment, in which we will write e.g. dimensions of the stock. Just be careful not to make a brackets in brackets.
Then we have the G functions. G17 means choosing the XY plane as the work plane. G90 means absolute positioning, i.e. from the beginning of the coordinate system.
Then a comment with information about the tools used in this program. So a simple tool list.
Then we have the M functions. M6, which is responsible for calling the tool, and in this case the tool number 11 will be selected.
And the M3 function is responsible for switching on the right spindle revs at the speed speed specified in the S1000 parameter, i.e. 1000 revolutions per minute.
It should also be noted that there is a semicolon before the M6 function. The semicolon often means that this function is dimmed for the machine controller. So it will be skipped when reading the program by a CNC machine.
The reason is probably that this postprocessor is written for amateur CNC milling machines that do not have a tool magazine and the tool is changed manually.
Ok, let’s go further we have G functions. At the beginning we have G0, i.e. rapid feed at Z5 coordinate, i.e. Clearance Height value, at this level, also with rapid move there will be a move to X97 Y7 coordinates, i.e. the coordinates of the beginning of the tool path. Then, also with the rapid move G0, the tool moves to the Z3 coordinate, i.e. the value specified in the Safe Height parameter, and from this point the machining with the work move G1 starts with the feed value specified in the tool parameters. Where we entered the values for Horizontal Feed and Vertical Feed.
And here in the first G1 line the tool will only move in the Z axis to the Z0 coordinate. And why only in the Z axis, since there are also XY coordinate values here?
Because the tool had already been set in these XY coordinates with a rapid move, it was only in a different coordinate in the Z axis. And then the coordinate of the Z axis does not change, we only have changes in the XY axes, i.e. the tool will start machining the material from this point.
Let’s check the values for the Z axis and see that here there is a change to the Z-0.8 coordinate, and then to Z-1, which was similar in the G-code analysis, except that here we simply have Z-1 and in the g-code analysis it was Z-0.9999, i.e. almost 1, and it would not make any difference in the workpiece.
And finally we have a fast G0 move at the Z5 coordinate, i.e. to the value of the safety plane.
M5 function means turning off the spindle revs. Again, we have G17 and G90. This can be to restore the default values. Such a kind of security, reset settings.
And the M2 function means the end of the program.
Now let’s return to the feed values for a moment.
In the tool parameters, we determined horizontal feed and vertical feed. So the values of the work feed. The Horizontal Rapid and Vertical Rapid values were also there.
We can guess that Horiz Rapid and Vert Rapid are the values for rapid move. But these values were grayed out and the number 0 was entered there. And as you can see in the G0 move there is no parameter F defining the value of the feed for the rapid move.
That is why this value is not available, because the rapid move G0 is usually defined in the machine tool controller and its value is not defined in the machining program. Simply G0 means rapid move and that’s it, and its value is already predetermined. And this value can be predetermined, because the tool during rapid move does not machine the material but moves in the air and the feed value with this movement for each tool and for each material can be the same.
Sometimes it happens that the tool moves rapid into the material, but it is usually a programming error or CNC operator error when setting the workpiece and then there is a collision, where often the smallest problem is a broken tool…
The work move G1 is different, it is a move during which the tool machine the material and for each tool and for each type of workpiece the parameters may be different and here we have to define these parameters ourselves. We usually read them from the tool manufacturer’s catalog or we know from experience what values to enter.
And ok, everything would be fine if the feed values in the machining program matched what we entered in the tool parameters.
And here we see that if we have move in the Z axis only, we have a feed value of 600 mm/min, and we entered the value 10, and the feed in the XY axes is 6000 mm/min and we entered 100.
And when analyzing g-code such values were, and here we suddenly have values 60 times higher.
Only that, as you remember, the values we entered were given in units of mm/s, and when generating the machining program were converted to mm/min. Hence, they are 60 times larger.
Of course, we could independently calculate and enter values in the tool parameters 60 times smaller than required, then when generating the program they would be converted to the correct values.
But we can also change the settings in FreeCAD, which will allow us to give the feed values in the right units, i.e. in mm/min.
And to do this, from the Edit tab, choose the Preferences option.
Here, select General and go to the Units tab.
U in the User system option we select the option Small metric and CNC and in brackets we have mm and mm / min. And click Ok.
Now let’s get into the parameters of the tool and we already have units in mm/min. Only they have been converted in mm/s and we need to change them. So for Horizontal Feed we enter 100 and for Vertical Feed we enter 10.
And now as we generate the machining program again, everything is ok.
This program is simply a text file and we can open the file, e.g. in an Notepad.
Here we can also manually enter any changes if, for example, the postprocessor is not perfectly adapted to our machine. Usually, the beginning and the end of the program need to be changed. Eg, just add some G functions.
Let’s simulate this machining in FreeCAD. And to run the simulation, select the Simulate Path option.
We start the simulation by clicking the Activate Simulation button.
The Speed slider controls the speed of the simulation, the Accuracy slider we can set the accuracy of displaying the stock and workpiece. Sometimes it may be worth reducing it for more complex machining.
The Pause Simulation button can be used to pause the simulation.
With Single step simulation button we can run the simulation in single step mode.
And with Run simulation till end without animation we can run the simulation without animation and only the final result will be shown.
The Stop running simulation button is used to stop the simulation.
And in this window we have a list of operations for which we carry out the simulation.
If you click OK, the model after simulation will be saved and will be visible in the operations tree and in the work area.
If you want to exit the simulation without saving the pointer model, click Cancel.
Ok, the Face operation has not been fully discussed yet, so we will come back to it for a moment.