Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Motion program stops when nested while loops used
#1
I have a program with a while loop nested inside another while loop. When I run it, the program stops after one iteration of the outer while loop, and exits. When I run "list apc, 1" it reports that the program stopped at the outer while loop conditional statement. Please advise:

open prog 1

local Lvar0=0;
local Lvar1=0;
local Lvar2=0;
local Lvar3;
L3=ldata.coord

abs
linear

// Enable external time base use
Coord[L3].pDesTimeBase=EncTable[8].DeltaPos.a
Coord[L3].TimeBaseSlew=1

while( L1 < 5 ) {
while ( L2 < 2 ) {
x10000 tm500
delay 2000

x30000 tm500
delay 2000

L2++
}

L1++
}

send 0 "done"
sendall

close
Reply
#2
After it stops check the CS feedrate override. Is it 0 or close to it?
Reply
#3
Try increasing the value of Coord[x].GoBack. This parameter is designed to prevent indefinite loops in the program from causing a situation where the next move can't be computed before it is needed to blend from the current move. But you want to be able to jump back in the program twice as you exit the inner loop.
Reply
#4
Thanks Curt, that did the trick. I set Coord[x].GoBack=1, and now I can iterate the outer and inner loops any number of times.

(10-17-2012, 04:30 PM)curtwilson Wrote: Try increasing the value of Coord[x].GoBack. This parameter is designed to prevent indefinite loops in the program from causing a situation where the next move can't be computed before it is needed to blend from the current move. But you want to be able to jump back in the program twice as you exit the inner loop.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)