Wait for input in custom M code?
19 Nov 2014 15:20 - 19 Nov 2014 16:02 #53199
by jeeybee
Wait for input in custom M code? was created by jeeybee
I´m working on a custom M code that changes gear on a spinde and need it to wait for an input that the gear is in place so it can turn off the valve.
It seem like the usual HAL commands will just skip the row if the conditions are not met but I need it to wait or loop while the input is inactive, and also a max time with error message would be nice.
How could this be accomplished?
It seem like the usual HAL commands will just skip the row if the conditions are not met but I need it to wait or loop while the input is inactive, and also a max time with error message would be nice.
How could this be accomplished?
Last edit: 19 Nov 2014 16:02 by jeeybee.
Please Log in or Create an account to join the conversation.
19 Nov 2014 16:49 - 19 Nov 2014 16:49 #53201
by ArcEye
Replied by ArcEye on topic Wait for input in custom M code?
Hi
You should not need to write your own
M66 will wait for a specified input type for Q seconds
If the period expires, parameter #5399 is set to -1 and you can test that value and send a warning message / halt the program etc
eg
M66 P0 L3 Q10
(digital input 0, wait for pin to go high for 10 secs)
M101 P#5399
(where M101 tests $1 to see if it is -1 and acts accordingly)
www.linuxcnc.org/docs/devel/html/gcode/m...ec:M66-Input-Control
regards
You should not need to write your own
M66 will wait for a specified input type for Q seconds
If the period expires, parameter #5399 is set to -1 and you can test that value and send a warning message / halt the program etc
eg
M66 P0 L3 Q10
(digital input 0, wait for pin to go high for 10 secs)
M101 P#5399
(where M101 tests $1 to see if it is -1 and acts accordingly)
www.linuxcnc.org/docs/devel/html/gcode/m...ec:M66-Input-Control
regards
Last edit: 19 Nov 2014 16:49 by ArcEye.
Please Log in or Create an account to join the conversation.
19 Nov 2014 16:59 #53202
by jeeybee
Replied by jeeybee on topic Wait for input in custom M code?
Yes but this is just the first step, later I would like to do it something like this:
M3 Sxx is issued
Check the S value and set a variable
For every gear there is a condition:
if that is that then set outputs
check input that the gear is in right position
start the spindle
So I guess all the code should be in the HAL file when I want it to do this and I think I can manage most of it, its just the wait for the input I dont understand how to do.
Or maybe I think about it the wrong way?
M3 Sxx is issued
Check the S value and set a variable
For every gear there is a condition:
if that is that then set outputs
check input that the gear is in right position
start the spindle
So I guess all the code should be in the HAL file when I want it to do this and I think I can manage most of it, its just the wait for the input I dont understand how to do.
Or maybe I think about it the wrong way?
Please Log in or Create an account to join the conversation.
19 Nov 2014 17:29 #53203
by ArcEye
You really need a gearchange component, the wait etc can be handled inside it
The basic one is here
www.linuxcnc.org/docs/devel/html/man/man9/gearchange.9.html
Les Newall has done several more complex, multi gear components variations of which are running on huge milling machines.
This is but one example from a GNL machine with 4 gears
regards
Replied by ArcEye on topic Wait for input in custom M code?
Or maybe I think about it the wrong way?
You really need a gearchange component, the wait etc can be handled inside it
The basic one is here
www.linuxcnc.org/docs/devel/html/man/man9/gearchange.9.html
Les Newall has done several more complex, multi gear components variations of which are running on huge milling machines.
This is but one example from a GNL machine with 4 gears
regards
Please Log in or Create an account to join the conversation.
19 Nov 2014 17:30 #53204
by ArcEye
Replied by ArcEye on topic Wait for input in custom M code?
Or, alternately do it via classic ladder.
A lot of applications are perhaps better suited to it, especially for non-programmers
A lot of applications are perhaps better suited to it, especially for non-programmers
Please Log in or Create an account to join the conversation.
19 Nov 2014 17:45 #53205
by jeeybee
Replied by jeeybee on topic Wait for input in custom M code?
Hmm yes I have taken a look at it and that would probably be the right choice.
Thank you for your help.
Thank you for your help.
Please Log in or Create an account to join the conversation.
19 Nov 2014 18:01 #53207
by jeeybee
Replied by jeeybee on topic Wait for input in custom M code?
I have looked some more at the comp file you posted and it seem to be pretty straight forward and easy to change but how do I load the component into linuxcnc?
Like this: ?
sudo apt-get install linuxcnc-dev
comp --install gear4gnl.comp
Then loadrt xxx
and net the pins like sol1 to the appropriate output
Like this: ?
sudo apt-get install linuxcnc-dev
comp --install gear4gnl.comp
Then loadrt xxx
and net the pins like sol1 to the appropriate output
Please Log in or Create an account to join the conversation.
19 Nov 2014 21:07 #53213
by ArcEye
Yep, that is pretty much it, just remember to addf the component to a thread, it won't do anything otherwise
regards
Replied by ArcEye on topic Wait for input in custom M code?
I have looked some more at the comp file you posted and it seem to be pretty straight forward and easy to change but how do I load the component into linuxcnc?
Like this: ?
sudo apt-get install linuxcnc-dev
comp --install gear4gnl.comp
Then loadrt xxx
and net the pins like sol1 to the appropriate output
Yep, that is pretty much it, just remember to addf the component to a thread, it won't do anything otherwise
regards
Please Log in or Create an account to join the conversation.
Time to create page: 0.197 seconds