art yet another message hope you like reading
I got the script to run some of the problem was I copy this xcor = GetAxisPos( 1 ); from the doc file and just realized it needed the enging xcor = Engine.GetAxisPos( 1 );
now the script will run to the end...
still some strange behaver I still need to run the script first though the script RUN to work,
if I press button and let run to the full distance entered for the axis I would have to do the script RUN first before every button press and I find if I have X-25 it stops at different distances usably at -28 after the first run.. I find the same when reversing if 1 have X3 It will run to X3 the first time but run again seem to stop at X0 this is all without hitting the probe....
if I run the script though script RUN then do a button press X-25 Axis starts running then I hit probe it stops ok pauses and then starts to reverse I hit the probe it stops and ZEROS the X axis.
the strange part is as long as I hit the probe while axis is running, I only have to run the script thought the script RUN Once as long as I keep hitting the probe while running I can just use the button.
here is the latest script
global mytable = table( "X", "Y", "Z","A" );
global ZeroToPlate = function(axis,dir,feedrate)
{
if ( axis < 1 || axis > 3 )
{
print("Error: Axis can only be 1 X, 2 Y, 3 Z");
return;
}
print("a = ",axis);
print(mytable[axis]);
axis = mytable[axis-1]; //X = 0 Y = 1 Z = 2 A = 3
print("a = ",axis);
print("d = ",dir);
print("f = ",feedrate);
GlobalSet("ProbeInvert",0); //set probe to normal state
string = "G31"+axis+"-25" + "F" + 100;
print(string);
Engine.GCode(string); //probe 25mm down in Z
block("MotionStill"); //wait for all motion to stop, no system delay for this.
pinstate = Pokeys1.GetPinDig(19);
if( pinstate )
//if( !GlobalGet("ProbeHit"))
{
print("No hit on probe ..Try again closer to plate.");
return;
} //we didnt hit the probe during the move
print("hit on probe");
sleep(0.5);
GlobalSet("ProbeInvert",1); //invert probe switch
string = "G31"+axis+"3" + "F" + 100;
print(string);
Engine.GCode(string); //probe upwards slowly till switch releases
block("MotionStill"); //wait for all motion to stop, no system delay for this.
xcor = Engine.GetAxisPos( 1 );
print("xcor = ",xcor);
pinstate = Pokeys1.GetPinDig(19);
if( pinstate )
//if( GlobalGet("ProbeHit"))
{
print("Zero Axis, probe complete.");
GlobalSet("Zero1",1); //this will zero axis #3-Z (the numbering starts at 1 for X in zeroing
//function even though some other functions start with 0 for X
}
else { print(" Error in touchoff" );
};
};
thanks gary