Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: Apples on February 17, 2009, 10:32:20 PM

Title: What is a Macro? and what can it do for me?
Post by: Apples on February 17, 2009, 10:32:20 PM
What is a Macro?  and what can it fo for me?

I'm thinking a macro is a pre saved snipped of code that is entered into the standard g code where ever you need
it so that you only type in the one line instead of heaps of lines of code every time you need to do the same command.

Is this correct?  or am I off with the fairy's?

Peter
Title: Re: What is a Macro? and what can it do for me?
Post by: Graham Waterworth on February 19, 2009, 03:31:35 AM
You are sort of there, what you are talking about is a g-code sub program, a macro is a block of visual basic code that is called with an M code and a list of variables that can be changed on the fly. The macro in effect writes the g-code to do the function.  Macros can also be used to configure/drive machine functions, tool changers etc.

Graham
Title: Re: What is a Macro? and what can it do for me?
Post by: Apples on February 19, 2009, 06:28:16 AM
Hmm,  okay I'll tell you what I'm thinking of doing and maybe you can point me in the right direction.


So imagine a 3 axis machine.  Then on the bottom/ underside of the z there is another axis a,b or c?  For tangential knife function.
Then under that is another axis a,b or c?  I don't know which axis  is which.  anyway.

The two axis underneath the z will just need to be used as, I think they call it just as "indexers"

1.  So I want to move machine to start position. 
2.  Then move tangential axis (a) (rotate to say 90deg.)
3.. Then move other axis (b) (say 90deg. as well)
  This above part is what I want maybe make into a macro or as you called it a sub program.

4.  Then when the tool is in that position move to next position.
5.  Maybe have to change angles of a and b axis to something else then move on agian etc.

So the part I want to not have to keep punching into g-code will be that a,b axis (index) tool position.
This might be like a tool change macro?

Also those a,b angle adjustments will be different.  There might be 3 or 4 diffent combitnations or,
a,b axis moves to do.

Do you understand?

Peter
Australia
Title: Re: What is a Macro? and what can it do for me?
Post by: Graham Waterworth on February 19, 2009, 12:12:29 PM
Yes and no.

What is the difference between typing A90. and M590 ?

You will save nothing.

Graham
Title: Re: What is a Macro? and what can it do for me?
Post by: machininginc on July 17, 2009, 04:31:16 PM
Where are the macros on mach 3 software  and can they be changed, I have a demo version so maybe not ? (not sure) I wanna set it up to use H#148 for a tool height & D#148 for the dia
Title: Re: What is a Macro? and what can it do for me?
Post by: machininginc on July 17, 2009, 04:57:58 PM

 Here is the way I wanna program my mach 3 mill is it possiible and how can I set this up, also how can I look at my sub-rutines

T1 (#1 X 90 CENTER)
M6
M1
G80G90G40G00G54S2000M3
#148=#51999
G43X0Y0Z1.H#148T2M8
G83Z-.07R.1F4.Q.05L0
M98P20
G00G80Z1.M9
G91G28Z0Y0
M1
T2 (1/16 DRILL)
M6
M1
G80G90G40G00G54S4000M3
#148=#51999                                           (wanna use these variables or macros)
G43X0Y0Z1.H#148T3M8
G83Z-.2R.1F10.0Q.05L0
M98P20
G00G80Z1.M9
G91G28Z0Y0
M00 (CLEAR CHIPS FROM DRILL)
T3 (1/16 CEM)
M6
M1
G80G90G40G00G54S4000M3
#148=#51999
G43X0Y0Z1.D#148H#148T1M8
G66P21Z-.15D#148F5.
M98P20
G67
G00G80Z1.M9
G00A0.
G91G28Z0Y0
M30
Title: Re: What is a Macro? and what can it do for me?
Post by: vmax549 on July 17, 2009, 06:04:16 PM
SORRY but that is a mess.  I have no idea of what you are trying to do other than drill some holes.

Also there are some gcodes you called that do not exist in mach.

I would suggest you set down with the mach manual and work out what you want to do.

OR better explain what iit is you are trying to do.( Drawings work well here). AND we will try to help

Sorry (;-) TP
Title: Re: What is a Macro? and what can it do for me?
Post by: machininginc on July 17, 2009, 09:51:51 PM
I'm brand new wiith mach, so I appoloigize if this sounds dumb, what do I do first to load a program, I have been able to draw in Gibbs and generate a program using a haas post processer, that gives me my code then I have been coping and pasteing into the edit screen on mach that will load it, however I'm not gettin any tool path and I can't veiw my sub programs
Title: Re: What is a Macro? and what can it do for me?
Post by: Chip on July 17, 2009, 10:12:03 PM
Hi, Machininginc

Try using a Fanuc Post I think it's close to what Mach want's at this time, I can see you've found yourself in a little different world at the moment.

Hears a link to a some what outdated manual, http://www.machsupport.com/docs/Mach3Mill_1.84.pdf

Under File, Load G-Code, Use this to load a G-code file by Browsing to C:\Mach3\GCode folder and select a file, Pic's below.

Hears some G-code to cut and past, It will take a little time for things to sink in, But will work thought it..

%
G90 G20 G61 G80 G40  ;  I added these to make sure Mach is configured for it to run
N5 (File Name = test55Dotpolyline 12 04 06 A1 on Friday, July 17, 2009)
N10 (Default Mill Post)
N15  G91.1
N20 G0  Z0.1000
N25 M3 S3000
N30  X0.0000  Y0.5000
N35 G1  Z-0.1000  F1.00
N40  Y1.0000  
N45  X1.0000  
N50  Y0.0000  
N55  X0.0000  
N60  Y0.5000  
N65 G0  Z0.1000
N70  X1.5000  Y0.7500
N75 G1  Z-0.1000  
N80  Y1.0000  
N85  X2.0000  
N90  Y0.5000  
N95  X1.5000  
N100  Y0.7500  
N105 G0  Z0.1000
N110  X1.4980  Y2.0080
N115 G1  Z-0.1000  
N120 G2  X2.5020  Y2.0080  I0.5020  J-0.0000
N125  X1.4980  Y2.0080  I-0.5020  J0.0000
N130 G0  Z0.1000
N135  X3.0000  Y1.0040
N140 G1  Z-0.1000  
N145  X4.0000  Y2.0080  
N150  Y0.0000  
N155  X2.0000  
N160  X3.0000  Y1.0040  
N165 G0  Z0.1000
N170  
N175  Y1.2500
N180 G81  X3.0000  Y1.2500  Z-0.1000  R0.1000  F1.00
N185 X3.7500  Y2.0000
N190  Y2.7500
N195 X0.2500
N200  Y1.5000
N205 G80
N210 G0
N215  S3000
N220  X2.7500  Y1.2500
N225 G1  Z-0.1000  
N230  X0.2500  
N235 G2  X0.0000  Y1.5000  I0.0003  J0.2500
N240 G1  Y2.7500  
N245 G2  X0.2500  Y3.0000  I0.2500  J-0.0002
N250 G1  X3.7500  
N255 G2  X4.0000  Y2.7500  I0.0000  J-0.2500
N260 G1  Y2.2500  
N265 G0  Z0.1000
N270 M5
N275 M30
%

Welcome to the Group, Chip.
Title: Re: What is a Macro? and what can it do for me?
Post by: machininginc on July 17, 2009, 11:33:32 PM
I tried to run the program and it thru a alarm  of default mill post what do this mean, It ran about half way thru
Title: Re: What is a Macro? and what can it do for me?
Post by: machininginc on July 17, 2009, 11:33:59 PM
 N125 line
Title: Re: What is a Macro? and what can it do for me?
Post by: Chip on July 17, 2009, 11:39:41 PM
Hi,

N125 just doesn't have a G command earlier ver's had issues with this.

Look under HELP, About Mach, What Ver. are you using.

Where do you live ? , Sent you a PM message, Top of this screen, Click on your user Name to see.

Chip
Title: Re: What is a Macro? and what can it do for me?
Post by: machininginc on July 18, 2009, 01:25:24 PM
awesome Thank you some much I'm not sure what VER means
Title: Re: What is a Macro? and what can it do for me?
Post by: Chip on July 18, 2009, 02:27:59 PM
Hi, Machininginc

Hears a picture, Click on Help then About, Version R3.042.029 is what I'm using.

Chip
Title: Re: What is a Macro? and what can it do for me?
Post by: machininginc on July 20, 2009, 01:21:44 PM
I am using  VERSION R3.041
Title: Re: What is a Macro? and what can it do for me?
Post by: Val on September 06, 2014, 04:51:11 AM
is there a macro or a g-code in mach3 for THC on and THC off? How can I turn off/on the THC? I need that to solve the diving problem at the end of the cut. Sheetcam people make it look so simple in their cutting rules tutorial on youtube. It doesn't seem to work though. Can anybody help?
Title: Re: What is a Macro? and what can it do for me?
Post by: stirling on September 06, 2014, 11:47:05 AM
is there a macro or a g-code in mach3 for THC on and THC off? How can I turn off/on the THC? I need that to solve the diving problem at the end of the cut.

This is not really the way to go about solving your issue. A dive at the end of a cut is either because your accel is too low OR because you're crossing a kerf. The second is easy to solve - don't do it. The first can be solved either by upping your accel if possible OR by using Mach's THC anti-dive.

Even if you did do what you want with a macro - you're going to get a pause in movement - no way around it.
Title: Re: What is a Macro? and what can it do for me?
Post by: Val on September 13, 2014, 05:29:28 AM
Well, as you said, I can turn on and off the THC with the macros but that pause makes it useless. My problem is not around corners, I have great accel., and a never cross kerfs, the problem is at the end of cuts. The torch dives at the end of cuts whether is a hole or the contour of the part (a bigger hole in fact). I gave up leads out. Useless.
And I have another problem, maybe one out of five cuts the torch doesn't fire and the cut continues with no fire.  It seems that mach doesn't order the torch to fire and doesn't expect it to be lit. And is never in the same place. Just random.  I cut the same part with the same code and it misses the cuts randomly.
If I could solve these 2 problems than I could say I have a plasma cutter.
Can anyone help?
Title: Re: What is a Macro? and what can it do for me?
Post by: stirling on September 13, 2014, 06:54:33 AM
1st problem: I can only repeat...

either by upping your accel if possible OR by using Mach's THC anti-dive.

2nd problem: See http://www.machsupport.com/forum/index.php/topic,27826.0.html

EDIT: when you say...

and doesn't expect it to be lit.

It does when you have THC turned on - no arcok - no movement. However THC turned off - it doesn't care whether you have arok or not - hence (part of) the discussion in the link above.
Title: Re: What is a Macro? and what can it do for me?
Post by: Val on September 16, 2014, 02:00:58 AM
I did the activate/deactivate thing. Works in a strange way. The machine starts the cut without ark and the ark starts maybe 1 sec after the movment begun. You can see the result in the attach.
I went back to dospinCW.... with the same problem. Misses holes.
Title: Re: What is a Macro? and what can it do for me?
Post by: stirling on September 16, 2014, 05:05:46 AM
I did the activate/deactivate thing.

Whatever that means.

Post the M3 macro you tried.
Title: Re: What is a Macro? and what can it do for me?
Post by: Val on September 16, 2014, 06:13:24 AM
here they are
Title: Re: What is a Macro? and what can it do for me?
Post by: stirling on September 16, 2014, 06:16:26 AM
so how much of the thread I linked to did you actually read?
Title: Re: What is a Macro? and what can it do for me?
Post by: Val on September 16, 2014, 09:46:23 AM
all of it, but now that you ask, it seems I didn't understand all. Again, I'm seeking help for these 2 problems:
1. the torch doesn't always turn off at the end of the cut and instead starts diving
2. sometimes misses a cut because the torch doesn't turn on at the beginning of the cut but the movement continues like it were on

I thought you suggested  the M3 and M5 "dospin type" are not fast enough and this is the cause. I thought you recommended using activate deactivate type macros. I tried that but it was worse.
I use a Proma THC.
Title: Re: What is a Macro? and what can it do for me?
Post by: danshambo on November 13, 2021, 12:28:15 PM
1st Time posting here.

Macros are for doing many things that can be complicated and tiresome to create. Every single G and M code is a macro that cause the machine as you all know to do different things. The great thing about Macros is there is no limit to what you can create from engraving to tool setting. But you have to have a great deal of experience and it takes a lot of time to learn and execute.

I have 40+ years of working in machine shops working on equipment and programming it. Macro's are the most difficult task there is in programming of course a lot of that depends on how complicated the Macro. Then there are different forms of macro programming and more and more builders are developing their own language when it comes to macros. For instance Fanuc uses the most common form used Macro B's but as I said companies like Fagor have their own language when it comes to macros.  And still more companies are writing Macros for use in their machines so operators can do things with the machine that in the past they couldn't even contemplate doing.

Macro's are every G code and every M code you use in a machine control. That said there is less and less need to be able to write Macro's like I said the builders are writing them and giving them away with their machines. To the point of using them as a sales point. I would stick to being really good with G code and even that takes a lot of time to become good at.

I have written lots of Macro's and post processors over the years I like doing it because it gives me a tool that someone else may not have, so I gain an advantage or used too. That said like I said more and more builders are supplying their machines loaded with tons of Macros so the need to be able to write Macro's for the daily programmer or user isn't really needed much any more. Still a powerful tool. By the time you learn them and write them it's likely someone will give them to you for nothing.