Hello Guest it is December 14, 2024, 11:23:51 AM

Author Topic: MDI G92  (Read 3295 times)

0 Members and 1 Guest are viewing this topic.

MDI G92
« on: July 22, 2023, 08:12:15 PM »
Greetings,

I'm trying to figure out how to automatically set work coordinates to zero after sending the spindle to a specific set of coords after the machine homes by inserting 2 lines in the home all section of ScreenScript.lua.

Ex: Press "Home X Y Z Axis" button --> Machine homes --> moves to some pre-set coordinates --> Zero's X Y Z WORK coordinates.

As you can see I added the following lines:

mc.mcCntlMdiExecute(inst, "G53 X12.4129 Y433.9433")  -- This line works
mc.mcCntlMdiExecute(inst, "G92 X0 Y0")        --This line doesn't work

G53 works as expected but G92 does not and the XYZ work coordinates do not change to zero.

If I run the G53 and G92 commands directly in the MDI window they both work as expected.

Any ideas why and how I can get this to work?

Thanks!

---------------------------------------------------------------
-- Ref All Home() function.
---------------------------------------------------------------
function RefAllHome()
   local inst = mc.mcGetInstance("Screen load script, RefAllHome()")
   local valEnable = mc.mcProfileGetInt(inst, "AvidCNC_Profile", "iConfigEnableSoftLimitsAfterHomed", 1)
   local valSimHome = mc.mcProfileGetInt(inst, "AvidCNC_Profile", "iConfigHomeXYSimultaneously", 0)
  local valCustomHoming = mc.mcProfileGetInt(inst, "AvidCNC_Profile", "iConfigCustHomingEnabled", 0)
  local msg = ""

   mc.mcAxisDerefAll(inst)  --Just to turn off all ref leds
   mc.mcAxisHomeAll(inst)
  coroutine.yield() --yield coroutine so we can do the following after motion stops
 
  if (valEnable == 1) then
    pf.EnableSoftLimits()
    msg = "Homing of machine is complete. Soft limits will now be enabled."
  else
    msg = "Homing of machine is complete."
  end
   wx.wxMessageBox(msg, "Homing")
   mc.mcCntlMdiExecute(inst, "G53 X12.4129 Y433.9433")
   mc.mcCntlMdiExecute(inst, "G92 X0 Y0")
end

Offline Graham Waterworth

*
  • *
  •  2,747 2,747
  • Yorkshire Dales, England
Re: MDI G92
« Reply #1 on: July 22, 2023, 09:11:44 PM »
G53 is an absolute unchangeable machine value that is set to zero by Mach3/4 after going to the machine home position.

G92 sets the fixture position.

G10 sets a new value in the selected fixture offset.

G52 sets a local fixture offset.

Without engineers the world stops
Re: MDI G92
« Reply #2 on: July 28, 2023, 08:43:29 PM »
I figured it out. If it helps anyone, this is the scripting I added. Cheers!

GCode = ""
   GCode = GCode .. string.format("G53 X12.4129 Y433.9433\n")
   GCode = GCode .. string.format("G92 X0 Y0 Z0\n")
   mc.mcCntlGcodeExecuteWait(inst, GCode)