Jump to content
OMRON Forums

synchronize problems


JeffB

Recommended Posts

Is there any way to call a motion program from another motion program and wait for the called motion program to finish?

 

I tried something like this:

 

angle = 0;

while (angle < 100)

{

﹒﹒test_running = FALSE;

﹒﹒test_running == TRUE;

 

﹒﹒start 1.10 //start prog 10 in CS 1

﹒﹒while (!(test_running) && Coord[1].InPos == FALSE) {};

﹒﹒﹒﹒test_running == FALSE;

﹒﹒angle += 1;

}

 

Then in the terminal I typed

&0 b ScanTest r

 

Instead of the angle incrementing by 1 it incremented by 4. I assume the motion program is looking ahead but I'm not sure how to force it to synchronize with my logic.

 

Thanks

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

There is no reason to wait since motion programs are sequential and execution will return automatically when it is done.

test_running will be false when it is done without the while loop (ignoring any lookahead for now). Note that the synchronous assignment == must be followed by a move (e.g. DWELL) for it to take effect. I would do it this way:

test_running == TRUE

START 1:10

DWELL 0 // Break Lookahead

test_running == FALSE

DWELL 0 // Force synchronous assignment

angle += 1

Link to comment
Share on other sites

I'm still struggling a bit with the lookahead. I modified my code as below and it does one scan at 25°. scan_angle is 25 and angle is 26. So somehow still looking ahead.

But if I uncomment out the while line it can work. Why?

 

Thanks

 

angle = 0;

while (angle < 25.1)

{

﹒﹒//variables used by prog 10

﹒﹒scan_angle = angle

﹒﹒scan_distance_mm = ((300*cosd(tilt_angle))/cosd(scan_angle))+50

 

﹒﹒test_running == TRUE;

﹒﹒start 1:10;

﹒﹒dwell(0); //break lookahead

 

﹒﹒test_running == FALSE;

﹒﹒dwell(0) //force synchronous assignment

﹒﹒//while (!(test_running) && Coord[1].InPos == FALSE) {};

﹒﹒angle += 1.0;

}

Link to comment
Share on other sites

I think the issue is that if angle is 25 (or less than 25.1) it will be increased at the end of a loop of code.

 

angle = 0;
while (angle < 25.1)
{
﹒﹒Code
﹒﹒angle += 1.0;
}

 

If you want the angle variable to be equal to 25 at the end you may have to adjust the format of the code. Here is one possible example.

angle = -1;
while (angle < 24.1)
{
﹒﹒angle += 1.0;
﹒﹒Code
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...