CNC Macro Programming
Category : Macro
Classroom Training Click Here
CNC Macro Programming an Introduction
Book Now CNC Macro Programming Course
CNC Macro programming is sometimes thought of as a bit of a black art in CNC programming.
Macro programming is sometimes known as parametric programming.
It means you are controlling a program by external parameters.
Its Easy
In fact the use of macro programming in its simplest form is very easy and the rest is shrouded bullshit.
Macro programming uses the #(variable) sign to represent values.
Historically macro programming was used for things like bolt hole circles and cycles that machines didn’t have built in. Most modern controls have this kind of functionality as standard so you might think why would I need to learn macro programming.
Good question. If you have a touch probe on your CNC machine you almost definitely will have the use of macro programming.
Oh by the way before you read anymore of this just check if you have macro programming on your machine as it is usually an option. I would hate you to read the whole of this very boring article only to find you can’t do any of the stuff I am talking about.
A bit like reading the manual for your car only to find you bought the one with the small engine and you can’t actually get from 0-60 in under 5 seconds.
You can use a variable to replace any number in a program and then define its value externally.
Here is an Example
The macro programming example shown is for drilling some holes. Initially just using a cycle to spot drill and then another cycle to drill.
This macro uses a sub program. The first time it’s called we want a depth of 5mm and a feed-rate of 100mm/min. The second time we want a depth of 15mm and a feed-rate 200mm/min.
#1 represents the depth
#2 represents the feed-rate
So you can see that in the sub-program the depth and the feed-rate are defined as variables. So, each time the sub-program is called it will look to see what is in variable 1 and variable 2
Here is the program as it would be normally
O0001(Macro Programming Demo)
G21 G90 G40
T01 M06 (20mm Spot Drill)
G90 G0 G54 X0 Y0 S2546 M3
G43 H01 Z15.0 M8
G81 G98 Z-5. R1.0 F100.
X25.
Y25.
X-25.
G80
G0 G53 Z0 M9
T02 M06 (16mm Drill)
G90 G0 G54 X0 Y0 S1000 M3
G43 H02 Z15.0 M8
G81 G98 Z-15. R1.0 F200.
X25.
Y25.
X-25.
G80
G0 G53 Z0 M9
M30
Here is the program as CNC Macro Programming
O0001(Macro Programming Demo)
G21 G90 G40
T01 M06 (20mm Spot Drill)
G90 G0 G54 X0 Y0 S2546 M3
G43 H01 Z15.0 M8
#1=5.
#2=100.0
M98 P500(Call Programme 500)
G0 G53 Z0 M9
T02 M06 (16mm Drill)
G90 G0 G54 X0 Y0 S1000 M3
G43 H02 Z15.0 M8
#1=15.
#2=200.0
M98 P500(Call Programme 500)
G0 G53 Z0 M9
M30
O500(Sub Programme)
G81 G98 Z-#1 R1.0 F#2
X25.
Y25.
X-25.
G80
M99
Advantages
There are a lot of advantages to using a basic CNC Macro Programming.
1.When you prove it out the first time you know the positions will be correct for the second time.
2.Much less code.
3.You can change your mind without too much code alteration.
4.Sorry I can’t think of a number 4 but 3 advantages didn’t look enough.
As you get more and more into macro programming you start to realise the massive potential it unlocks. You can interrogate the control for example:
What speed is the spindle running at?
What tool is in the spindle,?
What is the current position?
What are the winning numbers on tonight’s lottery?
You can carry out mathematical calculations with variables, adding, subtracting, simple trigonometry etc.
Taster
This is just to give you a taste of what macro programming can do. Try some of this out it’s very addictive. You will find you will get better and better at using it and I’m sure you will have loads of creative ideas as you unlock it’s supernatural powers.
It seems rather daunting at first that’s why I demonstrate a really simple example. It is best to start with small steps that you fully understand and gradually build on your skills.
Good luck.
Other Macro Information
Macro Training
Macro
More**Free**Macro**Stuff
Haas spindle warm up.
Mazak Spindle warm up.
Please contact us if you are interested in learning more on one of our training courses.
Call : 07834 858 407
If you want to learn to program CNC Machines
If you want to learn to program CNC Milling Machines
If you want to learn to program CNC Lathes
Look no further Contact CNC Training Centre 07834 858 407
Please contact me if you require:
- Fanuc training.
- CNC programming training.
- Want to Learn CNC programming.
- Fanuc programming training.
- Yasnac programming training.
- Any type of CNC course.
Services offered at CNC Training Centre
Edgecam programming and training.
Classroom programmer training.
CNC Programming and Training on all controls and machines.
Mazak Training Fanuc Training
Don’t forget we offer training on all types of Mazak Machines and all Fanuc Controls 6m to 31i Oi old to young.
3 Comments
gnanasekar
October 17, 2016 at 9:46 amGood
nelson
August 21, 2021 at 4:11 amI made many macro programs for the company.that no machinist knows nothing. but they all know how to use. I am get bored and quit…. now I am jobless and they still using my macro programs 🙁 what the beaty of the world 😉
K.sivaraman
October 1, 2021 at 6:31 pmMacro programming I am interested