What's new
What's new

help understanding OMc tool change program?

xa-mont

Hot Rolled
Joined
Apr 4, 2014
Location
Victoria, Australia
Hey guys,

I just recently got a new to me hartford VMC running. It's got an OMc controller and so far most things seem to be working well - one issue i have is that when i give an "M06 T#" and the tool is the same as what's currently in the spindle when its doing it's G28 Z0. move it actually heads to Z0 for whatever work coords are currently active, without any tool offset applied - so basically it drives into the workpiece - no bueno.

I tried stuffing some g91's in the tool change program before the g28 lines. that fixed the plunging to z0 issue, but it then started running the program without tool offsets applied.

basically i need someone with some more knowledge of macros and g/m code than me to sus out where my problem/s are stemming from? (all of my other machines are Mazaks, so my g/m code experience is very limited.) If someone could take the time to explain the whole thing so I can learn a bit more that'd be awesome too. (i have a bit of a programming background so if/else/etc all makes sense already)

here's my tool change prog.
Code:
:9020G00 
IF[#1015EQ1]GOTO180
#1111=1
#100=0 
WHILE[#100LE20]DO1 
#[#100+100]=0
#100=100+1 
END1 
#1100=0
#1101=0
#1102=0
#1103=0
#1104=0
#110=#4001 
#111=#4002 
#112=#4003 
#113=#4006 
#114=#4017 
G63G0G40G80G49 
#1100=1
M94
#107=#1032 
IF[#20EQ#107]GOTO150 
G17G91G21
M92
#109=#1032 
/M73 
N10G28Z0 
IF[#5023NE0.0]GOTO10 
M19
IF[#20EQ#107]GOTO170 
IF[#107EQ99.0]GOTO120
IF[#20EQ99.0]GOTO140 
IF[#107EQ#105]GOTO110
 
 
M93
 
 
N110M82
 
 
M11
N120G30Z0
T#20 
M82
M11
#1101=1
G91
G28Z0
G90
M10
#1102=1
M83
GOTO150
N140IF[#107EQ#105]GOTO145
M93
N145G28Z0
M82
M11
G30Z0
M10
#1103=1
M83
N150G28Z0
GOTO170
N160#1104=1
N170#1100=0
#1101=0
#1102=0
#1103=0
#1104=0
G64G#110G#111G#112G#113
#100=0 
WHILE[#100LE20]DO1 
#[#100+100]=0
#100=#100+1
END1 
N180M95
M74
#1111=0
M99
%
 
Hey guys,

I just recently got a new to me hartford VMC running. It's got an OMc controller and so far most things seem to be working well - one issue i have is that when i give an "M06 T#" and the tool is the same as what's currently in the spindle when its doing it's G28 Z0. move it actually heads to Z0 for whatever work coords are currently active, without any tool offset applied - so basically it drives into the workpiece - no bueno.

I tried stuffing some g91's in the tool change program before the g28 lines. that fixed the plunging to z0 issue, but it then started running the program without tool offsets applied.

basically i need someone with some more knowledge of macros and g/m code than me to sus out where my problem/s are stemming from? (all of my other machines are Mazaks, so my g/m code experience is very limited.) If someone could take the time to explain the whole thing so I can learn a bit more that'd be awesome too. (i have a bit of a programming background so if/else/etc all makes sense already)

here's my tool change prog.
Code:
:9020G00 
IF[#1015EQ1]GOTO180
#1111=1
#100=0 
WHILE[#100LE20]DO1 
#[#100+100]=0
#100=100+1 
END1 
#1100=0
#1101=0
#1102=0
#1103=0
#1104=0
#110=#4001 
#111=#4002 
#112=#4003 
#113=#4006 
#114=#4017 
G63G0G40G80G49 
#1100=1
M94
#107=#1032 
IF[#20EQ#107]GOTO150 
G17G91G21
M92
#109=#1032 
/M73 
N10G28Z0 
IF[#5023NE0.0]GOTO10 
M19
IF[#20EQ#107]GOTO170 
IF[#107EQ99.0]GOTO120
IF[#20EQ99.0]GOTO140 
IF[#107EQ#105]GOTO110
 
 
M93
 
 
N110M82
 
 
M11
N120G30Z0
T#20 
M82
M11
#1101=1
G91
G28Z0
G90
M10
#1102=1
M83
GOTO150
N140IF[#107EQ#105]GOTO145
M93
N145G28Z0
M82
M11
G30Z0
M10
#1103=1
M83
N150G28Z0
GOTO170
N160#1104=1
N170#1100=0
#1101=0
#1102=0
#1103=0
#1104=0
G64G#110G#111G#112G#113
#100=0 
WHILE[#100LE20]DO1 
#[#100+100]=0
#100=#100+1
END1 
N180M95
M74
#1111=0
M99
%

Hello Travis,
It would take quite a bit to explain what each and every Block is doing, so I'll limit the discussion to your issue.

First of all, is the copy of your program listed in your Post accurate, or could there be typos if you typed the program rather than a Copy and Paste into your opening Post?

The following extract from your listed program

WHILE[#100LE20]DO1
#[#100+100]=0
#100=100+1
END1

I believe should read as the following

WHILE[#100LE20]DO1
#[#100+100]=0
#100=#100+1
END1

otherwise the DO Loop makes little sense

Putting G91 before each G28 was correct to do and just to be safe, G91 should also be placed before all G30 addresses in the program.

After setting G91 before each G28 and G30, the issue of the program running without an apparent offset (Tool Length and Workshift) is more to do with your Work Program than the Tool Change Program.

The following Block that appear near the Start of your Tool Change Program
#112=#4003
records the Group 03 G Code (G90 - G91) that was current when control passed to the Tool Change Macro.

The following Block that appear towards the End of your Tool Change Macro is to restore the value of various G Codes (including G90/G91) that were current before control was passed to the Tool Change Macro.

G64G#110G#111G#112G#113

There is nothing in the Tool Change Macro that you have listed that would circumvent Tool and Workshift Offsets in your Work Program, other than the current Group 03 G Code being G91 when control is returned to the Work Program. Given that #112 records the Group 03 G Code that was current before the Tool Change Macro was called and its restored with:

G64G#110G#111G#112G#113

before control is returned to the Work Program, G91 must have been current before control was passed to the Tool Change Macro.

Post a copy of your Work Program to give the Forum a better understanding of what is going on in your program.

If your Work Program was arranged something like the following:

M06 T20
S3000 M03
G90 G54 X_ _ Y_ _(or whatever the Work Shift Offset is)
G43 Z_ _ H20

then your program should work with the Tool Change Macro you have Posted.

It is far from a well written Macro, with many redundant Macro Statements. However, at a glance, I believe the Macro will work in spite of the program's short comings.

Regards,

Bill
 
Last edited:
Hello xa-mont,
It would take quite a bit to explain what each and every Block is doing, so I'll limit the discussion to your issue.

First of all, is the copy of your program listed in your Post accurate, or could there be typos if you typed the program rather than a Copy and Paste into your opening Post?

The following extract from your listed program

WHILE[#100LE20]DO1
#[#100+100]=0
#100=100+1
END1

I believe should read as the following

WHILE[#100LE20]DO1
#[#100+100]=0
#100=#100+1
END1

otherwise the DO Loop makes little sense

Putting G91 before each G28 was correct to do and just to be safe, G91 should also be placed before all G30 addresses in the program.

After setting G91 before each G28 and G30, the issue of the program running without an apparent offset (Tool Length and Workshift) is more to do with your Work Program than the Tool Change Program.

The following Block that appear near the Start of your Tool Change Program
#112=#4003
records the Group 03 G Code (G90 - G91) that was current when control passed to the Tool Change Macro.

The following Block that appear towards the End of your Tool Change Macro is to restore the value of various G Codes (including G90/G91) that were current before control was passed to the Tool Change Macro.

G64G#110G#111G#112G#113

There is nothing in the Tool Change Macro that you have listed that would circumvent Tool and Workshift Offsets in your Work Program, other than the current Group 03 G Code being G91 when control is returned to the Work Program. Given that #112 records the Group 03 G Code that was current before the Tool Change Macro was called and its restored with:

G64G#110G#111G#112G#113

before control is returned to the Work Program, G91 must have been current before control was passed to the Tool Change Macro.

Post a copy of your Work Program to give the Forum a better understanding of what is going on in your program.

If your Work Program was arranged something like the following:

M06 T20
S3000 M03
G90 G54 (or whatever the Work Shift Offset is)
G43 Z_ _ H20

then your program should work with the Tool Change Macro you have Posted.

It is far from a well written Macro, with many redundant Macro Statements and variables that have not been set. However, at a glance, I believe the Macro will work in spite of the program's short comings.

Regards,

Bill

I started writing a bit old response but then left my computer and didn't get back to it for a few days :P

Basically thanks heaps. i have a much better understanding of it from what you have described. I didn't realise what a lot of those variables were taking information from the current state of the machine etc, so that helps a lot.

If i can be bothered i'll try write another tool change program myself that's a little less messy.

Cheers,
Trav
 
I started writing a bit old response but then left my computer and didn't get back to it for a few days :P

Basically thanks heaps. i have a much better understanding of it from what you have described. I didn't realise what a lot of those variables were taking information from the current state of the machine etc, so that helps a lot.

If i can be bothered i'll try write another tool change program myself that's a little less messy.

Cheers,
Trav

Hello Travis,

Following is a rough explanation of what the Macro is doing. There are more elegant ways of writing a Macro to do as your Macro is doing, but as the saying goes, if its not broken, don't fix it. The Changes you can safely make are shown in RED. As I suggested in my earlier Post, the issue of the program running without an apparent offset (Tool Length and Workshift) is more to do with your Work Program than the Tool Change Program. Solution, change the syntax of your Calling Program to include G90 when control is returned from the Tool Change Macro.

O9020
IF[#1015EQ1]GOTO180 (IF #1015 OUTPUT FROM PMC IS ON - ABORT TOOL CHANGE)
#1111=1 (WRITE #1111 INPUT SIGNAL BIT TO PMC)
#100=0
WHILE[#100LE20]DO1 (SETS VARIABLES #101 TO #120 TO ZERO)
#[#100+100]=0
#100=100+1 #100=#100+1
END1
#1100=0 (INITIALIZE USER INTERFACE INPUT BITS TO PMC STARTS HERE)
#1101=0
#1102=0
#1103=0
#1104=0 (INITIALIZE USER INTERFACE INPUT BITS TO PMC END HERE)
#110=#4001 (STORE GROUP 01 G CODE)
#111=#4002 (STORE GROUP 02 G CODE)
#112=#4003 (STORE GROUP 03 G CODE)
#113=#4006 (STORE GROUP 06 G CODE)
#114=#4017 (STORE GROUP 17 G CODE)
G63G0G40G80G49
#1100=1 (WRITE #1100 INPUT SIGNAL BIT TO PMC)
M94
#107=#1032 (READ ALL 16 BITS OF A SIGNAL FROM PMC – SPINDLE TOOL NUM I SUSPECT)
IF[#20EQ#107]GOTO150 (IF SPINDLE TOOL EQUALS REQUESTED TOOL – ABORT TOOL CHANGE)
G17G91G21
M92
#109=#1032 (NOT USED EXCEPT FOR DEBUGGING PERHAPS)
M73
N10G28Z0 N10G91G28Z0
IF[#5023NE0.0]GOTO10 (DAGY METHOD USED TO ENSURE REFERENCE RETURN IS COMPLETE)
M19
IF[#20EQ#107]GOTO170 (IF SPINDLE TOOL EQUALS REQUESTED TOOL – ABORT TOOL CHANGE)
IF[#107EQ99.0]GOTO120 (NO SPINDLE TOOL NUMBER HELD BY PMC – GOTO N120)
IF[#20EQ99.0]GOTO140 (NO LEGAL TOOL NUMBER PASSED TO MACRO FROM CALLING PROGRAM – GOTO N140)
IF[#107EQ#105]GOTO110 (SPINDLE TOOL = ZERO – PROBABLY EMPTY – GOTO N110)


M93


N110M82


M11
N120G30Z0 N120G91G30Z0
T#20
M82
M11
#1101=1
G91 Delete
G28Z0 G91G28Z0
G90 (Did you put that here? If yes - Delete)
M10
#1102=1
M83
GOTO150
N140IF[#107EQ#105]GOTO145
M93
N145G28Z0 N145G91G28Z0
M82
M11
G30Z0 G91G30Z0
M10
#1103=1
M83
N150G28Z0 N150G91G28Z0
GOTO170
N160#1104=1
N170#1100=0
#1101=0
#1102=0
#1103=0
#1104=0
G64G#110G#111G#112G#113 (RESTORE G CODE GROUP 01, 02, 03 AND 06)
#100=0
WHILE[#100LE20]DO1 (SETS VARIABLES #101 TO #120 TO ZERO)
#[#100+100]=0
#100=#100+1
END1
N180M95
M74
#1111=0 (EXTINGUISH INPUT SIGNAL BIT #1111 IN PMC)
M99
%

The use of User Interface System Variables #1000 – #1015 and #1100 – #1115 requires the PMC Program to determine their exact use.

Regards,

Bill
 
Last edited:
Hello Travis,

Following is a rough explanation of what the Macro is doing. There are more elegant ways of writing a Macro to do as your Macro is doing, but as the saying goes, if its not broken, don't fix it. The Changes you can safely make are shown in RED. As I suggested in my earlier Post, the issue of the program running without an apparent offset (Tool Length and Workshift) is more to do with your Work Program than the Tool Change Program. Solution, change the syntax of your Calling Program to include G90 when control is returned from the Tool Change Macro.

O9020
IF[#1015EQ1]GOTO180 (IF #1015 OUTPUT FROM PMC IS ON - ABORT TOOL CHANGE)
#1111=1 (WRITE #1111 INPUT SIGNAL BIT TO PMC)
#100=0
WHILE[#100LE20]DO1 (SETS VARIABLES #101 TO #120 TO ZERO)
#[#100+100]=0
#100=100+1 #100=#100+1
END1
#1100=0 (INITIALIZE USER INTERFACE INPUT BITS TO PMC STARTS HERE)
#1101=0
#1102=0
#1103=0
#1104=0 (INITIALIZE USER INTERFACE INPUT BITS TO PMC END HERE)
#110=#4001 (STORE GROUP 01 G CODE)
#111=#4002 (STORE GROUP 02 G CODE)
#112=#4003 (STORE GROUP 03 G CODE)
#113=#4006 (STORE GROUP 06 G CODE)
#114=#4017 (STORE GROUP 17 G CODE)
G63G0G40G80G49
#1100=1 (WRITE #1100 INPUT SIGNAL BIT TO PMC)
M94
#107=#1032 (READ ALL 16 BITS OF A SIGNAL FROM PMC – SPINDLE TOOL NUM I SUSPECT)
IF[#20EQ#107]GOTO150 (IF SPINDLE TOOL EQUALS REQUESTED TOOL – ABORT TOOL CHANGE)
G17G91G21
M92
#109=#1032 (NOT USED EXCEPT FOR DEBUGGING PERHAPS)
M73
N10G28Z0 N10G91G28Z0
IF[#5023NE0.0]GOTO10 (DAGY METHOD USED TO ENSURE REFERENCE RETURN IS COMPLETE)
M19
IF[#20EQ#107]GOTO170 (IF SPINDLE TOOL EQUALS REQUESTED TOOL – ABORT TOOL CHANGE)
IF[#107EQ99.0]GOTO120 (NO SPINDLE TOOL NUMBER HELD BY PMC – GOTO N120)
IF[#20EQ99.0]GOTO140 (NO LEGAL TOOL NUMBER PASSED TO MACRO FROM CALLING PROGRAM – GOTO N140)
IF[#107EQ#105]GOTO110 (SPINDLE TOOL = ZERO – PROBABLY EMPTY – GOTO N110)


M93


N110M82


M11
N120G30Z0 N120G91G30Z0
T#20
M82
M11
#1101=1
G91 Delete
G28Z0 G91G28Z0
G90 (Did you put that here? If yes - Delete)
M10
#1102=1
M83
GOTO150
N140IF[#107EQ#105]GOTO145
M93
N145G28Z0 N145G91G28Z0
M82
M11
G30Z0 G91G30Z0
M10
#1103=1
M83
N150G28Z0 N150G91G28Z0
GOTO170
N160#1104=1
N170#1100=0
#1101=0
#1102=0
#1103=0
#1104=0
G64G#110G#111G#112G#113 (RESTORE G CODE GROUP 01, 02, 03 AND 06)
#100=0
WHILE[#100LE20]DO1 (SETS VARIABLES #101 TO #120 TO ZERO)
#[#100+100]=0
#100=#100+1
END1
N180M95
M74
#1111=0 (EXTINGUISH INPUT SIGNAL BIT #1111 IN PMC)
M99
%

The use of User Interface System Variables #1000 – #1015 and #1100 – #1115 requires the PMC Program to determine their exact use.

Regards,

Bill

You're a Legend Bill. I'd gone through and written a lot of what you have (more question marks in mine) so this confirms a lot.

The g91/g90 on separate lines in there i didn't do, I tried adding others around the ones that DIDN'T have them to no effect though.

Thanks again mate. helps me understand it a lot better.
 
You're a Legend Bill. I'd gone through and written a lot of what you have (more question marks in mine) so this confirms a lot.

The g91/g90 on separate lines in there i didn't do, I tried adding others around the ones that DIDN'T have them to no effect though.

Thanks again mate. helps me understand it a lot better.

Hello Travis,
If the original author of the Macro included the G90 in the place it appears in the Macro, then perhaps it may be required for the M10 function, or it could be just clumsy programming in keeping with other poor practices demonstrated in the Macro Program; I couldn't say for sure without knowing what the various M Codes used with your machine do. Apart from that requirement, I can't see any reason for its inclusion.

G90
M10

However, including G91 with G28 and G30 as they occur though out the program is good practice, along with Restoring the Group 03 G Codes before exiting the Tool Change Macro.

If G90 Mode is required for the M10 Function, then it would have to be included before other executions of M10 in the program, if G91 is included with each G28 and G30.

Regards,

Bill
 








 
Back
Top