M-code to toggle macrobutton not working on QtDragon

More
09 Feb 2025 15:44 - 09 Feb 2025 16:13 #321066 by Guytou
       Hi,
I am trying to assign to a macrobutton in QtDragon an o-word script that would allow me to toggle the button to switch on and off a laser.
The laser is connected to an output pin (hal_pi_gpio.pin-10-out) and this pin is connected to a signal (laser-on).  But, it doesn't seem to work. Enclosed are the custom M100 macro (to obtain the actual value of the output pin) and the o-word subroutine called by MDI-COMMAND = o<laser_on> call. Any idea why this won't work. Any suggestions how to do this?  Many thanks !!
Attachments:
Last edit: 09 Feb 2025 16:13 by Guytou.

Please Log in or Create an account to join the conversation.

More
09 Feb 2025 18:42 #321089 by cmorley
Is there any indication of something working when you press the macro button?

What does this line mean? (doesn't seem valid to me)o<hal_value> include "/tmp/gcode_var.ngc"

Please Log in or Create an account to join the conversation.

More
09 Feb 2025 19:44 #321106 by Guytou
Hi, to be really honest, this line came from ChatGPT, but indeed, I am still trying to understand where this comes from . Didn't found anything in the docs describing this include thing. What I am trying to do is to pass a variable from a macro (state of output pin) to a subroutine. Since subroutine variable can only be flaoting points, I changed the VALUE in the macro to be 1.0 if if true and 0.0 if false. Now the macro does work, however the subroutine gives the error message that there is a wrong command in the subroutine.... must indeed be the 'include' thing

Please Log in or Create an account to join the conversation.

More
10 Feb 2025 10:18 #321148 by Guytou
Hi, I think I am progressing, but not completely.Enclosed my new M100 and subroutine files.The purpose is to assign to a macrobutton in QtDragon an o-word script with a MDI-COMMAND that would allow me to toggle on and off a laser. (I have a 10W from Creality), besides my spindle that will of course be switched off.The laser is connected to an output pin (hal_pi_gpio.pin-10-out) and this pin is connected to a signal (laser-on). In the subroutine, I want to check what the status of this output pin is and then switching OFF if it is ON or switching ON if it is OFF.Since the hal-pi-gpio is connected to a signal, I cannot use getp and are using gets. But since subroutines do not accept halcmd gets commandes, I made a macro (M100) to fetch the status of the hal-pi-gpio. So far so good.Now when pushing the button, M100 does his job and stores the status of the hal-pi-gpio in a variable (

File Attachment:

File Name: M100.zip
File Size:0 KB

File Attachment:

File Name: laser_on.ngc
File Size:0 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
12 Feb 2025 12:55 #321337 by Guytou
In the meantime I solved the issue. I connected the Raspberry Pi gpio output pin to motion.digital-in-00 and now I can read this RPI output pin with M66. No need for a macro anymore...

Please Log in or Create an account to join the conversation.

Time to create page: 0.093 seconds
Powered by Kunena Forum