Hello Guest it is April 23, 2019, 06:41:03 AM

Author Topic: Subroutine attempt  (Read 3809 times)

0 Members and 1 Guest are viewing this topic.

Subroutine attempt
« on: May 28, 2008, 06:52:03 PM »
I am trying to use a subroutine to produce several copies of a part on a single piece of plate but with no obvious progress.
So far this is on the study PC not in the workshop.
Using the manual and answers on this type of problem given in the Forum I have written a program to cut two squares by calling a subroutine twice. If I run this program the sequence seems to jump the subroutine. If I single step through the program it still seems to skip the subroutine. If I start single stepping in the sub-routine it appears to execute correctly.

So my first question is - can such a program be single stepped through OK in Mach3 when correctly programmed?
I have also noticed that generally M98 & M99 are used but sometimes examples use G98 G99; are these typing errors?
Neither version helped me though.

tmsmith

Offline Graham Waterworth

*
  • *
  •  1,851 1,851
  • West Yorkshire, England
    • View Profile
Re: Subroutine attempt
« Reply #1 on: May 29, 2008, 02:19:43 PM »
Hi Malcolm,

firstly, the G98/G99 are typos, ignore them. G98 and G99 are used in drilling routines.

This is the basic layout of a program with a sub and a datum shift for more than 1 part on a plate:-

%
O0001 (MAIN PROGRAM)

G21 G40 G00 G80

N1 (FIRST TOOL)
T1 M6
G00 G90 G43 X0 Y0 Z25. H1 S2000 M3 (initial move)
M98 P0002 (call sub)
G52 X100. (shift local datum for second part)
M98 P0002 (call sub)
G52 X0 (cancel shift)
(do more shifts and sub calls here)
G00 Z25.(rapid safe)
M30

O0002 (SUB PROGRAM)
G00 X0 Y0
Z1.
G01 Z-10. F50.
G00 Z1.
M99
%

Try and get into the habit of putting the % signs top and bottom of the program code, the main reason for failing sub programs is that the carriage return is missing off of the last line.

Graham.
America gave us powered flight, England the steam train and Germany the car.  Who invented the first boat?
Re: Subroutine attempt
« Reply #2 on: May 29, 2008, 06:25:07 PM »
Thanks Graham,
I will try your prog. tomorrow.

Malcolm
Re: Subroutine attempt
« Reply #3 on: May 30, 2008, 04:23:17 PM »
Graham,
I typed your code into 'Notepad' and loaded it into Mach3.
I have tried your code, ie simulated in Mach3, and of cause it worked fine in single stepping and normal run mode though the graphics showed it cutting the same part twice despite the G52 shift of origin (expected).

I then typed in my code, very similar to yours, but it would not jump into the subroutine!.
Checked it in 'Word' and all carriage returns seemed OK.
Tried various changes to the code but without success so getting quite frustrated.

Will hopefully attache my code and I wonder if you could look at it and let me know what the problem is.

Malcolm Smith

Offline Graham Waterworth

*
  • *
  •  1,851 1,851
  • West Yorkshire, England
    • View Profile
Re: Subroutine attempt
« Reply #4 on: May 31, 2008, 03:36:39 AM »
Hi Malcolm,

try this version of your code, the only line that can not have a line number is the program number line eg. N105 O0002

This is true for the main program and any subs.

Graham.
« Last Edit: May 31, 2008, 04:25:24 AM by Graham Waterworth »
America gave us powered flight, England the steam train and Germany the car.  Who invented the first boat?
Re: Subroutine attempt
« Reply #5 on: May 31, 2008, 05:46:51 PM »
Graham, You are a genius.

I dont recall seeing the info about the line numbers in the manual;and I always use them which explains everything.
Now I can stop banging my head against the wall.

thanks
Malcolm
Re: Subroutine attempt
« Reply #6 on: June 02, 2008, 06:12:54 PM »
It is in the manual. Read more carefully next time.

tmsmith