Hello Guest it is March 28, 2024, 05:22:26 PM

Author Topic: GoToWorkZero  (Read 3614 times)

0 Members and 1 Guest are viewing this topic.

GoToWorkZero
« on: March 10, 2019, 02:16:36 PM »
Hi anyone,  Is there anyway to associate the "GoToWorkZero" button to a keyboard Key?   I got the cyclestart, cyclestop, reset to work with keyboard C, S, R key but cannot for the life of me get any key to work with the GoToWorkZero.   Hmmmmm.  It either gives me either an "axis 3 commanded while disabled" or it just resets my gcode to the first line like a reset or rewind with no axis movement.

Thanks for anyone who has a solution.
Re: GoToWorkZero
« Reply #1 on: March 10, 2019, 02:39:41 PM »
Hi,
open the screen editor and open the screen load script. Scan down through the file till about line 225
until you find the GoToWorkZero function:

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

Note that the active line (mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z)) has an A axis move.
I'm guessing that you don't have an A axis defined in your machine. So either edit the line to delete the A axis
reference or comment it out and add this line instead:

Code: [Select]
mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 \nG00 Z)

To add a physical button....define a pin on your controller as an input, say ISIG_INPUT10 and then put this in the
SigLib{} in the screen load script:

Code: [Select]
[mc.ISIG_INPUT10]=function(state)
if state==1 then
      GoToWorkZero()
end
end,

Note that this is an entry in the signal library table and the second 'end' statement concludes the in line function definition
and the trailing ',' (comma) concludes the table entry. Don't forget the trailing comma!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: GoToWorkZero
« Reply #2 on: March 10, 2019, 03:02:01 PM »
Hi,   Are you thinking in putting a physical button someplace?   I only want to use the screen button "GoToWorkZero" and also have a keyboard key do the same thing.

Thanks,
Fritz
Re: GoToWorkZero
« Reply #3 on: March 10, 2019, 03:05:07 PM »
Hi,
if you only want  the screen button to work then edit the GoToWorkZero() function as I have
suggested and ignore the signal library addition.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: GoToWorkZero
« Reply #4 on: March 10, 2019, 03:10:13 PM »
couple of pics what I have.
Re: GoToWorkZero
« Reply #5 on: March 10, 2019, 03:13:37 PM »
I have the screen button already, was in the mach4 download, I'm trying to associate it with my keyboard 10' away from my cnc machine.   
Re: GoToWorkZero
« Reply #6 on: March 10, 2019, 03:23:12 PM »
Hi,
looking at the code I would guess you have that in the PLC script?
That works, but is not efficient. The PLC script runs many times a second, and your code will therefore
run many times per second. This type of input is called 'polling' and is common in Mach3.

With Mach4 however there is another way. Whenever a signal (input or output or even an internal Mach signal)
changes state the Signal Script runs, and the signal script looks into the Signal Library (SigLib{}) in the ScreenLoad
script for an entry corresponding to the signal which has changed. If it finds an entry it executes the inline function
defined there. If it doesn't find an entry, ie we are not interested in that signal then it returns without doing anything.

It sounds complicated and it certainly takes some effort to understand at first but thereafter is  very elegant
and programmatically efficient.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: GoToWorkZero
« Reply #7 on: March 10, 2019, 03:27:53 PM »
Hi,
I notice that you have made your own screenset? You have very few Tabs to call on.

May I suggest loading wx4.set and see all those additional screens.....including diagnostics, probing  etc.
Then make a copy of it and THEN customize it. Its all very well making a new set from scratch but is there any need
to do without all those features that NFS has laboriously programmed into Mach?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: GoToWorkZero
« Reply #8 on: March 10, 2019, 03:32:13 PM »
Them codes in my PLC script works great, just can't get this line entry to work, the red arrow.
Re: GoToWorkZero
« Reply #9 on: March 10, 2019, 03:39:42 PM »
Mach4 screen