1
Mach4 General Discussion / Coroutine question/problem
« on: September 15, 2021, 05:58:31 PM »
i double posted this by accident (over in the General mach forum)
First, what I am attempting to do is create a button that raises the router to what I call "safeZ" - just to get it out of the way to work on my workpiece or whatever.
I created a coroutine so the DRO would show the progress. Now, after the GCode move is complete, I'd liek to do some other stuff. But, after the move is complete, nothing happens! I've tried all sorts of commands down there and nothing happens. One thing I was trying to add was to disable the machine after the move. If I add that down there, it disables before the move!
What I mean by down there is after the else where it says back to work coordinates.
So, basically I am trying to complete a move and keep the DRO live, then do other things like display the error message and perhaps disable the machine.
One more thing I noticed....in the function, message boxes are executed, but not the mach functions like mc.CntlSetLastError.
Thanks for any help!
Tony
First, what I am attempting to do is create a button that raises the router to what I call "safeZ" - just to get it out of the way to work on my workpiece or whatever.
I created a coroutine so the DRO would show the progress. Now, after the GCode move is complete, I'd liek to do some other stuff. But, after the move is complete, nothing happens! I've tried all sorts of commands down there and nothing happens. One thing I was trying to add was to disable the machine after the move. If I add that down there, it disables before the move!
What I mean by down there is after the else where it says back to work coordinates.
So, basically I am trying to complete a move and keep the DRO live, then do other things like display the error message and perhaps disable the machine.
One more thing I noticed....in the function, message boxes are executed, but not the mach functions like mc.CntlSetLastError.
Thanks for any help!
Tony
Code: [Select]
--10FE20
--This script is to test using a coroutine so that when a Gcode
--is sent, the DRO's are updated live and the completion message doesn't
--show up until the move is complete
--another post on Mach4 suggested checking to see if the machine is indeed in the
--correct location before displaying the finished message in case something happened
-- to prevent it from getting there - not sure how to do that yet.
local inst = mc.mcGetInstance()
local val
local rc
local homed
--Change to machine coords
local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_CORD)
local sig = mc.mcSignalGetState(hsig)
if (sig == 0) then
mc.mcSignalSetState(hsig,1)
end
--check if Z is homed . if not - do nothing
homed , rc = mc.mcAxisIsHomed(inst,mc.Z_AXIS)
if homed == 1 then
SafeZ = coroutine.create(function()
mc.mcCntlGcodeExecute(inst, "G53 G1 Z-0.5 F25")
coroutine.yield()
val,rc = mc.mcAxisGetMachinePos(inst,mc.Z_AXIS)
if val == -0.5000 then
--wx.wxMessageBox("Safe Z Finished")
mc.mcCntlSetLastError("Safe Z completed")
else
wx.wxMessageBox("Oops! - Didn't make it to -0.5'")
end
--wx.wxMessageBox("Safe Z Finished")
end)
else
wx.wxMessageBox("Move Cancelled - Z is not homed")
end
--back to work coords
mc.mcSignalSetState(hsig,0)
wx.wxMessageBox("Safe Z Finished")