Hello Guest it is May 23, 2024, 01:42:55 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.


Topics - McRoth

Pages: 1
1
Mach4 Toolbox / Umbrella Style M6 Script
« 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


2
HiCON Motion Controller / Spindle Setup with 7866 control and VFD
« on: March 18, 2024, 09:10:36 PM »
I'm setting up my servo spindle with 0-10V control.  I have the quadrature encoder wired in, so I wanted to know if there is any need to wire in the outputs from the VFD for "Speed reach" and "zero speed" since the control is using the encoder it should already know? 
It also has a "warn output" which I'm guessing is to let the control know if there is an issue with the VFD.  How would I go about wiring this in correctly?
Thanks!

Mike

3
Mach4 Plugins / Spindle Encoder OA+- OB+- OZ+- or EA+- EB+-?
« on: April 24, 2023, 09:26:45 AM »
I'm working on trying to hook up this servo spindle motor via step/dir: https://www.automationtechnologiesinc.com/products-page/cnc-milling-spindle/3-7kw-2-2kw-8000rpm-milling-spindle-motor-and-inverter-220v , the 3.7KW 220V single phase version to my ESS with a C82 board.  ESS only wants an A, B and Index input, but this encoder has OA+- OB+- OZ+- and/or EA+- EB+-.  How would I go about getting this to work?  Do I need some kind of converter?

Thanks!

Mike

Pages: 1