Hello Guest it is October 23, 2021, 05:45:53 AM

Author Topic: Selecting number of "instances" of a program (hard to describe in a subject)!  (Read 4928 times)

0 Members and 1 Guest are viewing this topic.

Hi all, first post on the site. I've been using Mach 3 for a bit over a year now and have basically been learning G-code as I need it and don't really know what to search on for this topic.

I've got a part I'm making using a vacuum fixture to hold down and it uses 4 tools total.  I'm starting to get orders and re-orders for multiples and what I'd like to do is make a vacuum fixture with three or four vacuum hold down locations and use offsets to machine each part with the tool that's loaded.  i.e., I'd like it to do the 1/4" square operation on all the boards, then the 1/2" round operation on all the boards etc. in order to save time on tool changes.  I'd also like to set up the program so that it's written for four copies but I can select how many copies I actually want make at run time.  I'm using VisualMill for my CAM and when using multiple offsets, what it does is e.g. output G59P1, then the stream of G-code, then G59P2 and the same stream of G-code etc. for as many instances as you select.

Is there some relatively simple way I could modify the G-code so I could enter a variable at the start of the G-code (say a number between 1 and 4) and use some sort of loop to actually cut the parts?

The brute force method would be to simply output 4 files each time I post code but that seems rather inelegant to me.   The other thought I just had would be to output a file for each tool operation and wrap it in a loop.  This adds loading the code at each tool change though. Any ideas on how to start searching for a solution?
Hi Banduramaker,
yes and no.
The easiest way would be to set conditions, but these do not exist in Mach.
Another way is to work with variables. Unfortunately this is not possible because there is an issue in mach.
I attach a g code file for example. The variables are changed by the LookAhead function of mach.
The G code should work correkt if :  the LookAhead function in general config is set to 1 line or
you type the whole G code in sigle block mode.
The easiest thing is do do it in your cam program. copy your part so that you have 4 parts for example then
generate your G-code.

Yes, I've spoken with a few people and it seems like there's only complicated ways to do this.  I'll probably just output 3 or 4 versions of the code when I generate the files - 1 part, 2 parts, 3 parts or 4 parts.  I'll see if I can program a macro or something to do it in my CAM software.

Offline BR549

  •  6,952 6,952
    • View Profile
SUBs are what you what to use it works fine even with parameters.

Alex your program will never work right the way you have it.

You set the #2=54 at the start and at the end of each sub you are incrementing it up, YES ?

BUT after the sub ends and returns to the main program you have the #2 resetting back to #2=54 so the next sub call is NOT incremented up and you recut at G54 each time.

Mach3 subs and Parameteric runs fine as long as there are no tool offsets and then it can get squirrley beyond the first pass in SOME instances,

SUBs are what you want, (;-) TP
Have you looked at the Nesting Wizard included with Mach3?  I use it to make 4 parts at a time, although without tool changes.
John Champlain

Offline BR549

  •  6,952 6,952
    • View Profile
WOOPS my mistake I see where you are heading with it now.

BUT it works fine here running it. But the toolpath is  being tricked out by the G#2 call it thinks it is a G2 and draws circles BUT the code runs fine on the table.
(;-) TP
« Last Edit: July 03, 2012, 10:14:36 PM by BR549 »
Hi TP,
no the #2=54 is only set at the end of the sub.
The G-code work as it should.
there is an issue in mach I'm sure.
You can test this as follows: load the code. input different values for the Fixtures e.g. for G54 X axis -40 for G55 X axis -60 and so on.
it is not necessary that the computer is connected to a machine to see what i mean. so it should be safe to test.
Set the LookAhead in general config to 20 lines ( default ) open the G code variable monitor in Operator section
start the code and watch the G Code Line ( the line that shows what G code is actual active ) look for the fixtures ( G54, G55 ....)
You will see the first part cutting with fixture G55 what is not correct.
now set the LookAhead in general config to 1 line
You will see then the first part cutting with fixture G54 what is correct.
if you look closely, you will realize that mach " Looks Ahead" in this case 20 lines calculate the values of the variables and set it.
In other words how can variable #2 set to 55 before the line is executed?
sorry, for the bad English :-\

alex :)

Offline BR549

  •  6,952 6,952
    • View Profile
I see what you are saying BUT the machine cuts correctly(;-) The mode status line is a bit quirky along with the toolpath display with offsets and fixtures. BUT in the end the machine cuts it correctly.

(;-) TP
Hi again,
sorry, now i see it. it is cutting right. So what you see in the mode status line and the G code variable monitor are not the presence values but the future values.
I could not imagine that mach3 is also a time machine. LOL  :D
Everything works as it should. (Sometimes it's still better to have the machine connected to test something )

Alex  :)

Offline BR549

  •  6,952 6,952
    • View Profile
yes mach3 has a few quirks in the display system as far as showing the buffered data in some areas.

(;-) TP