Hello Guest it is April 18, 2024, 11:31:56 AM

Author Topic: How do determine if Gcode move is complete?  (Read 1073 times)

0 Members and 1 Guest are viewing this topic.

How do determine if Gcode move is complete?
« on: February 08, 2020, 11:08:56 PM »
I understand the Gcode execution options (I think).  If I use the wait option, nothing happens until its done but the DRO's are not 'live' during the move.  If I don't wait, then how can I determine if the move is done?  I want both - I want the DRO's to be live during the move and I want to know the move is done so I can flash a message upon completing the move. 

I found the IsStill inquiry, but I'm also read some posts that it may not be working.  In Mach3, it was easy. 

For example, I wrote a script that moves to G53 -0.5.  I use that in a button to get the router out of the way with one click so I can do whatever.  Its very handy.  I'd like to see the DRO change as it moves (just 'cause) and I'd like to flash a message when it gets there or play a sound.  Right now, the finished message is displayed while it is still moving.

Thanks!

Tony
Re: How do determine if Gcode move is complete?
« Reply #1 on: February 09, 2020, 12:22:56 AM »
Hi,

Quote
I want both - I want the DRO's to be live during the move and I want to know the move is done so I can flash a message upon completing the move. 

That's problematic. The DROs are  part of the GUI and so can only update when the GUI chunk is running. Gcode on the other hand is part
of the Gcode interpreter chunk. The GUI is one chunk and the Gcode interpreter is another chunk, and only one chunk can run at a time.


mc.mcGcodeExecuteWait will execute a move but will not return UNTIL its complete and therefore the DROs are stalled until it does so.
mc.mcGcodeExecute on the other hand will start the move and generate the required PVT data and return and thus while the machine is still
moving the GUI chunk can run and therefore the DRO's update.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How do determine if Gcode move is complete?
« Reply #2 on: February 09, 2020, 03:09:38 PM »
https://www.youtube.com/watch?v=t2xQYvAXT8o

try this link ,i think its answer yours requirement
Re: How do determine if Gcode move is complete?
« Reply #3 on: February 09, 2020, 10:52:22 PM »
Thanks!  That is a little over my head at this point, but I may give it a shot.  Need to learn as much as I can about this stuff.  Thanks for the help.

Tony
Re: How do determine if Gcode move is complete?
« Reply #4 on: February 10, 2020, 03:01:37 AM »
You can use the following code to achieve what you want using a coroutine as Katz pointed out. You can move the function into the screen load script if you prefer. The standard mach screens use a coroutine on the 'Reference All' button so you can see how that is done also.

Modify the g-code string to suit your need. If the machine is stopped during the move, the message will still appear so you may want to check if the axis positions matches the commanded before showing the message?

Code: [Select]
wait = coroutine.create(function()
local inst = mc.mcGetInstance()
mc.mcCntlMdiExecute(inst, "g01 x100 f1000")
coroutine.yield()
wx.wxMessageBox("Move complete")
end)
Re: How do determine if Gcode move is complete?
« Reply #5 on: February 10, 2020, 02:46:56 PM »
It worked!  Thanks all.  Now I just have to try and understand what I did and why it works. 

Tony