Switch mode from Auto to Man after abort
28 Sep 2024 03:42 #310942
by spumco
Switch mode from Auto to Man after abort was created by spumco
Starting new thread from here:
forum.linuxcnc.org/qtpyvcp/53922-probe-c...axes?start=10#310882
Topic: Aborted probing routine leaves LCNC in auto mode. Jogging, MDI, or other recovery actions not possible without the user manually switching modes.
@Lcette:
Yes, I think it's a chicken and egg problem.
@Aciera's response:
My idea - untested - is to do it through HAL using <on_abort.ngc>. I think Aciera's suggestion would be more graceful, especially if there's a way to point the python script to an INI section to connect the appropriate motion pin and other settings.
setp timedelay.N.on-delay 2
setp oneshot.N.width 1
net SIGNAL1 <= motion.digital-out-n
net SIGNAL1 => oneshot.N.in
net SIGNAL2 <= oneshot.N.out
net SIGNAL2 => timedelay.N.in
net SIGNAL3 <= timedelay.N.out
net SIGNAL3 => halui.mode.manual
I'll test out my HAL experiment this weekend and report back.
forum.linuxcnc.org/qtpyvcp/53922-probe-c...axes?start=10#310882
Topic: Aborted probing routine leaves LCNC in auto mode. Jogging, MDI, or other recovery actions not possible without the user manually switching modes.
@Lcette:
Yes, I think it's a chicken and egg problem.
@Aciera's response:
It's not possible to switch to manual from gcode but you could set an analog output in gcode to indicate to a python component that you want to switch to manual mode when the gcode finishes or aborts (ie the interpreter switches to IDLE):
Warning: Spoiler!
#!/usr/bin/env python3
import time
import hal
import linuxcnc
h = hal.component("auto2manual")
h.ready()
s = linuxcnc.stat()
c = linuxcnc.command()
# wait time in milliseconds between checks
check_interval = 500
flag = False
check_timer_start = round(time.time()*1000)
def ok_for_mdi():
s.poll()
return not s.estop and s.enabled and (s.homed.count(1) == s.joints) and (s.interp_state == linuxcnc.INTERP_IDLE)
try:
while 1:
if round(time.time()*1000) >= check_timer_start + check_interval:
s.poll()
if s.task_mode == linuxcnc.MODE_AUTO:
if hal.get_value('motion.analog-out-00') == 1:
flag = True
if flag == True and ok_for_mdi():
c.mode(linuxcnc.MODE_MDI)
c.wait_complete() # wait until mode switch executed
c.mdi("M68 E0 Q0")
c.wait_complete() # wait until analog output reset
c.mode(linuxcnc.MODE_MANUAL)
c.wait_complete() # wait until mode switch executed
flag = False
check_timer_start = round(time.time()*1000)
except KeyboardInterrupt:
raise SystemExit
import time
import hal
import linuxcnc
h = hal.component("auto2manual")
h.ready()
s = linuxcnc.stat()
c = linuxcnc.command()
# wait time in milliseconds between checks
check_interval = 500
flag = False
check_timer_start = round(time.time()*1000)
def ok_for_mdi():
s.poll()
return not s.estop and s.enabled and (s.homed.count(1) == s.joints) and (s.interp_state == linuxcnc.INTERP_IDLE)
try:
while 1:
if round(time.time()*1000) >= check_timer_start + check_interval:
s.poll()
if s.task_mode == linuxcnc.MODE_AUTO:
if hal.get_value('motion.analog-out-00') == 1:
flag = True
if flag == True and ok_for_mdi():
c.mode(linuxcnc.MODE_MDI)
c.wait_complete() # wait until mode switch executed
c.mdi("M68 E0 Q0")
c.wait_complete() # wait until analog output reset
c.mode(linuxcnc.MODE_MANUAL)
c.wait_complete() # wait until mode switch executed
flag = False
check_timer_start = round(time.time()*1000)
except KeyboardInterrupt:
raise SystemExit
My idea - untested - is to do it through HAL using <on_abort.ngc>. I think Aciera's suggestion would be more graceful, especially if there's a way to point the python script to an INI section to connect the appropriate motion pin and other settings.
%
o<on_abort> sub
...[i]normal abort codes[/i]...
[b]M64 Pn[/b]
o<on_abort> endsub
%
setp timedelay.N.on-delay 2
setp oneshot.N.width 1
net SIGNAL1 <= motion.digital-out-n
net SIGNAL1 => oneshot.N.in
net SIGNAL2 <= oneshot.N.out
net SIGNAL2 => timedelay.N.in
net SIGNAL3 <= timedelay.N.out
net SIGNAL3 => halui.mode.manual
I'll test out my HAL experiment this weekend and report back.
The following user(s) said Thank You: Unlogic
Please Log in or Create an account to join the conversation.
Time to create page: 0.162 seconds