Passing a value to a subroutine from a Spinbox

More
18 Oct 2014 19:47 #52168 by BigJohnT
I have a plasma file that I might cut 1 part or 24 parts it just depends on the size of the material as I often use drops to cut the parts from. In the past I had a variable at the top of the file for the repeat section below. While this works fine, my fear is that I'll open the file and forget to set the number and it will try and cut more parts than I have material for.

With some suggestions from the IRC I came up with a way to pass the value of the pyvcp spinbox to my G code program. What I did was connect the output of the spinbox to analog in 00 then in my G code file I ran M66 E0 L0 which puts the value from the analog in pin into the #5399 variable. Then I use the #5399 variable in my o100 REPEAT [#5399] to set the number of repetitions of the code. The beauty of this is when I start LinuxCNC the spinbox is 0 so I can't hardly screw up.

JT

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

More
19 Oct 2014 12:48 #52184 by Rick G
Neat idea John,

Rick G

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

More
21 Oct 2014 23:21 - 21 Oct 2014 23:26 #52246 by DaBit
If you can connect the spinbox to a HAL signal, you can also use #<_hal[hal_name]>
Maybe even directly the gladevcp.xxx name?

linuxcnc.org/docs/html/remap/structure.h..._referto_hal_items_a
Last edit: 21 Oct 2014 23:26 by DaBit.
The following user(s) said Thank You: jtc

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

More
22 Oct 2014 05:33 #52258 by BigJohnT
When I tried that with a debug I got "######" instead of the float value of the signal.

JT

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

More
22 Oct 2014 14:06 #52265 by DaBit
Did you also add:

[RS274NGC]
FEATURES =12

to your ini file?

(linuxcnc.org/docs/html/remap/structure.h...d_sub_ini_features_a)

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

More
22 Oct 2014 18:41 #52273 by BigJohnT
Hmmm, no I assume.

JT

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

More
23 Oct 2014 02:20 #52300 by BigJohnT
FEATURES = 8 seemed to do the trick...

JT

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

More
23 Oct 2014 05:12 #52313 by DaBit
FEATURES=12 (8+4) also allows you to read INI file values.
I didn't find a use for that yet, but it might come in handy someday.

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

More
23 Oct 2014 08:19 #52317 by andypugh

FEATURES = 8 seemed to do the trick.


This works nicely at the start of a file. But the values only update when a program is not running, so if you need "live" data the G-code analogue inputs are the way to go.

This was an mah addition, and he has decided it was a mistake. Personally I use it too much to agree, it just needs the limitations to be documented.

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

More
23 Oct 2014 14:34 #52322 by DaBit

This was an mah addition, and he has decided it was a mistake. Personally I use it too much to agree, it just needs the limitations to be documented.


Why is this considered a mistake? It is a blessing to be able to interact with HAL in a much cleaner way than M-codes-calling-bash-scripts-that-in-turn-use-halcmd-to-interact-with-hal. Too bad you cannot set a signal from NGC except through the use of M6x

(probably I should just learn Python and use that instead of NGC code)

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

Time to create page: 0.242 seconds
Powered by Kunena Forum