Hello Guest it is April 25, 2024, 09:26:19 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DazTheGas

401
Mach4 General Discussion / Re: Macro - Pause until input triggered
« on: September 27, 2016, 02:40:49 AM »
Take a look at the api docs for mcSignalWait located in the mach4 docs directory.

DazTheGas

402
Modbus / Re: Mach4 and modbus - help needed
« on: September 21, 2016, 11:47:30 AM »
If it helps the -27 means  MERROR_REG_NOT_FOUND

DazTheGas

403
Mach4 General Discussion / Re: Return Codes
« on: September 18, 2016, 07:14:41 AM »
To do something like this you would need to look at creating a wizard that you can load a file and then use something like "wxstc.wxStyledTextCtrl" which contains search and replace features, notepad++ is built using the same scintilla libraries, infact the mcLua editor is using the C++ wxWidgets version.

DazTheGas

404
Mach4 General Discussion / Re: Return Codes
« on: September 18, 2016, 04:57:47 AM »
I am rather confused as to what you are trying to do??

Macros are normally run from gcode so if your gcode calls this macro then it would be trying to load another gcode on top of itself, which I would say mach4 wont allow this for safety.

DazTheGas

405
Mach4 General Discussion / Re: Return Codes
« on: September 17, 2016, 09:22:55 AM »
It is always easier for a function to return an int than char, the more common codes are,

 MERROR_NOERROR            0
 MERROR_INVALID_INSTANCE      -1
 MERROR_INVALID_ARG         -2
 MERROR_INVALID_DIR         -3
 MERROR_INVALID_PROFILE      -4
 MERROR_FILE_EXCEPTION      -5
 MERROR_FILE_EMPTY         -6
 MERROR_FILE_SHARING         -7
 MERROR_FILE_INVALID         -8
 MERROR_FILE_BADSIZE         -9
 MERROR_REGEN_DONE         -10
 MERROR_NODATA            -11
 MERROR_GRID_ACTIVE         -12
 MERROR_NOT_IMPLEMENTED      -13
 MERROR_MOTOR_NOT_FOUND      -14
 MERROR_INVALID_PARAM      MERROR_INVALID_ARG
 MERROR_AXIS_NOT_FOUND      -16
 MERROR_API_INIT            -17
 MERROR_NOT_NOW            -18
 MERROR_NOT_CREATED         -19
 MERROR_SIGNAL_NOT_FOUND      -20
 MERROR_IO_NOT_FOUND         -21
 MERROR_SPIN_RANGE_NOT_FOUND -22
 MERROR_PLUGIN_NOT_FOUND      -23
 MERROR_DEVICE_NOT_FOUND     -24
 MERROR_INVALID_STATE        -25
 MERROR_AXIS_NOT_ENABLED     -26
 MERROR_REG_NOT_FOUND        -27
 MERROR_IPC_NOT_READY        -28
 MERROR_NO_ROOM_AVALABLE     -29
 MERROR_NOT_COMPILED         -30
 MERROR_NOT_ENABLED          -31
 MERROR_SCRIPT_KILLED        -32
 MERROR_FILE_NOT_FOUND       -33
 MERROR_TOOLPATH_NOT_FOUND   -39
 MERROR_TIMED_OUT            -40
 MERROR_SOFTLIMITS           -41
 MERROR_FILE_BADFORMAT       -42
 MERROR_INVALID_TYPE         -43
 MERROR_TLM_ALLOC_FAILED     -44
 MERROR_TLM_TOOL_UNMANAGED   -45
 MERROR_TLM_GROUP_EXPIRED    -46
 MERROR_TLM_GROUP_NOT_FOUND  -47
 MERROR_TLM_GROUP_ADDED      -48
 MERROR_TLM_GROUP_CHANGED    -49
 MERROR_TLM_TOOL_NOT_FOUND   -50
 MERROR_TLM_TOOL_ADDED       -51
 MERROR_TLM_TOOL_CHANGED     -52

DazTheGas

406
Mach4 General Discussion / Re: Altering M6 but am confused
« on: September 17, 2016, 04:12:29 AM »
Scrap the last post, had this problem before.... although in dev enviroment will work fine it wont work from a macro as the main thread (core) will not allow you to run a modal dialog!!

DazTheGas

407
Mach4 General Discussion / Re: Altering M6 but am confused
« on: September 16, 2016, 05:53:25 PM »
Here you go a modal dialog for ya to fit in to speed up lowering you z - change to whatever............



Code: [Select]
LowerZ = wx.wxDialog (wx.NULL, wx.wxID_ANY, "Touch Z", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxCAPTION + wx.wxCLOSE_BOX )
LowerZ:SetSizeHints( wx.wxDefaultSize, wx.wxDefaultSize )
mainSizer = wx.wxBoxSizer( wx.wxVERTICAL )
z_info = wx.wxStaticText( LowerZ, wx.wxID_ANY, " Undefined Tool Lower Z Then Click Continue or Cancel To Stop Probing!", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
z_info:Wrap( -1 )
mainSizer:Add( z_info, 0, wx.wxALIGN_CENTER_HORIZONTAL + wx.wxTOP + wx.wxBOTTOM + wx.wxRIGHT, 5 )
buttonSizer = wx.wxBoxSizer( wx.wxHORIZONTAL )
z_lower = wx.wxButton( LowerZ, wx.wxID_ANY, "Lower Z", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
buttonSizer:Add( z_lower, 0, wx.wxALL, 5 )
z_ok = wx.wxButton( LowerZ, wx.wxID_ANY, "Continue", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
buttonSizer:Add( z_ok, 0, wx.wxALL, 5 )
z_cancel = wx.wxButton( LowerZ, wx.wxID_ANY, "Cancel Probe", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
buttonSizer:Add( z_cancel, 0, wx.wxALL, 5 )
mainSizer:Add( buttonSizer, 1, wx.wxALIGN_CENTER_HORIZONTAL, 5 )
LowerZ:SetSizer( mainSizer )
LowerZ:Layout()
mainSizer:Fit( LowerZ )
LowerZ:Centre( wx.wxBOTH )

z_lower:Connect( wx.wxEVT_LEFT_DOWN, function(event)
--Lower Z Start
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGZN), 1)
event:Skip()
end )

z_lower:Connect( wx.wxEVT_LEFT_UP, function(event)
--Lower Z Stop
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGZN), 0)
event:Skip()
end )

z_ok:Connect( wx.wxEVT_LEFT_UP, function(event)
--Continue Probe
LowerZ:EndModal(0)
event:Skip()
end )

z_cancel:Connect( wx.wxEVT_LEFT_UP, function(event)
--Cancel Probe
LowerZ:EndModal(1)
event:Skip()
end )

ZProbe =  LowerZ:ShowModal()

if ZProbe == 0 then
wx.wxMessageBox("Continue with Probe")
else
wx.wxMessageBox("Quit Probing")
end

DazTheGas

408
Mach4 General Discussion / Re: Altering M6 but am confused
« on: September 16, 2016, 03:33:02 AM »
As a quick attempt to clean up the code this is what I feel is a more clean approach, its not tested but should give you something to go on.

Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)
    local changetoo = mc.mcToolGetDesc(inst,selectedtool)
    local toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool)
    local probestart = (-11.5 + toollen ) -- math here needs to be the -travel distance between collet and touchplate + toollen + probe depth


    if selectedtool == currenttool then
        mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0") --move z axis all the way up
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X0.464 Y-99.808") -- Move XY to above fixed touchplate location
wx.wxMessageBox("Please change to tool "..selectedtool.." which is a "..changetoo.."")
       
        if toollen ~= 0 then -- if toollen is defined do this
            mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\n G91 G31 Z-.5 F8")
    mc.mcAxisSetPos(inst, 2, 0)
            mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
            mc.mcCntlSetLastError(inst, "ToolChange Finished")
        else -- if toollen is not defined do this
    wx.wxMessageBox("No tool length currently defined Lower Z to above touch plate, hit enter to start probe")
--need a way to lower Z manually here and have not verified this portion of code--
-- This can be done with a modal dialog I can sort later --
-- Do not run this part until dialog is sorted --
    mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-.5 F8")
    mc.mcAxisSetPos(inst, 2, 0)
            mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
            mc.mcCntlSetLastError(inst, "ToolChange Finished")
end
    end
    mc.mcToolSetCurrent(inst, selectedtool)
end

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

DazTheGas

409
Mach4 General Discussion / Re: Altering M6 but am confused
« on: September 16, 2016, 02:58:49 AM »
Just out of curiosity what version of Mach4 are you running??

DazTheGas

410
Mach4 General Discussion / Re: Altering M6 but am confused
« on: September 15, 2016, 04:54:31 AM »
I would hold off from running this code for now as at a quick glance there are quite a few problems that will arise but should have time today or tomorrow to go through it live on machine.

1.  the "do return end" is not needed (was a mistake on my part originally)
2.  the "repeat - until" could give you a constant loop, if it doesnt hit on first run then it will go straight back to 0 and do the same again.
3.  mc.mcAxisSetPos(inst, 2) will not set anything as correct format is mc.mcAxisSetPos(inst, AxisNumber, AxisPos) so you are missing what you are setting too.

DazTheGas