Hello Guest it is April 18, 2024, 05:10:56 AM

Author Topic: probing with do loop  (Read 1702 times)

0 Members and 1 Guest are viewing this topic.

probing with do loop
« 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...

Quote

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


Quote
prb.SingleSurfY(ypos,work)  -- works fine when used alone without the other code to loop and increment X

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: probing with do loop
« Reply #1 on: April 02, 2017, 12:17:32 AM »
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. 
Re: probing with do loop
« Reply #2 on: April 02, 2017, 06:28:03 AM »
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!
Re: probing with do loop
« Reply #3 on: April 02, 2017, 07:48:52 AM »
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.
Steve Stallings
www.PMDX.com
Re: probing with do loop
« Reply #4 on: April 02, 2017, 01:36:17 PM »
Probing success!