LaserWeb4 icon indicating copy to clipboard operation
LaserWeb4 copied to clipboard

Support M0 pause for tool changes

Open tbfleming opened this issue 6 years ago • 63 comments

It'd be nice to support this to allow tool changes:

  • Program pauses at M0
  • A notification shows comment on M0 line. e.g. "Switch to tool 7"
  • User can jog, set zero, and enter manual commands
  • A resume button (maybe the run button) continues running code

We'd probably have to do this client side. grbl allows jogging during M0 pause, but doesn't execute any sync commands, such as set zero, during pause.

tbfleming avatar Jul 14 '17 13:07 tbfleming

One of the few places I believe a pop-up is in order. It'd have the message, but not interfere with the left side.

tbfleming avatar Jul 14 '17 13:07 tbfleming

Smoothieware doesn't support M0-M2 (according to http://smoothieware.org/supported-g-codes) but M600 sounds to do the same. If M600 works, I would be able to replace all M0 by M600 for Smoothieware on server side.

cprezzi avatar Jul 14 '17 16:07 cprezzi

Mach3 uses Tx M6 for Tool Change.

cprezzi avatar Jul 14 '17 16:07 cprezzi

The way we understand it, T/M6 is for automated tool change, while M0 means "pause until the user manually presses the 'continue' button" ( presumably to manually change a tool ) We plan on implementing both with smoothie v2, v1 lacks space a bit.

On Fri, Jul 14, 2017 at 6:46 PM, Claudio Prezzi [email protected] wrote:

Mach3 uses Tx M6 for Tool Change.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-315408093, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpFZSMIjtXd3_3pbHoEt5a0tAzDl80ks5sN5tWgaJpZM4OYPAx .

-- Courage et bonne humeur.

arthurwolf avatar Jul 14 '17 16:07 arthurwolf

If we do this client side, then neither Smoothie nor grbl will see the M0.

tbfleming avatar Jul 14 '17 16:07 tbfleming

the controller doesn't really need to see the M0 ...

  1. see M0 in gcode stream
  2. stop sending gcode
  3. wait for user to press "resume" button ( in lw )
  4. start sending gcode again

as I understand it this is a correct implementation of M0, and doesn't require anything on the controller's side ( it would if the "resume" button was plugged into the controller instead of in lw's gui )

On Fri, Jul 14, 2017 at 6:51 PM, Todd Fleming [email protected] wrote:

If we do this client side, then neither Smoothie nor grbl will see the M0.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-315409336, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpFSszYYx5jQpaboPyYORWY0YQmYjsks5sN5yMgaJpZM4OYPAx .

-- Courage et bonne humeur.

arthurwolf avatar Jul 14 '17 16:07 arthurwolf

Yep.

tbfleming avatar Jul 14 '17 17:07 tbfleming

Ok, that sounds doable too.

cprezzi avatar Jul 14 '17 17:07 cprezzi

But what if the gcode is run from SD card?

cprezzi avatar Jul 14 '17 17:07 cprezzi

then you can't really do anything about it currently

On Fri, Jul 14, 2017 at 7:17 PM, Claudio Prezzi [email protected] wrote:

But what it the gcode is run from SD card?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-315415409, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpFRHZW8tk419j3fjPHLSpaTebiw_Pks5sN6KvgaJpZM4OYPAx .

-- Courage et bonne humeur.

arthurwolf avatar Jul 14 '17 17:07 arthurwolf

Is M600 in a gcode file running from the SD card not suspending the job and can be resumed?

cprezzi avatar Jul 14 '17 18:07 cprezzi

nope, I don't expect to. M600 is meant to be sent from a switch module or the serial connection or the screen

On Fri, Jul 14, 2017 at 8:50 PM, Claudio Prezzi [email protected] wrote:

Is M600 in a gcode file running from the SD card not suspending the job and can be resumed?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-315438409, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpFd_NSK2EaYuT8_o4EdRHNlPDLvsmks5sN7iTgaJpZM4OYPAx .

-- Courage et bonne humeur.

arthurwolf avatar Jul 14 '17 19:07 arthurwolf

I'm working on the M0 for tool change. At the moment, when the queue detects an M0, the streaming stops and sets the runStatus to paused. The frontend is then waiting for the "resume job" button to be clicked. Peter somewhen implemented disabling of all jog buttons while on pause, but I think we need jogging for toolchange, right?

@tbfleming @openhardwarecoza @cojarbi What is the exact process needed for a manual tool change?

cprezzi avatar Jul 18 '17 16:07 cprezzi

Short term plan for lathe:

  • M0 with message
  • User jogs to a spot where it's safe to change tools
  • User changes tool
  • User jogs and sets zero
  • Resume

Long term plan for lathe:

  • CAM produces gcode which moves to a spot where it's safe to change tools
  • M0 with message
  • User changes tool
  • Resume. CAM uses tool table to adjust the gcode it generates. grbl's tool length offsets right now aren't suitable for lathes; I may fix that.

Mill is probably similar, but user could also use probing to set tool offset.

tbfleming avatar Jul 18 '17 16:07 tbfleming

Yip would need jogging active when paused. The disabled buttons on jog is for during PLAY. Anytime its not playing (paused, stopped, disconnected, lost connection, aborted, in M0, etc) it should be enabled (now that you mention it, i should open an issue. When usb connection gets lost, upon reconnecting, buttons stay disabled)

On Jul 18, 2017 6:32 PM, "Claudio Prezzi" [email protected] wrote:

I'm working on the M0 for tool change. At the moment, when the queue detects an M0, the streaming stops and sets the runStatus to paused. The frontend is then waiting for the "resume job" button to be clicked. Peter somewhen implemented disable of all jog buttons while on pause, but I think we need jogging for toolchange, right?

@tbfleming https://github.com/tbfleming @openhardwarecoza https://github.com/openhardwarecoza @cojarbi https://github.com/cojarbi What is the exact process needed for a manual tool change?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-316120955, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVr23gYaC_Il-wuSWgp4c1VajxWL5Usks5sPN4IgaJpZM4OYPAx .

ghost avatar Jul 18 '17 17:07 ghost

Ok. I made toolchange an additional status and only special commands like jogging, probing or setZero of Z are allowed in this status.

Probably it would be good to let the user define pre-M0 and post-M0 gcodes. This way the user could define where/how to move for toolchange and how to get back to the location before.

cprezzi avatar Jul 18 '17 18:07 cprezzi

Yay! I like. Dedicated statusses in backend make debugging and changes easier.

Now, @tbfleming you know its not going to be long will we want Tools in CAM now (; lol.

On Jul 18, 2017 8:54 PM, "Claudio Prezzi" [email protected] wrote:

Ok. I made toolchange an additional status and only special commands like jogging, probing or setZero of Z are allowed in this status.

Probably it would be good to let the user define pre-M0 and post-M0 gcodes. This way the user could define where/how to move for toolchange and how to get back to the location before.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-316162868, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVr24Lo5opf7g9QoXGXJl3c7e1jZGvOks5sPP9cgaJpZM4OYPAx .

ghost avatar Jul 18 '17 18:07 ghost

Now, @tbfleming you know its not going to be long will we want Tools in CAM now (; lol.

Yep. I need to add a tool table for lathe.

tbfleming avatar Jul 18 '17 19:07 tbfleming

Yay!

On Jul 18, 2017 9:42 PM, "Todd Fleming" [email protected] wrote:

Now, @tbfleming https://github.com/tbfleming you know its not going to be long will we want Tools in CAM now (; lol.

Yep. I need to add a tool table for lathe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-316175742, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVr294fwTKC53ne13MZUr1NtO38sWUfks5sPQq_gaJpZM4OYPAx .

ghost avatar Jul 18 '17 19:07 ghost

Is that on cnc or also on 3dprint? I expected to use regular filament change plugin from cura on my next reprap iteration...

El 14 jul. 2017 9:22 p. m., "Arthur Wolf" [email protected] escribió:

nope, I don't expect to. M600 is meant to be sent from a switch module or the serial connection or the screen

On Fri, Jul 14, 2017 at 8:50 PM, Claudio Prezzi [email protected] wrote:

Is M600 in a gcode file running from the SD card not suspending the job and can be resumed?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-315438409 , or mute the thread <https://github.com/notifications/unsubscribe-auth/AAGpFd_NSK2EaYuT8_ o4EdRHNlPDLvsmks5sN7iTgaJpZM4OYPAx> .

-- Courage et bonne humeur.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-315446011, or mute the thread https://github.com/notifications/unsubscribe-auth/ABoIYICjEfV35WK93f1LSQ9xMB1xWDFfks5sN8AJgaJpZM4OYPAx .

jorgerobles avatar Jul 18 '17 19:07 jorgerobles

Ok. I made toolchange an additional status and only special commands like jogging, probing or setZero of Z are allowed in this status.

Short term: Lathe will need setZero of X

Long term: Lathe will need setDiameter of X: user jogs to touch tool to workpiece, and enters measured diameter. Sets X to either +Diameter/2 (for back tools) or -Diameter/2 (for front tools).

tbfleming avatar Jul 18 '17 19:07 tbfleming

Shouldnt we catch M6 then too? Since many other CAMs use M6 Tx as the command? Just in case

ghost avatar Jul 18 '17 19:07 ghost

I just realized: Lathe will need to set Z to a user-entered value also. The first op often shaves away Z=0, leaving Z=some other value as a touch point.

tbfleming avatar Jul 18 '17 19:07 tbfleming

M0 and M6 are two very different things. M0 is "wait for user to press button before continue" and M6 is "automatically change tools". All users will want M0 to do the same thing, but some users will want M6 to be the same as M0, but others will want M6 to be up to the controller. Thinking about it some users will want M0 too to be up to the controller ...

On Tue, Jul 18, 2017 at 9:51 PM, Peter van der Walt < [email protected]> wrote:

Shouldnt we catch M6 then too? Since many other CAMs use M6 Tx as the command? Just in case

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-316177920, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpFb9QUSh61nqwIDQFXIyKfSx405Tvks5sPQzIgaJpZM4OYPAx .

-- Courage et bonne humeur.

arthurwolf avatar Jul 18 '17 19:07 arthurwolf

Well aware of the diff... But ... CP handles the M6 in host... works well with Grbl and TinyG (Remember, we are a multi firmware host)

ghost avatar Jul 18 '17 19:07 ghost

I'm not talking about any particular firmware, just saying you most probably want a configuration option to let users choose what M0 and M6 do since different users will want them to do different things.

On Tue, Jul 18, 2017 at 9:56 PM, Peter van der Walt < [email protected]> wrote:

CP handles the M6 in host... works well with Grbl and TinyG (Remember, we are a multi firmware host)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb4/issues/378#issuecomment-316179100, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGpFYx6gpMqZ1KQAP3xyz-kV-Gp0nbmks5sPQ3TgaJpZM4OYPAx .

-- Courage et bonne humeur.

arthurwolf avatar Jul 18 '17 19:07 arthurwolf

https://github.com/grbl/grbl/issues/1103#issuecomment-251807161 (Explains Grbl implementation of M6)

https://github.com/synthetos/TinyG/issues/186#issuecomment-263029588 (Explains CP+TinyG use of M6)

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

Mach3: Calls a Macro when M6 is encountered:

Here is the default Mach3 M6 tool change macro scripts.

C:\Mach3\macros\Mach3Mill\M6Start.m1s
Code:
  tool = GetSelectedTool()
  SetCurrentTool( tool )
C:\Mach3\macros\Mach3Mill\M6End.m1s
Code:
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
a = GetToolChangeStart( 3 )
b = GetToolChangeStart( 4 )
c = GetToolChangeStart( 5 )
if(IsSafeZ() = 1) Then
   SafeZ = GetSafeZ()
   if  SafeZ  > z then StraightTraverse x, y,SafeZ, a, b, c 
      StraightFeed  x, y,  z  , a, b, c
else
Code"G00 X" & x & "Y" & y
end if

Tormach: https://www.tormach.com/m6.html Calls a macro too

LinuxCNC: Pauses and prompts (same as M0 in LW): http://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m6

Due to the popular use (abuse) of M6, we can't really ignore it. None of the targetted controllers has an automated tool changer that reacts to M6. Things like XTC (Xpix) would also rely on the Macros instead.... So if anything, we should make M0 pause only, and M6 should pause, maybe call macros?

ghost avatar Jul 18 '17 20:07 ghost

Jep, we should support M0 and M6 Tx. M0 hast to be implemented in the backend, as it has to stop the streaming. The M6 could probably be implemented in the frontend (before sending the gcode to the backend) and use a pre- and post macro (in which M0 could be used).

cprezzi avatar Jul 19 '17 08:07 cprezzi

@arthurwolf Yes, it probably makes sense to make the behaviour for M0/M6 configurable or dependant to the used firmware.

cprezzi avatar Jul 19 '17 08:07 cprezzi

I've implemented M0 support in https://github.com/LaserWeb/lw.comm-server/tree/Toolchange (needs actual lw4/dev-es6).

Can someone test please?

This is the actual implementation:

  • M0 in the code stops streaming (server side)
  • The frontend shows the job like paused (Run Job button with play sign)
  • In this mode, supported functions (like jogging, probing, setZero...,) are sent directly to the machine instead of adding at the end of the queue
  • Clicking the play button resumes from M0, which resumes the queue

To initiate a "toolchange" in the cam, you can create a M0 Toolchange macro with only M0 in it and assign this macro as the post-operation macro (or pre-operation of next operation).

The presentation to the user is not finished yet. I would prefer a tri-state button Run Job / Pause Job / Resume Job instead of just Run Job and probably a better state display at the top.

cprezzi avatar Jul 27 '17 15:07 cprezzi