Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Banduramaker on June 30, 2012, 09:22:24 AM

Title: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: Banduramaker on June 30, 2012, 09:22:24 AM
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?
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: cncalex on July 03, 2012, 12:02:45 PM
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.

alex
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: Banduramaker on July 03, 2012, 12:11:22 PM
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.
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: BR549 on July 03, 2012, 07:40:25 PM
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
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: Picengraver on July 03, 2012, 09:55:09 PM
Have you looked at the Nesting Wizard included with Mach3?  I use it to make 4 parts at a time, although without tool changes.
Regards,
John Champlain
www.picengrave.com
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: BR549 on July 03, 2012, 10:11:50 PM
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
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: cncalex on July 03, 2012, 10:59:35 PM
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 :)


Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: BR549 on July 03, 2012, 11:25:05 PM
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
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: cncalex on July 04, 2012, 12:18:56 AM
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  :)
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: BR549 on July 04, 2012, 09:25:13 AM
yes mach3 has a few quirks in the display system as far as showing the buffered data in some areas.

(;-) TP
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: Banduramaker on July 04, 2012, 09:36:11 AM
Alex,

As I'm looking through your code, I'm having a really hard time following what's going on.  Is there a good guide anywhere on how mach 3 handles variables and subroutines?  Perhaps you could comment your code a bit more or describe a general code flow?

At the end of the day, I'm hesitant to set my look ahead to 1 but it's probably not a bad idea to understand how this works.
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: cncalex on July 04, 2012, 03:51:33 PM
Hi Banduramaker,
I attached a new file. May be (or not) it's easier to read and understand.
How to work with parameters is found in the manual.
You can set your LookAhead to what you want, it is ok.
The way i did it in the attached code is only one way to get what you want.
If all parts have the same distance you can do it using G52. If your parts
have every time the same position on your table you can use G10.
In all cases you have to work with parameters to stop machining when an amount
of pieces is reached. You also can try the nesting wizard.
Alex
Title: Re: Selecting number of "instances" of a program (hard to describe in a subject)!
Post by: cncalex on July 04, 2012, 03:54:37 PM
OOps,
foggot the file!
 :D