Haas Spindle Warm Up Macro
Category : Macro Useful Stuff
Warm up Programme
This Haas 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 Mazak, Haas and Fanuc.
This course will be available online soon.
Please fill out the enquiry form on the right if you are interested.
I must admit I often think that where Macro programming is concerned, a little knowledge is a dangerous thing. I just think it’s more about a programmer’s ego than really getting good code.
This article gives a brief description of macro programming if you just want the Haas Spindle Warm Up Macro then jump to the end and copy it. I won’t be offended, honestly.
Be Careful What you Wish for.
Gratuitous use of macro programming , can be dangerous and very confusing to the operator using it.
If you don’t know what gratuitous means don’t worry neither do I, I just heard a bloke say it on the telly.
- Using a macro can automate a regular task.
- Families of parts can be grouped together in one programme.
- All macros need to be “fool proofed” you must add alarms to protect from erroneous input.
- Use parameters to lock and protect your macro programmes.
- Macros can be aliased to G and M codes.
- Don’t reinvent the wheel every day, just use a macro.
- Don’t forget to check if you have the macro option on your machine it can be quite expensive to add on.
This macro (Haas Spindle Warm Up Macro) is for the warming up of the spindle on your Haas machine.
It does not take big leaps in speed so it’s smoother and more gradual.
Set the maximum rpm you want to warm up to and the time you want the warm up to run for. You also set the initial speed you want your spindle to start at from cold. Also give it the amount the speed increases per step.
It will calculate the difference between your start speed and your maximum speed. Then it divides this speed by the speed increment that you give it. From this it will know how many times to loop.
Once in the loop it uses the machine timer #3001. It zeros the timer then runs it for the calculated time each step.
Time needs to be set in milliseconds because that’s what the geeks use in these machine timers, so it multiplies by 60,000.
Ideally I suggest you alias it to an M code.
Alias what the fuck is an alias?
No it’s not like changing your name from Reginald Kenneth Dwight to Elton John no no it is a bit more sophisticated.
What does Alias mean.
It means you can access a programme using your own G code or M code.
So for example see above. If you put 201 into parameter 91 when you programme a G201 it enters programme 9010. Like programming M98 P9010 or G65 P9010. 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. These are called arguments. So now you can do the same with your very own G code.
G81 G98 Z-10. R1. F100.
Also for parameter 81 (see above) if you put 33 into parameter 81 when you programme M33 the control will jump into programme 9000. You cannot pass arguments when you use an M code. Best not to argue then, I say.
So for my Haas 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. (It can be our little secret). They will not be able to edit or delete it either.
All they need to know is that M33 will run the Haas Spindle Warm Up Macro.
A word about testing.
When you test your macro you don’t want your control to look ahead.
Why Does Your Programme Need to Look Ahead?
Let’s talk about cutter compensation:
Below is a tool path where the tool is compensated to the left. To machine the part without cutting into it the control would need to read in front.
It moves up the left hand side so it needs to know where its going in advance, moving round the outside in single block it would stop here.
If it were about to cancel compensation it would end here.
If it were about to go left on the inside it would stop here.
They would all be the same Y position but in single block it would stop in three different places.
So this explains why the control needs to look ahead. Each move relies on the next one for it’s positioning.
When we write macro programmes and are testing them this look ahead can be a real pain in the arse. You see the system often will know the answer before you think it has seen the question.
Complicated? Read on, I meant to confuse you so it makes me look intelligent.
Please Explain
Right , what we do is to use a G code that will stop the system from looking ahead. We can then single block through our macro and check the calculations as we go.
When we are happy with the code we can let the system look ahead again by turning look ahead back on.
Although what you are doing may be very simple in terms of calculations a very simple mistake can really bugger things up.
Be very systematic in your approach and test each section of your macro as you go. As you are happy that each line works move on to the next.
Try my Haas Spindle Warm Up Macro below. Turn off the block look ahead and the single block restriction and check each variable as it changes. It will help you to understand how the Haas Spindle Warm Up Macro works.
One other thing, plan your macro before you start don’t get too excited and rush on. Keep a record of what variables you have used so you don’t accidentally use a variable twice. Things can get very messed up if you do.
Comment, comment, and more comments to say what the comments mean. You can’t have too many comments in a macro. The best approach is to imagine you were abducted by aliens. Will anyone understand your code if they don’t bring you back to Earth?
If you are like me and you have the memory of a goldfish then you will need them for yourself when you look back at this macro in years to come.
Check out this fantastic article on how to lay out your CNC code and comments.
“The code, give me the code?” you ask.
OK OK.
So here is my Haas Spindle Warm Up Macro.
Hope it is useful to you.
PLEASE DO NOT USE THIS MACRO IF UNDER 18 OR OF A NERVOUS DISPOSITION
Oh by the way if you get bored easily then don’t read all this shit. Just put the code in your machine and enjoy it with my compliments.
Haas Spindle Warm Up Macro
O09000 (Haas Spindle Warm Up Macro)
G103 P1 (NO BLOCK LOOK AHEAD)
#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)
G103 P0 (NO BLOCK LOOK AHEAD)
M30
Very boring so what does it all mean? You ask.
Explanation of my Haas Spindle Warm Up Macro
O09000 (Haas Spindle Warm Up Macro)
G103 P1 (NO BLOCK LOOK AHEAD)
(This will stop block look ahead)
#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.)
G103 P0 (BLOCK LOOK AHEAD)
(This will put block look ahead back on)
M30
Single Block
You can stop single block from working in a macro.
It is really annoying if you expect your spindle to warm up in 20 minutes. You come back having made tea cos you left the machine in single block.
“Shit” (expletive of your choice) “the machines been on single block and stopped on 500 rpm for 20 minutes”
#3003= 1 (SINGLE BLOCK OFF)
#3003= 0 (SINGLE BLOCK ON)
Stop single block is used in a G84 tapping cycle. There is a thought, imagine using single block when tapping. (You may need to think about that one)
I also have suppressed spindle override because you want the correct speed in a warm up programme. So your override control won’t work until it’s cancelled again at the end of the macro.
Again this is used in G84.
If you read the code and explanations above you’ll see how it works.
Oh and by the way here is a similar article for a Mazak machine.
Services offered at CNC Training Centre
Classroom programmer 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.