Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: kvid on February 16, 2020, 01:10:34 PM
-
How can I disable any motion before the machine is homed?
-
make flag ,for example registry can be for this
-
I am sorry but I don't understand what you are talking about. Please explain.
-
can create registry as 0 then when homing finish change to 1
and in jog add condition only if that registry is 1,also when its 0 put machine in hold ,so cant move
-
Hi,
How can I disable any motion before the machine is homed?
That's easy, in the screen load script or the first run of the PLC script deactivate any and all servo/stepper enables.
But now what? You want to home your machine....but you can't you have just disable ALL movement.
What you really want is to stop any MDI commands, any Gcode jobs or any jogging to occur before the machine is homed...
am I correct?
Craig
-
can create registry as 0 then when homing finish change to 1
and in jog add condition only if that registry is 1,also when its 0 put machine in hold ,so cant move
Ok, I think I understand the concept but I don't have any experience with coding in LUA.
Hi,
How can I disable any motion before the machine is homed?
That's easy, in the screen load script or the first run of the PLC script deactivate any and all servo/stepper enables.
But now what? You want to home your machine....but you can't you have just disable ALL movement.
What you really want is to stop any MDI commands, any Gcode jobs or any jogging to occur before the machine is homed...
am I correct?
Craig
I should have explained what I am trying to do a little better.
I created a simple screenset for production which contains only what is necesarry. I am trying to prevent the worker who is working on the machine from accidentaly running the program with Cycle Start before he has homed the machine with Reference All Axes Home button.
I attached the screen.
-
Simply put a sign on the computer.... Machine Must be Homed before any other movement!
-
Simply put a sign on the computer.... Machine Must be Homed before any other movement!
This. Simply brilliant!!! :)
Way back when, I was a systems analyst. Believe it or not, systems analysts existed before computers got so accessible/popular. System analysts were basically problem solvers when trying to improve any system, be it a manual or automated system of any type. It could be logistics flow of material through a plant, or simply how to keep track of shipment items when they are loaded onto a truck. And later on when computers became "the way" to solve problems, everyone wanted to do things that way. But sometimes, the more direct approach was the cheaper and BETTER solution. A sign is cheap. Nothing more simple or direct than that. And a lot of times, that simpler and more direct approach was job training.
So I found myself becoming a big proponent signs and training!
But I'm not ignoring the fact that sometimes a completely automated means to force a certain behavior is a bad idea. I like shock collars. LOL
All that being said, here is my implementation of the no motion before home op.:
The following functions are put in the Screen Load script.
function InhibitMotion(inhibit)
local inst = mc.mcGetInstance('InhibitMotion()')
local rc, hSigInhitbitMotion
hSigInhitbitMotion, rc = mc.mcSignalGetHandle(inst, mc.ISIG_MOTION_INHIBIT)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 600, 'Could not retrieve ISIG_MOTION_INHIBIT signal handle!')
return
end
if (inhibit) then
rc = mc.mcSignalSetState(hSigInhitbitMotion, 1) -- raise the mc.ISIG_MOTION_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 602, 'Could not set ISIG_MOTION_INHIBIT signal state to 1!')
return
end
else
rc = mc.mcSignalSetState(hSigInhitbitMotion, 0) -- lower the mc.ISIG_MOTION_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 604, 'Could not set ISIG_MOTION_INHIBIT signal state to 0!')
return
end
end
end
function InhibitJog(inhibit)
local inst = mc.mcGetInstance('InhibitMotion()')
local rc, hSigInhitbitJog
hSigInhitbitJog, rc = mc.mcSignalGetHandle(inst, mc.ISIG_JOG_INHIBIT)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 601, 'Could not retrieve ISIG_JOG_INHIBIT signal handle!')
return
end
if (inhibit) then
rc = mc.mcSignalSetState(hSigInhitbitJog, 1) -- raise the mc.ISIG_JOG_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 603, 'Could not set ISIG_JOG_INHIBIT signal state to 1!')
return
end
else
rc = mc.mcSignalSetState(hSigInhitbitJog, 0) -- lower the mc.ISIG_JOG_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 605, 'Could not set ISIG_JOG_INHIBIT signal state to 0!')
return
end
end
end
function InhibitMotionAndJog(inhibit)
InhibitMotion(inhibit)
InhibitJog(inhibit)
end
function CheckHomed()
local inst = mc.mcGetInstance('CheckHomed()')
local homedX, homedY, homedZ, homed, rc, hSigInhitbitMotion, inhibitMotion
homedX, rc = mc.mcAxisIsHomed(inst, mc.X_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5000, 'Could not retrieve X axis homed condition!')
return
end
homedY, rc = mc.mcAxisIsHomed(inst, mc.Y_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5001, 'Could not retrieve Y axis homed condition!')
return
end
homedZ, rc = mc.mcAxisIsHomed(inst, mc.Z_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5002, 'Could not retrieve Z axis homed condition!')
return
end
hSigInhitbitMotion, rc = mc.mcSignalGetHandle(inst, mc.ISIG_MOTION_INHIBIT)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5003, 'Could not retrieve ISIG_MOTION_INHIBIT signal handle!')
return
end
inhibitMotion, rc = mc.mcSignalGetState(hSigInhitbitMotion)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5005, 'Could not retrieve ISIG_MOTION_INHIBIT signal state!')
return
end
homed = homedX and homedY and homedZ
if ((homed == 0) and (inhibitMotion == 0)) then
InhibitMotionAndJog(true)
elseif ((homed == 1) and (inhibitMotion == 1)) then
InhibitMotionAndJog(false)
end
end
And put this one liner in your PLC script:
CheckHomed()
Steve
-
Also, the PMC could be used to accomplish the same thing.
Steve
-
Yeah... the PMC rules for this kind of stuff. It is a one rung'er. :)
Unfortunately, I broke the PMC editor in builds 4394 to 4410. A new dev build will be there soon. But you can try it out just dropping the .pmc and .lua files in your Pmc directory and then telling the screen set to use them. Like I said, only the PMC Editor was broken. I tried to get fancy and had an epic failure. LOL
Both the scripts above and this pmc file raise ISIG_MOTION_INHIBIT (Gode/MDI) and ISIG_JOG_INHIBIT (jogging).
Steve
-
Simply put a sign on the computer.... Machine Must be Homed before any other movement!
This. Simply brilliant!!! :)
Way back when, I was a systems analyst. Believe it or not, systems analysts existed before computers got so accessible/popular. System analysts were basically problem solvers when trying to improve any system, be it a manual or automated system of any type. It could be logistics flow of material through a plant, or simply how to keep track of shipment items when they are loaded onto a truck. And later on when computers became "the way" to solve problems, everyone wanted to do things that way. But sometimes, the more direct approach was the cheaper and BETTER solution. A sign is cheap. Nothing more simple or direct than that. And a lot of times, that simpler and more direct approach was job training.
So I found myself becoming a big proponent signs and training!
But I'm not ignoring the fact that sometimes a completely automated means to force a certain behavior is a bad idea. I like shock collars. LOL
All that being said, here is my implementation of the no motion before home op.:
The following functions are put in the Screen Load script.
function InhibitMotion(inhibit)
local inst = mc.mcGetInstance('InhibitMotion()')
local rc, hSigInhitbitMotion
hSigInhitbitMotion, rc = mc.mcSignalGetHandle(inst, mc.ISIG_MOTION_INHIBIT)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 600, 'Could not retrieve ISIG_MOTION_INHIBIT signal handle!')
return
end
if (inhibit) then
rc = mc.mcSignalSetState(hSigInhitbitMotion, 1) -- raise the mc.ISIG_MOTION_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 602, 'Could not set ISIG_MOTION_INHIBIT signal state to 1!')
return
end
else
rc = mc.mcSignalSetState(hSigInhitbitMotion, 0) -- lower the mc.ISIG_MOTION_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 604, 'Could not set ISIG_MOTION_INHIBIT signal state to 0!')
return
end
end
end
function InhibitJog(inhibit)
local inst = mc.mcGetInstance('InhibitMotion()')
local rc, hSigInhitbitJog
hSigInhitbitJog, rc = mc.mcSignalGetHandle(inst, mc.ISIG_JOG_INHIBIT)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 601, 'Could not retrieve ISIG_JOG_INHIBIT signal handle!')
return
end
if (inhibit) then
rc = mc.mcSignalSetState(hSigInhitbitJog, 1) -- raise the mc.ISIG_JOG_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 603, 'Could not set ISIG_JOG_INHIBIT signal state to 1!')
return
end
else
rc = mc.mcSignalSetState(hSigInhitbitJog, 0) -- lower the mc.ISIG_JOG_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 605, 'Could not set ISIG_JOG_INHIBIT signal state to 0!')
return
end
end
end
function InhibitMotionAndJog(inhibit)
InhibitMotion(inhibit)
InhibitJog(inhibit)
end
function CheckHomed()
local inst = mc.mcGetInstance('CheckHomed()')
local homedX, homedY, homedZ, homed, rc, hSigInhitbitMotion, inhibitMotion
homedX, rc = mc.mcAxisIsHomed(inst, mc.X_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5000, 'Could not retrieve X axis homed condition!')
return
end
homedY, rc = mc.mcAxisIsHomed(inst, mc.Y_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5001, 'Could not retrieve Y axis homed condition!')
return
end
homedZ, rc = mc.mcAxisIsHomed(inst, mc.Z_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5002, 'Could not retrieve Z axis homed condition!')
return
end
hSigInhitbitMotion, rc = mc.mcSignalGetHandle(inst, mc.ISIG_MOTION_INHIBIT)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5003, 'Could not retrieve ISIG_MOTION_INHIBIT signal handle!')
return
end
inhibitMotion, rc = mc.mcSignalGetState(hSigInhitbitMotion)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5005, 'Could not retrieve ISIG_MOTION_INHIBIT signal state!')
return
end
homed = homedX and homedY and homedZ
if ((homed == 0) and (inhibitMotion == 0)) then
InhibitMotionAndJog(true)
elseif ((homed == 1) and (inhibitMotion == 1)) then
InhibitMotionAndJog(false)
end
end
And put this one liner in your PLC script:
CheckHomed()
Steve
Thank you Steve!
The code works very well. It is exactly what I was looking for.
-
Yeah... the PMC rules for this kind of stuff. It is a one rung'er. :)
Unfortunately, I broke the PMC editor in builds 4394 to 4410. A new dev build will be there soon. But you can try it out just dropping the .pmc and .lua files in your Pmc directory and then telling the screen set to use them. Like I said, only the PMC Editor was broken. I tried to get fancy and had an epic failure. LOL
Both the scripts above and this pmc file raise ISIG_MOTION_INHIBIT (Gode/MDI) and ISIG_JOG_INHIBIT (jogging).
Steve
Awesome! It worked with both methods but the one with PMC is much simpler.
I did not know before what PMC was but just after watching the following video from the support I was able to install your script
successfully.
https://www.youtube.com/watch?v=jVhH9qyjjf0
The script is basically fine and does it's job - prevents a crash.
There is one thing that I would like to fix though. When Cycle Start is pressed Mach4 will still run a first few lines of code. I assume that is because of cycle time being minimum 1 ms.
Is there a way to just grey out the Cycle start button until the machine is homed?
-
It will run G code up to the point where there is movement and then stop. It is motion inhibit, not cycle start inhibit. So there are will be that distinction.
Steve