If the macro can ask for the value of the variabl

More
11 Aug 2014 01:16 - 11 Aug 2014 01:44 #49663 by bubels
Hello,

This is my first topic on the forum so hello everyone.

I can not get it to find answers to the question whether the macro can ask for the value of a variable or retrieve this value, eg. from ngcgui.

The CAM generates code which is calling for example. Macros M91. This macro needs to work a numerical variable but is determined by the operator.

Someone tell which way to go?

Add 20:42

I have found this:

20. Named parameters and HAL items
To read arbitrary HAL pins, signals and parameters from G-code, use the following named parameter syntax:
#<_hal[hal_name]>
where hal_name may be a pin, parameter or signal name.
Example:
(debug, #<_hal[motion-controller.time]>)
Access of HAL items is read-only. Currently, only all-lowercase HAL names can be accessed this way.
EXISTS can be used to test for the presence of a given HAL item:
o100 if [EXISTS[#<_hal[motion-controller.time]>]]
(debug, [motion-controller.time] exists: #<_hal[motion-controller.time]>)
o100 else
(debug, [motion-controller.time] does not exist)
o100 endif
This feature was motivated by the desire for stronger coupling between user interface components like GladeVCP and PyVCP to act as paramter source for driving NGC file behaviour. The alternative - going through the M6x pins and wiring them - has a limited, non-mmemonic namespace and is unncessary cumbersome just as a UI/Interpreter communications mechanism.


It is light in the tunnel for me.
How can I creat a prameter in hal?
Last edit: 11 Aug 2014 01:44 by bubels.

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

More
12 Aug 2014 01:47 #49716 by andypugh

This macro needs to work a numerical variable but is determined by the operator.


I am starting to think that there ought to be a G-code for this...

But, as there isn't you need to do it in a number of steps.

First you need somewhere to put the number, such as a GladeVCP or PyVCP panel.

PyVCP is quicker, GladeVCP is a lot more flexible. Both will create a graphical textbox and will make a HAL "pin" that holds the value entered.
www.linuxcnc.org/docs/html/hal/pyvcp.html
www.linuxcnc.org/docs/html/gui/gladevcp.html
If you are using the latest version of LinuxCNC then you can configure the system to allow G-code access to HAL items as described in the documentation you found.

Having decided that there should be a G-code, we could consider creating one:
www.linuxcnc.org/docs/html/remap/structure.html
You mention M91, and that is free. So add
REMAP = M91 python=numberbox
Then you can write a bit of Python code to ask for a value and to set/create a G-code parameter:

(I had a quick play around, but I have other things to do today, and I didn't actually get it working)

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

Time to create page: 0.159 seconds
Powered by Kunena Forum