Hello Guest it is April 20, 2024, 12:56:43 AM

Author Topic: My Script Won't Work On Mach 2 and Won't Display Right On Mach 3 - My Bad?  (Read 3102 times)

0 Members and 1 Guest are viewing this topic.

Offline j1sys

*
  •  16 16
    • View Profile
I have Mach 2 6.11N and Mach 3 2.0.040 installed on my laptop to test some g-code I'm trying to write.

My goal is to have a dynamic step and repeat that can be given the size of a piece of wood, left, right, top, bottom borders, cutter size, # of rows, # of columns, vertical divider size, and horizontal divider size and it will then route a set of niches with little ridges between each one.

I've worked on this for two or three days and have been frustrated in many ways. I have tried using G92 / G92.1 combo to set the lower left corner of each niche. I've switched to G52 to try and get around the two problems I'm running into.

My technique may not be the best method but it is my first attempt at parameterized g-code. For visual testing I've not yet added any spindle on/off or Z axis movement.

To make each niche I first pass around the outside of the niche, then inset a little and zig-zag up from the bottom to remove the rest of the inside.

The problem with Mach 2 is:

It completely ignores the O2100 subroutine and/or resets or destroys the #501 and #502 parameters. So it both displays and executes the toolpath with just the first pass around each niche. So it won't work for me.

The problem with Mach 3 is:

It displays the toolpath properly (including the zig zag cuts to clean the interior of each niche) but when it goes to run the program it 'screws' up the display by only displaying the excuted toolpath for each niche on top of the lower left niche. Based on switching the x/y/z display to "Machine Coords" it appears that it will actually route correctly since the x/y go up correctly for each niche. It also doesn't, IMHO, report the workpiece movement extremes correctly.

So what stupid thing am I doing? What stupid assumption am I making? Or have I found two idiosyncrasies of the two versions?

Any help would be appreciated.

Thanx,

Ed Bryson

Script Follows:

% GCodeGenericGameBoard - route pockets in flat surface for tiles
%

% design parameters used:

#101=3.      ( board width )
#102=3.      ( board height )
#103=.5      ( left border )
#104=.5      ( right border )
#105=.25   ( top border )
#106=.25   ( bottom border )
#107=.05   ( horizontal divider )
#108=.05   ( vertical divider )
#109=.1      ( depth of pockets )

#111=4      ( rows )
#112=4      ( columns )

#201=.1875   ( cutter size )
#202=.050   ( cutter depth of cut per pass )
#203=6.      ( feed rate )

% calculated parameters:

#301=[[#101-#103-#104-[[#111-1]*#107]]/#111]   ( pocket width )
#302=[[#102-#105-#106-[[#112-1]*#108]]/#112]   ( pocket height )

#311=0
#312=0

% main progam - move to start and iterate rows
%
f#203
#311=[#103]
#312=[#106]
m98 p1000 l#111
g52 x0 y0
g90
g0 x0 y0
m30

; o1000 - do a row
;
o1000
m98 p1100 l#112
#311=[#103]
#312=[#312+#302+#108]
m99

% o1100 - do a single box within a row
%
o1100
g52 x#311 y#312 z0
g90
g0 x0 y0
m98 p2000
g90
g0 x0 y0
#311=[#311+#301+#107]
m99

% o2000 - do a layer of routing for a box
%
o2000
#401=[#201/2]         ( half the cutter size )
#411=[#301-#401]      ( width of path based on cutter size )
#412=[#302-#401]      ( height of path based on cutter size )
g91
g0 x#401 y#401
g1 y#412
g1 x#411
g1 y[0-#412]
g1 x[0-#411]
#501=[[#411]-.02]      ( left/right pass size )
#502=[[#201]-.02]      ( y move each pass )
#503=[FIX[[[#302-.02]/#502]]-1]   ( left/right pass count )
g1 x.01 y.01
m98 p2100 l#503
m99

% o2100 - do a left/right pass to route the area withing a box
%
o2100
g91
g1 y#502      ( move to next pass )
g1 x#501      ( do a pass )
#501=[0-#501]      ( setup for reverse )
m99

% end of file!!

Offline Graham Waterworth

*
  • *
  •  2,672 2,672
  • Yorkshire Dales, England
    • View Profile
Re: My Script Won't Work On Mach 2 and Won't Display Right On Mach 3 - My Bad?
« Reply #1 on: February 01, 2007, 04:40:56 AM »
For a first attempt this is very good, I can't find a fault, but I have cleaned it up a bit, I have found that % can cause problems.

When you run the code through Mach3 it will display the tool path that it will cut.

When you cycle through the code the tool path will be drawn on the first part of the path only,  It can't draw using the G52 offsets. But it will cut it right.

Graham.


O0001

(GCodeGenericGameBoard - route pockets in flat surface for tiles)


(design parameters used)

#101=3.      ( board width )
#102=3.      ( board height )
#103=.5      ( left border )
#104=.5      ( right border )
#105=.25   ( top border )
#106=.25   ( bottom border )
#107=.05   ( horizontal divider )
#108=.05   ( vertical divider )
#109=.1      ( depth of pockets )

#111=4      ( rows )
#112=4      ( columns )

#201=.1875   ( cutter size )
#202=.050   ( cutter depth of cut per pass )
#203=6.      ( feed rate )

(calculated parameters)

#301=[[#101-#103-#104-[[#111-1]*#107]]/#111]   ( pocket width )
#302=[[#102-#105-#106-[[#112-1]*#108]]/#112]   ( pocket height )

#311=0
#312=0

(main program - move to start and iterate rows)
f#203
#311=[#103]
#312=[#106]
m98 p1000 l#111
g52 x0 y0
g90
g0 x0 y0
m30

O1000(do a row)
m98 p1100 l#112
#311=[#103]
#312=[#312+#302+#108]
m99

O1100(do a single box within a row)
g52 x#311 y#312 z0
g90
g0 x0 y0
m98 p2000
g90
g0 x0 y0
#311=[#311+#301+#107]
m99

O2000  (do a layer of routing for a box)
#401=[#201/2]         ( half the cutter size )
#411=[#301-#401]      ( width of path based on cutter size )
#412=[#302-#401]      ( height of path based on cutter size )
g91
g0 x#401 y#401
g1 y#412
g1 x#411
g1 y[0-#412]
g1 x[0-#411]
#501=[[#411]-.02]      ( left/right pass size )
#502=[[#201]-.02]      ( y move each pass )
#503=[FIX[[[#302-.02]/#502]]-1]   ( left/right pass count )
g1 x.01 y.01
m98 p2100 l#503
m99

O2100 (do a left/right pass to route the area withing a box)
g91
g1 y#502      ( move to next pass )
g1 x#501      ( do a pass )
#501=[0-#501]      ( setup for reverse )
m99
« Last Edit: February 01, 2007, 04:50:11 AM by Graham Waterworth »
Without engineers the world stops