What's new
What's new

How to I know if the program runs in AUTO mode or MDI mode with MACRO?

Stephan Spears

Aluminum
Joined
Apr 12, 2014
Location
AB,Canada
Hi all,

As the title states, how do we identify whether the current running program is started within MDI mode or AUTO mode using Macro?

I ask because I come across situations as the followings:

I want to call a customized G-code(which is actually a main(sub) program itself) in MDI mode or in my main program. Let's call this G-code G12 and the program behind it O9010.

1) If I input and run only G12 in MDI, I want O9010 to end with M30 so that it won't loop and run again(looping is the behavior for M99 if M99 is interpreted as the program end).

2) If G12 is integrated with other command lines to form a main program which is run in Auto Mode, I want O9010 to end with M99 so that it returns to the point where it is called.

Is there any way to achieve this with Macro B?

Thanks in advance,

Steph
 
Presuming you have a Fanuc control, no, there is no way to do exactly what you want without a modification to your ladder program.

Are you passing variables with your G12? If not, then just use M98 P9010 when using MDI. If you are passing variables then use G65 P9010 A__ B__ when using MDI.

I use a toolchange macro M6 on my Mori and ran into the same issue you describe. For a while I did the G65 thing then decided to fix it properly by modifying the ladder so system variable #1015 is set to 1 when MDI mode is active. Then use an IF statement to check variable #1015 and branch to M99 or M30 depending on the state. My machine has ladder editing capability on the control so a pretty easy fix.
 
Hi all,

As the title states, how do we identify whether the current running program is started within MDI mode or AUTO mode using Macro?

I ask because I come across situations as the followings:

I want to call a customized G-code(which is actually a main(sub) program itself) in MDI mode or in my main program. Let's call this G-code G12 and the program behind it O9010.

1) If I input and run only G12 in MDI, I want O9010 to end with M30 so that it won't loop and run again(looping is the behavior for M99 if M99 is interpreted as the program end).

2) If G12 is integrated with other command lines to form a main program which is run in Auto Mode, I want O9010 to end with M99 so that it returns to the point where it is called.

Is there any way to achieve this with Macro B?

Thanks in advance,

Steph

Hello Steph,
I've never encountered an issue where a Macro Program ran as a loop if called via a Custom "G" or "M" Code in MDI Mode. Calling a Macro Program with with a Custom "G" or "M" Code is exactly the same as calling it with G65 P_ _ _ _. Accordingly, if the Macro Program is called when in MDI Mode with G65 P_ _ _ _, it will behave in the same manner as if called by a Custom "G" or Custom "M" Code.

All of my client's machines have been equipped with Macro Programs that I've written for Tool Length Measurement and Work Shift Offset setting that can be successfully executed in either MDI Mode or Auto Mode. In all cases, the Macro programs finish in M99.

If you were to call the Macro Program up in Edit or Memory Mode, so that it became the Foreground program, and then executed the the program in Auto Mode, then it would continually Loop if M99 was the terminating Block. However, when calling a Macro Program by G65 P_ _ _ _, or Cusrom "G" or "M" Code, either from within a Memory Program in Auto Mode, or via MDI, the Macro Program in this instance is not the Foreground Program.

With most Fanuc Controls (early controls excluded), more than one Command Block, each being terminated by an EOB, can be entered and executed either in Single Block, or Continuous Operation in MDI Mode. Take for example the following:

G12 X_ _ Y_ _; (MACRO PROGRAM CALLED BY CUSTOM G CODE - 12)
S2000 M03;
G04 X2.0;
M05;

Why, using the above example, would you expect Control to get stuck in a Loop of the Macro Program when called with G12, and not return to execute the remainder of the MDI Program Blocks?



Regards,

Bill
 
Hi Bill,

Your example would not loop. Because after the G12 returns at M99 in its background program, there are still some command lines to be executed. But what if you just input G12 in MDI and run (Nothing follows)? Like this:

In MDI mode:
G12;

Would it get into a loop if M99 is used to end the background program of G12?

Thanks in advance

Steph
 
My Mitsubishi Meldas 50M does loop if a Macro or program ending in M99 is executed from MDI. Prior to my ladder mod, the command M6 T_ in MDI would cause the toolchange motions to be repeated continuously until feed hold or single block were activated.
 
Hi Bill,

Your example would not loop. Because after the G12 returns at M99 in its background program, there are still some command lines to be executed. But what if you just input G12 in MDI and run (Nothing follows)? Like this:

In MDI mode:
G12;

Would it get into a loop if M99 is used to end the background program of G12?

Thanks in advance

Steph

Hello Steph,
I used the multi-block example simply to illustrate the point. With the Macro Program I use to measure and set Tool Length Offsets the syntax is as follows and executed in MDI Mode:

G101 T_ _ E_ _ (One Block Only)

Where:
G101 = Custom "G" Code to call Macro Program
T_ _ = Tool Number passed to the Macro to be measured
E_ _ = Last Tool Number in an unbroken sequence if more than one tool is to be measured (Optional)

The Macro called by the above Custom "G" Code in MDI Mode:
1. Tool Changes the specified tool into the Spindle if not already there

2. Rapids to a predetermined X/Y coordinate where a Setting Device is located

3. Displays a Message instructing the operator to select Manual Mode and move the tool to touch the Setting Device

4. After 3 above is completed, MDI Mode is again selected and Cycle Start pressed. This action causes the Tool Offset to be calculated and registered in the Offset Registry corresponding to the current Tool Number, and the Z axis to rapid to the Z Reference Return Position.

5. If for some reason the X/Y position of 2 above was changed by manually moving the Spindle after point 2 completes, the new X/Y coordinate is remembered for successive Tool Length measurements.

6. If the "E" argument is included in the Macro Call, the above processes from 1 to 4 are repeated until all Tools from T_ _ to E_ _ have been processed.

The Macro Program in the above example ends in M99.

Regards,

Bill
 








 
Back
Top