Reading a global number parameter in python handler
- scsmith1451
-
Topic Author
- Away
- Premium Member
-
Less
More
- Posts: 80
- Thank you received: 3
22 Jun 2026 17:58 #347236
by scsmith1451
Reading a global number parameter in python handler was created by scsmith1451
Hi;
I have a gladevcp panel that I would like to display a counter from a gcode routine. In my gcode I have something like lcnt = lcnt + 1 to track the iteration number of a loop. IF I understand the documentation correctly I could assign this value to a global number parameter, say #1000 by using the syntax #1000 = lcnt. That all seems simple enough.
Now I would like to:
1. Read the contents of #1000 in a python handler associated with the gladevcp panel and display the value on the panel. (I understand the display part, just not the read part)
2. Know when the value of #1000 changes to update the display
Is this possible? How would I code python to read the value? How could I know if the value has been changed by the gcode? Is there an on_changed signal for variable updates?
Kind regards,
I have a gladevcp panel that I would like to display a counter from a gcode routine. In my gcode I have something like lcnt = lcnt + 1 to track the iteration number of a loop. IF I understand the documentation correctly I could assign this value to a global number parameter, say #1000 by using the syntax #1000 = lcnt. That all seems simple enough.
Now I would like to:
1. Read the contents of #1000 in a python handler associated with the gladevcp panel and display the value on the panel. (I understand the display part, just not the read part)
2. Know when the value of #1000 changes to update the display
Is this possible? How would I code python to read the value? How could I know if the value has been changed by the gcode? Is there an on_changed signal for variable updates?
Kind regards,
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4718
- Thank you received: 2114
22 Jun 2026 18:26 #347239
by Aciera
Replied by Aciera on topic Reading a global number parameter in python handler
Gcode parameters live inside the interpreter and are not directly accessible from outside the gcode program. However there are ways to expose the values from within the Gcode program.
In your case you could use 'M68 E0 Q#1000' to send the parameter value to the hal pin 'motion.analog-out-00' which you can then connect to your gladevcp display.
The M68 code would need to be called every time after the #1000 parameter is changed in the gcode.
linuxcnc.org/docs/html/gcode/m-code.html#mcode:m68
linuxcnc.org/docs/html/man/man9/motion.9.html
In your case you could use 'M68 E0 Q#1000' to send the parameter value to the hal pin 'motion.analog-out-00' which you can then connect to your gladevcp display.
The M68 code would need to be called every time after the #1000 parameter is changed in the gcode.
linuxcnc.org/docs/html/gcode/m-code.html#mcode:m68
linuxcnc.org/docs/html/man/man9/motion.9.html
The following user(s) said Thank You: scsmith1451
Please Log in or Create an account to join the conversation.
Moderators: HansU
Time to create page: 0.227 seconds