Hello Guest it is March 29, 2024, 07:02:34 AM

Author Topic: Restart program  (Read 1825 times)

0 Members and 1 Guest are viewing this topic.

Restart program
« on: September 17, 2019, 02:00:25 PM »
Hi I am trying to learn how Mach 4 works.  I am more used to Fanuc.  If I want to run a program a certain amount of cycles I use the Macro B statements.  But I tried using the GOTO command in Mach4 but it just hung there. Do you have any ideas on how to do this?


N10
G0XOYO
...
#100=#100+1
IF[#100LT10]GOTO10
M30
Re: Restart program
« Reply #1 on: September 17, 2019, 02:33:09 PM »
Hi,
Mach4Hobby (or Mach3) does not have MacroB, Mach4Industrial does.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Restart program
« Reply #2 on: September 17, 2019, 02:39:43 PM »
It's just like Fanuc... you have to pay extra for the Macro B option.  :'(

But in Fanuc it was just a parameter change; you just had to know the one.  ;)
Re: Restart program
« Reply #3 on: September 17, 2019, 02:52:37 PM »
I guess it is all about what/who you know.    Do you have an idea on how to get the program to auto-restart or loop?   There has got to be a way.
Re: Restart program
« Reply #4 on: September 17, 2019, 02:54:53 PM »
M99
Re: Restart program
« Reply #5 on: September 17, 2019, 02:58:44 PM »
So would you write it:

O2692
 G0X0
...
M98P2692
Re: Restart program
« Reply #6 on: September 17, 2019, 03:10:05 PM »
Hi,
you can call a subroutine a certain number of times, this is from the Mill Gcode manual that is in the Docs folder that
ships with Mach4:

Quote
M98 – Subprogram Call
Subprograms are external programs referenced by the current running program. When called program execution will continue in the subprogram. This allows the user to reduce program length and complexity by providing the ability to easily repeat sections of code, run the same section of code in multiple locations or in multiple fixture offsets, the possibilities are limited only by the programmer. To call a subprogram command M98 with the program number as shown.
Format: M98 P____ Q__ L__
P specifies the number of the program to be called. This is a four digit integer number. When the M98 is read Mach scans the current file for a block containing the program number in the following form:
Format: O1234
Note that the letter “O” is used to specify the program number 1234, NOT the number “0”.

The arguments Q and L are optional. Q specifies the sequence number in the subprogram to start at. If
Q is omitted then execution will start at the beginning of the sub program; see figure 198-1. L is the
number of repetitions. For example, if L=2 the subprogram is run two times before execution of the
main program continues. If L is omitted the program will run only once.

If you want to use conditionals (IF-THEN-ELSE, DO_WHILE) in Mach4Hobby then you use macros, the macros are coded in Lua.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Restart program
« Reply #7 on: September 17, 2019, 03:17:01 PM »
I read that, was not sure how to apply that to the main program.  I guess you could create the main program as one program name and then use it as a spring board into your sub program that carries your whole program inside.  I have never used it that way but I guess it would work.

(Main Program)
12345
G0G90X0Y0
M98P2692L10
M30

(Sub program)
O2692
G0X20.Y10.
...
M99
Re: Restart program
« Reply #8 on: September 17, 2019, 04:42:00 PM »
Hi,
yes thats how I would apply it.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Restart program
« Reply #9 on: September 17, 2019, 04:43:10 PM »
Thank-you so much!!