Hello Guest it is July 12, 2020, 02:34:44 PM

Author Topic: How to setup Auto Zero button in latest version of Mach4  (Read 3704 times)

0 Members and 1 Guest are viewing this topic.

Offline cv580

*
  •  50 50
    • View Profile
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #20 on: March 21, 2018, 12:11:22 PM »
Craig
I am not able to get the code to work, in the debugger I get the following error message: 

Compilation error on line number: 1
Lua: Syntax error during pre-compilation
:1: unexpected symbol near '['

cv580
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #21 on: March 21, 2018, 01:57:47 PM »
Hi,
there was something weird happening when I was posting the code and some extra symbols ended up in the post.


Remove '
Code: [Select]
' from the first line.

Craig
My wife left with my best friend...
     and I miss him!
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #22 on: March 21, 2018, 02:02:02 PM »
Hi,
even typing out the offending symbol screws with the posting.....

On the very first  line remove the word 'code' and the square brackets that enclose it. It ended up there because I did something screwy when posting the code.

Craig
My wife left with my best friend...
     and I miss him!

Offline cv580

*
  •  50 50
    • View Profile
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #23 on: March 21, 2018, 03:20:48 PM »
Craig,
I have the code working in the debugger now, so I put code file into the macros folder in my Mach4 profile and tried linking a button to it but not having any success making that happen (trying the left up and left down thing in screen editor).
What do I have to do to link a button to the code file?

cv580
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #24 on: March 21, 2018, 05:17:58 PM »
Hi,
no its no good in the macros folder.

To put in the screen script strip off the bottom few lines:

if mc.mcInEditor==1 then
   autozero()
end

These lines were just to get the debugger to run properly. As I say strip them off and place the remaining
code in the screen load script...where is your choice I prefer to put functions like this just before the  signal
library.

Now as left-up script of your button put autozero(). Thus when you hit the button it will call the function autozero()
which happens to be in your screen load script and therefore available across Machs GUI.

Craig
My wife left with my best friend...
     and I miss him!

Offline cv580

*
  •  50 50
    • View Profile
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #25 on: March 21, 2018, 08:14:05 PM »
Craig,

I have everything working now, but after the Z axis has retracted from the tool plate I am not able to move any axis to work zero and get a message in Mach saying:

"Cannot use G53 incremental"

I do not see G53 being implemented in the code.
Do I need to add a line to the code to cancel G53 at the end?

cv580
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #26 on: March 21, 2018, 08:27:47 PM »
cv580,
Somewhere along the line you have used a "G91"
This puts Mach in incremental mode. 
You need to be in Absolute Mode ... "G90"
Chad Byrd
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #27 on: March 21, 2018, 08:32:04 PM »
I Just looked at Craig's code.  The last modal call for Absolute/Increment is Increment.  It is the move after the Probe move.

"mc.mcCntlGcodeExecuteWait(inst, 'G00 G91 Z1');  --Rapid move to 1 inch above current pos"

In the code you need to have it change back to absolute mode.
Just put this line after the G91 line.

mc.mcCntlGcodeExecute(inst, "G90") 
« Last Edit: March 21, 2018, 08:34:11 PM by Cbyrdtopper »
Chad Byrd
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #28 on: March 21, 2018, 09:37:10 PM »
Hi,
kool missed that, I actually just copied and pasted that part from OPs original code.
All I've really done is strip out the extraneous stuff and roll it into a function which can be debugged.

Craig
My wife left with my best friend...
     and I miss him!
Re: How to setup Auto Zero button in latest version of Mach4
« Reply #29 on: March 21, 2018, 09:43:10 PM »
Hi,
point is that you now have some code which works. You can now apply various ideas that may make it better.

I would recommend that any edits be made in the remote function so you can step thru with the debugger.
Only when you are happy with it incorperate those changes or overwrite the code in the screen load script.

The idea being to keep potential buggy code from ending up in the LuaScript.

Craig
My wife left with my best friend...
     and I miss him!