Hello Guest it is April 28, 2024, 05:55:08 AM

Author Topic: Subroutine construction  (Read 3587 times)

0 Members and 1 Guest are viewing this topic.

Subroutine construction
« on: December 18, 2009, 09:44:23 AM »
Hi.
    I got some useful help a couple of weeks ago regarding subroutines.    The programme lay out and sub call are pretty straight foreward.  the one thing that I can't seem to find out is, how to close a subroutine.    I intend to write five routines (P01 to P05)
As these blocks of programme, will follow one after the other, what symbol or letter is required to separate one from the other.    I haven't done any three axis programming for about ten years, but back then a routine was closed by % Is this still the case.    One sub will be a roughing routine with three separate Z depths, how do I call a variable Z depth?   I seem to remember it use to be =#Z  underneath the line move prior to the sub call.    If this is the case where is the variable Z depth designated ie. Z-1.5  Z-3.0 Z-4.5 etc in the actual programme.
Regards.

Offline Sam

*
  • *
  •  987 987
    • View Profile
    • hillbillyhilton.com
Re: Subroutine construction
« Reply #1 on: December 18, 2009, 01:58:45 PM »
You close a sub with an "M99".  It will then start scanning the next line in the main program, after that subs call. The only time I have seen an "%" sign is at the end of the program, and it only serves as a visual indicator for a carriage return. I don't think the actual sign has any code value to it. Are you getting an error or unintended behavior when your trying to end subs?
Quote
what symbol or letter is required to separate one from the other
You don't need to separate the subs by anything. After it sees the M99 at the end of the sub, the main program is resumed scanning.
The sub calls need to be on their own line......

M98 P2
M98 P3
M98 P4

NOT

M98 P2 M98 P3 M98 P4

If your having problems with your code, it might be best to attach it to your reply ("additional options" at the bottom left when your replying) so we can have a look and point you directly to the problem.
"CONFIDENCE: it's the feeling you experience before you fully understand the situation."
Re: Subroutine construction
« Reply #2 on: December 19, 2009, 05:43:00 AM »
Hi. Sam
          I still writting the programme, so I haven't run it yet.    The only three axis control I've ever used was BOSS6.1 which was properly old hat in the late eighties!    The rules then were to start every sub with #1 #2 etc and close every routine with $ not as I thought %
      As I mentioned in my last post, I want to include three Z depths to run in the routine.  With the only control I have experience of, I would have written, as the first line of the sub: G01Z* then when the sub was called in the drive programme the command would appear as:  =#1Z*-1.5
So how would you include this information in the Mach3 format?
Thanks for your help so far.
Regards.
                                Mick

Offline Sam

*
  • *
  •  987 987
    • View Profile
    • hillbillyhilton.com
Re: Subroutine construction
« Reply #3 on: December 19, 2009, 04:29:37 PM »
I'll start by saying that in no way am I well versed in subs, and other code. Most of what I have told you here, and prior post, I dug up in the manual, and referred to prior sub test of my own. I have no idea about boss 6 methods, but from an uneducated guess, I would guess they had their own proprietary code/rules. This is pretty common, especially among older machines and the younger days of NC. You might want to go through the Mach manual, and stick to the methods enclosed. I do believe they are pretty much the industry standard. As far as the Z depth for the subs, it really depends on what your wanting, and how you want to do it. There's more than one way to skin that cat, and giving out misguided advise would certainly not be beneficial to you, or others. I have attached two files that demonstrate basic subs. They both cut a square perimeter, and have two Z depths. The only difference being that the subs are incremental in one file, and absolute in the other. The main program in both are absolute. These should give a general method of construction to learn upon. I believe that to be of any further use for what your trying to accomplish, one would need a detailed description, or even better, a dimensional drawing of exactly what your wanting to cut. If it's not overly difficult/time consuming, I'm sure someone can whip up a program for you, and you can pick it apart to see the exact methods used.
"CONFIDENCE: it's the feeling you experience before you fully understand the situation."
Re: Subroutine construction
« Reply #4 on: December 20, 2009, 06:06:21 AM »
Hi. Sam.
           Thanks for your reply.   Looking at the two examples its pretty clear that all Z- moves are part of the drive programme and not part of the actual sub, as I was use to back in the day.      That being the case writting the programme should be fairly straight foreward.      If I do encounter any problems I'll let you know.
Regards.
                       Mick