Hello Guest it is March 28, 2024, 01:49:59 PM

Author Topic: G31 not working in screen function  (Read 1091 times)

0 Members and 1 Guest are viewing this topic.

G31 not working in screen function
« on: December 17, 2020, 09:51:44 AM »
Mach4Lathe: When G31 G01 X-.20 F5 is called from the MDI the machine stops at the probe strike as it should.

I have this function in the screen load script and it is called from a button press.
Code: [Select]
function TestG31()
local inst = mc.mcGetInstance()
mc.mcCntlGcodeExecute(inst, "G31 G01 X-.20 F5")
mc.mcAxisHome(inst,0,0)
end
It doesn’t stop at the probe strike but finishes as a G01 X-.20 command. I eventually would like this code in the RefAllHome() function to stop on an encoder Index pulse.
Any help with this would be appreciated.

Offline Bill_O

*
  •  562 562
    • View Profile
Re: G31 not working in screen function
« Reply #1 on: December 17, 2020, 10:20:23 AM »
Do not put the G1 in the code.
Re: G31 not working in screen function
« Reply #2 on: December 17, 2020, 10:42:00 AM »
Thank you! That worked. I've been fighting with this for a week. I really do appreciate your help.
Tony
Re: G31 not working in screen function
« Reply #3 on: December 17, 2020, 10:51:58 AM »
I think I'll have to write a coroutine.yield() after the probe move for the rest of the code to execute properly. Stay tuned!

Offline Bill_O

*
  •  562 562
    • View Profile
Re: G31 not working in screen function
« Reply #4 on: December 17, 2020, 10:53:15 AM »
Glad I could help someone.
I have gotten a lot of help on here.

Offline Bill_O

*
  •  562 562
    • View Profile
Re: G31 not working in screen function
« Reply #5 on: December 17, 2020, 03:45:58 PM »
Use mc.mcCntlGcodeExecuteWait
Re: G31 not working in screen function
« Reply #6 on: December 18, 2020, 07:29:25 AM »
The trouble with mc.mcCntlGcodeExecuteWait is that it pauses the PLC script while it is waiting so the position DROs in the GUI don’t update until it is done.

DasTheGas has a great tutorial on coroutines that explains this: https://www.youtube.com/watch?v=t2xQYvAXT8o

Offline Bill_O

*
  •  562 562
    • View Profile
Re: G31 not working in screen function
« Reply #7 on: December 18, 2020, 08:56:07 AM »
True, but I do not need to know the exact position Mach does.
When it is done is fine for me.