How to run file from another file in?

More
04 Jun 2017 19:07 #94054 by aleksamc
Hi all.

I want to mill big relief that takes much memory.

That's why I want at the end of file open another file to run.

I've found in G-code quick reference "6. Calling Files"

I've make small test program
------main.ngc----
g0 X100
oprog1.ngc call
-------------------------------------------
------prog1.ngc-----------
oprog1.ngc sub
   X200 
   X100
oprog1.ngc endsub
-----------------------------

When I load main.ng in linuxcnc, I have a messege: "Unknown word where unary operation could be"
What I make wrong?
What means "The file must be in the directory pointed to by PROGRAM_PREFIX or SUBROUTINE_PATH in the ini file." in guick reference? Where it should be pointed?

Please Log in or Create an account to join the conversation.

More
04 Jun 2017 19:42 #94055 by Todd Zuercher
First some minor syntax corrections.
------main.ngc----
g0 X100
o<prog1> call
-------------------------------------------
------prog1.ngc-----------
o<prog1> sub
   X200 
   X100
o<prog1> endsub
-----------------------------

The directory(s) your sub program(s) should be saved in is defined in your ini file. The default location is ~/linuxcnc/nc_files. But you can add other directories to the path by adding the line SUBROUTINE_PATH = to the [RS274NGC] section of your ini file and listing up to 10 different directories.
linuxcnc.org/docs/2.6/html/config/ini_co...sub:RS274NGC-section
The following user(s) said Thank You: cuagn, aleksamc

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 09:53 #94079 by aleksamc
It's work good! Thanks a loot!

Please Log in or Create an account to join the conversation.

More
18 Mar 2019 17:10 #128908 by cuagn
Coming back after many years I was missing this important info:
"...The default location is ~/linuxcnc/nc_files. "
Now my subroutines work!
Tnks

Please Log in or Create an account to join the conversation.

More
21 Mar 2019 07:08 #129144 by pl7i92
you can run up to 100k lines to the memory
without reloading g-code
The following user(s) said Thank You: aleksamc

Please Log in or Create an account to join the conversation.

More
24 May 2019 15:39 - 24 May 2019 15:48 #134819 by Glemigobles
Is it possible to use MDI to call a file as a subroutine?

I've been trying to type in o<file> call from the MDI to check if it would work but it wouldn't.

All my file paths in the ini are set to the same folder (both programs and subroutines).

EDIT: I also have no luck trying to run the same file from a program, but in it I don't get any errors, it just doesn't do anything. When I run the command from MDI I get: EOF filepath/masterfile.ngc seeking o-word: o<file> from line 5.
Last edit: 24 May 2019 15:48 by Glemigobles.

Please Log in or Create an account to join the conversation.

More
24 May 2019 16:07 #134822 by Todd Zuercher
Yes you can, but the file you are calling must be properly configured as a subroutine. (it needs to start and end with "o<file> sub" and "o<file> endsub")

Please Log in or Create an account to join the conversation.

More
24 May 2019 16:20 #134824 by Glemigobles
Okay, now I can get the subroutine running from the MDI line, but when it's executed as part of a file, it opens the subroutine but doesn't move. The file is so far really basic:

G90
G54
o<subroutine> call
G10 L20 P1 X-3.15
M2

It also only actually opens the subroutine file when I click on start a few times.

Please Log in or Create an account to join the conversation.

More
24 May 2019 16:28 - 24 May 2019 16:50 #134826 by Glemigobles
Does the subroutine file need to have an M2/M30 code at the end?

I'm trying to do a layout of multiple of the same part. I don't want the spindle to stop in between parts, and I also want the G54 offset to be moved in X with every repetition. So I want a repeat o-code, which will have a call file o-code and a G10 programmed.

But I'm having trouble just running the basic file from a file. Both the master file so far and the subroutine begin and end with % signs. But only the master file sets the offset to G54 and has an M2 at the end.

EDIT: since I'm short on time, I decided to copy the code from the file I wanted to run as a subroutine into the main file, make it into a basic subroutine, and have that repeated. That works, and plots out the toolpath for the whole layout as a bonus. But it would be nice to know how to do it as I'd originally planned. That's because I think it's a tidy way to organize work when you're calling multiple files in the same layout. You see immediately that file x is called twice, while file y is called 15 times, for example.
Last edit: 24 May 2019 16:50 by Glemigobles.

Please Log in or Create an account to join the conversation.

More
24 May 2019 17:00 #134828 by Todd Zuercher
No, subroutines do not need to have M2, M30. And if a sub does contain an M2, M30, or % before the endsub line, that will end the program, rather than return to it. Otherwise I don't think % sign at the beginning or end will matter .

Please Log in or Create an account to join the conversation.

Time to create page: 0.185 seconds
Powered by Kunena Forum