On/Off button in code
09 Oct 2022 15:24 #253811
by RoberCNC
On/Off button in code was created by RoberCNC
Hello community.
I would like to know how I can control a button that I currently have in the GUI through code. This only turns on or off a relay that controls a vacuum cleaner. Initially I had thought to do it via M8 just as I have the coolant with M7, the problem with this is that M9 would turn off both and I am interested in controlling them independently. I imagine that the correct thing is assigning a user-defined M (M100-M199) but I don't know how to do it.
All help is welcome.
Attached file in case it helps.
Thank you very much.
I would like to know how I can control a button that I currently have in the GUI through code. This only turns on or off a relay that controls a vacuum cleaner. Initially I had thought to do it via M8 just as I have the coolant with M7, the problem with this is that M9 would turn off both and I am interested in controlling them independently. I imagine that the correct thing is assigning a user-defined M (M100-M199) but I don't know how to do it.
All help is welcome.
Attached file in case it helps.
Thank you very much.
Please Log in or Create an account to join the conversation.
10 Oct 2022 07:54 #253854
by HansU
Replied by HansU on topic On/Off button in code
Have you looked at the example in linuxcnc.org/docs/2.9/html/gcode/m-code.html#mcode:m100-m199?
Your case is described in the example "M101 Example File".
Your case is described in the example "M101 Example File".
The following user(s) said Thank You: RoberCNC
Please Log in or Create an account to join the conversation.
10 Oct 2022 08:06 #253855
by RoberCNC
Replied by RoberCNC on topic On/Off button in code
Yes, in fact I have an M100 for something else, but it is G code itself, the case now is to activate and deactivate an output of the Table. It is as easy as assigning to activate M102 (for example) and in the file put:
"#!/bin/bash
setp hm2_5i25.0.7i76.0.0.output-01 true
exit 0"
And M103 to false to disable?
It is something completely new and unknown to me, then I would be linking it with its corresponding button in the GUI.
"#!/bin/bash
setp hm2_5i25.0.7i76.0.0.output-01 true
exit 0"
And M103 to false to disable?
It is something completely new and unknown to me, then I would be linking it with its corresponding button in the GUI.
Please Log in or Create an account to join the conversation.
10 Oct 2022 19:23 #253906
by HansU
Yes it is
You only have to put that file in the correct folder (specified in "PROGRAM_PREFIX=") and set the executable bit of that file.
And don't forget the "halcmd":
Replied by HansU on topic On/Off button in code
Yes, in fact I have an M100 for something else, but it is G code itself, the case now is to activate and deactivate an output of the Table. It is as easy as assigning to activate M102 (for example) and in the file put:
"#!/bin/bash
setp hm2_5i25.0.7i76.0.0.output-01 true
exit 0"
And M103 to false to disable?
It is something completely new and unknown to me, then I would be linking it with its corresponding button in the GUI.
Yes it is
You only have to put that file in the correct folder (specified in "PROGRAM_PREFIX=") and set the executable bit of that file.
And don't forget the "halcmd":
#!/bin/bash
halcmd setp hm2_5i25.0.7i76.0.0.output-01 true
exit 0
The following user(s) said Thank You: RoberCNC
Please Log in or Create an account to join the conversation.
10 Oct 2022 19:37 #253908
by RoberCNC
Replied by RoberCNC on topic On/Off button in code
OMG!!!!
I had done the test and it didn't work, it was the halcmd that I was missing!!!
Thank you very much, I will continue to try.
How do I get the is-on, on and off signals to link to the GU button and LED?
I had done the test and it didn't work, it was the halcmd that I was missing!!!
Thank you very much, I will continue to try.
How do I get the is-on, on and off signals to link to the GU button and LED?
Please Log in or Create an account to join the conversation.
10 Oct 2022 20:46 #253915
by HansU
The simplest would be to use a PyVCP:
linuxcnc.org/docs/html/gui/pyvcp.html
linuxcnc.org/docs/html/gui/pyvcp-examples.html
But it depends a bit on which GUI you are using, a GladeVCP or QtVCP might look more suitable:
linuxcnc.org/docs/2.9/html/gui/gladevcp.html
linuxcnc.org/docs/2.9/html/gui/qtvcp-vcp-panels.html
Replied by HansU on topic On/Off button in code
How do I get the is-on, on and off signals to link to the GU button and LED?
The simplest would be to use a PyVCP:
linuxcnc.org/docs/html/gui/pyvcp.html
linuxcnc.org/docs/html/gui/pyvcp-examples.html
But it depends a bit on which GUI you are using, a GladeVCP or QtVCP might look more suitable:
linuxcnc.org/docs/2.9/html/gui/gladevcp.html
linuxcnc.org/docs/2.9/html/gui/qtvcp-vcp-panels.html
The following user(s) said Thank You: tommylight, RoberCNC
Please Log in or Create an account to join the conversation.
19 Oct 2022 15:12 #254533
by RoberCNC
Replied by RoberCNC on topic On/Off button in code
Sorry for taking time to answer mate.
Thank you very much for the help and info! I'll be doing tests
Thank you very much for the help and info! I'll be doing tests
Please Log in or Create an account to join the conversation.
Time to create page: 0.083 seconds