Hello Guest it is April 26, 2024, 03:24:18 PM

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

671
Where is Screwie??

Daz

672
Mach4 General Discussion / Re: Lua While Loops
« on: October 21, 2015, 10:16:06 AM »
on this line... "local Carousel =  mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.OSIG_OUTPUT1),1)"  You have combined SetState with GetHandle just by using "( )"?  Is this correct?

yes thats correct if you dont need the rc from the function then this works just fine, just does all 3 things in one go.

DazTheGas

673
Mach4 General Discussion / Re: Lua While Loops
« on: October 21, 2015, 09:27:11 AM »
The logic behind the code is correct, but with the loop you will receive thousands of Carousel Moving Forward into the log.

However with forward thinking from the mach team there is a command call mc.mcSignalWait so you can change your loop too mc.mcSignalWait(inst, mc.ISIG_INPUT1, mc.WAIT_MODE_HIGH, 0) or mc.mcSignalWait(inst, mc.ISIG_INPUT1, mc.WAIT_MODE_LOW, 0) - depends which way you need to go. The 0 on the end denotes wait indefinate, if you change this to 10 it will wait for the signal for 10 seconds then continue.

Apart from that all looks good, heres my version tested

Code: [Select]
local inst = mc.mcGetInstance()
local Carousel =  mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.OSIG_OUTPUT1),1)
mc.mcCntlSetLastError(inst, "Carousel Moving Forward")
mc.mcSignalWait(inst, mc.ISIG_INPUT1, mc.WAIT_MODE_HIGH, 10)
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.OSIG_OUTPUT1),0)

as you will notice you can join commands into 1 liners.

DazTheGas

674
Mach4 General Discussion / Re: Mach4 GUI Handle
« on: October 14, 2015, 02:23:36 PM »
It needs the handle of the current active mach4 gui. there is  a command mcGuiGetWindowHandle but that is at the api level where we cant go from lua.

DazTheGas

675
Mach4 General Discussion / Re: Mach4 Keyboard Mapp
« on: October 14, 2015, 10:44:28 AM »
Use the keyboard plugin and set them as you require.

DazTheGas

676
Mach4 Videos / Creating an M6 Toolchange in Mach4 (Part 3)
« on: October 13, 2015, 03:50:37 PM »
Yay Finished (with a crashed machine  ???

Although the machine crashed at the end the code has been retested completely and works a treat.

Video https://youtu.be/w1xzYPT27NY

The Final Code

Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)
    local xstart = mc.mcAxisGetPos(inst,0)
    local ystart = mc.mcAxisGetPos(inst,1)

    if selectedtool == currenttool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n X14 Y30")
    wx.wxMessageBox("Please turn off spindle and click ok to continue") --can be removed if required
    RunProbe(currenttool)
    local toolz = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    local changetoo = mc.mcToolGetDesc(inst,selectedtool)
    wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press ok to continue")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
    RunProbe(selectedtool)
    mc.mcAxisSetPos(inst, 2 , toolz)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    wx.wxMessageBox("Please turn on spindle and click ok to continue") --can be removed if required
    mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.." Y"..ystart)
    mc.mcToolSetCurrent(inst, selectedtool)
    mc.mcCntlSetLastError(inst, "ToolChange Finished")
    end
end

function RunProbe(tool)
    local inst = mc.mcGetInstance()
    toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, tool)
    if toollen == 0 then toollen = 40 end -- User Preference
    mc.mcCntlSetLastError(inst, "Changing to Fallback Length")
    local probestart = -60 + toollen
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\nG91 G31 Z-15 F25")
end

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

now to do a quick vid on that crash!!!!

DazTheGas

677
Mach4 General Discussion / Mach4 GUI Handle
« on: October 12, 2015, 11:12:31 AM »
A bit of a long shot here, but is there anybody that knows how to retrieve the wxWindow handle for mach4 using lua/wxlua

got a small macro that needs to get input from the user, however it needs the wxWindow handle to run.

DazTheGas

678
Mach4 Videos / Creating an M6 Toolchange in Mach4 (Part 2)
« on: October 08, 2015, 07:26:07 PM »
This is part 2 of creating my own M6 Toolchange in mach4, Well couldnt fit it all in 2, in the last part we will add a failsafe for the code and do a bit of tidying up in the code.

https://youtu.be/TZ5fUIRjzxE

The Code so far in this part

Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local guesslen = -60.00
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)
    local toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
    local probestart = guesslen + toollen
    local xstart = mc.mcAxisGetPos(inst,0)
    local ystart = mc.mcAxisGetPos(inst,1)

    if selectedtool == currenttool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart)
    mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-15 F25")
    local toolz = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    local changetoo = mc.mcToolGetDesc(inst,selectedtool)
    wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press ok to continue")
    currenttool = selectedtool
    toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
    probestart = guesslen + toollen
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart)
    mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-15 F25")
    mc.mcAxisSetPos(inst, 2 , toolz)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.." Y"..ystart)
    mc.mcToolSetCurrent(inst, selectedtool)
    wx.wxMessageBox('Toolchange finished')
    end

end

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

DazTheGas

679
Mach4 General Discussion / Re: Mach4 Keyboard Emulation
« on: October 07, 2015, 02:27:55 PM »
yes they can, on the second that u want to use as a pendant you can configure your keys such as shft alt cntrl plus another key, you wouldnt normaly use this combination in everyday life so shouldnt interfere with anything else.

DazTheGas

680
Mach4 Videos / Re: Creating an M6 Toolchange in Mach4 (Part 1)
« on: October 07, 2015, 03:37:37 AM »
Yes that is correct and such lines can be joined after function is finished, but during a tutorial it makes sense to show in separate steps so others can follow easier what the function is doing.

BTW \n = newline

DazTheGas