Trying to loop incremental code

116 views
Skip to first unread message

jaco...@gmail.com

unread,
Dec 14, 2018, 7:08:22 PM12/14/18
to Pocket NC
I've got a project that has repetitive features (blades) about the b table axis. The gcode for a single feature is about 5mb, so having all 6 features is too big. I changed the code to incremental and ran a few minutes of it on the PNC to verify the code generated correctly. My thought was that I could make the code a sub program and run a macro loop to call the code 6 times. When I made a sample macro the PCN gave the warning that M97 and M98 were not recognized codes.

Are there any other suggestions on how to loop a code multiple times and rotate the B table an additional angle between code repetitions?

Manohj Kumaar

unread,
Dec 14, 2018, 7:27:08 PM12/14/18
to Pocket NC
Hi Jacob,

If all of your blade profiles are same you can use circular pattern to do 3+1 axis machining. Hope this will help out

jaco...@gmail.com

unread,
Dec 14, 2018, 10:04:19 PM12/14/18
to Pocket NC
Manohj,

I don't know what you mean by circular pattern. I know how to make the full 360 pattern in cam. The challenge is that I can't have them all in one .nc file and I don't want to have to baby sit my PNC and load 6 different files throughout the day.

Tokyo Pav

unread,
Dec 15, 2018, 8:44:19 AM12/15/18
to Pocket NC
I’m not sure if pocketnc has it implemented but you could use this kind of technique to overcome the issue.
http://wiki.linuxcnc.org/cgi-bin/wiki.pl?SubProgramFiles
Regards
TP

jaco...@gmail.com

unread,
Dec 15, 2018, 2:26:19 PM12/15/18
to Pocket NC
Tokyo,

Thanks, that link set me to a path were I figured it out.

Subroutines were what worked, thought it seems the PNC doesn't support logical loops (IF, WHILE, etc). http://wiki.linuxcnc.org/cgi-bin/wiki.pl?SubroutineSample

So here is a sample code to explain for others how to repeat incremental or absolute code.

(Start of file)

#500=0 (#500 is an example variable with a starting value of 0, will be used for B angle)

o1000 sub (start of subroutine code to be repeated)
G0 B#500 (rapid movement to B angle stored in #500 value)
(Your g-code here)
o1000 endsub

o1000 call (first call of the subroutine with B = 0 deg)
#500 = [#500+90] (increases stored value of #500 by 90)
o1000 call (2nd call of subroutine, now with B = 90 deg)
#500 = [#500+90] (increases stored value of #500 by 90)
o1000 call (3rd and final call of subroutine, now with B = 180 deg)

M30 (end of file)

Depending on if you have incremental or absolute will change how you do things, but this is an example of what I'll use.


Tokyo Pav

unread,
Dec 15, 2018, 4:53:16 PM12/15/18
to Pocket NC
Excellent work. Thanks for posting how you implemented the solotion. This will help others for sure.
Regards
TP

joum...@gmail.com

unread,
Jan 18, 2019, 12:17:08 PM1/18/19
to Pocket NC
This work will definetly help me later on.
Thank you so much!

joum...@yahoo.com

unread,
Mar 26, 2019, 11:01:55 AM3/26/19
to Pocket NC
It seems I am struggling with the call function...
I did include sub and endsub before the call in the same program, but I get an error: cannot find O100 file.
I manage with a while endwhile loop without the call function.
But I am curious about the exact way of calling subroutines...
If someone can help.

Ross D

unread,
Mar 13, 2020, 11:00:22 AM3/13/20
to Pocket NC
Hi, Thank-You, I used your example, worked GREAT !!   In the past I've only ever used the old Fanuc method with M97, M98, M99  Thank-You again
Reply all
Reply to author
Forward
0 new messages