Hello Guest it is April 19, 2024, 04:42:22 AM

Author Topic: Nested subroutines  (Read 4796 times)

0 Members and 1 Guest are viewing this topic.

Nested subroutines
« on: February 10, 2012, 06:25:16 AM »
I use a laser to cut up to several hundred small parts. To reduce program size & allow the operators to change quanties each part is a subroutine (holes & cut-outs in the part may also be subroutines) and this subroutine is repeated the required number of times. I currently use an ANCA controller where the subroutines are listed before they are called (& a NUM controller where there is a jump to the main program).
Can this been done with Mach3?
I have 10000s of ANCA programs that I want to be able to use a converter to swap g codes, not move lines around. Also I have a complex post that I would like to modify rather that completely re-write.
Re: Nested subroutines
« Reply #1 on: February 14, 2012, 05:03:09 AM »
Sorted out the nesting subroutines - I cut a row of parts along a sheet, step up, rotate 180deg & cut a row back.
HOWEVER
The part has holes in it cut using incremental subroutines. When cutting at 180 deg, the lead in (G1) cuts in the correct direction but the arc (G2) is upside down - a J5 puts the arc centre 5mm above the start point whatever the rotation.

Why are I's & J's after a G91 not affected by a G68?

Any explanations?
« Last Edit: February 14, 2012, 05:14:40 AM by GordonW »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Nested subroutines
« Reply #2 on: February 14, 2012, 01:25:07 PM »
YEP there are many parts in Mach3 that were never finished and do not work as expected such as G68. Is there a reason you NEED to rotate the part and not just do an offset.

You will also find when using SUBS some thing do not work correctly as well. The G68 problem more than likely is related to the use of the SUBs. Tool comp has problems with subs as well.

Just a thought, (;-) TP
Re: Nested subroutines
« Reply #3 on: February 15, 2012, 03:31:35 AM »
About 50% of the parts we cut are non-rectangular. If I cut a row of right-angle triangles (eg) there is scrap the same size as the triangle, so material cost doubles. If I cut a row at 0 deg & a row at 180 deg I can cut the 2nd row in the scrap left by the 1st row. Sometimes we use fixtures on the bed & it's easier to rotate the coordinate system rather than the fixture.

I try to keep the programs short & simple to allow the operator to change the spacing between parts and number of repeats (programs are associated with parts not jobs).  We are upgrading from ANCA as it can't process fast enough for some of the profiles we cut, and although it has non-standard g-codes it is very operator friendly.

On another thread someone suggested that the fault could be with the toolpath display not simulating correctly. I am currently working offline to get things sorted before we upgrade the machines.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Nested subroutines
« Reply #4 on: February 15, 2012, 11:37:39 AM »
YEs the toopath display has quirks with offsets and maybe rotations . BUT it does always seem to cut correctly.

Do you have a piece of test code that shows the problem that you can post for testing.

(;-) TP
Re: Nested subroutines
« Reply #5 on: February 16, 2012, 03:37:18 AM »
This is an adaptation of a typical ANCA program. It starts with a rotation 180 to start cut at top right corner (away from clamps) keeping X & Y values positive. I haven't bothered with laser on/off & dwells, etc.

(machtest)
G71G90
F2500.
M98P1Q3
G0X100.
Y106.
M98P2Q3
G0X100.Y-8.
M30
O1
(*** NEST 180 DEG ***)
G68R180.
M98P3    
G0X106.Y0.
M99
O2  
(*** NEST 0 DEG ***)
G68R0.
M98P3    
G0X106.Y0.
M99
O3  
(*** MAIN PROGRAM ***)
G92X0.Y0.
G0X15.Y35.
G91
G1Y-5.
G2Y0.J5.
G1Y1.
G90
%M98P4
G0X15.Y15.
M98P4
G0X100.Y-6.
G42D15
G1X100.Y0.
Y25.
G3X75.Y50.I-25.J0.
G1X0.
Y0.
X100.
X101.
G40  
M99
O4  
(*** HOLE ***)
G91
G1X0.Y-4.95
G02X0.Y0.I0.J4.95
G1X0.Y0.5
G90
M99

Thanks
« Last Edit: February 16, 2012, 03:41:17 AM by GordonW »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Nested subroutines
« Reply #6 on: February 16, 2012, 05:11:11 PM »
YEP I can confirm that the code will NOT run correctly in mach3. The problem seems to be the G68. the G42, and G91 and deep nested subs OR a combination of the 3. Each can make it fail in the SUB enviroment.

Just a thought, (;-)
Re: Nested subroutines
« Reply #7 on: February 20, 2012, 02:56:31 AM »
Thanks. Not what I wanted to hear.

We could do this with NUM & ANCA over 20 years ago! We also had an ancient DOS program that could send g-codes to a plotter that could do this.