Program Question

Using help that I have received in this great NG, I have been able to write a program that does ALMOST what I want to do. But I am asking
the community to take a look at it and see one thing for me. Here is the program (the notes I put in there after the ; are for my employees to learn, I am assuming most people in here might know what those codes meant already, but I left them in there in case)
The two questions I have are 1. For some reason the coolant is only coming on for the SECOND operation/subroutine. Now when I look at the program, it seems my m08 code is in the FIRST operation and NOT in the second, but yet it is not turning on until after I have switched to the 1 tool. Can anyone see why this might be happening? 2. I am trying to drill these holes to Z-.06 and Z-.105 deep using the mill and drill respectively. It seems that in this program it is moving the tool -.06 and -.105 from the ORINGINAL Z starting point of Z.04 (which I have just for a clearance), meaning it seems its doing an incremental move of .06. What I need it to do is come to an ABSOLUTE point of Z-.06. Is there something that I am doing wrong here? (like should there be a g90/91 switch somewhere)?
; 2 POINT LBS:
N100;THIS FILE FOR 40 HOLE BOLT HOLE PATTERN
N106 G40;
N110 M08 M06 T02;TOOCHANGE .060 carbide mill N111 G43 H02;TOOL HEIGHT OFFSET REF FOR TOOL 2
N115 S9000 M03;SETS SPINDLE SPEED TO 9000
N120 G0 X0 Y0 Z0.04 N125 M03 N130 G16 N135 G91 X.4675 Y0;RADIUS OF .4675 N140 M98 P1 L40; M98 SUBROUTINE CALL P1 STARTS SUBROUTINE L40 IS 40 HOLES
N145 M06 T01;TOOCHANGE .037 STEEL DRILL N146 G43 H01;TOOL HEIGHT OFFSET REF FOR TOOL 1
N150 S8000 M03;SETS SPINDLE SPEED TO 8000
N155 G16 G90
N157 G0 X0 Y0 Z0.04 N160 M03 N165 G16 N170 G91 X.4675 Y0;RADIUS OF .4675 N171 M98 P2 L40; M98 SUBROUTINE CALL P2 STARTS SUBROUTINE L54 IS 54 HOLES
N174 G16 G90
N175 M09 M2 ; program end
; subroutines O1 Y9.0 F8.0;01 IS SUBROUTINE Y IS DEGREES BETWEEN HOLES (360/54) G81 Z-.06 R0 F8.0 G80 M99
O2 Y9.0 F5.0;02 IS SUBROUTINE Y IS DEGREES BETWEEN HOLES (360/54) G81 Z-.105 R0 F5.0 G80 M99
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Ratedr says...

[SNIP]

Ratedr, I may have prematurely posted a reply, if so this is the "good" one. Others have addressed the M08 problem. I would just add more M08 commands, can't hurt. As for the absolute/incremental problem I think I see it. You have G91 in lines N135 and N170 which are each prior to you subroutine call. I think you want the first line of each subroutine to be incremental so add code to the subs as follows:
O1 Y9.0 F8.0;01 IS SUBROUTINE Y IS DEGREES BETWEEN HOLES (360/54) G90(SET ABSOLUTE FOR DRILL DEPTH) G81 Z-.06 R0 F8.0 G80 G91(RESET TO INCREMENTAL FOR SUBSEQUENT REPETITIONS OF LOOP) M99
Do the corresponding thing in O2.
Cheers, plh

--
Where are we going and why am I in this HAND BASKET??

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

I had exactly this in mind, too, I was too lazy/busy to post it. =)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Wed, 9 Apr 2008 04:25:34 -0700 (PDT), Ratedr

Looks like on your machine you are only allowed one M code per block.
Put your M08 in the block with the tools first move or in a block by itself right after a tool change.

I add this following format for most machines as a safety (some machines require different format). (xx) = block number or tool number (xx.xxx) = value
********** (Beginning of tool)
N(xx) (TOOL DESCRIPTION); G40 G17 G80 G90 G49 G20 G54; M6 T(xx); S5000 M03; G00 X(xx.xxx) Y(xx.xxx) /M08; G43 H(xx) Z(xx.xxx);
(End of tool) G00 Z1.0 / M09; G40 M05; G91 G30 Z.0; (or G28 depending upon machine) M01; (M30 or M2 if end of pgm depending upon machine) ; *************

Use format above that way you know the state of every tool.

Only ONE M code per line allowed.

I would put H offset on the first Z move.

I would normally position XY first in its own block and then Z.
It is safer in the long run as a standard for clearing clamps etc. Then add M08 to the first move with a / so you can use block skip on setup if you don't want the coolant coming on. (make sure the /M08 is at the end of the block)
Like this:
G00 X.0 Y.0 / M08; G43 H02 Z.04;

You already have M03 on block N115, it is modal you don't need it again.

I don't know off the top of my head, what is G16? Is it is prep for the BHC.

G91 is incremental, if you want absolute use G90.
G90/G91 are modal, you only need it in the program when you want to change it. If you use the format I listed above you will be set to absolute.
If you need incremental for the sub program I would put it in the sub and at end of sub return it go absolute before returning to main pgm.

I would add this to each end of tool or end of pgm
(End of tool) G00 Z1.0 / M09; G40 M05; G91 G30 Z.0; (G28 depending upon your machine) M01; ;

I would put H offset on the first Z move.

On tool 2 you didn't have G90 in this position

G00 X.0 Y.0 / M08 G43 H01 Z.04

Don't need it twice

If you need incremental for the sub program I would put it in the sub and at end of sub return it go absolute before returning to main pgm.

Only 1 M code per block

(360/40)
R.04 to return to start Z

(360/40)
R.04 if you want to return to start Z.

Based upon your sample program and input this is what I suggest your program look like:
Assumes: G30 is tool change position G16 is BHC prep command BHC incremental positioning Drill cycle you want absolute
O3 (40 HOLE BOLT HOLE PATTERN); ; N10 (.060 CARBIDE END MILL); N20 G40 G17 G80 G90 G49 G20 G54; N30 M6 T02; N40 S9000 M03; N50 G00 X.4675 Y-0.0 /M08; N60 G43 H2 Z.04; N70 M98 P1 L40; N80 G00 Z4.0 /M09; N90 G40 M05; N100 G91 G30 Z0.0; N110 M01; ; N130 (.037 HSS DRILL); N140 G40 G17 G80 G90 G49 G20 G54; N150 M6 T1; N160 S8000 M03; N170 G00 X.4675 Y-0.0 /M08; N180 G43 H01 Z.04; N190 M98 P2 L40; N200 G00 Z4.0 / M09; N210 G40 M05; N220 G91 G30 Z.0; N230 M2 (M30 depending upon machine);
O1 (SUB 40 HOLES .06 DEEP); N10 G16 G91; N20 Y9.0 F8.0 (Y IS DEGREES BETWEEN HOLES 360/40); N25 G90 N30 G81 Z-.06 R.04 F8.0; N40 G80; N50 M99;
O2 (SUB 40 HOLES .105 DEEP); N10 G16 G91; N20 Y9.0 F5.0 (Y IS DEGREES BETWEEN HOLES 360/40); N25 G90; N30 G81 Z-.105 R.04 F5.0; N40 G80; N50 M99;
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
I just did a quick read of your machines manual and need to make some changes to the standard tool start, tool end and end of pgm that I recommended earlier.
What this recommendation does is force every tool to start exactly the same, with the same machine condition each and every time without question. It also overrides any settings in your settings page or control panel except the optional block skip and optional stop.
Assuming when M6 is called machine rapids to tool change position which I believe is G28 Z home and when you start the program current Z position is clear of any obstructions, Clamps, Material etc. as it rapids to tool change position.
**********
(Beginning of each and every tool)
N(xx); TOOL DESCRIPTION G40 G17 G80 G90 G49 G70 G54 G15 $ M6 T(xx) S(xxx) M03 G00 X(xx.xxx) Y(xx.xxx) /M08 G43 H(xx) Z(xx.xxx)
****************
(end of every tool except end of prm)
G00 Z1.0 / M09 G40 M05 G91 G28 Z.0 /M01
******************
(end of last tool/ end of pgm)
G00 Z1.0 / M09 G40 M05 G91 G28 Z.0 M2
******************* ******************* Explanation:
(Beginning of each and every tool)
N(xx); TOOL DESCRIPTION
Beginning block number xx ; Comment (anything after this character) (on the same block) (is treated as a comment) Add tool description
G40 G17 G80 G90 G49 G70 G54 G15 $
G40 = Cancel Cutter Comp G17 = XY Plane G80 = Cancel Canned Cycle G90 = Absolute G49 = Cancel Tool Length Offset G70 = Inch Mode G54 = Use Coordinate System 1 G15 = Polar Programming Cancel $ = Absolute Arc Centers (your machines default)
M6 T(xx)
Change tool to tool # xx
S(xxx) M03
Spindle Speed xxx, CW rotation
G00 X(xx.xxx) Y(xx.xxx) /M08
First rapid move X and or Y / optional block skip M08 Coolant on During setup if you enable optional block skip on the operators panel or in settings page coolant will not come on.
G43 H(xx) Z(xx.xxx)
G43 = Height offset positive direction H (xx) = H offset register Z (xx.xxx) = First Z rapid move towards part
*************** ***************
I think end of tool and end of pgm are self explanatory.
I also need to revise the sample code I posted for you, I will do that later on today or early tomorrow.
Tom
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Here is the revised sample code. You can literally copy and paste this into your control and try it out.
Setup:
For this program; XY Zero is center of BHC Z Zero is top of part
Your shops standard practice determines how you calculate & input your G54 & H offset inputs.
O1 ; BOLT HOLE PATTERN N10 N20 ;.060 CARBIDE END MILL N30 G40 G17 G80 G90 G49 G70 G54 G15 $ N40 M6 T02 N50 S9000 M03 N60 G00 X.4675 Y0.0 /M08 N70 G43 H2 Z.04 N80 G16 N90 M98 P2 L40 N100 G80 G15 N110 G00 Z1.0 / M09 N120 G40 M05 N130 G91 G28 Z.0 N140 /M01 N150 N160 ;.037 HSS DRILL N170 G40 G17 G80 G90 G49 G70 G54 G15 $ N180 M6 T1 N190 S8000 M03 N200 G00 X.4675 Y0.0 /M08 N210 G43 H01 Z.04 N220 G16 N230 M98 P3 L40 N240 G80 G15 N250 G00 Z1.0 / M09 N260 G40 M05 N270 G91 G28 Z.0 N280 M2 O2 ;SUB 40 HOLES .06 DEEP N290 X.0 Y9.0 ;X IS ARC CENTER ABS, Y IS DEGREES 360/40 N300 G81 Z-.06 R.04 F8.0 N310 M99 O3 ;SUB 40 HOLES .105 DEEP N320 X.0 Y9.0 ;X IS ARC CENTER ABS, Y IS DEGREES 360/40 N330 G81 Z-.105 R.04 F5.0 N340 M99
****************************** End sample code ******************************
EXPLANATION
O1 ; BOLT HOLE PATTERN Pgm # ; = comment character followed by program comment
N10
empty block between tools makes it easier to find tools start N20 ;.060 CARBIDE END MILL
; = comment character followed by tool comment N30 G40 G17 G80 G90 G49 G70 G54 G15 $
G40 = Cancel Cutter Comp G17 = XY Plane G80 = Cancel Canned Cycle G90 = Absolute G49 = Cancel Tool Length Offset G70 = Inch Mode (your machine) G54 = Use Coordinate System 1 G15 = Polar Programming Cancel $ = Absolute Arc Centers (your machines default)
N40 M6 T02
Tool change to tool #2
N50 S9000 M03
Spindle speed Normal rotation
N60 G00 X.4675 Y0.0 /M08
Rapid to X Y position start optional block skip Coolant on
N70 G43 H2 Z.04
Height offset plus direction Tool Height offset register Rapid to Z.04 Absolute
N80 G16
Polar coordinate on
N90 M98 P2 L40
Sub program call Sub program O2 Repeat sub 40 times
N100 G80 G15
Cancel Canned Cycle Cancel Polar Coordinate
N110 G00 Z1.0 / M09
Rapid Clear Z 1" above part optional block skip coolant off N120 G40 M05
Cancel offset Spindle stop
N130 G91 G28 Z.0
Incremental mode Home Since G00 & G40 are modal and still effective machine will rapid to home Z zero position N140 /M01
optional block skip optional stop
******** SAME FOR SECOND TOOL CALLED UP ********
EXPLANATION SUBS
O2 ;SUB 40 HOLES .06 DEEP
Sub program # ; comment character followed by program comment
N290 X.0 Y9.0 ;X IS ARC CENTER ABS, Y IS DEGREES 360/40
X.0 = Arc Center absolute position Y9.0 = Degrees between each hole F8.0 = Feed IPM
N300 G81 Z-.06 R.04 F8.0
G81 Drill Canned Cycle Z-.06 End Z position Absolute R.04 Drill retract point F8.0 Feed IPM
N310 M99
End sub program
************* Sub O3 SAME format ************
Tom
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
This didnt drill bolt holes, it just kept drilling in the same area
On Apr 10, 10:05 pm, snipped-for-privacy@aol.com wrote:

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Wed, 16 Apr 2008 05:33:15 -0700 (PDT), Ratedr
It figures I printed out sections of your manual, hadn't heard from you for a while and threw them out yesterday.
I missed something in the manual where it said we could use absolute mode and/or X center arc value should be in the main program right after G16 not in the sub.
Send me an email in the subject line put "Program Question" & I will send you my phone number. When you are ready to run give me a call and we can walk through it together live.
snipped-for-privacy@aol.com
Here is the corrected code using incremental
O1 ; BOLT HOLE PATTERN N10 N20 ;.060 CARBIDE END MILL N30 G40 G17 G80 G90 G49 G70 G54 G15 $ N40 M6 T02 N50 S9000 M03 N60 G00 X.0 Y0.0 /M08 N70 G43 H2 Z.04 N80 G16 N85 G91 X.4675 Y0.0 N90 M98 P2 L40 N100 G90 G80 G15 N110 G00 Z1.0 / M09 N120 G40 M05 N130 G91 G28 Z.0 N140 /M01 N150 N160 ;.037 HSS DRILL N170 G40 G17 G80 G90 G49 G70 G54 G15 $ N180 M6 T1 N190 S8000 M03 N200 G00 X.0 Y0.0 /M08 N210 G43 H01 Z.04 N220 G16 N225 G91 X.4675 Y0.0 N230 M98 P3 L40 N240 G90 G80 G15 N250 G00 Z1.0 / M09 N260 G40 M05 N270 G91 G28 Z.0 N280 M2
O2 Y9 G81 Z-.1 R.0 F8.0 M99
O3 Y9 G81 Z-.145 R.0 F5.0 M99
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.