Hello Guest it is April 18, 2024, 10:42:26 AM

Author Topic: Setup Mach4 for floating head switch  (Read 1751 times)

0 Members and 1 Guest are viewing this topic.

Setup Mach4 for floating head switch
« on: December 15, 2021, 01:55:34 PM »
I have retrofitted an old plasma table, with Mach4 and added a Floating head for the torch mount. It uses proximity switches to detect a collision with the material.  In Mach4, I’d like to map the proximity switch and setup Mach to stop motion in the event a collision is detected during cutting. It would have to stop the plasma torch also.   Can you offer some suggestions on where I can get started, as I am struggling to find how to go about this?
Thanks,
ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive
Re: Setup Mach4 for floating head switch
« Reply #1 on: December 15, 2021, 06:56:15 PM »
I forgot to include that the controller being used for this is the Vital Systems Hicon Controller 7866. 
ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive
Re: Setup Mach4 for floating head switch
« Reply #2 on: December 16, 2021, 01:38:28 AM »
2 option ,event handler or PMI ,are written on manual ,and i think its not complex do but batter for you to read it direct from the instruction
Re: Setup Mach4 for floating head switch
« Reply #3 on: December 16, 2021, 10:12:55 AM »
Thank you for the help.  I have read the Mach4 Installation manual and have also searched through Mach4 CNC controller config and Plasma Configuration, but I just don't see what I need.  I am lost.  You suggest 2 options: Event Handler ( lua scripting I think) and PMI ( what is PMI?)

I am very new at this..

Chris

ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive

GOOMBA

*
Re: Setup Mach4 for floating head switch
« Reply #4 on: December 16, 2021, 03:48:15 PM »
Package your profile by going to Help > Support > Package Profile and attach it here.
Let me know what input you'd like to assign the switch to and I'll program into the signal script to trigger an emergency stop (or if you'd prefer a feed hold or Error Alarm) if this input becomes active this will trigger. Include any other specific requests with the profile and I'll help you.
Best Regards,
Trevor
Re: Setup Mach4 for floating head switch
« Reply #5 on: December 16, 2021, 05:33:48 PM »
Travor Thank you, Ill gather up a few things that I know of and get back to you.
ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive
Re: Setup Mach4 for floating head switch
« Reply #6 on: December 26, 2021, 10:46:55 AM »
Trevor,
Thanks for helping me setup this retro fitted CNC Plasma table and I hope you had an enjoyable Christmas. I posted the Profile and some additional reference info. 
Please feel free to question anything here because this is the first time I have retrofitted a CNC table. I do appreciate what ever help you are able to provide. This is a new project. The hardware was mounted, software installed, and we have successfully run some sample Gcode files with Mach4 and have movement!
Setup that we need help with:
1.   Floating Head torch mount with switches for Collision Detection/ Probing. The floating head has 3 proximity switches mounted to it.  We intend to use them (wired in series) to detect a collision during machine movement to protect the torch from damage.  However, it is also to be used for setting the Z material height during a Probe move.
  a.   When Collision Detection switch is tripped (Mach4 [P11] Input 9). I’d like the reaction to be:
    i.   Stop X, Y, Z motor movement
    ii.   Turn off Plasma cutter’s torch (Mach4 [P14] Output 3).
    iii.   Allow user to use the Axis Limit Override button located on (Program Run Tab ->Jogging Tab-> Axis Limit Override Toggle Button) This will allow torch to be jogged off the obstruction.
    iv.   Press Cycle Start to continue operations.
    v.   Please note: This same input (P11 Input 9) would be used as a Probe input during a Probe action.
1.   During Probe action disable Collision reaction response.
2.   When Ac Servo Drive faults, an Alarm signal is provided. Currently, Mach4 does nothing during this event.  I’d like Mach4 to perform a STOP action and inform user with a message in the Message Bar(at bottom of Mach4 Screen).  The AC SERVO Drive Alarm Circuits are connected to HiCON control board at:
  a.   X Drive Alarm connects to (Mach4 P11 input 0)
    i.   Update Message Bar with: “Error X AC Servo Drive Alarm” 
  b.   Y Drive Alarm connects to (Mach4 P11 input 6)
    i.   Update Message Bar with: “Error Y AC Servo Drive Alarm”
  c.   Z Drive Alarm connects to (Mach4 P11 input 7) 
    i.   Update Message Bar with: “Error Z AC Servo Drive Alarm”

3.   GO TO WORK ZERO error:  When I Press “Go to Work Zero” button in MACH4 I get the following message - "AXIS 3 COMMANDED WHILE DISABLED"   Our table only has 3 Axis and code is attempting set the 4th axis that does not exist.  Can you please update the script under the Go to Work Zero button and remove the AXIS 3?
4.   Setup Mach4 with two small Toggle Buttons, located on the (wxArcProPlasma-4.set->Program Run->Jogging->tabFileOps) to operate two Hicon controller relays. (See attached screen image)
  a.   Toggle Button 1 (label: “Table Light”) Turns on/off Light using (Mach 4 P14 input 4) 
  b.   Toggle Button 2 (label: “Laser Cross”) Turns on red cross hair laser using Mach4 P14 input 7)   
5.   Add a Set Laser X, Y Zero Button, for use during “Find work piece zero location and set fixture offset”. This was inspired by (https://youtu.be/8m_K9WfCiEY?t=67).  After user aligns laser to corner of work piece, user presses Button, the code moves torch to where the user initially placed the red cross hair laser and it then zeros the X and Y axis.
  a.   Add a custom Button to the wxArcProPlasma-4.set->Program Run tab-> Current Positions tab. (labeled: “Set Laser X, Y Zero”)
    i.   When the user presses the Button:
1.   X and Y axis moves so that torch tip is aligned where laser cross hair used to be.
2.   Zero the DRO’s X and Y Axis.
If you could just have the code set X axis by 2.5 and Y axis by .06 and I’ll edit these values once we determine the red cross hair laser location offset from the torch tip.

Wow this is long...and I am asking for too much!
I sincerely thank you for what help your able to provide
« Last Edit: December 26, 2021, 10:51:29 AM by ChrisO »
ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive
Re: Setup Mach4 for floating head switch
« Reply #7 on: February 15, 2022, 07:27:47 AM »
I have made some progress and wanted to share: for the Floating torch mount with  Collision Detection and material height sensing. The idea was if the switch is activated, check to see if material height sensing is taking place. If yes, allow movement to continue, if no, stop movement. Coding Strategy: Use Registers,  Module with 2 functions, and Screen Script and Macro M3. Using Screen Script Signal Library, monitor the switch on the floating torch mount.
Register--  Used to store a value  to be used between signal library and m3 macro.
Module--  Use to store functions that Set the register value or Get the register value.
M3-- Will pass the value to the Set function in the module,   that inturn, updates the register value.
Screen Script Signal library—Will use a Get Function, to  obtain the value from the register when switch is triggered. 
Screen Script-- Will use a function to stop motion of machine if not in a M3, material height sensing cycle.

Following the Mach4 scripting manual I created a new value in existing Register: iregs0, created m3probing='nf'  -- the default value . --set to persistent to false.
---- Create Module -- file name: arcprorwig.lua -- file location:C:\Mach4Hobby\Modules\
-- How: Mach4->operator-> edit/debug script-> place jibberish in file name. click ok, it generates error, and then puts you in untitled.mcs. Do file saveas arcprorwig.lua
--  Place the following code in the arcprorwig.lua file:
Code: [Select]
-- start of arcprorwig.lua module code --
-- function to Get Register value
function GetRegister(regname)
local inst = mc.mcGetInstance()
local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
return mc.mcRegGetValueString(hreg)
end
--function to Set Register value
function WriteRegister(regname, regvalue)
local inst = mc.mcGetInstance()
local hreg = mc.mcRegGetHandle(inst, string.format("iRegs0/%s", regname))
mc.mcRegSetValueString(hreg, tostring(regvalue)) -- converts any value to a string
end
-- end of module code---
In the Screen Script, Load modules area:
-- look for "--Load modules----“, In the loaded modules area, place this code after mcErrorCheck and before the code for loading mcTrace. I found that placing it after, that the debugging process stops during mcTrace function for some reason.
Code: [Select]
mcErrorCheck = require "mcErrorCheck"
--start of  code changes to load module: arcprorwig--
    package.loaded.arcprorwig = nil
    aro = require("arcprorwig")
-- end of loading module code----

--Trace module
-- M3 code changes:
Code: [Select]
function m3()
local inst = mc.mcGetInstance()
--start of M3 code change
-- loads the arcprorwig.lua module functions
-- create path to module
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
package.path = path .. "\\Modules\\?.lua;" .. path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;"
-- load module to memory
package.loaded.arcprorwig = nil  -- clears previous instance of module
local aro = require("arcprorwig") -- loads the arcprorwig.lua module functions
-- end of code change
-- Start of original M3 code--
if (arcpro == nil) then…..
--  Find in original M3 code: locate in code the area just before the probe process..for me it was:
if (OmitTouchoff == 0) then --Do the touch off
--start of M3 code change
WriteRegister("m3probing", 1) -- sets the m3probing to '1'
--end of code change------
-- Find in original M3 code: Locate the code the area just after probe process is completed.. for me it was:
rc = mc.mcCntlGcodeExecuteWait(inst, string.format("G91\nG0 Z%4.4f", TorchOnHeight + ProbeOffset)) --Move to torch on height
--start of M3 code change
WriteRegister("m3probing", 0) -- sets the m3probing to '0'
--end of code change---
Signal Library area of Screen Script Code:
Code: [Select]
-----start of code change----
[mc.ISIG_INPUT9]= function (state) -- Torch Probe/collision switch state has changed
if(state==1) then
local areweprobing = GetRegister("m3probing") -- determine if the machine is probing
if (areweprobing=='1') then -- uses value from ireg0 register
--do nothing
else
stopmovement() -- call function to stop movement
mc.mcCntlSetLastError(inst, "Error- Torch Collision Detected")  -- Put message in message box
end
end
end,
-- end of code change--
-- Placed at the bottom of the screen script:
--start of stopmovement code-----------------
function stopmovement()
local inst = mc.mcGetInstance()
mc.mcSpindleSetDirection(inst,0)  -- Set to 0 to turn spindle off
mc.mcCntlCycleStop(inst)  -- stops Gcode file that is running. Alternative: mc.mcCntlEStop(inst)
end
----------------End of stopmovement code----------------------

ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive
Re: Setup Mach4 for floating head switch
« Reply #8 on: February 15, 2022, 07:33:10 AM »
For monitoring the AC Servo drives Alarm input I have the following code, that goes in the Signal Library area of the screen script
Code: [Select]
-------------start of alarm code-----------------------------
[mc.ISIG_INPUT0]= function (state)
if(state==1) then -- If True
ACSERVO_AlarmAction() -- call function to stop movement
mc.mcCntlSetLastError(inst, "Error- X Axis Servo Drive Alarm"); -- message box
else
-- do nothing
end
end,
[mc.ISIG_INPUT6]= function (state)
if(state==1) then-- If True
ACSERVO_AlarmAction() -- call function to stop movement
mc.mcCntlSetLastError(inst, "Error- Y Axis Servo Drive Alarm"); -- message box
else
-- do nothing
end
end,
[mc.ISIG_INPUT7]= function (state)
if(state==1) then-- If True
ACSERVO_AlarmAction() -- call function to stop movement
mc.mcCntlSetLastError(inst, "Error- Z Axis Servo Drive Alarm"); -- message box
else
-- do nothing
end
end,
-------------------------end of alarm code-------------
Code that goes at the bottom of page in Screen script
-- Code change --
Code: [Select]
function ACSERVO_AlarmAction()
local inst = mc.mcGetInstance()
mc.mcSpindleSetDirection(inst,0); -- Set to 0 to turn spindle off
mc.mcCntlCycleStop(inst); -- stops Gcode file that is running.
End
-- End of Code--
ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive
Re: Setup Mach4 for floating head switch
« Reply #9 on: February 15, 2022, 07:36:02 AM »
To resolve my GoTo Work Zero button issue:  SOLUTION: In the Screen Script change the following code to:
Code: [Select]
function GoToWorkZero()
    -- replace this line with below--mc.mcCntlMdiExecute(inst, "G00 X0 Y0 A0")--Without Z moves
mc.mcCntlMdiExecute(inst, "G00 X0 Y0 Z0")--With Z moves
    --mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z0")--With Z moves
end 
ChrisO

Mach4 Hobby
Vital Systems Hicon Controller 7866 with 77ISO board and ArcPro Plasma Profile
DYN4 DYN4-H01A2-00 AC SERVO Drives
DMM 750 Watt NEMA 34 motors
Thermal Dynamics Pak Master PCM-100XL Machine Torch with floating head
Retrofit Table: 6’x24’ linear rail and belt drive