Hi Dan,
Thanks for offering to share your code.
The main problem I see with your code is with this:
while(!ReadBit(20))
Jog(Y,0); // stop Y motion
You are basically missing a semicolon. The syntax structure of a C while loop is:
while (condition) statement;
The while loop keeps executing the single statement while the condition is true. C statements are terminated with semi colons. BTW If you need multiple statements to be executed you can group the statements into a single "block" using curly brackets.
But in these type of situations we normally want to do nothing while the condition is true (simply wait). So we put nothing followed by a semi colon like this:
while(!ReadBit(20)) ;
The code without the semicolon causes the following Jog command to be executed continuously in the loop. Calling continuous Jogs without any time for the newly created trajectory to even begin causes problems.
Please try adding the ; for all the while statements and test if things work better.
On another note the delays can probably be replaced by while (!CheckDone(X)) ; statements to improve performance.
Also to make your code more readable and understandable to others there is a convention of indentation that C Programmers use. Lines of code are indented by different amounts to indicate which level of grouping they belong to. This has no effect on the execution of the code but simply makes it more readable and shows the intent of the author. So for example if the Jog was intended to be looped by the "while" statement it would be written as:
Code:
while(!ReadBit(20))
Jog(Y,0); // stop Y motion
If multiple statements were to be grouped together with curly brackes and desired to be and looped by the while statement it might look something like:
Code:
while(!ReadBit(20))
{
Jog(X,0); // stop Y motion
Jog(Y,0); // stop Y motion
Jog(Z,0); // stop Y motion
}
HTH
Regards