Hello Guest it is January 21, 2022, 01:20:04 PM

Author Topic: G31.1, G31.2, G31.3 working?  (Read 4231 times)

0 Members and 1 Guest are viewing this topic.

Offline Dan13

  •  1,208 1,208
    • View Profile
    • DY Engineering
Re: G31.1, G31.2, G31.3 working?
« Reply #10 on: May 30, 2015, 12:49:52 PM »
I've been playing with the probing code posted by Brian on the Yahoo group. It works fine and you have control of how the data in the output file is formatted - comma separated, having XYZ prefix before the coordinates, omitting particular axis, etc. For your convenience, here is the orginal code Brian posted:

function M401()
inst = mc.mcGetInstance();
    -- create the wxFrame window
    mainframe = wx.wxFrame( wx.NULL,          -- no parent
                        wx.wxID_ANY,          -- whatever for wxWindow ID
                        "Mach4 Bolt Hole Wizard", -- frame caption
                        wx.wxDefaultPosition, -- place the frame in default position
                        wx.wxDefaultSize,     -- default frame size
                        wx.wxDEFAULT_FRAME_STYLE ) -- use default frame styles

    -- create a panel in the frame
    panel = wx.wxPanel(mainframe, wx.wxID_ANY)--We are not going to show it but we need to have this to use the File dialog

local file = wx.wxFileDialog(panel, "Select Probe File", "", "", "Text files (*.txt)|*.txt|Tap files (*.tap)|*.tap",
                             wx.wxFD_SAVE,wx.wxDefaultPosition,wx.wxDefaultSize, "File Dialog" );
        if(file:ShowModal() == wx.wxID_OK)then
            local path = file:GetPath() 
            mc.mcCntlProbeFileOpen(inst, path, "X%.3AXIS_X Y%.3AXIS_Y Z%.3AXIS_Z \r\n", true);


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

You have to put it in a file and name it M401.mcs

To close the file, in a file named M400.mcs put this code:

function M400()
inst = mc.mcGetInstance();
mc.mcCntlProbeFileClose( inst );

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

Re: G31.1, G31.2, G31.3 working?
« Reply #11 on: May 30, 2015, 02:16:18 PM »
This is actually pretty good. It demonstrates the following functions:

1. How to create a frame and panel for GUI purposes
2. How to open a file and define the input parameters when the file is appended
3. Tell the input of the probe where to go (ie, the file path above)
4. Close a file

What is not demonstrated is the code to actually move across a coordinate plane and collect the data. G01 moves in exact stop mode. This code uses the mc.Motion functions to interface with the core. I think G31/G31.X scripting is done by motion controller plugin OEM and the core because electrical latching signals on the PCB itself. I think we can code around this...specific code for your particular requirement.

We can use poppabear's switch case statement example or just use a signal table where the input would be high/low signals and a function call ie mc.MotionSetProbePos()...to emulate G31.X

Offline dude1

  •  1,253 1,253
    • View Profile
Re: G31.1, G31.2, G31.3 working?
« Reply #12 on: May 30, 2015, 06:51:26 PM »
just one thing M needs to be m