Subroutine within gcode

Post anything you want to discuss with others about the software.

Subroutine within gcode

Postby Delco » Fri Jul 17, 2020 8:42 am

Does UCCNC support running a subroutine within the gcode like Mach3 does ? if so is the sysntax the same as this example ?

O0001 (MAIN PROGRAM)
G00 G90 G43
etc..
G54
M98 P0002 L1 (call to sub routine, with L being number of times to run it)
G55
M98 P0002 L1 (call to sub routine, with L being number of times to run it)
G58
M98 P0003 L1 (call to sub routine, with L being number of times to run it)
M30

O0002 (SUB PROGRAM)
(SOME CODE)
M99 (return to main program)

O0003 (SUB PROGRAM)
(SOME CODE)
M99 (return to main program)
Delco
 
Posts: 364
Joined: Tue Apr 02, 2019 4:23 am

Re: Subroutine within gcode

Postby Robertspark » Fri Jul 17, 2020 11:56 am

Delco wrote:Does UCCNC support running a subroutine within the gcode like Mach3 does ? if so is the sysntax the same as this example ?


yes

syntax is within the uccnc users manual installed within the C:\uccnc\documentation folder.

the document is specific to the version of uccnc you have installed although these functions have not changed for some time.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Subroutine within gcode

Postby Delco » Fri Jul 17, 2020 11:11 pm

Found it finally withing the documentation , would be nice for the document to include some examples

This bit shows nothing about using the O

Subroutine call: M98
To call a subroutine program: M98 P... L..., where the P parameter defines the number of the
subroutine to call and the L number defines the number of times the subroutine needs to be called.
If the L parameter is not programmed then the default L value of 1 is used.
It is an error if the P parameter is not programmed.
A subroutine call can be placed inside another subroutine. The subroutine stack is 100 level deep.
If a subroutine call is deeper than the subroutine stack size then the stack will get full and a popup
window will indicate this error and the code execution will be stopped. The stack full error is likely
to happen if a subroutine is called from itself which will create an infinate loop and stack overflow.
Return from subroutine: M99
To return from a subroutine program M99.
This will return the line pointer to the code line the call was made.
It is an error if the M99 code was called without an M98 code was called, in this case the code
interpreter will not know where to return the code line pointer and a popup window will indicate
this error and the code execution will stop


Found it in another section though

Subroutines: O
The subroutines are labeled with the 'O' prefix.
Usually the subroutines are placed at the end of the program, after the M30 or M47 code
Delco
 
Posts: 364
Joined: Tue Apr 02, 2019 4:23 am

Re: Subroutine within gcode

Postby Delco » Fri Jul 17, 2020 11:13 pm

Found it finally withing the documentation , would be nice for the document to include some examples

This bit shows nothing about using the O

Subroutine call: M98
To call a subroutine program: M98 P... L..., where the P parameter defines the number of the
subroutine to call and the L number defines the number of times the subroutine needs to be called.
If the L parameter is not programmed then the default L value of 1 is used.
It is an error if the P parameter is not programmed.
A subroutine call can be placed inside another subroutine. The subroutine stack is 100 level deep.
If a subroutine call is deeper than the subroutine stack size then the stack will get full and a popup
window will indicate this error and the code execution will be stopped. The stack full error is likely
to happen if a subroutine is called from itself which will create an infinate loop and stack overflow.
Return from subroutine: M99
To return from a subroutine program M99.
This will return the line pointer to the code line the call was made.
It is an error if the M99 code was called without an M98 code was called, in this case the code
interpreter will not know where to return the code line pointer and a popup window will indicate
this error and the code execution will stop


Found it in another section though

Subroutines: O
The subroutines are labeled with the 'O' prefix.
Usually the subroutines are placed at the end of the program, after the M30 or M47 code



:)

Any good books on subroutines for dummies ?
Delco
 
Posts: 364
Joined: Tue Apr 02, 2019 4:23 am

Re: Subroutine within gcode

Postby Robertspark » Sat Jul 18, 2020 8:10 am

yes, examples would be nice for those sorts of g and m codes (especially when you don't do it for a while then want to write something, and need a quick refresher)

I have a few by Peter Smid on CNC / parametric programming, although uccnc is not as developed as it would be more usable imo YMMV.

....they are available for pdf download if you search for them.... I have both pdfs and some paper copies... I find the books best to find quickly and flick through
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Subroutine within gcode

Postby beefy » Sun Jul 19, 2020 2:37 am

A quick glance through the listed G codes, M codes, and other codes in the UCCNC manual would have gave the answer. Yes the subroutine "O" code could have been mentioned in the subroutine explanation, but seeing as the OP already knows about subroutines in Mach3, and the required "O" code, a quick look in the codes section of the manual would have revealed that.

And as for examples, Google and Youtube have heaps of them. Aren't we talking pretty standard gcode programming here, not some special dialect that Cncdrive would need to explain.
I've never had a need to use subroutines so 5 minutes ago looked at one Youtube instructional video, wrote some very simple gcode (3 pass subroutine, just doing some simple straight line moves) and tried it out in UCCNC.

I was a complete beginner when I first bought Mach3. A read through the codes section told me what it could do. Did the same with the UCCNC manual. Anything the manual did not explain I learned from Google and Youtube. I never really expected a machine controller manual to teach me how to program.
beefy
 
Posts: 449
Joined: Mon Sep 05, 2016 10:34 am

Re: Subroutine within gcode

Postby Robertspark » Sun Jul 19, 2020 6:58 pm

sometimes the syntax can be a little different
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Subroutine within gcode

Postby Delco » Mon Jul 20, 2020 11:54 am

Syntax seems to be the most important part and different between systems and nearly always no examples given .

In a similar vein , does UCCNC support extra work coordinates such as G54P2 etc ? I have looked and can find no mention of it in the manual.
Delco
 
Posts: 364
Joined: Tue Apr 02, 2019 4:23 am

Re: Subroutine within gcode

Postby Robertspark » Mon Jul 20, 2020 6:16 pm

Delco wrote: does UCCNC support extra work coordinates such as G54P2 etc ? I have looked and can find no mention of it in the manual.


no just g54-g59
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Subroutine within gcode

Postby cncdrive » Mon Jul 20, 2020 9:03 pm

There is no mention of G54P2 in the manual, because UCCNC does not support that, it supports the basic offsets only G54 to G59.
G59P2 would be the G59 + 2 more offsets, but as I said UCCNC does not support this.
If you need lots of offsets you could use the G52/G59 temporary offsets.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm


Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: Bing [Bot] and 7 guests