Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: OldePhart on March 24, 2019, 05:33:53 PM

Title: RefAllHome - then back off.
Post by: OldePhart 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
Title: Re: RefAllHome - then back off.
Post by: Cbyrdtopper 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).
Title: Re: RefAllHome - then back off.
Post by: OldePhart 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
Title: Re: RefAllHome - then back off.
Post by: OldePhart on March 24, 2019, 07:27:38 PM
cant use G01 and G53... ok interesting side effect
Title: Re: RefAllHome - then back off.
Post by: Cbyrdtopper 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?
Title: Re: RefAllHome - then back off.
Post by: OldePhart 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!
Title: Re: RefAllHome - then back off.
Post by: Cbyrdtopper 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.
Title: Re: RefAllHome - then back off.
Post by: thosj 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.
Title: Re: RefAllHome - then back off.
Post by: OldePhart 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 :)
Title: Re: RefAllHome - then back off.
Post by: OldePhart on March 25, 2019, 12:33:51 AM
is there a doc that describes all the "mc." functions available?
Title: Re: RefAllHome - then back off.
Post by: joeaverage on March 25, 2019, 12:52:31 AM
Hi,

Quote
is there a doc that describes all the "mc." functions available?

Yes...is there what!  Its called Mach4CoreAPI.chm and it found in the help documents which opens with the <Help Docs>
button or found in the Docs folder in Mach4Hobby directory.

There are hundreds of functions....enjoy.

Craig
Title: Re: RefAllHome - then back off.
Post by: Cbyrdtopper on March 25, 2019, 08:09:59 AM
API Document in the Docs folder in your Mach4 folder.
Title: Re: RefAllHome - then back off.
Post by: Cbyrdtopper on March 25, 2019, 08:28:49 AM
File name:  Mach4CoreAPI.chm
Title: Re: RefAllHome - then back off.
Post by: OldePhart on March 25, 2019, 09:53:23 AM
Would you be kind enough to attach that file?
I'm at work today and at a conference all week, I'd like to convert and print it.
If you can't that's fine I'll just install the demo on a VM here and pull it that way.
Title: Re: RefAllHome - then back off.
Post by: joeaverage on March 25, 2019, 04:05:19 PM
Hi,

Quote
I'm at work today and at a conference all week, I'd like to convert and print it.

Not sure that you can convert and print it. It is a .chm file and is intended to be opened by a Windows Help function.
Aside from anything else the printout would be several hundred pages. Download and read it, then work out which
bits you want to print....

Craig
Title: Re: RefAllHome - then back off.
Post by: thosj on March 25, 2019, 04:42:00 PM
Can do easy....but still a lot of paper!!

https://www.print-driver.com/how-to/convert-chm-to-pdf

Tom
Title: Re: RefAllHome - then back off.
Post by: OldePhart on March 25, 2019, 07:02:13 PM
I've done it before - it's poorly paginated to be sure but its a simple conversion.