586,102 active members*
2,872 visitors online*
Register for free
Login
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2013
    Posts
    1788

    Subroutines from MDI

    There is a file, mysub.ngc, in the subroutines directory which I want to call from the MDI. If I enter O<mysub> call in the MDI I get an error message saying "EOF reached in (path to currently loaded program) seeking o-word <mysub> from line 0"

    Is it possible to run a subroutine from the MDI? What is the syntax?

  2. #2
    Join Date
    Nov 2012
    Posts
    591

    Re: Subroutines from MDI

    One way is to define an M code in a .hal file to run whatever you need to run, and make sure that .hal file is loaded by your main tormach_mill.hal file.

  3. #3
    Join Date
    Apr 2013
    Posts
    1788

    Re: Subroutines from MDI

    Calling a subroutine from the MDI suits my needs better. If that is impossible I'll try your approach. However, I suspect that I've made some stupid mistake for which I'll hang my head in shame.

  4. #4
    Join Date
    Dec 2008
    Posts
    740

    Re: Subroutines from MDI

    Quote Originally Posted by kstrauss View Post
    Is it possible to run a subroutine from the MDI? What is the syntax?
    I haven't found a way, but I find it easy enough to write a minimal g-code file that just calls the subroutine. If you also want to pass arguments it's usually easier to add them to a text file than typing them into the mdi.
    Step

  5. #5
    Join Date
    Apr 2013
    Posts
    1788

    Re: Subroutines from MDI

    Solved!
    My problem was that I saved the subroutine as gcode/subroutines/mySub.ngc. Changing the filename to mysub.ngc (all lowercase) allows it to work perfectly. Just enter: "O<MYSUB> CALL" from the MDI. I suppose that it is intuitive that a filename referenced as all uppercase must be stored on disk as all lowercase. NOT! Apologies for the interruption.

  6. #6
    Join Date
    Apr 2013
    Posts
    1788

    Re: Subroutines from MDI

    While on the topic of subroutines, is it possible to determine the number of parameters passed to a subroutine? The online examples that I have found check for the parameter having a value of zero to indicate that it was not passed. For my application zero is a valid value for an optional parameter.

  7. #7
    Join Date
    Nov 2012
    Posts
    591

    Re: Subroutines from MDI

    You can do this when REBIND-ing M-codes in the hal + python files, but I don't know how to do it for O-codes.
    If you can make it so that 0 is the default value (does the same thing whether passed or not) then it doesn't matter :-)

  8. #8
    Join Date
    Mar 2008
    Posts
    82

    Re: Subroutines from MDI

    You can also just load the subroutine as you would any other file, and run. it

  9. #9
    Join Date
    Apr 2013
    Posts
    1788

    Re: Subroutines from MDI

    Yes but how do you pass parameters to it? Anyway, all is now good running it as a subroutine from the MDI.

Similar Threads

  1. Subroutines
    By JohnToner in forum Tormach PathPilot™
    Replies: 7
    Last Post: 11-21-2015, 01:12 AM
  2. PathPilot Subroutines
    By Jerry McFarland in forum Tormach PathPilot™
    Replies: 2
    Last Post: 09-21-2015, 05:35 AM
  3. with subroutines
    By Thad Swarfburn in forum G-Code Programing
    Replies: 0
    Last Post: 06-25-2009, 02:37 AM
  4. EMC and Subroutines?
    By watchman in forum LinuxCNC (formerly EMC2)
    Replies: 9
    Last Post: 06-17-2007, 08:30 PM
  5. Oi subroutines help
    By mishikwest in forum Fanuc
    Replies: 1
    Last Post: 08-01-2006, 11:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •