- Posts: 863
- Thank you received: 0
SPINBOX DATA to G-Code Variable
11 years 8 months ago #55651
by ArcEye
Replied by ArcEye on topic SPINBOX DATA to G-Code Variable
Looking good!
Have a good read of the pyVCP docs page, because I changed a lot of the widgets a while back.
Now not only can some widgets be pre-set to a value, but also enabling the 'param-pin' allows their value to be changed remotely.
Therefore this allow their state to be saved and restored again, which is what I wrote it for, but opens up the way for values to be passed to and from gcode.
As you have shown, the value in a spinbox can be used in gcode.
If you write a user M199 code which contains something like
halcmd setp pyvcp.spinbox0.param_pin $1
Then you can call
M199 P 123
which will result in the spinbox0 being set to 123 - the reverse process.
Also have a look in the sample configs/apps/pyvcp
It has been parred down from the original full config I submitted, but still shows examples of widgets being set by other widgets etc using the param-pin interface
regards
Have a good read of the pyVCP docs page, because I changed a lot of the widgets a while back.
Now not only can some widgets be pre-set to a value, but also enabling the 'param-pin' allows their value to be changed remotely.
Therefore this allow their state to be saved and restored again, which is what I wrote it for, but opens up the way for values to be passed to and from gcode.
As you have shown, the value in a spinbox can be used in gcode.
If you write a user M199 code which contains something like
halcmd setp pyvcp.spinbox0.param_pin $1
Then you can call
M199 P 123
which will result in the spinbox0 being set to 123 - the reverse process.
Also have a look in the sample configs/apps/pyvcp
It has been parred down from the original full config I submitted, but still shows examples of widgets being set by other widgets etc using the param-pin interface
regards
Please Log in to join the conversation.
11 years 8 months ago #55665
by Askjerry
Replied by Askjerry on topic SPINBOX DATA to G-Code Variable
The document i have been reading is this one:
linuxcnc.org/docs/html/hal/pyvcp.html
Making progress... now fiddling with the probe again... routines work great, then they get the "move with probe tripped" and "move when not in contact"... blah blah... playing with debounce settings, Probe feed-rates, etc. Bringing it all together slowly. But I'm making steady progress now... so that's good. (Might even be an issue with my relay circuit)... tempted to make a solid-state version... but that's a whole other post.
Jerry
Making progress... now fiddling with the probe again... routines work great, then they get the "move with probe tripped" and "move when not in contact"... blah blah... playing with debounce settings, Probe feed-rates, etc. Bringing it all together slowly. But I'm making steady progress now... so that's good. (Might even be an issue with my relay circuit)... tempted to make a solid-state version... but that's a whole other post.
Jerry
Please Log in to join the conversation.
11 years 1 month ago #63238
by Askjerry
Replied by Askjerry on topic SPINBOX DATA to G-Code Variable
Getting back to this thread...
I can now send data from a pyVCP panel to G-Code like an ACE... no problem and thanks!!!
Example: I want to evaluate the speed of a spindle and wait until it has slowed down before switching directions... so we wait until the spindle is less than 100 RPM to avoid blowing a breaker. The pyVCP has a meter with a hal pin called "spindle-speed" in actual RPM. Given this... I have learned that I can reference it in G-Code as...
#<_hal[pyvcp.spindle-speed]>
Then do whatever I need...
So thanks so much for that... but now I'm scratching my head with something ArcEye said about passing variables BACK to the pyvcp panel... something I could really use in a project to send canned messages by just sending a number and having graphics icons displayed... would look cool too.
I installed the following in a test panel...
So in G-Code I should be able to send back 123.456 and the display would show that. If I get that far... then I'll have the concept enough to create everything else. I see that there are a few parts to this... and i only need to get a handle on how they tie together... I think I'm close.
In reading ArcEye's text... I believe I need to set up something like this in the HAL or CUSTOM_POSTGUI.HAL file... but not 100% sure...
halcmd setp pyvcp.my-number.param_pin $1
Then he said to do something like this... presumably in the G-Code... M199 P 123
That's where I'm doing a bit of head scratching... looking up the M-Codes... I see there are M100 to M199 which... if I understand this correctly... are treated internally as M1nn where nn is 00 to 99. And if so... I would think that halcmd setp pyvcp.my-number.param_pin $1 would reference M101 instead of M199... hence my confusion.
In other words... _pin$00 to _pin$99 to associate with M100 through M199 inclusive.
So I'm a bit confused... if I had five <number> boxes... let's call the halpins "alpha", "beta","charlie","delta", and "foxtrot"... I would obviously need something like...
Right?
And would they then attach to M101 through M105?
I'll experiment... if I get it... I'll post results. It will be cool to make interactive display that tells the status of G-Code without DEBUG, MSG, or PRINT appearing on the bottom of the display.
What would REALLY be cool... would be a new TEXTBOX widget or be able to pass text to a LABEL... hint hint.
Yeah... I'm reading...
linuxcnc.org/docs/html/man/man1/halcmd.1.html
linuxcnc.org/docs/html/hal/halmodule.html
and it's not making sense to me... :blush:
This one... linuxcnc.org/docs/html/gcode/m-code.html...ser_defined_commands a little bit...
but when I get to the #!/bin/bash I'm lost... not making sense to me.
I can now send data from a pyVCP panel to G-Code like an ACE... no problem and thanks!!!
Example: I want to evaluate the speed of a spindle and wait until it has slowed down before switching directions... so we wait until the spindle is less than 100 RPM to avoid blowing a breaker. The pyVCP has a meter with a hal pin called "spindle-speed" in actual RPM. Given this... I have learned that I can reference it in G-Code as...
#<_hal[pyvcp.spindle-speed]>
Then do whatever I need...
Code:
O <set-spindle-forward> sub
M05
o100 while [#<_hal[pyvcp.spindle-speed]> GT 99]
o100 endwhile
M03 S500
O <set-spindle-forward> endsub
So thanks so much for that... but now I'm scratching my head with something ArcEye said about passing variables BACK to the pyvcp panel... something I could really use in a project to send canned messages by just sending a number and having graphics icons displayed... would look cool too.
I installed the following in a test panel...
Code:
<number>
<halpin>"my-number"</halpin>
<font>("Helvetica",24)</font>
<format>"+4.4f"</format>
</number>
In reading ArcEye's text... I believe I need to set up something like this in the HAL or CUSTOM_POSTGUI.HAL file... but not 100% sure...
halcmd setp pyvcp.my-number.param_pin $1
Then he said to do something like this... presumably in the G-Code... M199 P 123
That's where I'm doing a bit of head scratching... looking up the M-Codes... I see there are M100 to M199 which... if I understand this correctly... are treated internally as M1nn where nn is 00 to 99. And if so... I would think that halcmd setp pyvcp.my-number.param_pin $1 would reference M101 instead of M199... hence my confusion.
In other words... _pin$00 to _pin$99 to associate with M100 through M199 inclusive.
So I'm a bit confused... if I had five <number> boxes... let's call the halpins "alpha", "beta","charlie","delta", and "foxtrot"... I would obviously need something like...
Code:
halcmd setp pyvcp.alpha.param_pin $1
halcmd setp pyvcp.beta.param_pin $2
halcmd setp pyvcp.charlie.param_pin $3
halcmd setp pyvcp.delta.param_pin $4
halcmd setp pyvcp.foxtrot.param_pin $5
And would they then attach to M101 through M105?
I'll experiment... if I get it... I'll post results. It will be cool to make interactive display that tells the status of G-Code without DEBUG, MSG, or PRINT appearing on the bottom of the display.
What would REALLY be cool... would be a new TEXTBOX widget or be able to pass text to a LABEL... hint hint.
Code:
<textbox>
<halpin>"my-display"</halpin>
<font>("Helvetica",10)</font>
<fg>#000000</fg>
<bg>#FFFFFF</bg>
</textbox>
Yeah... I'm reading...
linuxcnc.org/docs/html/man/man1/halcmd.1.html
linuxcnc.org/docs/html/hal/halmodule.html
and it's not making sense to me... :blush:
This one... linuxcnc.org/docs/html/gcode/m-code.html...ser_defined_commands a little bit...
but when I get to the #!/bin/bash I'm lost... not making sense to me.
Please Log in to join the conversation.
11 years 1 month ago #63240
by ArcEye
Replied by ArcEye on topic SPINBOX DATA to G-Code Variable
Wrong track I'm afraid
M199 is a file name, it just happens to be mostly numbers
$1 is the first command line parameter (argument)
$2 is the second, etc
M199 P123 Q456 from gcode
calls M199 with $1 = 123.000000 and $2 = 456.000000
so note that it will be a float value, whether that was what you input or not, which can cause problems.
regards
M199 is a file name, it just happens to be mostly numbers
$1 is the first command line parameter (argument)
$2 is the second, etc
M199 P123 Q456 from gcode
calls M199 with $1 = 123.000000 and $2 = 456.000000
so note that it will be a float value, whether that was what you input or not, which can cause problems.
regards
Please Log in to join the conversation.
11 years 1 month ago #63247
by andypugh
Be aware that these values might not update at the times you expect them to. Especially in Auto mode.
M66 is rather more reliable, and can actually be programmed to wait too.
M68.
Then net mysignal motion.analog-out-00 => pyVCP.input.pin in the postgui HAL
Replied by andypugh on topic SPINBOX DATA to G-Code Variable
Askjerry wrote: #<_hal[pyvcp.spindle-speed]>
Be aware that these values might not update at the times you expect them to. Especially in Auto mode.
M66 is rather more reliable, and can actually be programmed to wait too.
So thanks so much for that... but now I'm scratching my head with something ArcEye said about passing variables BACK to the pyvcp panel... something I could really use in a project to send canned messages by just sending a number and having graphics icons displayed... would look cool too.
M68.
Then net mysignal motion.analog-out-00 => pyVCP.input.pin in the postgui HAL
Please Log in to join the conversation.
11 years 4 weeks ago #63298
by Askjerry
Replied by Askjerry on topic SPINBOX DATA to G-Code Variable
I was staring at this with that duhhh :blink: face... going wahhhhh????
Then the light bulb went on. :ohmy:
I see....
linuxcnc.org/docs/html/gcode/m-code.html#_m68_analog_output
So I would link them up in the HAL file to my panel widgets...
Then in G-Code...
M68 E02 Q123 would push "123" to the second analog output... pyVCP.charlie
And "charlie" would need to be able to handle the float number... or I would need to convert it.
So in my previous example using the number box... with a pyvcp.my-number I would simple need the following in the HAL file...
net my-number motion.analog-out-00 => pyvcp.my-number
Then pass data via M68 E00 Qnnn.nnnn where nnn.nnnn is the number I want to pass.
Let me give that a try...
That got it... experiment time!
Thanks folks!
jerry
Then the light bulb went on. :ohmy:
I see....
linuxcnc.org/docs/html/gcode/m-code.html#_m68_analog_output
So I would link them up in the HAL file to my panel widgets...
Code:
alpha motion.analog-out-00 => pyVCP.apha
beta motion.analog-out-01 => pyVCP.beta
charlie motion.analog-out-02 => pyVCP.charlie
delta motion.analog-out-03 => pyVCP.delta
Then in G-Code...
M68 E02 Q123 would push "123" to the second analog output... pyVCP.charlie
And "charlie" would need to be able to handle the float number... or I would need to convert it.
So in my previous example using the number box... with a pyvcp.my-number I would simple need the following in the HAL file...
net my-number motion.analog-out-00 => pyvcp.my-number
Then pass data via M68 E00 Qnnn.nnnn where nnn.nnnn is the number I want to pass.
Let me give that a try...
Attachment not found
That got it... experiment time!
Thanks folks!
jerry
Please Log in to join the conversation.
11 years 4 weeks ago #63319
by cncbasher
Replied by cncbasher on topic SPINBOX DATA to G-Code Variable
slow down Jerry , before you blow a gasket !
Please Log in to join the conversation.
11 years 4 weeks ago #63342
by Askjerry
Replied by Askjerry on topic SPINBOX DATA to G-Code Variable
Are you kidding... I already figured out how to convert float to u32 (integer) and pass it to image buttons with multiple states.
Now I can have a status indicator with a different graphic for...
Or a graphics panel that looks like a display screen with canned messages...
All kinds of new options now.
Now I can have a status indicator with a different graphic for...
- Spindle Running
- Spindle At Speed
- Spindle Slowing
- Spindle Stopped
Or a graphics panel that looks like a display screen with canned messages...
- Phase 1 - Spindle Starting - Keep Hands Clear
- Mount the part - On the Run/Safe switch, select RUN
- Remove the Part - Rotate 180 Degrees and Press Start
- Phase 2 - Spindle Starting - Keep Hands Clear
- Part is complete - Flip the switch to SAFE and remove the part.
All kinds of new options now.
Please Log in to join the conversation.
8 years 1 month ago #116936
by JesusAlos
Replied by JesusAlos on topic SPINBOX DATA to G-Code Variable
Hi. Following the ArcEye example, I trying to execute this gcode:
M3 S400
F1000
G1 X0 Y0
G4 P#<_hal[pyvcp.spinbox0]>
G1 X10 Y0
G4 P#<_hal[pyvcp.spinbox0]>
G1 X10 Y10
G4 P#<_hal[pyvcp.spinbox0]>
G1 X0 Y10
G4 P#<_hal[pyvcp.spinbox0]>
G1 X0 Y0
G4 P#<_hal[pyvcp.spinbox0]>
M5
M30
But the pause time value don't change while the machine is executing the Gcode.
Are there a solution to change the variable Gcode value during the machine is executing the Gcode?
Thank.
M3 S400
F1000
G1 X0 Y0
G4 P#<_hal[pyvcp.spinbox0]>
G1 X10 Y0
G4 P#<_hal[pyvcp.spinbox0]>
G1 X10 Y10
G4 P#<_hal[pyvcp.spinbox0]>
G1 X0 Y10
G4 P#<_hal[pyvcp.spinbox0]>
G1 X0 Y0
G4 P#<_hal[pyvcp.spinbox0]>
M5
M30
But the pause time value don't change while the machine is executing the Gcode.
Are there a solution to change the variable Gcode value during the machine is executing the Gcode?
Thank.
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4739
- Thank you received: 2
8 years 1 month ago #116939
by Todd Zuercher
Replied by Todd Zuercher on topic SPINBOX DATA to G-Code Variable
Could you use m66 and parameter #5399. To input your value?
Please Log in to join the conversation.
Time to create page: 0.125 seconds
