Subroutine to wait for input using M66
- automata
- Offline
- Premium Member
-
Less
More
- Posts: 82
- Thank you received: 65
03 Sep 2011 07:08 #12923
by automata
Subroutine to wait for input using M66 was created by automata
I had this problem to wait for an input before executing the next line of gcode. like a punching machine / drilling mahcine.
This is a subroutine to to do that.
Put this subrouting at the start of your Gcode file and call it as:
This will wait for input 0 to go low and keep re-checking the input at every 1s.
The changes made to the HAL file are to link motion.digital-in-00 to the input pin. In my case I am using the MESA 7i43 card and I want a time delay after the input is received..
HAL File....
PLEASE USE ABOVE AT YOUR OWN DISCRETION and after understanding what it does... This is what works for me. Ofcourse I will also be changing this to make it better and am very open to suggestion to that same effect.
Regards,
automata
This is a subroutine to to do that.
O<wait_for_input_fall> sub
M66 P0 L2 Q1
O<loop> while [#5399 EQ -1]
M66 P0 L2 Q1
O<loop> endwhile
O<wait_for_input_fall> endsub
Put this subrouting at the start of your Gcode file and call it as:
O<wait_for_input_fall> call
This will wait for input 0 to go low and keep re-checking the input at every 1s.
The changes made to the HAL file are to link motion.digital-in-00 to the input pin. In my case I am using the MESA 7i43 card and I want a time delay after the input is received..
HAL File....
#use halui to configure estop... and machine on
#
net estop-in <= hm2_7i43.0.gpio.047.in_not
net estop-in => iocontrol.0.emc-enable-in
#load a time delay...
loadrt timedelay count=2
#add the time delay function to the servo-thread
addf timedelay.0 servo-thread
#set the on-delays and offselays in seconds
setp timedelay.0.on-delay 0.25
setp timedelay.0.off-delay 0.0
net estop-in => timedelay.0.in
net machineon <= timedelay.0.out
net machineon => halui.machine.on
# start the program...
# and step-program-input with mode auto
loadrt and2 count=2
loadrt edge count=1
addf and2.0 servo-thread
addf and2.1 servo-thread
addf timedelay.1 servo-thread
setp timedelay.1.on-delay 0.4
setp timedelay.1.off-delay 0.0
#connect andgate to step program edge
net step-program-input hm2_7i43.0.gpio.046.in => and2.0.in0
#and the input with machine on signal
net machineon => and2.0.in1
net step-and-machine and2.0.out => and2.1.in0
net modeauto halui.mode.is-auto => and2.1.in1
net step-program and2.1.out => timedelay.1.in
net progstep timedelay.1.out => motion.digital-in-00
PLEASE USE ABOVE AT YOUR OWN DISCRETION and after understanding what it does... This is what works for me. Ofcourse I will also be changing this to make it better and am very open to suggestion to that same effect.
Regards,
automata
The following user(s) said Thank You: nkp
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 23297
- Thank you received: 4938
03 Sep 2011 22:49 #12939
by andypugh
Replied by andypugh on topic Re:Subroutine to wait for input using M66
automata wrote:
I am a bit confused. Are you saying that M66 P0 L2 doesn't work properly?
M66 L2 is meant to wait P seconds for a falling edge on input Q. There shouldn't be any need for the rest of the subroutine.
I had this problem to wait for an input before executing the next line of gcode. like a punching machine / drilling mahcine.
This is a subroutine to to do that.
O<wait_for_input_fall> sub M66 P0 L2 Q1 O<loop> while [#5399 EQ -1] M66 P0 L2 Q1 O<loop> endwhile O<wait_for_input_fall> endsub
I am a bit confused. Are you saying that M66 P0 L2 doesn't work properly?
M66 L2 is meant to wait P seconds for a falling edge on input Q. There shouldn't be any need for the rest of the subroutine.
Please Log in or Create an account to join the conversation.
- automata
- Offline
- Premium Member
-
Less
More
- Posts: 82
- Thank you received: 65
04 Sep 2011 06:51 #12946
by automata
Replied by automata on topic Re:Subroutine to wait for input using M66
Hi Andy,
I am not saying the M66 does not work. Infact it works perfectly.
The routine is to wait indefinitely for an input or stop / abort being pressed.
Although this routine keeps writing to the disk at 1s intervals (to the .var file). So it is a problem if you want to minimize disk writes (if you are using SSD's or Flash based devices with finite write cycles and hve not implemented read-only root file systems).
regards,
automata
I am not saying the M66 does not work. Infact it works perfectly.
The routine is to wait indefinitely for an input or stop / abort being pressed.
Although this routine keeps writing to the disk at 1s intervals (to the .var file). So it is a problem if you want to minimize disk writes (if you are using SSD's or Flash based devices with finite write cycles and hve not implemented read-only root file systems).
regards,
automata
The following user(s) said Thank You: nkp
Please Log in or Create an account to join the conversation.
Time to create page: 0.055 seconds