needleworks wrote:Thanks beefy, that is exactly what I am trying to do. As I have already homed the machine, the Z axis is at the top of it's travel, the only way the Z axis can go after that is down. All my values are correct for going to "Park 1" , the only thing I am trying to achieve is to change the order in which the axis move. For example, where it says in the Macro :-
double parkZ = 100;
double parkX = 0;
double parkY = 0;
can I simply change this order to this, where the Z axis will move last :-
double parkX = 0;
double parkY = 0;
double parkZ = 100;
I'm "almost" sure I had it running this way before but I just can't remember how I done it.
Ha ha, I can tell you've had zippo to do with programming.
No, "double parkZ = 100;" for example is a variable declaration, not a C# command, so the order of variable declaration does not affect anything.
"double" is the type of variable. "parkZ" is the variable name. " = 100" is giving the variable an initial value of 100. The semicolon terminates that C# statement.
Look at the stock standard M200 macro, and then look at this modified one I've just done. I've added a few extra comments to help you understand a little more. Note I've added a 4th variable declaration for "parkZ_finish", and to make things clearer I've renamed "parkZ" to "parkZ_start". Carefully read through the code and you may get some idea of what's happening.
If your Z home position is zero then make "parkZ_start" equal to zero. Basically, if Z is homed, nothing will happen because Z is already at that position, BUT..............imagine if you wanted to use PARK1 and you'd forgot to home. Automatically Z will travel first to zero (if that's your Z home position).
- Code: Select all
// Go to Park position 1 macro
double parkZ_start = 100;
double parkX = 0;
double parkY = 0;
double parkZ_finish = 0;
if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here...
{
MessageBox.Show("The machine was not yet homed, home the machine before run to parking position!");
exec.Stop();
return;
}
int originalmodalmode = exec.actualmodal; // remember the modal mode
while(exec.IsMoving()){}
// FIRST MOVE COMMAND - MOVE Z TO "parkZ" position
exec.Code("G00 G53 Z"+ parkZ_start); // Move Z up first to park1 Z position
while(exec.IsMoving()){}
// SECOND MOVE COMMAND - MOVE XY TO "parkX" and "parkY" co-ordinates
exec.Code("G00 G53 X" + parkX +" Y" + parkY); // Move to XY park1 position
while(exec.IsMoving()){}
// THIRD MOVE COMMAND - MOVE Z TO FINAL POSITION
exec.Code("G00 G53 Z"+ parkZ_finish); // Move Z position desired after XY moves
while(exec.IsMoving()){}
exec.Code("G" + originalmodalmode); // Set system back to the original distance mode
If you like the thought of having the power to change stuff like this (took me just a few minutes to modify that macro), then I recommend learning a bit of C programming. Once you get the basics of that, you can move onto C# but C alone will give you a lot of understanding of what's happening in macros. Seriously it puts a real evil grin on your face when you can do that stuff.