Hello Guest it is March 29, 2024, 07:43:50 AM

Author Topic: Problem. How to make a generic MPG work with Mach 4 Guide,  (Read 3990 times)

0 Members and 1 Guest are viewing this topic.

Problem. How to make a generic MPG work with Mach 4 Guide,
« on: September 15, 2018, 05:28:58 AM »
Hello! I´ve found a guide online about how to use a Pendant in mach 4 by Shane | Engineer, added the code in screen load script and restarted mach4, has not plugged in and tested since I do not have an MPG / Pendant yet. but will build one soon.

The problem is that it removes on screen jog functions and Ref all home button? They get grayed out? or loose i´ts clickability and I still want to keep those features even if a pendant is installed? maybe if there is a Enable button for the pendant that deactivates jog on screen? or if the pendant only works when a axis is selected and then it deactivates the jog on screen features?

so if the pendant is not enabled the jog functions in mach 4 must be usable, and I don't care if the jog on-screen functions never get disabled, as long as both pendant and jog on screen works?

The Code below is added to the bottom of the screen load script:


--------------------------------------
-- MPG Code --
--------------------------------------
SigLib = {
    [mc.ISIG_INPUT10] = function (state)
        RunPendant()
    end,
    [mc.ISIG_INPUT11] = function (state)
        RunPendant()
    end,
    [mc.ISIG_INPUT12] = function (state)
        RunPendant()
    end,
    [mc.ISIG_INPUT13] = function (state)
        RunPendant()
    end,
    [mc.ISIG_INPUT14] = function (state)
        RunPendant()
    end,
    [mc.ISIG_INPUT15] = function (state)
        RunPendant()
    end,
    [mc.ISIG_INPUT16] = function (state)
        RunPendant()
    end,
    [mc.ISIG_INPUT17] = function (state)
        RunPendant()
    end
}
---------------------------------------------------------------
-- Pendant function.
---------------------------------------------------------------
function RunPendant()
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10) -- Is mapped to Port 2 Pin 4 *X Selection
    local XSelection, rc = mc.mcSignalGetState(hSig)
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT11) -- Is mapped to Port 2 Pin 5 *Y Selection
    local YSelection, rc = mc.mcSignalGetState(hSig)
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT12) -- Is mapped to Port 2 Pin 6 *Z Selection
    local ZSelection, rc = mc.mcSignalGetState(hSig)
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT13) -- Is mapped to Port 2 Pin 7 *A Selection
    local ASelection, rc = mc.mcSignalGetState(hSig)
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT14) -- Is mapped to Port 2 Pin 8 *.001 Selection
    local Step001, rc = mc.mcSignalGetState(hSig)
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT15) -- Is mapped to Port 2 Pin 9 *.010 Selection
    local Step010, rc = mc.mcSignalGetState(hSig)
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT16) -- Is mapped to Port 2 Pin 10 *.100 Selection
    local Step100, rc = mc.mcSignalGetState(hSig)
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT17) -- Is mapped to Port 2 Pin 15 *Estop
    local PenStop, rc = mc.mcSignalGetState(hSig)
    local PenJogOn, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT10)-- Is mapped to Port 2 Pin 1 *Jog on LED

    if XSelection == 1 then
        mc.mcMpgSetAxis(inst, 0, 0) --X Axis
        mc.mcCntlSetLastError(inst, "X Selected")
        mc.mcSignalSetState(PenJogOn, 1)
    elseif YSelection == 1 then
        mc.mcMpgSetAxis(inst, 0, 1) --Y Axis
        mc.mcCntlSetLastError(inst, "Y Selected")
        mc.mcSignalSetState(PenJogOn, 1)
    elseif ZSelection == 1 then
        mc.mcMpgSetAxis(inst, 0, 2) --Z Axis
        mc.mcCntlSetLastError(inst, "Z Selected")
        mc.mcSignalSetState(PenJogOn, 1)
    elseif ASelection == 1 then
        mc.mcMpgSetAxis(inst, 0, 3) --A Axis
        mc.mcCntlSetLastError(inst, "A Selected")
        mc.mcSignalSetState(PenJogOn, 1)
    else
        mc.mcMpgSetAxis(inst, 0, -1) --No Axis
        mc.mcCntlSetLastError(inst, "No Axis Selected")
        mc.mcSignalSetState(PenJogOn, 0)
    end

    if Step001 == 1 then
        mc.mcMpgSetInc(inst, 0, .001)
    elseif Step010 == 1 then
        mc.mcMpgSetInc(inst, 0, .010)
    elseif Step100 == 1 then
        mc.mcMpgSetInc(inst, 0, .100)
    end

    if PenStop == 1 then
        mc.mcCntlEStop(inst)
    end
end
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #1 on: September 20, 2018, 02:46:23 PM »
No one who has any knowledge or info in the area?
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #2 on: September 20, 2018, 04:36:48 PM »
I put this code into Mach4 on my laptop at home, it is just running the SIM but I had no issues with it disabling my jog functions or any buttons for that matter; I am unable to duplicate your issues.

I have MPGs on a mill and a lathe here in the shop.  When the MPG is set to an active state for an axis I still have keyboard and button click jogging available for all axis.
Chad Byrd
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #3 on: September 20, 2018, 05:07:13 PM »
Ohh, Then I’m the only one who’s experiencing this problem at the moment, I can’t remember what is changed with my button scripts or screen load script, it has been a while since anything was changed? There is a whole thread about VFD fix “machtric S800E” that will explain most of the modifications, a few clever guys helped me to sort out the code for it to work, I know that I have custom macros M3 M4 M5 for spindle funciton, and code  for E-stop and so on, I think that something that’s added in to the script interferes with the MPG code?

But what?
As explained in the first post? Everything gets grayed out and not clickable, maybe it’s the copy of “keyboard jog on” button but even when keyboard jog is active it still works to jog with on screen buttons

Sorry about my English, not the best.. understand 89% but type/talk is hard...
« Last Edit: September 20, 2018, 05:08:50 PM by Zuxztah »
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #4 on: September 20, 2018, 05:54:43 PM »
Hi Zuxtah,
could it be that the jogging functions get greyed out because Mach is still has focus on the Gcode interpreter?

Mach can jog or do Gcode, it can't do both at once.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #5 on: September 21, 2018, 12:21:49 AM »
Hello Craig! I remember you from last time thinkering with the vfd programming, “machtric S800e”


Gcode interpreter? Did we charge Anything in script? Or Marcos to make Gcode interpreter to behave wrong?
When it comes to mach/programming.. i dont understand the code/function I’ve tried to learn many many times but it’s hopeless
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #6 on: September 21, 2018, 05:20:57 AM »
Hi,

Quote
Did we charge Anything in script? Or Marcos to make Gcode interpreter to behave wrong?
No, we did not change anything along those lines.

Mach's core has a Gcode interpreter which reads Gcode from your file and it computes the toolpath from the Gcode. It sends the numeric
toolpath data to the motion controller, in your case a 57E.

Mach's core can also accept keyboard and MPG inputs and compute jog moves which it sends to the motion controller.

What Mach's core cannot do is both at the same time. If its computing and executing Gcode then certain functions, including jog functions, will be
disabled (greyed out). If you stop Mach from running Gcode its motion planner could now process jog commands and they would receive focus
which previously they had been denied.

From your description you have one motion mode active (Gcode interpreter for instance) but are expecting to be able to jog (immediate motion mode) at the
same time. Mach does not do that. Its not faulty.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #7 on: September 21, 2018, 08:49:35 AM »
Ohh, I understand. So it could be the keyboard jog plugin?
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #8 on: September 21, 2018, 03:02:02 PM »
Hi,
what do you mean?....from what you have described Mach is doing what its supposed to.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Problem. How to make a generic MPG work with Mach 4 Guide,
« Reply #9 on: September 21, 2018, 03:10:24 PM »
The problem is that I want the on screen jog functions to be enabled when no axis is selected on the MPG/Pendant? “Mpg disabled/inactive”

Ref all home won’t work when the code is added to the screen load script at all? With or without axis selected/keyboard jog on? Is it supposed to do that?

If I choose to use a pendant, Does it permanently disable “ref all home”  fuction? No matter what? I like to reference my machine at every startup of mach,

And don’t want to do it manually every time?

Hard to explain, but you understand the dilemma?