Hello Guest it is May 16, 2021, 05:38:39 PM

Author Topic: Mach 4 Goto Zero  (Read 2527 times)

0 Members and 1 Guest are viewing this topic.

Mach 4 Goto Zero
« on: February 05, 2018, 11:41:53 PM »
We are using Mach 4 on Windows 7 with the Darwin parallel port plugin.  The "Goto Zero" button is not working on our system.  We position the deck and zero the x, y, and z using the buttons in the axis control section.  If we jog the deck around and then want to re-center on zero we have always used the "goto zero" in Mach 3. This has not worked since we have upgraded to Mach 4.


As Always, thanks for the help.

Jay
Re: Mach 4 Goto Zero
« Reply #1 on: February 06, 2018, 01:21:45 AM »
Hi,
what screenset are you using?

I'll take a guess and say wx4.set. Is the <Go To WorkZero> button the same as pictured below?

If so go to the edit screen and is the 'left up script' the same also?

The code for that function is in the screenload script. It is conveniently placed and annotated so that users may have its behavior suit their wishes.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Goto Zero
« Reply #2 on: February 06, 2018, 09:14:10 PM »
Our button has the following script attached to that button profile.

local inst = mc.mcGetInstance()
mc.mcCntlMdiExecute(inst, 'G00 X0 Y0 A0')
--mc.mcCntlGcodeExecuteWait(inst, 'G01 X1 F10')

When I close the edit screen I get and error message to correct the script error and restart. 

Jay
Re: Mach 4 Goto Zero
« Reply #3 on: February 06, 2018, 10:26:27 PM »
Hi,
on the screenshot I posted the script attached is actually a function:

GoToWorkZero()

does your installation say the same?

The reason I ask is because that code fragment you posted doesn't look standard.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Goto Zero
« Reply #4 on: February 06, 2018, 10:28:07 PM »
Hi,
and just so there no misunderstanding what screenset are you using?

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Goto Zero
« Reply #5 on: February 06, 2018, 10:54:54 PM »
Our system was using the WXMach.set,  I changed the screen to use the wx4.set for the screen and the button text matched, although the code in the button appeared commented out.  When I removed the "--" for the script lines I get the same message when exiting the edit screen.  

UPLOAD SCRIPT ERROR - Correct the script error and restart.  Is is possible the lau script file is corrupt.


GoToWorkZero()
--local inst = mc.mcGetInstance()
--mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z0")

Jay
Re: Mach 4 Goto Zero
« Reply #6 on: February 07, 2018, 12:11:19 AM »
Here is the error message.

Re: Mach 4 Goto Zero
« Reply #7 on: February 07, 2018, 12:45:11 AM »
Hi,
OK, that function GoToWorkZero() is correct, the two lines which follow it and are commented out are just so you can see what is included in the function,
they were never intended to be uncommented.

The actual function is in the screenload script and has those two lines included, you comment out the one you don't want and leave the other.
What you have in fact done is  to have two definitions of that function.

This is whats it my screenload script at the moment:
Code: [Select]
---------------------------------------------------------------
-- Go To Work Zero() function.
---------------------------------------------------------------
function GoToWorkZero()
    mc.mcCntlMdiExecute(inst, "G00 X0 Y0 A0")--Without Z moves
    --mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z0")--With Z moves
end

I have a couple of other custom scripts so I guess you would find this code around line 220 in the screenload script. This is the code you should edit/replace or whatever.
You'll have to go back and apply  comment marks to those lines you uncommented earlier.

A couple of points that may help or certainly save you some grief in times to come.
Its great that you are starting to modify screensets and things, it very Much part of Mach4 that you customize it to suit your machine. Like you I use wx4.set.
There is a problem with that though....if I go and make  new buttons and controls, screen scripts and so on they get saved to wx4.set. That means I'm screwing
up my 'clean' copy but even that's not a big problem. What happens when I download the latest and greatest Mach4 build from NFS? The screenset wx4.set will
get overwritten with the latest and greatest wx4.set too. That means all my tweaks and scripts have been wiped....bugger!

The trick is to make a copy of wx4.set but call it something personal like Craigswx4.set and use that screenset in your profile and all your tweaks get saved to it and
won't be overwritten when you update Mach.

Next point is that there are quite a number of chunks of Lua code, the sreenload script you've encountered but there are others like the PLC script, the PMC script
and so on. When Mach runs ALL these scripts get rounded up and compiled into one big file called the Lua script. If you go to the operator menu there is an option
to view it. Interesting and you can use search functions to find specific bits of code but you CAN'T edit it, its just for looks!

Another point worth mentioning is that when you start writing your own scripts you will be putting some bits in the screenload script and other bits elsewhere.
If you make a mistake it can be awfully hard to track down where it is. What I do and recommend to you is that you make a folder in your profile and write all
your code in it. You'll be able to use the editor and debugger, and if you really screw it up you only have one bad file to dig out to get Mach running again.
Once your happy that the code will work without crashing Mach that's when you place it in the screenload script or wherever.

Craig

My wife left with my best friend...
     and I miss him!
Re: Mach 4 Goto Zero
« Reply #8 on: February 08, 2018, 12:28:43 AM »
Thanks, for all your help.  All the details you have given me has helped to resolve the problem.  I did a lot of playing with the screen editor and I am looking forward to customizing our screen.  After all the changes I did, "Goto Zero" still did not want to work.  One detail I did leave out not thinking it was critical is that we were also using the Mach4 launcher.  At this point, I used a default mill profile and everything worked.  I created a new profile for the default Mill profile and enabled Darwin and all seems fine now.  I still have the old profile and would like to understand what was mission or misconfigured in that profile?

Thanks,

Jay
Re: Mach 4 Goto Zero
« Reply #9 on: February 08, 2018, 01:07:25 AM »
Hi,
I'm not sure that identifying either missing or corrupt Lua code is going to be easy....particularly as you are learning and its very easy to overlook a seeming
innocuous detail which may in fact have a major influence on Mach.

One possibility is to use the Lua scripts. I presume the vast majority of the two Lua scripts will be the same, they were both generated from the same standard Mach profile.
If you compared the two scripts, the one good one you now have and the dodgy one you might find it. To compare them manually could be done but probably
time consuming.

I could imagine writing some code to do a text compare or maybe there is a feature like text compare in one of the text programs.

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