[Home]SubProgramFiles

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Subprograms

The O-word system allows for subprograms. If you are executing an ngc file, it can contain 2 types of sub.

Subprograms are files external to the main file. Subroutines are contained inside the main file.

the syntax for Subprogram is                                  example

o<filename> call                   o<clearancedrill> call
  or
oFilenumber call                   o123  call

the angle brackets are neccesary for filename they are not needed for labelname

filenames can be descriptive, and filenumbers can be enigmatic. ( ask anyone used to old fanuc systems )

filenumber needs no delimiters (no angle brackets)

all files must be located in the folder described by PROGRAM_PREFIX (usually the nc_files subdirectory) Note that a filename will be converted to lowercase and stripped of spaces so it is best to use neither.

in main, what follows the o must be file name.

Optionally a label or number can be added after the CALL statement. This is ignored by the interpreter, but can be used to clarify things for the opertaor.

as in:

o<labelName> call mumblemumble

example files

The main file is namnum.ngc, it calls 2 subprograms.

First it calls fred.ngc, which in turn calls ethel.ngc.

Program flow returns from ethel to fred to namnum.

Next namnum calls 333.ngc (NB: it's just referred to as lucy, it is named 333.ngc)

upload:subprog.png

namnum.ngc

 g90 g20 g17
 g0 x0 y0 z0 f30
 x.5
 g02 i-.5 j0
 g0 z.1
 x0 y0
 o<fred> call mumblemumble
 g20 f30
 g0 z1
 o333 call lucy
 g20 f30
 g90
 g0 z.1
 g0 x0 y0 z0
 m2

fred.ngc

 o<fred> sub
 g91g20f30
 g1x.5y.5
 x-1
 y-1
 x1
 y1
 x-.5y-.5
 z1
 o<ethel> call ethel
 o<fred> endsub
 M2

333.ngc

 o333 sub
 g91g20f30
 g1x.7071y.7071
 x-1.414
 y-1.414
 x1.414
 y1.414
 x-.7071y-.7071
 o333 endsub
 M2

ethel.ngc

 o<ethel> sub
 g91g20f30
 g1x.6y.6
 x-1.2
 y-1.2
 x1.2
 y1.2
 x-.6y-.6
 o<ethel> endsub
 M2

links

http://linuxcnc.org/docs/2.3/html/gcode_main.html#O%20Codes

unknown

namespace... what happens with 2 uses of o123? say: one in main and another inside a subprogram

kudos

Kenneth Lerman gave us some nice tools here Thanks!

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited December 3, 2010 11:57 am by Andypugh (diff)
Search:
Published under a Creative Commons License