[solved] cutter offset path not exported in g-code

Hi all,

I just tried QCADCAM the first time. I creatred a simple square size 30mm and tried to generate g-code. The cutter size is 2mm.
Independant of my chose to cut inside/outside/on the line I get the same G-Code as result.
I’m doing somthing wrong, but I can’t see it.
The generated path has the needed offset of 1mm, please see picture (cutting outside), but the G-Code speaks of X10/y10, should be X09/Y09 …
My version of QCADCAM is 3.19.2.0 (Linux).

I’d be glad to get an info what I’m doing wrong.

Regards,
Christof

You’ve chosen a postprocessor that uses G41/G42 for cutter radius compensation. This means that your controller will calculate the offset (if it supports G41/G42 at all).

If your controller does not support G41/G42, you need to choose a postprocessor that exports the offset coordinates instead (e.g. “G-Code (Offset)”).

From your screenshot, I guess that you are using the postprocessor for LinuxCNC which does support G41/G42, so your output should work fine for you.

Hi Andrew,

many thanks for your quick reply. You are right supposing I’m using LinuxCNC. With your hint I could see that (I suppose) the generated g-code is missing an important command, see this info from LinuxCNC (Tool Compensation):
“Cutter compensation uses the data from the tool table to determine the offset needed. The data can be set at run time with G10 L1”.
In my case the preprocessor created code without that G10 L1 information resp. tooltable, so my tool has diameter zero and the cutter follows the original edges.
If I’m right, can I influence myself the preprocessor for LinuxCNC and correct it?
I’d like to avoid entering this info manually after every new creation of g-code, I’m sure I do forget this at least once.

Many thanks,
Christof

Yes. The post processor is in your QCAD/CAM installation directory under postprocessors, for example LinuxCNCMM.js. It’s an ECMAScript (“JavaScript”) file. If you can attach an example file that works with your setup, I’m happy to help.

Hi Andrew,
thanks for your offer. I have two ideas to succeed. For both I need the programmers help.
The G-Code I need concerns the comand to set the tool table: G10 L1 Px Ry, where x is the Integer# of the tool (variable [T] stands for uppercase t plus the tool integer number, so not usable here) and y stands for the tool radius for which we easyly can use variable [TR] = ToolRadius.
So first we need a new variable for a solution:
this.registerVariable(“toolNumber”, “TN”, true, “P”, 0);
Now we have two posibilities:
a loop at the beginning of the gcode file to set the tool table like:

N50 G10 L1 P1 R1 //Tool1 with radius 1mm/diameter 2mm
N60 G10 L1 P2 R2 //Tool2 with radius 2mm/diameter 4mm

or we use the internal loop and send the command with every tool change:

N30 T1 M6
N40 S1002 M03
N50 G10 L1 P1 R1 //Tool1 with radius 1mm/diameter 2mm
.
.
N300 T2 M6
N310 S1002 M03
N320 G10 L1 P2 R2 //Tool2 with radius 2mm/diameter 4mm

after my opinion: I’d prefer solution 1 because you can better control the tool table at the beginning of the file.

for solution 2 we need a script like:

  • file start -
    include(“LinuxCNC.js”);

function LinuxCNCMM(cadDocumentInterface, camDocumentInterface) {
LinuxCNC.call(this, cadDocumentInterface, camDocumentInterface);

this.decimals = 4;
this.unit = RS.Millimeter;
this.toolHeader = [
“[N] [T] M6”,
“[N] [S] M03”,
“[N] G10 L1 [TN] R[TR]” //TN = new variable
];
}
LinuxCNCMM.prototype = new LinuxCNC();
LinuxCNCMM.displayName = “LinuxCNC [mm]”;

  • file end -

What do you think about an implementation in QCAD?
Do you see a solution that only affects the scripts?

Best Regards,
Christof

I’ve attached a first attempt at exporting a tool list as part of the header.

This file replaces the existing file postprocessors/LinuxCNC.js. The configurations LinuxCNCMM.js and LinuxCNCIN.js are derived from this configuration and are both affected by this change. This has been tested against QCAD/CAM 3.19.2.

Please let me know if other changes are needed to make this work with your controller.
LinuxCNC.js (1.16 KB)

Hi Andrew,

today I tested your new cde with success.
Thanks for your help. Maybe you allow me to mention a whish: a tool to generate bridges to fix the part you cut would help me a lot.
Are there any plans to introduce it or something simular?

Best Regards,
Christof

Thanks for the feedback. The adjusted postprocessor will also be included in the next update.

Yes, support for “tabs” (small bridges to keep a cut out shape in place) is planned.

Hello,

I am using version 3.26.4 of QCadCAM with Ubuntu 24.04.

I am experiencing the same issue described above.

The tool offset is not being applied.

I have copied the generated G-code below. Could you please let me know if I need to replace the linuxcnc.js file as well, or if there is another issue?

Thank you in advance.

JLMy

N10 G10 L1 P2 R1
N20 G0 Z50
N30 G0 X0 Y0
N40 T2 M6
N50 S15000 M03
N60 G1 Z-2 F100
N70 G1 Y20 F200
N80 G1 X160
N90 G1 Y0
N100 G1 X0
N110 G1 Z-4 F100
N120 G1 Y20 F200
N130 G1 X160
N140 G1 Y0
N150 G1 X0
N160 G1 Z-6 F100
N170 G1 Y20 F200
N180 G1 X160
N190 G1 Y0
N200 G1 X0
N210 G1 Z-8 F100
N220 G1 Y20 F200
N230 G1 X160
N240 G1 Y0
N250 G1 X0
N260 G1 Z-10 F100
N270 G1 Y20 F200
N280 G1 X38.5
N290 G1 Z-9
N300 G1 X41.5
N310 G1 Z-10 F100
N320 G1 X123.5694 F200
N330 G1 Z-9
N340 G1 X126.5694
N350 G1 Z-10 F100
N360 G1 X160 F200
N370 G1 Y0
N380 G1 X126.5694
N390 G1 Z-9
N400 G1 X123.5694
N410 G1 Z-10 F100
N420 G1 X41.5 F200
N430 G1 Z-9
N440 G1 X38.5
N450 G1 Z-10 F100
N460 G1 X0 F200
N470 G1 Z2
N480 G0 Z50
N490 M30

Hi,
The topic is from 98 months or about 8 years back. (QCAD/CAM 3.19.2.)
It is listed as ‘Solved’ by the original poster.
Your current <LinuxCNC.js> includes the fix, see G-Code line N10


At best you should have started a new topic.
On the older PHP forum it was also required to indicate your postprocessor and/or include at least a source document to replicate the issue.


Are you using a calculated offset or the G41/42 approach?
Because I don’t see the G41/42 instruction.
The calculated offset by QCAD should be left or right from the source shape by 1/2 tool diameter.
Then your Linux driver should not add an extra offset based on the G10 L1 Px Rx (…).
This instruction merely updates the tool list data of LinuxCNC.
It should be straightforward that the programmed data must match with the real tool. :wink:


Regards
CVH

Hello CVH,

Thank you for the information provided. As for the previous post, it explained my problem very clearly, and it is exactly the same. That is why I chose to include my query there.

As the previous post indicated, I do not wish to edit the .ngc file manually.

The generated G-code that I included in my previous post was created using the following QCadCAM settings (see screenshot below).

Is there a specific setting I need to configure so that the settings specified in the graphical interface are reflected in the G-code (commands G41/G42)?

Thank you in advance.

JLMy

Hi,
Postprocessors ‘LinuxCNC [mm]’ and ‘LinuxCNC [in]’ (LinuxCNCIN.js and LinuxCNCMM.js) use G41/G42. Then the preprocessor of LinuxCNC creates the offset depending the tool diameter and G41 or G42.


Postprocessors ‘LinuxCNC (Offset) [mm]’ and ‘LinuxCNC (Offset) [in]’ (LinuxCNCOffsetIN.js and LinuxCNCOffsetMM.js) use offset paths created by QCAD.


The term ‘Offset’ should be self-explanatory.


The export is quite different.
Offset path(s) to left or right or exactly the contour of the source shape(s) for G41/G42. That last without Lead In/Out.


The above profile is configured to generate an outer offset of 1 unit.
By QCAD or by LinuxCNC depends on the used postprocessors.


Regards,
CVH

Hello,

I have installed the latest trial version (see screenshot).

I have drawn a rectangle measuring 20 mm × 160 mm and created a toolpath (2 mm diameter) outside the workpiece (see screenshot)

I ran two toolpath tests using the following settings (see screenshot):

1. using the LinuxCNC post-processor (offset) [mm], and I exported and saved the G-code as contour.ngc (see screenshot)

contour_offset.txt (1.1 KB)

2. using the LinuxCNC [mm] post-processor, and I exported and saved the G-code as contour_offset.ngc (see screenshot)

contour.txt (708 Bytes)

It seems to me that the file generated by LinuxCNC [mm] still does not take the offset into account, whereas the offset should be integrated automatically (G41/G42).

However, with LinuxCNC (offset) [mm], the G-code shows a different positioning of the corner points of the rectangle.

I will test both files on my CNC machine tomorrow to see which of the two takes the offset into account.

It seems to me that this should be corrected.
Thank you for your patience.

Hi,
Replicating the issue would have been easier with example drawings.
Both exports DO NOT include a G41/42 and a G40 afterwards.


This is expected for the <contour.txt> export.
It traces a rectangle starting at (0.0, 0.0)
Then Y+20, X+160, Y-20 and X-160 (N70-N100).
And that repeated 5 times stepping down in Z, from Z-2 to Z-10.
Exactly the contour of the shape as expected.
But a G41 (left compensation) is missing.


The problem is probably the Lead In/Out.
Set to ‘Normal’ with a zero length approach path.
This parameter entry should be considered as an error.


Also mentioned in the LinuxCNC documentation:
“The only caveat is the programmer must program the lead in move to be at least as long as the largest tool radius that might be used.”


Set this to for example 5 (mm) and the export includes the G41.
Allowing zero is considered a bug, please report this on QCAD Bugtracker.


Without an approach route you could opt for ‘LinuxCNC (Offset) [mm]’.
The cutter should then plunge at (-1.0, 0.0) and trace a rectangle of 22 by 162 with rounded corners.
Not the case for your offset export, again because a zero length Lead In/Out path Is used.


Regards,
CVH