hy check this code how it works :
- if you declare z_zero only once, not for every bar :
.... input basic values:
.........v1 - how many parts
.........v3 - amount to change z_zero
.........v6 - your constant z_zero
.... program always starts from part one ( V2 =1 ); if by any reason you need to interrupt, and continue later, you may change V2 to the part to start; like this, you can continue a bar without needing to modify z_zero; also, if you forgot to declare V2=1 for the next bar, there is a M0 which raises whenever V2<>1, so it acts like a safety condition; even with V2 modified, V1 does not need to be modified
.... if all is ok, you just change bars, and don't interfere within the program; it will stop when V1 will be reached;
Code:
V1=100 ( how many parts )
V2=1 ( which part to begin with )
V3=1.0625 ( length to machine afferent to one cycle / program / part )
V6=... ( z_zero ... always the same )
( * )
CALL OCHK
V2=V2-1
VSZOZ=V6-V3*V2
NHERE
V2=V2+1
CALL OPROG
IF [ V2 EQ V1 ] NSKIP
VSZOZ=VSZOZ-V3
GOTO NHERE
NSKIP
M02
( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
OPROG
( program goes here )
RTS
( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
OCHK
IF [ V2 NE 1 ] GOTO N01
GOTO N03
N01 M0 ( be sure not to crash )
N03
RTS
- so far so good, but in reality, bars have different lenght, and maybe is hard to keep a constant z_zero; in this case :
... input bar, and initalize z_zero; program will read it and change it with each part just in case, there will be a backup for z_zero in the same soubroutine that comes up when V2 is not 1
... if you need to continue from a certain part, than :
....... only change V2 to desired part
..............or
....... leave V2=1 and change :
......... z_zero
......... V1 ( decrease number of total parts )
... thus, you need to change V1 when z_zero changes; this occurs when :
..... machining was interrupted after some parts have been crafted
.........or
..... there are bars with different length, so parts/bar will vary
if somehow a shorter bar is used, and V1 is not changed, than a crash may occur, so to avoid this, initalize V5 with the lower admisible value for z_origin; like this, if someone tries to craft more parts from a shorter bar, machine will stop when reaching a limit Z position
this condition may lead to a trick, when using the program :
... declare V5 as real as possible, so to stay safe
... don't buther about V1; for example, declare V1=9999.9999
.... if all is ok, you just change bars, and z_zero with every bar and don't interfere within the program, even if bars are not equal; it will stop always arround same phisical position
Code:
V1=99999 ( how many parts )
V2=1 ( which part to begin with )
V3=1.0625 ( length to machine afferent to one cycle / program / part )
V5=... ( lower admisible limit for z_zero ... always the same )
( * )
CALL OCHK
V2=V2-1
VSZOZ=VSZOZ-V3*V2
IF [ VSZOZ LE V5 ] NSKIP
NHERE
V2=V2+1
CALL OPROG
IF [ V2 EQ V1 ] NSKIP
VSZOZ=VSZOZ-V3
GOTO NHERE
NSKIP
M02
( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
OPROG
( program goes here )
RTS
( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
OCHK
IF [ V2 NE 1 ] GOTO N01
IF [ V2 EQ 1 ] GOTO N02
N01 M0 ( be sure not to crash )
GOTO N03
N02 V10=VSZOZ ( z_zero backup )
GOTO N03
N03
RTS
these examples don't just count, but handles particular cases often meet into practice :
... faster in cycle restart
... z_zero backup
... handles unequal bars
... stoping condition being not " how many parts have been crafted " but " don't crash "
... you may speed up initializing z_zero with each bar, by using G22 comand if it works
i like the final one; let's dehot it, using CALL O... Q_times
Code:
V2=1 ( which part to begin with )
V3=1.0625 ( length to machine afferent to one cycle / program / part )
V5=... ( lower admisible limit for z_zero ... always the same )
( * )
CALL OCHK ( same as before )
V2=V2-1
VSZOZ=VSZOZ-V3*V2
CALL OPROG Q99..999
M02
( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
OPROG
VSZOZ=VSZOZ-V3
IF [ VSZOZ LE V5 ] NSKIP
( program goes here )
NSKIP
RTS
shorter and safer and as mr Wizard said : main programs should contain all of your "running" code kindly !
Originally Posted by
dansteinmetz
I also tried to "schedule" a group of main programs to run in sequence....
it can be done also like this, but is not the case ... "schedule" is for a higher purpose, like ... hmm ... i would say " fried potatoes with cheese ", but i don't "schedule" that