Contact me: hankecnc@gmail.com

GRBL 手动换刀 #118

推推 grbl 3年前 (2023-02-02) 387次浏览
关闭
mandrav 打开了这个问题 2017 年 1 月 12 日 · 25条评论
关闭

GRBL 手动换刀#118

mandrav 打开了这个问题 2017 年 1 月 12 日 · 25条评论

注释

GRBL 手动换刀 #118

你好,

有没有计划为 M6 命令添加“支持”(工具更改)?
当遇到对用户指定的宏的调用时,它可以像替换 M6 线一样“简单”(它将移动到预定义的位置以允许手动更改工具,然后在恢复之前探测以重置 z 高度).

老实说,我已经被 bCNC 提供的这个功能宠坏了 :-)
但是将我的控制权转移到 RPi 后,我使用 bCNC 不再方便,我开始更多地使用你的软件(很棒顺便说一句!)。

无论如何,感谢您考虑到这一点。

GRBL 手动换刀 #118
合作者

bCNC 中的换刀

https://github.com/vlachoudis/bCNC/wiki/Tool-Change

你好@mandrav,

你有 bCNC 维基页面中描述的“工具更改”宏示例吗?谢谢。

GRBL 手动换刀 #118
作者

你好@cheton,

以下宏假定在机器坐标 (G53) 的 [X-300 Y-300 Z-50] 处有一个触摸板(或其他 Z 探测方式)。

这是将 M6 命令替换为 GRBL 的程序:

; [1]: keep a backup of current state ($G) as well as current XY
M5 ; stop spindle
G90 ; absolute coordinates
G53 G0 Z-1 ; raise the spindle up to (almost) the top of the travel
G53 G0 X-300 Y-300 ; go to tool change position
M0 ; pause the program to allow the manual tool change
G53 G0 Z-40 ; move above the touch plate
G91 G38.... ; probe command
; [2]: now calculate the offset and adjust WCS
G53 G0 Z-1 ; raise spindle up again to safe height
M0 ; optional extra pause (e.g. to remove probe wires if required)
; [3]: reset state ($G) to what was saved on [1] (also restart spindle etc)
G0 X[saved] Y[saved] ; [4]: move to XY that contained M6
... continue with program

请记住,以上不是 bCNC 中的宏,而是程序在运行时提供的。正如您所理解的,原因是有几个地方需要一些简单的计算(以及当前状态的保存/恢复)。
它的工作方式是这样的:

  1. 将工件归零(Z=0 在其上)
  2. 校准工具:这是一个类似的宏,它只执行上述的探测部分,因此它知道相对于工件 Z=0 的探头偏移
  3. 运行作业
  4. 每次更换工具时,运行上述代码并在点 [2] 调整 WCS Z=0,方法是将当前探针位置(使用新工具)减去先前工具的探针位置的差值添加到 Z。
  5. 继续工作

写完所有内容后,我明白它可能不太符合您的“程序播放器”的理念,需要进行相当多的修改。
这就是为什么我建议在遇到 M6 时只运行用户定义的宏。它需要用户对程序有一些了解,但至少,将允许在您的代码中使用 M6 而 GRBL 不会抛出它不受支持的错误。
这样的用户宏可能如下所示(用于放置在工件上以将其归零的触摸板):

M5 ; stop spindle
G53 G0 Z-1 ; raise spindle to the top
G53 G0 Xx Yy ; go where it's convenient to change the tool (machine coordinates!)
M0 ; pause for the tool change
; also put touch plate on the workpiece, on X0Y0
G0 X0 Y0 ; go to workpiece X0Y0
G0 Zprobe ; go to Z=touch_plate_height+10 give room for height diff. of new tool)
G91 G38 ... ; run the probe command as you like
G10 L20 P1 Zplate... ; adjust Z=0 by adding the touch plate's height
G91 G0 Z5 ; move up
G90 ; absolute coordinates
M0 ; pause for cleanup by the user (remove touch plate, wires, etc)
M3 ; restart spindle and go on

如果您认为可行,请告诉我。

GRBL 手动换刀 #118
合作者
奇顿 评论了 2017 年 1 月 15 日  

谢谢你的详细解释。您是否发现以下步骤有任何问题?

  1. 遇到 M6 时暂停向控制器发送 g 代码
  2. 保存当前模态状态 ($G) 以及机器位置
  3. 运行用户定义的宏来换刀
    • Grbl会在M0上进入Hold状态,点击PlayCycle Start按钮恢复
  4. 恢复先前保存的模态状态和机器位置
  5. 继续发送 g 代码

这里还有一个问题:你是否希望在遇到M6时手动选择一个用户自定义宏?这将在第 3 步之前显示一个弹出窗口。

GRBL 手动换刀 #118
作者

你好@cheton,

是的,我认为这会很好:-)
至于选择宏,要么要求从宏列表中选择一个,要么将其设置为一个设置(如“工具更改宏”)。

最后,如果显示一条消息以便用户知道是时候更换工具并且不奇怪为什么程序停止了,那就太好了 ;-)

GRBL 手动换刀 #118
合作者

我在gnea/grbl#91中提出了一个问题。工具编号对于自动选择工具更改宏也很有用。

GRBL 手动换刀 #118
作者

不错的收获!

GRBL 手动换刀 #118 cheton 将此 添加到 1.9里程碑 2017 年 2 月 5 日
GRBL 手动换刀 #118 cheton 提到了这个问题 2017 年 2 月 8 日
GRBL 手动换刀 #118 cheton 提到了这个问题 2017 年 2 月 24 日
40个任务
GRBL 手动换刀 #118
xpix 评论了 2017 年 4 月 8 日  

如果现在实现了,我可以得到一个 Toolchange 的示例宏吗?

GRBL 手动换刀 #118

它尚未发布。仍然是#139 1.9 Release Backlog 的一部分。

GRBL 手动换刀 #118
合作者
奇顿 评论了 2017 年 5 月 3 日  

v1.9.4 支持在 % 符号后评估表达式(类似于 bCNC)。您可以用以下表达式手动替换 M6 命令。手动工具更改 UI 将在以后的版本中添加。

%wait
%x0=posx,y0=posy,z0=posz  ; Keep a backup of current XYZ
   :   :   :
   <Your manual tool change commands>
   :   :   :
G0 X[x0] Y[y0]  ; Move to XY that contained M6
GRBL 手动换刀 #118
作者

一些好消息!
会尝试一下,让你知道。

GRBL 手动换刀 #118

@mandrav一旦您有机会测试它,请发布您的宏。你有改变要测试吗?

GRBL 手动换刀 #118
作者

@AustinSaintAubin不,我还没有时间测试这个,但是,根据@cheton,据我了解,您必须手动替换 M6 命令(不支持使用宏或其他方式自动替换)。

GRBL 手动换刀 #118
合作者
奇顿 评论了 2017 年 5 月 6 日  

我将要使用的宏类似于 bCNC 的手动换刀代码。您可以查看 CNC.py,如下所示:

https://github.com/vlachoudis/bCNC/blob/master/CNC.py#L1642

#----------------------------------------------------------------------
# code to change manually tool
#----------------------------------------------------------------------
def toolChange(self, tool=None):
    if tool is not None:
        # Force a change
        self.tool = tool
        self._lastTool = None

    # check if it is the same tool
    if self.tool is None or self.tool == self._lastTool: return []

    # create the necessary code
    lines = []
    lines.append("$g")  # remember state and populate variables
    lines.append("m5")  # stop spindle
    lines.append("%wait")
    lines.append("%_x,_y,_z = wx,wy,wz")    # remember position
    lines.append("g53 g0 z[toolchangez]")
    lines.append("g53 g0 x[toolchangex] y[toolchangey]")
    lines.append("%wait")

    if CNC.comment:
        lines.append("%%msg Tool change T%02d (%s)"%(self.tool,CNC.comment))
    else:
        lines.append("%%msg Tool change T%02d"%(self.tool))
    lines.append("m0")  # feed hold

    if CNC.toolPolicy < 4:
        lines.append("g53 g0 x[toolprobex] y[toolprobey]")
        lines.append("g53 g0 z[toolprobez]")

        # fixed WCS
        lines.append("g91 [prbcmd] f[prbfeed] z[-tooldistance]")

        if CNC.toolPolicy==2:
            # Adjust the current WCS to fit to the tool
            # FIXME could be done dynamically in the code
            p = WCS.index(CNC.vars["WCS"])+1
            lines.append("G10L20P%d z[toolheight]"%(p))
            lines.append("%wait")

        elif CNC.toolPolicy==3:
            # Modify the tool length, update the TLO
            lines.append("g4 p1")   # wait a sec to get the probe info
            lines.append("%wait")
            lines.append("%global TLO; TLO=prbz-toolmz")
            lines.append("g43.1z[TLO]")
            lines.append("%update TLO")

        lines.append("g53 g0 z[toolchangez]")
        lines.append("g53 g0 x[toolchangex] y[toolchangey]")

    if CNC.toolWaitAfterProbe:
        lines.append("%wait")
        lines.append("%msg Restart spindle")
        lines.append("m0")  # feed hold

    # restore state
    lines.append("g90")     # restore mode
    lines.append("g0 x[_x] y[_y]")  # ... x,y position
    lines.append("g0 z[_z]")    # ... z position
    lines.append("f[feed] [spindle]")# ... feed and spindle

    # remember present tool
    self._lastTool = self.tool
    return lines
GRBL 手动换刀 #118
成员
尼尔费雷里 评论了 2017 年 8 月 4 日  

@cheton关于这方面的任何更新?
@mandrav有宏可以分享吗?

GRBL 手动换刀 #118

@cheton我已经尝试过使用宏来更改工具,结果很接近,但我总是会出错。有时错误是由于语句无效,有时机器在工作过程中闲置并死机。似乎每当我%wait在 gcode 中放入 a 时,它都会引起问题。相同的简单宏在 BCNC 中正常工作(不使用内置工具更改)。我刚刚将 M6 命令替换为:
`%wait
G53 Z-15
M5
G53 X-220 Y-220

M0
G91
G38.2 F50 Z-50
G10 L20 P1 Z1.2

M0
G90`

我不确定还有什么可以与您分享以提供帮助。
谢谢…我很乐意在我们所有的机器上切换到您的 GUI。

GRBL 手动换刀 #118
合作者

@neilferreri

%wait只是一个等待规划器队列清空的驻留命令。它将被替换G4 P0.5 (%wait)为如下所示:
https ://github.com/cncjs/cncjs/blob/v1.9.7/src/app/controllers/Grbl/GrblController.js#L219-L230

dataFilter: (line, context) => {
    if (line === WAIT) {
        const { sent, received } = this.sender.state;
        log.debug(`Wait for the planner queue to empty: line=${sent + 1}, sent=${sent}, received=${received}`);

        this.sender.hold();

        return `G4 P0.5 (${WAIT})`; // dwell
    }

    return this.dataFilter(line, context);
}

你能试试下面的程序并检查它是否适合你吗?

G4 P0.5
G53 Z-15
M5
G53 X-220 Y-220

M0
G91
G38.2 F50 Z-50
G10 L20 P1 Z1.2

M0
G90
GRBL 手动换刀 #118

@cheton
我仍然遇到各种错误。我可以毫无问题地到达探测器,探测器工作正常,但它会抛出探测器的错误。有时立即,有时几行。您是否

喜欢 (0)