Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: thespindoctor on April 01, 2017, 06:54:40 PM
-
Using a do loop to repeat a probing action but in the loop it does not work properly, not sure why
This is the code from the probe a single Y surface from the probing screen. I have just added a loop to increment an X axis move. The code preceeding is not shown but remains as it was written by the coding Guru...
local iter
local travel = -4.2
for iter = 1, 100 do
local rc = mc.mcCntlGcodeExecuteWait(inst, "G00 X"..travel)
mm.ReturnCode(rc)
prb.SingleSurfY(ypos,work)
travel=travel-.1
end
prb.SingleSurfY(ypos,work) -- works fine when used alone without the other code to loop and increment X
-
The probing routines are using LUA co-routines (a cooperative multi-tasking scheme that emulates threads), if I remember correctly. This is so calling the probe routine from a buttons doesn't lock up the GUI for the duration of the probe operation. So I don't think you can use it in a loop like that because the probing function actually returns before the probing is complete! You might want to wait on the control to go to an idle state before looping. But you might also have to wait on the control to NOT be in the idle state before waiting on the idle state. It will be tricky. And if you call it from a button, the GUI will be unresponsive until the loops are done. So...
In my opinion, it would be easier to write a G code generator wizard to generate G code to digitize the surface.
-
That makes sense. What about the idea of taking the probesinglesurfy function from the module and copying it then adding the code to write to the probe file and then moving and looping within the new function?
I don't understand G31. Is there any Doc for G31 in Mach?
Thanks!
-
Probing, and other G-code functions are defined in the file
Mill GCode Programming.pdf
This file is installed in the Docs subfolder of you installation, typically
at C:\Mach4Hobby\Docs
It describes the action of G31 and where the results are stored.
-
Probing success!