Category Archives: Macro

Mazak Spindle Warm Up Macro

CNC Training Call David: 07834 858 407

CNC Training Centre Reviews

30 five star ratings on Google (just saying)

Warm up Programme

This Mazak Spindle Warm Up Macro is something I created recently for the Macro training course that we offer at the CNC Training Centre. The course covers Macro Programming suitable for Haas, Mazak and Fanuc.

I must admit I often think that with Macro programming a little knowledge is a dangerous thing. On visiting companies I just think it’s more about a programmer’s ego than really getting good CNC code.

See this article, it gives a brief description of macro programming.

If you just want the Mazak Spindle Warm Up Macro then just jump to the end and copy it. I won’t be offended by the fact that you are just too selfish and greedy and can’t even spare the time to read my articles that I slave for hours to produce!

Gratuitous use of macro programming (that’s bullshit to the normal folk), can be dangerous and really confusing to the operator using it.

  • A macro can automate a regular task.
  • Families of parts can be grouped together and simplified in one programme.
  • Macros should be fool proofed with alarms to prevent erroneous input.
  • The details of the macro ideally should be protected (ie lock the 9000 programmes).
  • Where possible alias the macro to a G or M code.
  • The machine operator is your customer so treat him or her well.
  • If you don’t like re-inventing the wheel every day then macros are for you.
  • Don’t forget to check if you have the macro option on your machine it can be quite expensive to add. Oh and it will really piss you off if you read this whole article and find you ain’t got it!

Some Explanation.

This macro (Mazak Spindle Warm Up Macro) is for the warming up of the spindle, it’s a much smoother warm up because it does not take big leaps in speed. It is a much more gradual approach.

You tell it your maximum rpm you want to warm up to and the time you want the warm up to last. You can tell it what RPM increase you want as a step. You also tell it the initial speed you want your spindle to start at from cold.

It goes on to calculate the difference between your start speed and your maximum speed. It divides this speed by the speed increment that you give it. This will tell it how many times to go around the loop.

In the loop it uses the machine timer. It zeros the timer then runs it for the calculated time for each step.

It has to then get this time in milliseconds because that’s what the geeks use in these machine timers.

Ideally it should be aliased to an M code.

Alias WTF? No it’s not like changing your name from Reginald Kenneth Dwight to Elton John it is a bit more sophisticated.

What it means.

Well it means you can access a programme using your own G code or M code.

Mazak Spindle Warm Up Macro

So for example if you put 200 into parameter 92 when you programme a G200 it will jump to programme 9011. Just as if you had put M98 P9011 or G65 P9011. With a G code you can pass arguments to the programme a bit like G81. In G81 you tell it the depth and rapid point these are the Z and the R values. Now you can do the same with your G code.

Also for parameter 82 if you put 33 into parameter 81 when you programme M33 the control will jump into programme 9001. You cannot pass arguments when you use an M code. Best not to argue then eh.

So for my Mazak Spindle Warm Up Macro we will use M33 and alias it to programme 9000. So having done all this you can lock out programme 9000 so no one can even see it. (Our little secret). They will not be able to edit it either.

All they need to know is that M33 will run the Mazak Spindle Warm Up Macro.

M33 is aliased to O9000

 

Now then a word about testing.

Actually it’s more than one word but here we go.

When you test your macro you need to stop your control from looking ahead, put the blinkers on as it were.

(Sorry that’s totally wrong blinkers actually make a horse look ahead and not to the side).  Anyway CNC controls have to look ahead and here is why.

Cutter Compensation.

Below is a typical tool path where the tool is compensated to the left. In order to machine the part without cutting into it the control needs to read in front.

Mazak Spindle Warm Up Macro

As it moves up the left hand side it needs to know where its going in advance, moving round the outside in single block it would stop here.

Mazak Spindle Warm Up Macro

If it were about to cancel the compensation it would end the move here.

Mazak Spindle Warm Up Macro

If it were about to go to the left on the inside it would need to stop here.

Mazak Spindle Warm Up Macro

They would all be the same Y position but in single block it stops ready for the next move (three different places).

So this explains why the control looks ahead. Each move relies on the next for correct positioning.

When we write a macro programme and we are testing it this look ahead is a real nightmare. The system often will know the answer before you think it has seen the question.

Complicated?  mm read on:

Right joking aside, what we do is to use a G code to stop the system from looking ahead. What we can then do is single block through the macro and check the calculations as we go.

When you are happy with the code you can let the system look ahead again by turning look ahead back on.

Although what you are doing may be very simple, a very small mistake can really bugger things up. (Sorry for saying bugger, I meant knacker).

Have a System.

Now my advise here is to be very systematic in your approach and test each line of your macro as you go. Be happy that each line works ok before you move on to the next.

You can try it this with the Mazak Spindle Warm Up Macro below. Turn off the block look ahead and the single block restriction and check each variable as it is changed. It will help you to understand how the Mazak Spindle Warm Up Macro works.

Oh one other thing plan your macro before you start don’t get to excited and rush on. Also keep a record of what variables you have used so that you don’t accidentally use a variable twice. Things can get very scary if you do this.

Comment, comment, comments and more comments to say what the comments are for. Honestly you can’t have too many comments in a macro. The best approach is to imagine that you were abducted by aliens (I sincerely hope you never are) but if you are the will anyone understand your code?

If the answer is no then you are not explaining your code well enough. Also if you are like me and you have a poor memory then you will need them for yourself. So when you look back at this macro in 200 years you will know what it meant.

Check this article on how to lay out your CNC code and add comments.

“The code give us the bloody code?”

OK.

So here is the Mazak Spindle Warm Up Macro.

I hope it works for you.

PLEASE DO NOT USE THIS MACRO IF YOU ARE UNDER 18 OR ARE OF A NERVOUS DISPOSITION

Mazak Spindle Warm Up Macro

Oh by the way if you get bored easily then I definitely wouldn’t read all this. Just put the code in your machine and enjoy it with my compliments (thicko).

Mazak Spindle Warm Up Macro

O09000 (Mazak Spindle Warm Up Macro)

#3004= 7 (OVERRIDE CONTROL NOT ALLOWED)
#100= 20. (TIME)
#101= #100 * 60000. (TIME MILLISECONDS)

#102= 500. (RPM FROM COLD)
#103= 7000. (MAX RPM)
#104= #103 – #102 (RPM INCREASE)

#105= 1. (RPM STEP)
#106= #104 / #105 (LOOP)
#107= #101 / #106 (DWELL)
M03 S#102 (Start spindle at initial speed)

WHILE [ #106 GT 0 ] DO1 (DO LOOP)
S#102 (START SPINDLE AT INCREASED RPM)
#3001= 0 (RESET INTERNAL TIMER TO ZERO)

WHILE [ #3001 LT #107 ] DO2
END2

#106= #106 – 1 (COUNTER DECREASES BY ONE)
#102= #102 + #105 (INCREASE SPEED BY STEP)
END1

#3004= 0 (OVERRIDE BACK ON)

M30 

Boring, boring so what does it all mean?

Explanation of  Mazak Spindle Warm Up Macro

O09000 (Mazak Spindle Warm Up Macro)

#3004= 7 (OVERRIDE CONTROL NOT ALLOWED)
(Set this to a 7 to stop override of speed.)

#100= 20. (TIME)
(Total time of warm up in minutes)

#101= #100 * 60000. (TIME MILLISECONDS)

#102= 500. (RPM FROM COLD)
(Spindle will start at 500 RPM)

#103= 7000. (MAX RPM)
(Maximum RPM you want the warm up to reach)

#104= #103 – #102 (RPM INCREASE)

#105= 1. (RPM STEP)
(This in the step used as the RPM increases)

#106= #104 / #105 (LOOP)
(Calculate the number of times it goes around the loop)

#107= #101 / #106 (DWELL)
(Dwell time after each speed increase)

M03 S#102 (Start spindle at initial speed)

WHILE [ #106 GT 0 ] DO1 (DO LOOP)
S#102 (START SPINDLE AT INCREASED RPM)
#3001= 0 (RESET INTERNAL TIMER TO ZERO)

WHILE [ #3001 LT #107 ] DO2
(TIMER COUNTS DOWN BY DWELL TIME)
END2

#106= #106 – 1 (COUNTER DECREASES BY ONE)
#102= #102 + #105 (INCREASE SPEED BY STEP)

END1

#3004= 0 (OVERRIDE BACK ON)
(Override works again.)
M30

Single Block

You can suppress single block in a macro. You can suppress single block in this macro (Mazak Spindle Warm Up Macro) because it is really annoying if you expect your spindle to warm up in 30 minutes. You come back having made tea, toast and croissants (as us engineers do).

“Shit” you say “the machines been on single block and stopped at 500 rpm for 30 minutes”

Just add these.

#3003= 1 (SINGLE BLOCK OFF)

#3003= 0 (SINGLE BLOCK ON)

I have suppressed spindle override because you need the correct speed in a spindle warm up programme.

If you read the explanations above you will see how it works.

 

CautionSwitchSingleBlock

Oh and by the way here is a similar article for a Haas or Fanuc type machine.

Services offered at CNC Training Centre

Edgecam Training.

Classroom programmer training.

Onsite CNC Machine Training.

CNC 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.


Training Course Fanuc Haas Macro Programming

CNC Training Call David: 07834 858 407

 

CNC Training Centre Reviews

30 five star ratings on Google (Just saying)

Haas Macro Programming

Fanuc Training Onsite

 

CNC Macro Programming Training Courses

Call David : 07834 858 407

(Suitable for Fanuc, Mazak and Haas Macro Programming)

Duration:          2 days.
Times:               Start 9.30am Finish 4.00pm
Location:          Barwell in Leicestershire.

Apply Now

 

Price £300 per day

Total £600 2 days

CNC Macro Programming Training Courses

If you want to learn how to use

  • Macro CNC Programming Fanuc
  • Macro CNC Programming Haas
  • Macro CNC Programming Mazak

Most ISO type controls that have Macro use a very similar system.

Follow the link to learn some more about Macro.

Heidenhain Q parameter programming is very similar to Macro CNC Programming for Haas and Fanuc.

Once you have grasped the concept of parametric programming you will find Heidenhain Q parameter programming easy to figure out.

Suitable for Fanuc, Mazak and Haas Macro Programming Lathe and machining centre


Haas, Fanuc or similar controls (ISO Mazak).

Haas Macro Programming   Haas Macro ProgrammingHaas Macro Programming

Make sure you have the Macro option on your control, it’s a real disappointment when you get all excited about this only to find you don’t have the option. Remember if you have a touch probe you will almost definitely have Macro installed on your machine.

Good news is you can buy the option, it don’t come cheap so sit the boss down and make him a cup of tea before you ask.

Haas Macro ProgrammingHaas Macro Programming


CNC Macro Programming Training Courses

What Use Will it Be?

This is where CNC Programming gets really exciting, welcome to the turbo charged world of Macro Programming for Haas and Fanuc type controls. There is so much exciting shit you can do with this I really don’t know where to start.

Write your own canned cycle

Yes you always dreamed of having your own personal G code, you can’t call it like Bill’s G code or something but you may have G271 or something which is personal to you.

Say you wanted a drilling cycle that changed speed half way down a hole or some daft thing well now you can do it.

Make A Set of Similar Parts

Imagine you had a bunch of parts that were similar, maybe the same holes but in different positions or a similar shape.

Haas Macro Programming

You could write a parametric (Macro) programme that would be completely adjustable and would make them all instead of having to keep writing similar programmes.

You can build these programmes and add to them as you get better and better and your ideas flood in.

I always say to students to start simple and build on your experience. Just using Macro in its simplest form will inspire you to go on to do greater things.

Interrogate Your CNC Machine

You can get almost any information you want from the machine.

  • Spindle Speed.
  • Position.
  • Datum.
  • Tool Length.
  • What tool is in the spindle.
  • Put the machine into an alarm state when things go wrong like wrong data is input.
  • And loads more.

You can even modify this information and send it back.

Do Calculations

  • Simple trigonometry.
  • Calculate feeds and speeds.
  • Simple maths.
  • Input formula and get answers.

I’m getting really excited just telling you this. It means you can add all sorts of functionality to your machine that you didn’t have before.


What Skills Will I Learn

  • Basic use of variables
  • Creating simple Macro programmes
  • How system variables work
  • How to write probing Macros
  • Creating your own G Codes
  • Create alarms to make sure your Macro users behave
  • Practical use of Macro
  • Creative use of Macro
  • and more, loads more

Fanuc Useful Variables

Category : Macro News

Call David: 07834 858 407  (On or off-site Training)



If you use macro programming quite a lot these Fanuc Useful Variables will definitely speed things up for you.

#0 Null Mmmm

#0 this is null, use this to make something have no value, that’s not zero by the way.

You can use this to see if your macro user has not entered a value for some letter you have used.

This means you can then apply a default value if there is none stated.

#1 to #33 are classed as local variables. These values are not retained depending on settings.

Fanuc Useful Variables

These variables will be assigned to corresponding letters in your macro call line.

For example using letter A will represent #1 in the body of your macro.

We have loads more articles on macro if you are interested.

System Variables

These are amazing you can interrogate the sytem, ask it questions like.

What tool is in the spindle?

What time is it?

What speed are you running at?

Almost anything, well you know not anything as in, will I go bald or what horse should I bet in the Grand National?

Fanuc Useful Variables Work Offsets

Fanuc Useful Variables

Or these

Fanuc Useful Variables

Setting a Macro As an Alias Using M Code

Fanuc Useful Variables

Fanuc Useful Variables

Setting a Macro As an Alias Using G Code

Fanuc Useful Variables

Fanuc Useful System Variables Modal Information

Fanuc Useful Variables

Don’t Be alarmed

#3000 is a system variable it puts the machine into an alarm state. You can assign a value of 0-200 and a message in brackets such as.

(THE TOOL IS BROKEN YOU TWAT)

#3000=100 (SORRY FOR SWEARING AT YOU)

Single block

#3003=1 will disable single block

#3003=0 will enable single block.

Thanks for reading my article, if you need to look for more information there’s loads more on this website or go here for Fanuc manuals.

It’s a bit spammy but you can get the manuals you need.

 

 

 

 


CNC Macro Programming

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

CNC Macro 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.

CNC 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.

CNC Macro Programming
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.
Macro programming is sometimes known as parametric programming.


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.

Onsite CNC Machine 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.


CNC Macro Programming Course

Category : Macro

 CNC Macro Programming Course

Duration:          2 days.
Date:                  See Dates
Times:               Start 9.30am Finish 4.00pm
Location:          Barwell Leicestershire England

Includes lunch, coffee and tea, oh and biscuits too.

£600 for two days

CNC Macro Programming Training Courses

If you want to learn how to use

  • Macro CNC Programming Fanuc
  • Macro CNC Programming Haas
  • Macro CNC Programming Mazak

Most ISO type controls that have Macro use a very similar system.

This course covers Lathes and Machining Centres with on-machine practical examples .

Follow the link to learn some more about Macro.

Heidenhain Q parameter programming is very similar to Macro CNC Programming for Haas and Fanuc.

Once you have grasped the concept of parametric programming you will find Heidenhain Q parameter programming easy to figure out.

Siemens uses R parameters instead of #


Haas, Fanuc or similar controls (ISO Mazak).

CNC Macro Programming Course   fanuc cnc custom macrosCNC Macro Programming Course

Make sure you have the Macro option on your control, its a real disappointment when you get all excited about this only to find you don’t have the option. Remember if you have a touch probe you will almost definitely have Macro installed on your machine.

Go into MDI key in #100=10. or something similar. Press cycle start.

If you have it you will get no alarm.

Good news is you can buy the option, it don’t come cheap so sit the boss down and make him a cup of tea before you ask.


CNC Macro Training Course

What Use Will it Be?

This is where CNC Programming gets really exciting, welcome to the turbo charged world of Macro Programming for Haas and Fanuc type controls. There is so much exciting shit you can do with this I really don’t know where to start.

Write your own canned cycle

Yes you can create your own fanuc cnc custom macros.

Yes you always dreamed of having your own personal G code, you can’t call it like Bill’s G code or something but you may have G271 or something which is personal to you.

Say you wanted a drilling cycle that changed speed half way down a hole or some daft thing well now you can do it.

Make A Set of Similar Parts

Imagine you had a bunch of parts that were similar, maybe the same holes but in different positions or a similar shape maybe.

Create fanuc cnc custom macros to make families of parts.

fanuc cnc custom macros

You could write a parametric (Macro) program that would be completely adjustable and would make them all instead of having to keep writing similar programs.

You can build these programs and add to them as you get better and better and your ideas flood in.

I always say to students to start simple and build on your experience. Just using Macro in it’s simplest form will inspire you to go on to do greater things.

Interrogate Your CNC Machine

You can get almost any information you want from the machine.

  • Spindle Speed
  • Position
  • Datum
  • Tool Length
  • What tool is in the spindle
  • Put the machine into an alarm state when things go wrong like wrong data is input
  • And loads more

You can even modify this information and send it back.

Do Calculations

  • Simple trigonometry
  • Calculate feeds and speeds
  • Simple maths
  • Input formula and get answers

I’m getting really excited just telling you this. It means you can add all sorts of functionality to your machine that you didn’t have before.


What Skills Will I Learn

  • Basic use of variables
  • Creating simple Macro programs
  • How system variables work
  • How to write probing Macros
  • Creating your own G Codes
  • Create alarms to make sure your Macro users behave
  • Practical use of Macro
  • Creative use of Macro
  • and more, loads more

Other Macro Information

Macro Training

Macro

More**Free**Macro**Stuff

Haas spindle warm up.

Mazak Spindle warm up.

Contact me if you are interested in Classroom Training 07834 858 407

Don’t forget to watch my Tutorial Videos on YouTube

Edgecam call 07834 858 407

We offer training on all types of CNC Machines and controls check em out.

Services offered at CNC Training Centre

Classroom programmer training.

Onsite CNC Machine 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.


Careers in CNC

View all current vacancies in CNC

Click here

Call David: 07834 858 407