Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: jamie325i on December 17, 2018, 06:13:35 PM
-
Hey folks,
Forgive me for asking, I know this topic has been covered, but the search function of this forum is busted and I am only getting so far with Google and the other forums.
I have my plasma cutter's "Arc OK" signal wired to Input A of my PMDX-410 and the THCON signal in Mach4. I verified that this is working because I added an "ARC OK" led to my Plasma screen. Now I need to add logic that will halt movement until the Arc OK signal is activated.
When M3 is called in my G-code, I'd like it to fire the torch, wait for the Arc OK signal, run the pierce delay (called in my G-code), then allow the next move once the pierce delay has expired.
I have read about several methods including a modified M3 function using the mc.ISIG_THCON signal. My problem is that I don't know how to create that function, or what else should be modified to add my logic. I have not had to modify Mach up to this point and now the info is a bit overwhelming...
Is anyone willing to share experience and some steps to get this working?
Thanks in advance,
Jamie
-
Hi,
yes this can be done. First you'll need to read up on substituting the m3 macro.
Mach4 CNC Controller
Lua Scripting Guide
in the Docs folder page 9 sections 3.1 and 3.1.1
You can write your own m3 macro and Mach will use that one instead of the built-in macro.
Couple of warnings.....Machs Gcode interpreter reduces ALL letters to lowercase and strips out leading zeros...thus:
M03
m03
m3
all mean the same thing. Sometimes Mach will misinterpret your chosen name for a macro because you didn't use lowercase or did use leading zeros.
Don't do it....it will really screw with your head when it happens.
What you do now is write your own m3 macro and put it in your profile macros folder.
You can cause the macro to wait on an Arc OK signal before returning using this API:
LUA Syntax:
rc = mc.mcSignalWait(
number mInst,
number sigId,
number waitMode,
number timeoutSecs);
Description:
Wait on a signal to change state.
Parameters: Parameter Description
mInst The controller instance.
sigId A valid signal ID. (NOT a signal handle)
waitMode An integer specifying whether to wait on the signal to go high (WAIT_MODE_HIGH) or low (WAIT_MODE_LOW).
timeoutSecs A double specifying a timeout period.
Note it is highly recommended to test the return code on this API to detect any quirky behavior.
Craig
-
Hey Craig,
thanks for the help! I have the following modified m3 function working and tested on the machine. I wired the Arc OK signal to input62 instead of "THC ON" because I can't figure out what input THC ON is wired to. It was easier to change to a numbered input...
The next thing I want to add is a watchdog that will stop the machine if the arc goes out mid-cut. Any idea how to implement that change?
Here is my code:
function m3();
local inst=mc.mcGetInstance();
mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_FWD); I use spindle FWD to turn my torch on
mc.mcCntlSetLastError(inst,"m3 waiting for Arc"); Display message while pilot arc is establishing
local returncode=mc.mcSignalWait(inst,mc.ISIG_INPUT62,mc.WAIT_MODE_HIGH,2); Arc OK signal tied to inpiut62. Timeout if arc does not establish in 2 seconds
if (returncode==mc.MERROR_TIMED_OUT) then
mc.mcCntlSetLastError(inst,"Arc does not respond"); Print message in display
mc.mcCntlCycleStop(inst); --end program ***** End program if arc times out
mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_OFF);
else;
mc.mcCntlSetLastError(inst,"m3 Arc OK"); Display message if Arc OK and continue with G-Code
end;
end
if (mc.mcInEditor() == 1) then
m3();
end
-
If the arc goes out, the Arc OK Signal changes in Mach4?
If so, you can have the PLC Script monitor the ARC OK Signal.
In the PLC Script, if SpindleCW is true and G Code is running and ARC OK signal is on then do nothing. If ARC OK Signal is off Cycle Stop, or E Stop.
You may have to put a time in the PLC Script when the m3 turns on, that way it doesn't read an error on the first several PLC Intervals after m3 comes on.
-
There will be a new build very soon that has a plasma screen, profile (including macros) etc., THC support........ pretty much everything you need for plasma.
-
Thanks for the suggestion Chad. I will look into the PLC script idea.
As for the new version coming soon, I cannot wait! The screenshots look very promising. I am building a new plasma table now and I was not certain that I could use Mach4 to run it so this would definitely change things for me.
Thanks again,
Jamie
-
Hi Jamie,
I am trying to get my M3 & M5 to start and stop my plasma from firing and using arc ok as well. mind sharing your M5 code as well?
I am trying to make the M3 code you shared work for my use, will update if it works!