注释
您是要附上 gcode 示例吗?我没有看到一个。 |
请将您的 G 代码文件拖放到评论字段中,以便我们帮助解决此问题。 |
@cheton – 我意识到我的电脑上有一份 T2Laser 的评估版,所以我用它来生成一些示例 GCode。它有这样一行: G0 X1.1 M03 S0 维基百科关于 gcodes 和 mcodes 的文章包括一个同时包含 G 和 M 代码的行示例,因此该公式至少是合理的。 如果你愿意,我可以调查一下这个问题。我对 GCode 解析有一些经验。 |
gcode-toolpath生成的刀具路径由gcode-interpreter预处理。在解释器内部,它按照G词和M词将词分成组。 https://github.com/cncjs/gcode-interpreter/blob/master/src/Interpreter.js#L36 const partitionWordsByGroup = (words = []) => {
const groups = [];
for (let i = 0; i < words.length; ++i) {
const word = words[i];
const letter = word[0];
if ((letter === 'G') || (letter === 'M')) {
groups.push([word]);
continue;
}
if (groups.length > 0) {
groups[groups.length - 1].push(word);
} else {
groups.push([word]);
}
}
return groups;
};
@MitchBradley |
注释: 不同激光控制器的S值范围不同。 有些激光柱不使用 M03 S0,而是使用 M5 关闭激光。 |
给定如下的 G 代码:
它将被 gcode-interpreter 分成以下几组:
这将解释为什么没有生成刀具路径。
https://github.com/cncjs/gcode-interpreter/blob/master/src/Interpreter.js#L62-L77 if ((letter === 'G') || (letter === 'M')) {
self.cmd = cmd;
args = fromPairs(words.slice(1));
} else {
// Use the same command if the line does not start with Gxx or Mxx.
// For example:
// G0 Z0.25
// X-0.5 Y0.
// Z0.1
// G01 Z0. F5.
// X0.5 Y0. I0. J-0.5
// X0. Y-0.5 I-0.5 J0.
// X-0.5 Y0. I0. J0.5
cmd = self.cmd;
args = fromPairs(words);
}
|
这似乎是一个很好的解决办法。我很确定 M 命令不应该在后续行中推断出来。 |
In fact, it might be better to infer the command only for G0 and G1 motion modes. |
Will all motion commands (e.g. G0, G1, G2, G3, G38.2, G38.3, G38.4, G38.5, G80) apply the same rule? |
My bad, I forgot the code. Here is the first 50 lines of a job I just ran. It is worth mentioning, the job runs fine, just doesn’t visualize properly. ( Generated by T2Laser ) |
所有这些 M03,除了第一个,都是不必要的。主轴速度(或激光功率)应仅随 Sxxx 变化。 |
Fixed in gcode-interpreter@2.0.1 G0, G1, G2, G3, G38.2, G38.3, G38.4, G38.5 will update the motion mode, and G80 will clear the motion mode. if (letter === 'G') {
cmd = (letter + code);
args = fromPairs(words.slice(1));
// Motion Mode
if (code === 0 || code === 1 || code === 2 || code === 3 || code === 38.2 || code === 38.3 || code === 38.4 || code === 38.5) {
self.motionMode = cmd;
} else if (code === 80) {
self.motionMode = '';
}
} else if (letter === 'M') {
cmd = (letter + code);
args = fromPairs(words.slice(1));
} else if (letter === 'T') { // T1 ; w/o M6
cmd = letter;
args = code;
} else if (letter === 'F') { // F750 ; w/o motion command
cmd = letter;
args = code;
} else if (letter === 'X' || letter === 'Y' || letter === 'Z' || letter === 'A' || letter === 'B' || letter === 'C' || letter === 'I' || letter === 'J' || letter === 'K') {
// Use previous motion command if the line does not start with G-code or M-code.
// @example
// G0 Z0.25
// X-0.5 Y0.
// Z0.1
// G01 Z0. F5.
// G2 X0.5 Y0. I0. J-0.5
// X0. Y-0.5 I-0.5 J0.
// X-0.5 Y0. I0. J0.5
// @example
// G01
// M03 S0
// X5.2 Y0.2 M03 S0
// X5.3 Y0.1 M03 S1000
// X5.4 Y0 M03 S0
// X5.5 Y0 M03 S0
cmd = self.motionMode;
args = fromPairs(words);
}
|
The bug fix will be included in CNCjs 1.9.12. For a temporary workaround, you can follow @neilferreri‘s suggestion to remove all M03s except the first one, as shown below:
If you want a hot fix in short, I can give you a patched JavaScript bundle to replace the file for CNCjs 1.9.11. |
Wow, that was quick work. Thanks for your help. I had done as you suggested (removing redundant M3s) during my testing and it worked well, but of course it is an extra step. If the hot fix is simply enough to apply, I would take it. Otherwise I’ll wait for the next version. |
Fixed in 1.9.12 |
描述
T2Laser 是一款激光凸轮软件,设计用于低功率二极管激光雕刻机。该软件在每个 G0 运动中使用 M3 命令来控制激光功率(请参见下面的 g 代码片段)。此 M3 命令阻止可视化工具显示刀具路径。我通过从文件中删除所有 M3 命令并重新加载来验证这是原因。然后显示刀具路径,但没有它们激光不会打开。
是否可以让可视化工具忽略 M3 命令?
版本
你如何安装CNCjs?
数控系统
硬件
操作系统