NC Macros start from the GUI
- mBender
- Offline
- Premium Member
-
- Posts: 113
- Thank you received: 11
I have written a few macros which I want to start from the GUI. I am fine with the pyvcp part, But how do I get a specific NC Programm as a Hal pin? I know it’s possible, saw it in a video on YouTube, but can’t find that video and can’t find it in the documentation either.
Mike
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
- Posts: 4328
- Thank you received: 1927
MDI_COMMAND = " your first command here (this will be halui.mdi-command-00)
MDI_COMMAND = " your second command here (this will be halui.mdi-command-01)
...
Then create the hal connection in your 'postguihal' file:
net :type0-button <= pyvcp.type0-button => halui.mdi-command-00
net :type1-button <= pyvcp.type1-button => halui.mdi-command-01
...
Please Log in or Create an account to join the conversation.
- mBender
- Offline
- Premium Member
-
- Posts: 113
- Thank you received: 11
1. How can I contribute to the documentation of LinuxCNC? I don't see it on Github,... I would love to add some comments to it.
3. I was able to call a subroutine and use a GUI variable to work within this subroutine. My question is: I thought I could give a subroutine a parameter/variable when I call the subroutine. However, I can not find a good example or documentation on how to do that.
I currently have solved it with having the hal pin variable directly in the subroutine. My subroutine and ini call below:
My file probeximinus.ngc
o<probexminus> sub ; Beginning of subprogram probexminus
N10 G91 G38.2 x-20 F100 ; Go fast to workpiece until Probe pin changes signal
N20 G1 x1 F900 ; Retract 1mm
N30 G91 G38.2 x-3 F10 ; Go slow to workpiece until Probe pin changes signal
N40 G1 x#<_hal[pyvcp.retract-distance-f]> F900 ; Retract according to GUI variable
o<probexminus> endsub ; End of subprogram
M99 ; Return from subprogram 100
My current ini call looks like this:
MDI_COMMAND = O<probexminus> CALL
What I would like is something like is:
MDI_COMMAND = O<probexminus> #<_hal[pyvcp.retract-distance-f]> CALL
With this subroutine:
o<probexminus> sub ; Beginning of subprogram probexminus
#1 = #<_hal[pyvcp.retract-distance-f]>
N10 G91 G38.2 x-20 F100 ; Go fast to workpiece until Probe pin changes signal
N20 G1 x1 F900 ; Retract 1mm
N30 G91 G38.2 x-3 F10 ; Go slow to workpiece until Probe pin changes signal
N40 G1 x#1 F900 ; Retract according to GUI variable
o<probexminus> endsub ; End of subprogram
M99 ; Return from subprogram 100
However, that does not work.
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
- Posts: 4328
- Thank you received: 1927
github.com/LinuxCNC/linuxcnc/tree/master/docs/man
3. Yes you can pass parameter values with an o-call. Have a look at 'configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/xyzac_switchkins.ngc':
; zmax zmin r frate n a b c dist
o<xyzac_switchkins_sub> call [10] [5] [10][1000][3][20][0][45][20]
m2
With 'configs/sim/axis/vismach/5axis/table-rotary-tilting/remap_subs/xyzac_switchkins_sub.ngc':
; ngcgui-compatible subroutine
(info: helix in each quadrant at angles A,C)
o<xyzac_switchkins_sub>sub
#<zmax> = #1 (=10)
#<zmin> = #2 (= 5)
#<r> = #3 (=10 radius)
#<frate> = #4 (=1000 feedrate)
#<n> = #5 (=3 n circles)
#<a> = #6 (=30 A angle)
#<b> = #7 (=0 B angle NA)
#<c> = #8 (=45 C angle)
#<dist> = #9 (=20 distance)
; quadrant I
M429 ;Identity kinematics
g53 g0 x0y0 z#<zmax> a0 c0 ;MACHINE coordinates
g10l20p0 x0y0 z#<zmax> a0 c0 ;new g54
g0 x+#<dist> y+#<dist> z#<zmax> ;move to pattern center position
o<helix_ac> call [#<zmax>][#<zmin>][#<r>][#<frate>][#<n>][#<a>][#<b>][#<c>]
; quadrant II
M429 ;Identity kinematics
g53 g0 x0y0 z#<zmax> a0 c0
g10l20p0 x0y0 z#<zmax> a0 c0
g0 x-#<dist> y+#<dist> z#<zmax>
o<helix_ac> call [#<zmax>][#<zmin>][#<r>][#<frate>][#<n>][#<a>][#<b>][#<c>]
; quadrant III
M429 ;Identity kinematics
g53 g0 x0y0 z#<zmax> a0 c0
g10l20p0 x0y0 z#<zmax> a0 c0
g0 x-#<dist> y-#<dist> z#<zmax>
o<helix_ac> call [#<zmax>][#<zmin>][#<r>][#<frate>][#<n>][#<a>][#<b>][#<c>]
; quadrant IV
M429 ;Identity kinematics
g53 g0 x0y0 z#<zmax> a0 c0
g10l20p0 x0y0 z#<zmax> a0 c0
g0 x+#<dist> y-#<dist> z#<zmax>
o<helix_ac> call [#<zmax>][#<zmin>][#<r>][#<frate>][#<n>][#<a>][#<b>][#<c>]
;final position
M429 ;Identity kinematics
g53 g0 x0y0 z#<zmax> ;MACHINE coordinates
g10l20p0 x0y0 z#<zmax> ;new g54
o<xyzac_switchkins_sub>endsub
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
- Posts: 4328
- Thank you received: 1927
linuxcnc.org/docs/devel/html/gcode/o-code.html
O- Call takes up to 30 optional arguments, which are passed to the subroutine as #1, #2 , …, #N. Parameters from #N+1 to #30 have the same value as in the calling context. On return from the subroutine, the values of parameters #1 through #30 (regardless of the number of arguments) will be restored to the values they had before the call. Parameters #1 - #30 are local to the subroutine.
Because 1 2 3 is parsed as the number 123, the parameters must be enclosed in square brackets. The following calls a subroutine with 3 arguments:
O- Call Example
o100 sub
(test if parameter #2 is greater than 5)
o110 if [#2 GT 5]
(return to top of subroutine if test is true)
o100 return
o110 endif
(this only gets executed if parameter #2 is not greater than 5)
(DEBUG, parameter 1 is [#1])
(DEBUG, parameter 3 is [#3])
o100 endsub
o100 call [100] [2] [325]
Subroutine bodies may not be nested. They may only be called after they are defined. They may be called from other functions, and may call themselves recursively if it makes sense to do so. The maximum subroutine nesting level is 10.
Subroutines can change the value of parameters above #30 and those changes will be visible to the calling code. Subroutines may also change the value of global named parameters (i.e. parameters whose names begin with the underscore character "_").
Please Log in or Create an account to join the conversation.
- mBender
- Offline
- Premium Member
-
- Posts: 113
- Thank you received: 11
Please Log in or Create an account to join the conversation.
- mBender
- Offline
- Premium Member
-
- Posts: 113
- Thank you received: 11
Please Log in or Create an account to join the conversation.
- mBender
- Offline
- Premium Member
-
- Posts: 113
- Thank you received: 11
Sorry to bring this up again, i just wanted to update the documents, but under that link I can‘t find it. I don‘t think this linuxcnc.org/docs/stable/html/config/ini-config.html comes from git.1. Have a look in the 'man' folders (man1, man3, man9):
github.com/LinuxCNC/linuxcnc/tree/master/docs/man
Please Log in or Create an account to join the conversation.
- phillc54
-
- Offline
- Platinum Member
-
- Posts: 5723
- Thank you received: 2095
github.com/LinuxCNC/linuxcnc/blob/master...nfig/ini-config.adoc
Please Log in or Create an account to join the conversation.