Hello Guest it is March 28, 2024, 04:47:57 AM

Author Topic: RefAllHome - then back off.  (Read 1980 times)

0 Members and 1 Guest are viewing this topic.

RefAllHome - then back off.
« on: March 24, 2019, 05:33:53 PM »
New user warning... Mach4 and ESS on PMDX-126

I am trying to get the machine to drive home to its limit switches, slowly, then slowly back off 2 inches X and Y and then zero the DRO.  Most of that works, but while I thought I had it with the script mods below, I am seeing that the amount of movement away from zero is increasing each time I run it. 

Perhaps I am chasing this the wrong way, like I said, I'm new at this.
Code: [Select]
---------------------------------------------------------------
-- Ref All Home() function.
---------------------------------------------------------------
function RefAllHome()
    mc.mcAxisDerefAll(inst)  --Just to turn off all ref leds
    mc.mcAxisHomeAll(inst) -- Bring to limit switch
coroutine.yield()
mc.mcCntlMdiExecute(inst, "G00 F25 X2 Y2") -- move away from the corner -mac
coroutine.yield() --again
mc.mcCntlMdiExecute(inst, "G92 X0 Y0")-- Reset Y and Z to Zero -mac
coroutine.yield() --again
wx.wxMessageBox('Referencing is complete - Moved into position')
end
Re: RefAllHome - then back off.
« Reply #1 on: March 24, 2019, 06:11:15 PM »
Try changing this line:
mc.mcCntlMdiExecute(inst, "G00 F25 X2 Y2") -- move away from the corner -mac

to this:
mc.mcCntlMdiExecute(inst, "G00 G53 X2. Y2.") -- move away from the corner -mac

You are not specifying the work offset (G54-G59), so it will default to whatever is active; this means that it will move to where ever the work offset thinks is X 2.0 and Y 2.0 and then call it X and Y 0.00. 

G53 is machine position; so when you move to Machine Position X 2. and Y 2. then it will move 2 inches off the home switches and then call them  0.00.  G53 is non modal so it will only be called on the line that is being processed, then it will revert back to the active work offset.
Also, you have an F25 in there, that is not going to do anything unless you use a G01 (Feed Move) instead of a G00 (Rapid).
Chad Byrd
Re: RefAllHome - then back off.
« Reply #2 on: March 24, 2019, 07:04:58 PM »
Thanks for the reply,  I did figure out the G01 .
I made the mod you showed and commented out the G92 line, but after it homes, it stopped, then continued in the same direction faulting the motors (clearpath) . I didn't put a negative number in there so why would it go that direction ?   
Code: [Select]
---------------------------------------------------------------
-- Ref All Home() function.
---------------------------------------------------------------
function RefAllHome()
    mc.mcAxisDerefAll(inst)  --Just to turn off all ref leds
    mc.mcAxisHomeAll(inst) -- Bring to limit switch
coroutine.yield() --yield coroutine so we can do the following after motion stops
    ----See ref all home button and plc script for coroutine.create and coroutine.resume
mc.mcCntlMdiExecute(inst, "G01 G53 F25 X2. Y2.") -- move away from the corner -mac
coroutine.yield() --again
--mc.mcCntlMdiExecute(inst, "G92 X0 Y0")-- Reset Y and Z to Zero -mac
wx.wxMessageBox('Referencing is complete - Moved into position')
end
Re: RefAllHome - then back off.
« Reply #3 on: March 24, 2019, 07:27:38 PM »
cant use G01 and G53... ok interesting side effect
Re: RefAllHome - then back off.
« Reply #4 on: March 24, 2019, 07:42:12 PM »
I'm not sure, maybe it needs to be negative the way your machine is set up.  Manually move the machine to where you want it and see what the machine position is, toggle "Machine Coordinates" or look on the Diagnostics tab.

Also, what does the last line mean?  You can't use G01 and G53 together?
Chad Byrd
Re: RefAllHome - then back off.
« Reply #5 on: March 24, 2019, 07:58:35 PM »
When I had G01 and G53 on the same line, that's when this reversing action took place. Removed the G01 and it worked as expected.
Appears that the F parm is not supported with G53, pity, I would like a slower movement. For the moment it seems to be working otherwise.

Got a bit of a learning curve here to go. Fun though!
Re: RefAllHome - then back off.
« Reply #6 on: March 24, 2019, 08:12:19 PM »
That's strange. 
Running in MDI it will allow me to use G01 and a feedrate with G53.
Chad Byrd

Offline thosj

*
  •  532 532
    • View Profile
Re: RefAllHome - then back off.
« Reply #7 on: March 24, 2019, 08:19:55 PM »
Might need a G90 in those G53 lines. G1 and G53 work in my RefAllHome script, and the only thing I notice is the G90 in there.
--
Tom
Re: RefAllHome - then back off.
« Reply #8 on: March 24, 2019, 08:26:53 PM »
Unsure. It has not been consistent in the way it works. I have been loading sample gcode files just to watch it move around and maybe those are changing some settings that make it behave inconsistently. From what I have read thats not unusual during initial setup and config. Restart mach4, don't restart mach4... it all makes a difference .
I've been at it all day and I'm tired, I'll print out some manuals and get smarter, maybe that will help :)
Re: RefAllHome - then back off.
« Reply #9 on: March 25, 2019, 12:33:51 AM »
is there a doc that describes all the "mc." functions available?