Hello Guest it is March 28, 2024, 09:33:12 PM

Author Topic: counting iterations of macro  (Read 5906 times)

0 Members and 1 Guest are viewing this topic.

counting iterations of macro
« on: June 16, 2008, 02:22:36 PM »
Hello all,

I am running programs that need to load a part, do movements, other stuff, move...etc... unload part, .. restart.  For now, the operator watches the machine run for several hours as it loads and unloads from a magazine.  I don't have a "part in magazine" detector and just want to tell the program to run 16 cycles.  I am pretty good at writing macros.. How would I recall values of variables to count through 16 cycles?

Thank You,
Ray Scott

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: counting iterations of macro
« Reply #1 on: June 16, 2008, 02:31:11 PM »
you can run a "G code sub routine", or if you want you can use "Vars" to hold your counts.

SetVar(100, 16) will set the # 16 in the VAR 100,
GetVar(100) will get the value in VAR 100

scott
fun times

vmax549

*
Re: counting iterations of macro
« Reply #2 on: June 25, 2008, 11:14:55 AM »
Ray I believe that mach has a built in loop counter that runs with subloop.

DRO# 222



Hope that helps, (;-) TP
« Last Edit: June 25, 2008, 11:20:11 AM by vmax549 »
Re: counting iterations of macro
« Reply #3 on: January 09, 2010, 03:54:01 PM »
I realize that this is a very old thread, but it's the only information I've been able to find.

vmax549, thank you for the tip.

I've tried both OEM DRO 222 (Sub Program depth) and 78 (Repetitions DRO) without success.

My test program is

G18 (X-Z plane)
G20 (inch units)
G90 (absolute coordinates)
M98 P01 L6 (perform subroutine 01 6 times)
M30 (end program)
O01 (the subroutine)
G00 Z0.2500
G00 Z0.0000
M99 (return)
M30 (redundant end of program for safety)


I'm testing the DRO on my lathe, thus the G18.  The DRO just stays at 0 and doesn't increment.

I just created a DRO on my run screen and assigned it OEM 222 (or 78).  Is there something else I need to do or that I'm not doing right?

Randy
« Last Edit: January 09, 2010, 03:59:12 PM by zephyr9900 »

Online Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: counting iterations of macro
« Reply #4 on: January 12, 2010, 07:00:34 AM »
If you set your DRO to 222 and run this program the DRO counts down to zero, you have to use a small delay to give mach time to update the DRO's.

Graham

%
G18 (X-Z plane)
G20 (inch units)
G90 (absolute coordinates)
M98 P01 L6 (perform subroutine 01 6 times)
M30 (end program)

O01 (the subroutine)
G00 Z0.2500
G00 Z0.0000
G4 P100
M99 (return)
%
« Last Edit: January 12, 2010, 07:08:26 AM by Graham Waterworth »
Without engineers the world stops