SPINBOX DATA to G-Code Variable

More
03 Feb 2015 23:30 #55651 by ArcEye
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
The following user(s) said Thank You: Askjerry

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

More
04 Feb 2015 13:26 #55665 by Askjerry
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

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

More
30 Sep 2015 11:36 - 30 Sep 2015 12:41 #63238 by Askjerry
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...
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...
<number>
    		<halpin>"my-number"</halpin>
    		<font>("Helvetica",24)</font>
    		<format>"+4.4f"</format>
</number>
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...
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
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.
<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. :unsure:
Last edit: 30 Sep 2015 12:41 by Askjerry.

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

More
30 Sep 2015 13:29 #63240 by ArcEye
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

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

More
30 Sep 2015 15:03 #63247 by andypugh

#<_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 or Create an account to join the conversation.

More
01 Oct 2015 02:16 #63298 by Askjerry
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...
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...



That got it... experiment time!
Thanks folks!
jerry
Attachments:

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

More
01 Oct 2015 15:27 #63319 by cncbasher
slow down Jerry , before you blow a gasket !

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

More
01 Oct 2015 23:25 #63342 by Askjerry
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...
  • Spindle Running
  • Spindle At Speed
  • Spindle Slowing
  • Spindle Stopped
or example...

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. B)
The following user(s) said Thank You: Nico2017

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

More
01 Sep 2018 01:16 #116936 by JesusAlos
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.

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

More
01 Sep 2018 02:34 #116939 by Todd Zuercher
Could you use m66 and parameter #5399. To input your value?

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

Time to create page: 0.143 seconds
Powered by Kunena Forum