Hello Guest it is March 28, 2024, 01:57:08 PM

Author Topic: Mach4: How to map MPG-X inputs, to Motor-X Step and Direction output?  (Read 2365 times)

0 Members and 1 Guest are viewing this topic.

Software: Mach4 Trial (www.machsupport.com)
Motion Controller: Smooth Stepper ESS (warp9td.com)
Breakout Board: MB3 (www.cncroom.com)
Pulse Generator: Sumtak 100ppr
   
Situation: I have a Sumtak 100ppr standard pulse generator (see attached) connected to the MB3 breakout board on inputs X310 and X311 in accordance to the MB3 manual (see attached diagram).  The BOB's optical encoders for X310 (Input Port-3 Pin-10) and X311 (Input Port-3 Pin-11) are high speed and designed for connecting to an MPG.  When I rotate the MPG, I see the diagnostic LED's on X310 (encoder terminal A) and X311 (encoder terminal B) changing state so I deduce that the BOB is receiving the encoder input ok and passing the signals to the Motion controller and then on to Mach4.

Question-1: In Mach4, is there a way to monitor input X310 and X311 to verify that Mach4 is able to observe the pin state changes? 
 
Question-2: In Mach4, how do I map MPG-X input to Motor-X step and direction output?

Question-3: Is there a section in the Mach4 manual that describes mapping encoder inputs?
 
Breakout Board Manual
MPG setup is described on Page-18 Figure-16.
http://www.cncroom.com/downloads/MB3%20Owner%20Manual%20E13R2.pdf

Thanks!
Re: Mach4: How to map MPG-X inputs, to Motor-X Step and Direction output?
« Reply #2 on: August 24, 2020, 10:06:59 AM »
MN300 Thanks for the link!  It should have resolved my issue but I'm still stuck.  I don't have a full pendant just the MPG so this should be easy.
 
Steps:
1) I configured the input pins for Encoder_Aux0-A and Encoder_Aux0-B in the ESS plugin
2) I mapped MPG#0 to Encoder_Aux0
3) I added a function to the Screen Load Script
 
--------------------------------------
-- MPG Code --
--------------------------------------
function MapMpgToX()
     mc.mcMpgSetAxis(inst, 0, 0)
end

MapMpgToX()

4) The code compiles and it runs but for some reason the mpg does not jog the x-axis.  So there is something I am missing.  Likely something basic, as if if am missing a button to turn on MPG jogging.  I can jog with the screen buttons just not the mpg. 
   
 

Offline MN300

*
  •  297 297
    • View Profile
Re: Mach4: How to map MPG-X inputs, to Motor-X Step and Direction output?
« Reply #3 on: August 24, 2020, 11:10:07 AM »
You will need a switch to enable the X axis, otherwise the MPG will always be active.
Load the Lua code provided and strip out the unused selections.
You also don't need the PenJogOn output, it's for an LED. The Pendant Estop input is optional too.

Offline MN300

*
  •  297 297
    • View Profile
Re: Mach4: How to map MPG-X inputs, to Motor-X Step and Direction output?
« Reply #4 on: August 24, 2020, 11:30:33 AM »
I currently don't have the means to test this. You need to edit the enable switch input and select a travel speed.

--------------------------------------
-- X only MPG Code --
--------------------------------------
SigLib = {
    [mc.ISIG_INPUT10] = function (state)
        RunPendant()
    end
}
---------------------------------------------------------------
-- Pendant function.
---------------------------------------------------------------
function RunPendant()
    local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10) -- Is mapped to Port ? Pin ? *X Selection
    local XSelection, rc = mc.mcSignalGetState(hSig)

    if XSelection == 1 then
        mc.mcMpgSetAxis(inst, 0, 0) --X Axis
        mc.mcCntlSetLastError(inst, "X Selected")
    else
        mc.mcMpgSetAxis(inst, 0, -1) --No Axis
        mc.mcCntlSetLastError(inst, "No Axis Selected")
    end

        mc.mcMpgSetInc(inst, 0, .001)  -- travel per encoder step
end