What's new
What's new

Haas VMC Programming Question

wrustle

Titanium
Joined
Jun 8, 2006
Location
Massachusetts
Still fairly new to programming my machine, and can get by pretty well, but one thing I have not been able to do is sub programs. Once I program a part on my Haas VMC how do I make a sub program to machine for example the other parts in my vises? If my main program is for G54, how do I make that same program as a sub program to do G55, G56, and G57 for the other three pieces? So far I have been copying and pasting my programs which is not only time consuming, but also makes for a long program. Any advice or suggestions greatly appreciated.

Best Regards,
Russ
 
First you have to make a main program. Then from the main program you transfer to the sub. Here's a quick example:

MILL 4 SQUARES 4X4 5 INCHES APART .25 DEEP

O0001 MAIN PROGRAM
G0 G90 G54 X0 Y0 S1000 M3.......(Go to position)
G43 H1 Z.25.......(tool height)
M98 P2.......(go to sub O0002)
G0 G90 X5 Y0.....(Back to absolute move to position from G54)
M98 P2........(Go to sub)
G0 G90 X10 Y0.....(Back to absolute move to position)
M98 P2.......(Go to sub)
G0 G90 X15 Y0......(Absolute move to position
M98 P2........(Go to O0002)
G91 G28 Z0.....(Go z home)
M30......(END OF PROGRAM)

SUB PROGRAM
O0002
G91.....(Switch to incremental)
G1 Z-.5 F25.....(Feed down .500)
X4.....(feed x 4)
Y-4.....(feed y -4)
X-4......(feed x -4)
Y4.......(feed y 4)
G0 Z.5....(go z .500)
M99.....(Back to main program)


I like to program the subs in incremental because its less confusing. Just don't forget to go back to absolute when you're done.
 
You can also add a "Loop" to the line on the main program that has the M98== M98 P2 L5; and it will do it 5 times. Only difference is you have to move to the next position on your sub. after it moves the Z up. While still in incremental move on the X 10 inches ex:

MILL 4 SQUARES 4X4 5 INCHES APART .25 DEEP

O0001 MAIN PROGRAM
G0 G90 G54 X0 Y0 S1000 M3.......(Go to position)
G43 H1 Z.25.......(tool height)
M98 P2 L4.......(go to sub O0002 Loop 4 times)
G91 G28 Z0.....(Go z home)
M30......(END OF PROGRAM)

SUB PROGRAM
O0002
G91.....(Switch to incremental)
G1 Z-.5 F25.....(Feed down .500)
X4.....(feed x 4)
Y-4.....(feed y -4)
X-4......(feed x -4)
Y4.......(feed y 4)
G0 Z.5....(go z .500)
X10.....(go x 10 inches to position for next square)
M99.....(Back to main program)

I havent done this in a while but i think it should work.

Feel free to correct.
 
If I may interject something else instead of sub programs.
I absolutely abhor having multiple programs for the same parts, therefore always prefer local subs. Unlike Fanuc, HAAS uses them easy as pie.
Also, in all cases I avoid using incremental programming.

So, to make an easy example, here is a 1" square done 4 times using G54 - G57 workoffsets.

%
O00100
(SAMPLE - SQUAREX4)
(DATE - 08/06/07)
(OPERATION - MILL SQUARE)
(X0=PART CTR, Y0=PART CTR)
(Z0=TOP)
(CYCLE TIME: )
(ROUGH 3/8 CARB)
(SET DIA TO .385)
G00 G53 Z0
G90 G17 G54 G80 G94 G49 G40
T1 M06
G00 G43 H01 D01
G00 X0. Y0 Z0.5
S700 M03
M08
M97 P1000
G55
M97 P1000
G56
M97 P1000
G57
M97 P1000
M09
M05
G00 G49 G53 Z0
(FINISH - 3/8 CARB)
T2 M06
G00 G43 H02 D02
G57
G00 X0 Y0 Z.5
S1400 M03
M08
M97 P1000
G56
M97 P1000
G55
M97 P1000
G54
M97 P1000
M09
M05
G00 G49 G53 Y0 Z0
T1 M06
M30
N1000 (MILL SQUARE SUB)
G00 X0 Y0 Z.5
G01 Z-.5 F200.
G01 G41 X0 Y.5 F2.
G01 X-.5 Y.5
G01 X-.5 Y-.5
G01 X.5 Y-.5
G01 X.5 Y.5
G01 X0 Y.5
G01 G40 X0 Y0 Z.5 F200.
M99
%

Note that this is a quick and dirty way of reducing the program size. The same sub is called for rough and finish for each part. The only caveat is that the roughing tool has a .01 oversize offset entered in the control, leaving you precisely .005 to finish all around.
Also note that the finishing is called in reverse order, so the table is not whizzing back and forth between rough and finish.
There is only one program and there is only one place to mess with to tweak.
 
I concur with SD. This is how I like to leverage local subs too.

1 thing I would do different is put the feedrate in the main program. That way I can finish faster than I rough.

After a second look he is feeding in the z also.

If you want to do this and still have main program control over your contour rate then just do the contour feed with a #500 variable.

%
O00100
(SAMPLE - SQUAREX4)
(DATE - 08/06/07)
(OPERATION - MILL SQUARE)
(X0=PART CTR, Y0=PART CTR)
(Z0=TOP)
(CYCLE TIME: )
(ROUGH 3/8 CARB)
(SET DIA TO .385)
G00 G53 Z0
G90 G17 G54 G80 G94 G49 G40
T1 M06
G00 G43 H01 D01
G00 X0. Y0 Z0.5
S700 M03
M08
#501=2.(rough feed rate)
M97 P1000
G55
M97 P1000
G56
M97 P1000
G57
M97 P1000
M09
M05
G00 G49 G53 Z0
(FINISH - 3/8 CARB)
T2 M06
G00 G43 H02 D02
G57
G00 X0 Y0 Z.5
S1400 M03
M08
#501=6.(finish feed rate)
M97 P1000
G56
M97 P1000
G55
M97 P1000
G54
M97 P1000
M09
M05
G00 G49 G53 Y0 Z0
T1 M06
M30
N1000 (MILL SQUARE SUB)
G00 X0 Y0 Z.5
G01 Z-.5 F200.
G01 G41 X0 Y.5 F#501
G01 X-.5 Y.5
G01 X-.5 Y-.5
G01 X.5 Y-.5
G01 X.5 Y.5
G01 X0 Y.5
G01 G40 X0 Y0 Z.5 F200.
M99
%

About time we got back into some good old fashioned G code fun. :D
 
Izzo....thanks for the help, looks simple enough, I'll have to give it a try.

Seymour....So if I understand this correctly, the sub program in the control would be "O1000" and is called for in the main program ("O0100")by "P1000" right? Why is it shown as "N1000" in the actual code for the sub program? Is that right? Not sure if I completely understand that part, since I thought the lines of the programs began with "N". It looks pretty simple though, and would be a heck of a lot easier when doing multiple pieces in the vises. Thank you.

Best Regards,
Russ
 
Thanks ARB....I've never heard of the feedrate numbers as you've shown, but it does make sense what you are saying. Is there any place to get some books or video's on Haas programming so I can learn more than just the basics?

Best Regards,
Russ
 
I run 3 6" kurt vises on my vf2 and do subs just like SD. I like it alot better that way. the whole program including the subs are saved as 1 program under the main program number.
Now if haas built a heavy duty machine or fanuc's were more like the haas control, well that would be great.
 
Wrustle,
With the local sub call M97. The control looks within the program for that particular line number. It does not look in the program list for the program like M98 does. This is the nice part of M97 local sub call. Notice the M99 at the end of the sub. Also not that the sub comes after the M30. If you have the subs up in the main part of the program you will end up with an endless loop.

I am not aware of any Haas books but if you do lots of looking back on this forum in the early days there was lots of G code discussion.


That and ask away here. There are enough of us that like to show off a little that you should learn some creative methods.

You might look at Mike Lynch's webside www.CNCcI.com he has some good basic information. Our own Heinz Putz has some good stuff as well. The codes may vary from fanuc but the concepts are the same.
 
Wrustle

Just like ARB has described, M97 is used for local subs. The sub resides in the same program as the main. The difference or gotcha is the M99.
All subprograms must end with M99, which in case of an M97 call will return the program pointer to the block right after the M97. In case however if the subprogram is encountered without a call, M99 will return to the top of the program, rewind/restart.
That is why as ARB had pointed out you must put the M30 BEFORE any of the local subs, and put the % sign at the END AFTER all the local subs.
Now for clearance of reading my programs, I only use N numbers whenever it's required. Haas does not need them on each block therefore any block I see with an N number is immediatey clear that it's either part of a subprogram or a canned cycle.
 
I prefer my subs be run like subroutines in a fadal.
All subs reside at the top of the program with a goto command before them so at the start the machine skips them until they are called.
 
Mikey
It's the same as the HAAS, except they are at the end and the main body is on top. The GOTO serves the same purpose as the M30. If you have macros in the HAAS, you can have them on top as well, just use a GOTO to jump over the subs to the main body.
 
On Friday last I marked 37 years in the machining profession. I keep learning new things all the time and pass on knowledge when I can do so. Thanks to SeymourDumore, I just got the local sub trick. I like it. Makes program saving easier by being all bundled and keeps the sequence of subs orderly. The Haas is fairly new to me, but the OM doesn't always download the programs in sequential, numerical order, and I can be a bit anal about some things.
Only a few sequence numbers to add to the program. I've only used them at tool changes before but I may modify my posts to use T# instead of N# to avoid any chance of confusion.
 
Unfortunately HAAS does not provide the capability to pass paramters to local subroutines. See G65 for external subroutines.

Thus, you have to load individual variables to accomplish this result.

Having local subroutines that are unique to a program within that program is a great advantage.

.


.
 
Reading the above brings back old memories...

Question...
You break a tool in the middle of part number 2

Can you stop and change the tool and then go right to Part number 2 and resume ??

Keep in mind that these may not be little parts in a vice,
they may be 3 ft x 8 ft parts on the table.
 
Gary,

I think it is possible to get as close as the beginning of a process using the current tool, at the correct work offset.

On Haas, I insert the tool change command lines at the beginning of every sub, not within the main program. On Haas, this does not pose a great difficulty because it can be set to skip over those tool change lines without unneccessary machine motions.

Keep in mind that the new tool will most likely require a re-reading of the tool length offset register to ensure that the new tool is being recognised. Running with the tool change within the sub permits a re-read of the length offset.

So, in restarting the program, I would cursor down within the main program to the sub call wherein the old tool failed. The machine will necessarily have to cut air until it finds metal again.
 
Hu.

With the "Program Restart" parameter turned on you don't even need to do that. It just runs the entire program in memory at full proc. speed until it reaches your restart point. It then turns on spindle, coolant, offsets and all just like if it was ran normally, retracts to machine Z0, plunges to the Z0 clearance for that operation and then feeds into the location where you restarted.
IOW no need to put the toolchange into the sub. You can do that but no need to.
 
Seymour,

That is true, but some day, I hope to grow my kahunas to such a size that I turn that option off :D Sometimes, it takes 10 minutes to get running again, and that time would be better spent letting the machine cut air within the sub, which it is going to have to do anyways.
 








 
Back
Top