Nesting Subroutine

More
7 years 5 months ago #134808 by BigJohnT
Nesting Subroutine was created by BigJohnT
I spend a few minutes this morning making a nesting subroutine, it's not 100% done but will nest the parts. I still need to add rotation so the parts nest better.

nest-test.ngc
Code:
; quantity, X step over, subroutine file, feed o<nest> call [2][6][123][25] M2

nest.ngc
Code:
o<nest> sub ; #1 number of repeats ; #2 X offset ; #3 sub to call ; #4 feed rate F[#4] o100 repeat [#1] (msg, test) ; Set X0 Y0 G10 L20 P0 X0 Y0 o[#3] call ; move to next position G91 G10 L2 P0 R0 G0 X[#2] G90 G10 L20 P0 X0 o100 endrepeat o<nest> endsub

123.ngc
Code:
o<123> sub G1 X0 Y0 X0 Y5 X1 Y5 X1 Y1 X5 Y1 X5 Y0 X0 Y0 o<123> endsub

Enjoy
JT

Please Log in to join the conversation.

More
7 years 5 months ago #134813 by Glemigobles
Replied by Glemigobles on topic Nesting Subroutine
Big thank you, I can already see crosschecking with the documentation that while I used to achieve coordinate system offsets with G92, the particular effect I wanted them for is better gained by using G10 L2/20 in LinuxCNC.

In fact, G10 is more of a direct LCNC replacement for my old G92/93 than the actual G92 to which I looked first. For example, the Philips 432 control included axis rotation in G92 and offered absolute/incremental offsets via G93/92. To get the same effects in LCNC it's necessary to use G10.

Now I need to get a grip on calling programs from programs through o codes. The latter are completely new to me.

Please Log in to join the conversation.

More
7 years 4 months ago #137446 by Larry
Replied by Larry on topic Nesting Subroutine
Hi Big John:

This is probably a stupid question, but since nest.ngc is a callable subroutine I don't think you need a m2 command at the end plus I believe o<nest> sub should be replaced with o<nest> endsub. If this code is still under development it might be useful to look at my topic titled, "Spiral Subroutine". That code nests subroutines 3 levels deep.

Please Log in to join the conversation.

More
7 years 4 months ago #137483 by BigJohnT
Replied by BigJohnT on topic Nesting Subroutine
At one time for some reason I thought every subroutine needed M2, dunno where I got that idea. Good catch on the endsub...

JT

Please Log in to join the conversation.

Time to create page: 0.126 seconds
Powered by Kunena Forum