Dynomotion

Group: DynoMotion Message: 9365 From: az9633@ymail.com Date: 3/24/2014
Subject: Motion in K flop
Tom, 
My application seems simple as it only requires independant axis motions in up to 6 axes.
I tried running a simple 2 axis program but I'm having difficulty with the motion sequencing. It looks like if the program has two move commands in sequence in a C code program they will both execute at the same time along with any output bit setting etc..  I"ve only been able to control the sequencing of the lines of motion code by using While statements based on Input I/O status. A "while (ReadBit(CheckDone(x)))" doesn't wait for the motion to complete.  What is it checking to be done?
 Is there a way to execute a motion and have the program wait until motion is complete before it executes the next motion whether its the same axis or a different one?  I can't find examples of this.
See below for my program.  What am I missing?
#include "KMotionDef.h"
void main() 
{
int i;
for (i=0; i<100; i++)
{
ClearBit(80);
ClearBit(81);
Delay_sec(0.1);
MoveAtVel(0,5000,10000);
while (ReadBit(CheckDone(0)));
MoveAtVel(1,6000,15000);
SetBit(80);
while (ReadBit(CheckDone(1)));
Delay_sec(2.5);
MoveAtVel(0,100,10000);
while(!ReadBit(75));
MoveAtVel(1,-150,8000);
while (ReadBit(CheckDone(1)));
SetBit(81);
Delay_sec(.5);
}

AZ

Group: DynoMotion Message: 9367 From: Tom Kerekes Date: 3/24/2014
Subject: Re: Motion in K flop
Hi Az,

CheckDone() basically returns 1 when the axis is done and 0 if the axis is not done.

In C zero is considered "false" and anything else is considered "true"

The statement:

while (ReadBit(CheckDone(0)));

doesn't really make any sense.  It will end up looping depending on the state of bit 0 or 1.

Instead just use:

while (CheckDone(0)==0);  // loop while Axis 0 Done is false

Or another way:

while (!CheckDone(0));  // loop while not Done Axis 0

To wait for more than one axis you might use:

while (!CheckDone(0) || !CheckDone(1));  // loop while not Done Axis 0 OR not Done Axis 1

HTH
Regards
TK

Group: DynoMotion Message: 9368 From: Tom Kerekes Date: 3/24/2014
Subject: Re: Motion in K flop
Hi Az,

CheckDone() basically returns 1 when the axis is done and 0 if the axis is not done.

In C zero is considered "false" and anything else is considered "true"

The statement:

while (ReadBit(CheckDone(0)));

doesn't really make any sense.  It will end up looping depending on the state of bit 0 or 1.

Instead just use:

while (CheckDone(0)==0);  // loop while Axis 0 Done is false

Or another way:

while (!CheckDone(0));  // loop while not Done Axis 0

To wait for more than one axis you might use:

while (!CheckDone(0) || !CheckDone(1));  // loop while not Done Axis 0 OR not Done Axis 1

HTH
Regards
TK

Group: DynoMotion Message: 9369 From: az@aimele.com Date: 3/25/2014
Subject: Re: Motion in K flop
Thank you Tom,

That sound you heard was me giving myself a dope slap.

AZ