Hello Guest it is April 19, 2024, 02:50:49 PM

Recent Posts

Pages: « 1 2 3 4 5 6 7 8 9 10
91
Mach4 Toolbox / Re: Umbrella Style M6 Script
« Last post by rhtuttle on March 31, 2024, 01:22:08 PM »
when in debug did you check the values sent and received and rc's returned of the mcCtntlGetPoundvar and mcCtntlSetPoundvar?
92
Mach4 Toolbox / Re: Umbrella Style M6 Script
« Last post by McRoth on March 30, 2024, 07:44:48 PM »
I completely forgot about the debug function! lol.  I ran it and found a couple of little things to fix but now I'm getting this error and I'm not sure why?
LuaExamples/m6.mcs:175: wxLua: Expected a 'number' for parameter 3, but got a 'nil'.
Function called: 'mcCntlSetPoundVar(number, number, nil)'
The script I modified from debugs with no issues even though I didn't change those sections?

Updated code:

Code: [Select]
----------Variables----------
local inst = mc.mcGetInstance()
local DrawBarOut = mc.OSIG_OUTPUT2 -------- Release drawbar ------
local BlowOut = mc.OSIG_OUTPUT3 -------- Tool blow ------
local UmbrellaIn = mc.OSIG_OUTPUT5 -------- Swing Umbralla In ------
local UmbrellaOutSensor = mc.ISIG_Input20 -------- Umbralla Out Sensor ------
local UmbrellaInSensor = mc.ISIG_Input21 -------- Umbralla In Sensor ------
local numtools = 6

local ToolCPositions = {}
ToolCPositions[1] = 0.0
ToolCPositions[2] = 60.
ToolCPositions[3] = 120.
ToolCPositions[4] = 180.
ToolCPositions[5] = 240.
ToolCPositions[6] = 300.


function m6()
local GCode = ""
GCode = GCode .. string.format("M9\n") --Coolant Off
    GCode = GCode .. string.format("M5\n") --Stop Spindle
GCode = GCode .. string.format("G04 P500\n")
mc.mcCntlGcodeExecuteWait(inst, GCode)

------ compare current and next tools ------
local SelectedTool = mc.mcToolGetSelected(inst)
local CurrentTool = mc.mcToolGetCurrent(inst)
if (SelectedTool == CurrentTool) then
mc.mcCntlSetLastError(inst, "Next tool = Current tool")
do return end
end

if (SelectedTool > numtools) or (SelectedTool <= 0) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end
else
end

------ Get current machine state ------
local CurFeed = mc.mcCntlGetPoundVar(inst, 2134)
local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)

------ Get Position data for current tool ------
Num1 = CurrentTool
CPos1 = ToolCPositions[CurrentTool]

------ Get position data for next tool ------
Num2 = SelectedTool
CPos2 = ToolCPositions[SelectedTool]

------ Move to tool change position ------
GCode = ""
GCode = GCode .. "G00 G90 G53 Z-2.0\n" --Z=Tool change position
GCode = GCode .. string.format("G00 G90 G53 C%.4f\n", CPos1) --Current tool Umbrella position
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Swing umbrella to get tool in spindle
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 1)

--Verify Umbrella is In
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaInSensor)
hReg, rc = mc.mcSignalGetState(hSig)

if (hReg == 0) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end

------ Unclamp tool ------
hsig = mc.mcSignalGetHandle(inst, DrawBarOut)
mc.mcSignalSetState(hsig, 1)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Move to tool change Clearance position
GCode = ""
GCode = GCode .. "G00 G90 G53 Z0\n" --Z=Tool change clearance position
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Swing umbrella to standby position
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 0)

--Verify Umbrella is Out
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaOutSensor)
hReg, rc = mc.mcSignalGetState(hSig)
if (hReg == 1) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end

--turn on tool blowoff nozzles
hsig1 = mc.mcSignalGetHandle(inst, BlowOut)
mc.mcSignalSetState(hsig1, 1)

--Rotate Umbrella to next tool
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 C%.4f", CPos2)
mc.mcCntlGcodeExecuteWait(inst, GCode)

--turn off tool blowoff nozzles
local hsig1 = mc.mcSignalGetHandle(inst, BlowOut)
mc.mcSignalSetState(hsig1, 0)

--swing umbrella to tool change position
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 1)

--Verify Umbrella is In
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaInSensor)
hReg, rc = mc.mcSignalGetState(hSig)
if (hReg == 0) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end

--lower Z to tool change position
GCode = ""
GCode = GCode .. "G00 G90 G53 Z-2.0\n" --Z=tool change position
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Clamp tool
local hsig = mc.mcSignalGetHandle(inst, DrawBarOut)
mc.mcSignalSetState(hsig, 0)
GCode = ""
GCode = GCode .. "G04 P1000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Swing umbrella to standby position
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 0)

--Verify Umbrella is Out
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaOutSensor)
hReg, rc = mc.mcSignalGetState(hSig)
if (hReg == 1) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end
end
------ Reset state ------
mc.mcCntlSetPoundVar(inst, 2134, CurFeed)
mc.mcCntlSetPoundVar(inst, 4001, CurFeedMode)
mc.mcCntlSetPoundVar(inst, 4003, CurAbsMode)

------ Set new tool ------
mc.mcToolSetCurrent (inst, SelectedTool)
mc.mcCntlSetLastError(inst, string.format("Tool change - Tool: %.0f", SelectedTool))

mc.mcCntlGcodeExecuteWait(inst, "G43 H"..SelectedTool)

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

93
VB and the development of wizards / Re: system command in the gcode
« Last post by TPS on March 30, 2024, 12:52:17 PM »
this is creating a string with date time xcoord ycoord zcoord

Code: [Select]
mystring = Date() & "_" & Time() & "_X_" & GetOEMDRO(800) & "_Y_" & GetOEMDRO(801) & "_Z_" & GetOEMDRO(802)

msgbox mystring
94
VB and the development of wizards / Re: passing variables from gcode to macro
« Last post by djmickyg on March 30, 2024, 12:34:52 PM »
thanks!!!
95
VB and the development of wizards / system command in the gcode
« Last post by djmickyg on March 30, 2024, 12:33:07 PM »
hello.

i have a custom mcode that captures a camera image, its basically running a system command to a command line image capture tool.
the macro create a unique filename for each images from the date_time_xyz then runs the capture utility

I was wondering if system commands could be called directly from the code?
96
VB and the development of wizards / Re: passing variables from gcode to macro
« Last post by TPS on March 30, 2024, 12:27:46 PM »
from Mach3_V3.x_Macro_Prog_Ref.pdf:

Code: [Select]
'Example:
‘ This macro expects three arguments: P, Q, & R
‘ If put into an M-macro, and invoked via MDI, it will
‘ display the argument values on the status line
‘ For example, if using M1200:
‘ M1200 P1.234 Q2.345 R3.456
‘ Executing the above line to MDI will display:
‘ P=1.234 Q=2.345 R=3.456
Parg = Param1()
Qarg = Param2()
Rarg = Param3()
Message “P=” & Parg & “Q=” & Qarg & “R=” & Rarg
97
VB and the development of wizards / passing variables from gcode to macro
« Last post by djmickyg on March 30, 2024, 12:21:12 PM »
is it possible to send a variable from gcode to a custom m code?

my m code is capturing images from a camera, I want to pass the commanded positions to use in the image file name

thanks
98
Mach4 Toolbox / Umbrella Style M6 Script
« Last post by McRoth on March 29, 2024, 05:18:43 PM »
I have an old Milltronics Partner 1 mill with a 6 tool umbrella style tool changer that I'm rebuilding and using Mach4 with a Hicon Integra controller.  I haven't been able to find a m6 script for this style so I have attempted to modify the tool change script that is on CNC4PC.  Can you guys that actually know how to program LUA check my code and let me know if it looks correct or what I should modify?  I'm using a stepper to rotate the umbrella and calling it C axis.  It has a home sensor and also a sensor for each tool position, but I'm not sure if I really need the tool position sensor.  I didn't use it in this code.  Once I finish getting the mill running I'll modify the I/O if I need to and set the correct tool change position.

Thanks!

Mike

Code: [Select]
----------Variables----------
local inst = mc.mcGetInstance()
local DrawBarOut = mc.OSIG_OUTPUT2 -------- Release drawbar ------
local BlowOut = mc.OSIG_OUTPUT3 -------- Tool blow ------
local UmbrellaIn = mc.OSIG_OUTPUT5 -------- Swing Umbralla In ------
local UmbrellaOutSensor = mc.ISIG_Input20 -------- Umbralla Out Sensor ------
local UmbrellaInSensor = mc.ISIG_Input21 -------- Umbralla In Sensor ------
local numtools = 6

local ToolXPositions = {}
ToolCPositions[1] = 0.0
ToolCPositions[2] = 60.
ToolCPositions[3] = 120.
ToolCPositions[4] = 180.
ToolCPositions[5] = 240.
ToolCPositions[6] = 300.


function m6()
local GCode = ""
GCode = GCode .. string.format("M9\n") --Coolant Off
    GCode = GCode .. string.format("M5\n") --Stop Spindle
GCode = GCode .. string.format("G04 P500\n")
mc.mcCntlGcodeExecuteWait(inst, GCode)

------ compare current and next tools ------
local SelectedTool = mc.mcToolGetSelected(inst)
local CurrentTool = mc.mcToolGetCurrent(inst)
if (SelectedTool == CurrentTool) then
mc.mcCntlSetLastError(inst, "Next tool = Current tool")
do return end
end

if (SelectedTool > numtools) or (SelectedTool <= 0) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end
else
end

------ Get current machine state ------
local CurFeed = mc.mcCntlGetPoundVar(inst, 2134)
local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)

------ Get Position data for current tool ------
Num1 = CurrentTool
CPos1 = ToolCPositions[CurrentTool]

------ Get position data for next tool ------
Num2 = SelectedTool
CPos2 = ToolCPositions[SelectedTool]

------ Move to tool change position ------
GCode = ""
GCode = GCode .. "G00 G90 G53 Z-2.0\n" --Z=Tool change position
GCode = GCode .. string.format("G00 G90 G53 C%.4f\n", CPos1) --Current tool Umbrella position
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Swing umbrella to get tool in spindle
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 1)

--Verify Umbrella is In
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaInSensor)
hReg, rc = mc.mcSignalGetState(hSig)

if (hReg == 0) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end

------ Unclamp tool ------
hsig = mc.mcSignalGetHandle(inst, DrawBarOut)
mc.mcSignalSetState(hsig, 1)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Move to tool change Clearance position
GCode = ""
GCode = GCode .. "G00 G90 G53 Z0\n" --Z=Tool change clearance position
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Swing umbrella to standby position
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 0)

--Verify Umbrella is Out
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaOutSensor)
hReg, rc = mc.mcSignalGetState(hSig)
if (hReg == 1) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end

--turn on tool blowoff nozzles
hsig1 = mc.mcSignalGetHandle(inst, BlowOut)
mc.mcSignalSetState(hsig1, 1)

--Rotate Umbrella to next tool
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 C%.4f", CPos2)
mc.mcCntlGcodeExecuteWait(inst, GCode)

--turn off tool blowoff nozzles
local hsig1 = mc.mcSignalGetHandle(inst, BlowOut)
mc.mcSignalSetState(hsig1, 0)

--swing umbrella to tool change position
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 1)

--Verify Umbrella is In
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaInSensor)
hReg, rc = mc.mcSignalGetState(hSig)
if (hReg == 0) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end

--lower Z to tool change position
GCode = ""
GCode = GCode .. "G00 G90 G53 Z-2.0\n" --Z=tool change position
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Clamp tool
local hsig = mc.mcSignalGetHandle(inst, DrawBarOut)
mc.mcSignalSetState(hsig, 0)
GCode = ""
GCode = GCode .. "G04 P1000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)

--Swing umbrella to standby position
hsig1 = mc.mcSignalGetHandle(inst, UmbrellaIn)
mc.mcSignalSetState(hsig1, 0)

--Verify Umbrella is Out
mc.mcSignalSetState(hsig,0)
mc.mcSignalSetState(hsig1,0)
mc.mcSignalSetState(hsig2,0)
GCode = ""
GCode = GCode .. "G04 P2000\n"
mc.mcCntlGcodeExecuteWait(inst, GCode)
hSig, rc = mc.mcSignalGetHandle(inst, UmbrellaOutSensor)
hReg, rc = mc.mcSignalGetState(hSig)
if (hReg == 1) then
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Umbrella Not In Position!")
do return end
end
end
------ Reset state ------
mc.mcCntlSetPoundVar(inst, 2134, CurFeed)
mc.mcCntlSetPoundVar(inst, 4001, CurFeedMode)
mc.mcCntlSetPoundVar(inst, 4003, CurAbsMode)

------ Set new tool ------
mc.mcToolSetCurrent (inst, SelectedTool)
mc.mcCntlSetLastError(inst, string.format("Tool change - Tool: %.0f", SelectedTool))

mc.mcCntlGcodeExecuteWait(inst, "G43 H"..SelectedTool)

end

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

99
I know this is an ancient thread, but I am working on a similar machine, just with a 6 tool umbrella.  Did you get this working?  If so, can you post the code? 
I'm modifying the code that CNC4PC has on their site and have the basics down, I think, but I need to get the umbrella rotation and counting worked out.  Also, it'll need to be homed in the machine homing script, but I don't think that'll be too bad.

Thanks!

Mike
100
Mach4 General Discussion / Re: input to stop machine
« Last post by MN300 on March 29, 2024, 09:05:40 AM »
If the air pressure drops slowly enough a pressure switch could signal the impending problem with enough time to stop the machine with the feed hold. This would allow you to continue once pressure is reestablished.
Pages: « 1 2 3 4 5 6 7 8 9 10