reading Pokeys pins
Re: reading Pokeys pins
Gary:
Looks as efficient as any script ID write. Good job.
Art
Looks as efficient as any script ID write. Good job.
Art
Re: reading Pokeys pins
Art
One problem on large files it seems to read the EOF before its read the whole file at least it exits the loop and stops printing
small files its good, don't see any errors popping up is there a buffer limit to a table ?..
Gary
One problem on large files it seems to read the EOF before its read the whole file at least it exits the loop and stops printing
small files its good, don't see any errors popping up is there a buffer limit to a table ?..
Gary
Re: reading Pokeys pins
Gary:
Im sure a limit may exist, but I dont think in this case, unless one line gets too
large it shouldnt run into memory problems.
Your routine will skip the first line though... Id suggest the following change.
I might add the the null check may not be necessary as the print routine shouldn't
fail on a print(null) and it is possible for readline to return null without being at
the end of a file.
line = 0;
next_line[line] = myfile.ReadLine();
while (next_line[line] != EOF)
{
print(next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == null)
{
print("Null line found before end of file"); //can be ignored in many cases..
exit();
}
};
Art
]
Im sure a limit may exist, but I dont think in this case, unless one line gets too
large it shouldnt run into memory problems.
Your routine will skip the first line though... Id suggest the following change.
I might add the the null check may not be necessary as the print routine shouldn't
fail on a print(null) and it is possible for readline to return null without being at
the end of a file.
line = 0;
next_line[line] = myfile.ReadLine();
while (next_line[line] != EOF)
{
print(next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == null)
{
print("Null line found before end of file"); //can be ignored in many cases..
exit();
}
};
Art
]
Re: reading Pokeys pins
Art
I gave it a try same results, it seems its reading the end of file early...
It printed part of the file then quit, I assume it thought it read EOF, because it didn't print the null line..
it seems to run for a few second before it starts to print, I have no delays in there.. do you think its looping faster that it can print to screen..?
I will try looping with no print just storing the text lines in the table then print out the table in a loop worth a try..
Gary
I gave it a try same results, it seems its reading the end of file early...
It printed part of the file then quit, I assume it thought it read EOF, because it didn't print the null line..
it seems to run for a few second before it starts to print, I have no delays in there.. do you think its looping faster that it can print to screen..?
I will try looping with no print just storing the text lines in the table then print out the table in a loop worth a try..
Gary
Re: reading Pokeys pins
Gary:
There shouldnt be any buffer limit for the file, but the table may have a
line limit. Try replacing the same table line each time and see if it reads
the entire file. Im not sure the error, I havent played with files much, just
scripting tests early on for putting out point clouds and such.
Art
There shouldnt be any buffer limit for the file, but the table may have a
line limit. Try replacing the same table line each time and see if it reads
the entire file. Im not sure the error, I havent played with files much, just
scripting tests early on for putting out point clouds and such.
Art
Re: reading Pokeys pins
Art
Will give that a shot, I added line numbers to the print, one file reaches line 48 before it thinks it is reading a null and the other file stopped at line 46 before nulling out of the loop..
so could be table does have a limit and one file has more char's per line than the other so reads a couple more lines..
tried printing the file and only using a var next_line no table clearing the var each loop but did the same thing..
I wouldn't think there is some sort of looping limit going on?. just a thought
Update I have tried a few different txt files now and seems to make it to line 50 then exits the loop no print output so its not getting the null check just quits looping at or just under 50 lines of text..
Thanks gary
Will give that a shot, I added line numbers to the print, one file reaches line 48 before it thinks it is reading a null and the other file stopped at line 46 before nulling out of the loop..
so could be table does have a limit and one file has more char's per line than the other so reads a couple more lines..
tried printing the file and only using a var next_line no table clearing the var each loop but did the same thing..
I wouldn't think there is some sort of looping limit going on?. just a thought
Update I have tried a few different txt files now and seems to make it to line 50 then exits the loop no print output so its not getting the null check just quits looping at or just under 50 lines of text..
Thanks gary
Last edited by gburk on Wed Jul 24, 2019 9:27 am, edited 1 time in total.
Re: reading Pokeys pins
Art
I tried a loop that should loop 200 times and reading the file but it seems after 50 line read it exits the loop it doesn't print any of my messages like it hit a null or EOF or file closed just exits the loop.. here is a sample..
global next_line = table();
fileload = function()
{
myfile = system.File();
myfile.Open("*");
line = 0;
next_line[line] = myfile.ReadLine();
dowhile (line !=200)
{
print("Line # "+line+" "+next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == EOF)
{
print("EOF Reached");
myfile.Close();
print("File Closed");
return;
}
if (next_line[line] == null)
{
print("Line = Null");
myfile.Close();
print("File Closed");
exit();
}
};
myfile.Close();
print("File Closed");
};
fileload();
this script also only print 49 or 50 lines
x = 0;
dowhile( x < 400)
{
x = x + 1;
print("X = "+x);
};
gary
I tried a loop that should loop 200 times and reading the file but it seems after 50 line read it exits the loop it doesn't print any of my messages like it hit a null or EOF or file closed just exits the loop.. here is a sample..
global next_line = table();
fileload = function()
{
myfile = system.File();
myfile.Open("*");
line = 0;
next_line[line] = myfile.ReadLine();
dowhile (line !=200)
{
print("Line # "+line+" "+next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == EOF)
{
print("EOF Reached");
myfile.Close();
print("File Closed");
return;
}
if (next_line[line] == null)
{
print("Line = Null");
myfile.Close();
print("File Closed");
exit();
}
};
myfile.Close();
print("File Closed");
};
fileload();
this script also only print 49 or 50 lines
x = 0;
dowhile( x < 400)
{
x = x + 1;
print("X = "+x);
};
gary
Last edited by gburk on Thu Jul 25, 2019 1:29 pm, edited 1 time in total.
Re: reading Pokeys pins
Art
I removed the print during the loops, and only printed the last line read and line number when exiting the loop.
Its seems to finish looping this way, so it does seem that the print() is doing something to the loops if printing every line in the loop..
then it doesn't finish the loop or give an error either..
but read a 5000 plus line file not printing the lines only printed the last line on exit of the loop and it printed line 5082..
Gary
I removed the print during the loops, and only printed the last line read and line number when exiting the loop.
Its seems to finish looping this way, so it does seem that the print() is doing something to the loops if printing every line in the loop..
then it doesn't finish the loop or give an error either..
but read a 5000 plus line file not printing the lines only printed the last line on exit of the loop and it printed line 5082..
Gary
Re: reading Pokeys pins
have you tried a
sleep(.04); //of some micro second
after or before a line read?
sounds like reading of the file or printing is causing a buffer spooling/overload/limit of some kind.
I believe Art is off cruising on vacation.
sleep(.04); //of some micro second
after or before a line read?
sounds like reading of the file or printing is causing a buffer spooling/overload/limit of some kind.
I believe Art is off cruising on vacation.
Re: reading Pokeys pins
Ya-Nvr-No
Thanks that seemed to fix it I thought there was a buffer problem but had no errors, I wouldn't use the print while loading a file normally but was testing to make sure the entire file was loaded, and it is..
Thanks gary
Thanks that seemed to fix it I thought there was a buffer problem but had no errors, I wouldn't use the print while loading a file normally but was testing to make sure the entire file was loaded, and it is..
Thanks gary
Re: reading Pokeys pins
Hi Gary:
Sorry I missed that one, luckily YaNvrNo was around, he knows Auggie
pretty much as well as I and somewhat better in scripting. He was instrumental
in its development. Im deep into serious math learning for an upcoming (perhaps)
module Im writing so Im a bit intermittant. When the math gets too deep
for me I tend to lose track and hadnt checked in a few days to see how this
thread was doing (for some reason it no longer sends me notifications on this
thread.).
Glad the fix helped, probably the print buffer was filled and waiting for a sleep or
yield to get time to finish its work.
Art
Sorry I missed that one, luckily YaNvrNo was around, he knows Auggie
pretty much as well as I and somewhat better in scripting. He was instrumental
in its development. Im deep into serious math learning for an upcoming (perhaps)
module Im writing so Im a bit intermittant. When the math gets too deep
for me I tend to lose track and hadnt checked in a few days to see how this
thread was doing (for some reason it no longer sends me notifications on this
thread.).
Glad the fix helped, probably the print buffer was filled and waiting for a sleep or
yield to get time to finish its work.
Art
Re: reading Pokeys pins
Thanks art
I have run into a small strange issue when running a g code file it seems to run at a good speed then for no reason at least no one I see...
when it gets to running a profile it runs great then it hits a spot and the Feed rate seems to slow down in half it may make I or two passes then the feed rate go's back to normal, I have look in the g code file at the lines it seems to slow down but I don't see any thing different that could make it slow down so much..
The feed rate is constantly changing form Z that I have at F10 and X Y at F30 it almost seems like it just all of a sudden reads the F10 and doesn't switch to F30 for the x y
the feed rate lines are always back to back Z F then change to X Y Feed, looks like next time it gets to the next feed rate change it's back to normal
then maybe 3 or 4 passes it will do it again...
not sure if it me or a buffer problem the g code file is over 5000 lines..
I did test this with motors connected and running but cutting air...
Gary
I have run into a small strange issue when running a g code file it seems to run at a good speed then for no reason at least no one I see...
when it gets to running a profile it runs great then it hits a spot and the Feed rate seems to slow down in half it may make I or two passes then the feed rate go's back to normal, I have look in the g code file at the lines it seems to slow down but I don't see any thing different that could make it slow down so much..
The feed rate is constantly changing form Z that I have at F10 and X Y at F30 it almost seems like it just all of a sudden reads the F10 and doesn't switch to F30 for the x y
the feed rate lines are always back to back Z F then change to X Y Feed, looks like next time it gets to the next feed rate change it's back to normal
then maybe 3 or 4 passes it will do it again...
not sure if it me or a buffer problem the g code file is over 5000 lines..
I did test this with motors connected and running but cutting air...
Gary
Re: reading Pokeys pins
Gary:
What is your look ahead set to? Try 500 or so. See if that cures it.
Auggie is different in the way it plans, it will achieve whatever speed it can
up to demanded feedrate speed by adding lines and re-planning after each line
to see if it can readjust the previous lines speeds to go faster. When it starts
to move it has already planned its stop. So, if lines get added, as they always
do it will look ahead about 1/2 second, lock up to there and replan the
rest of motion to ensure its going as fast as it can, while knowing exactly
when it will run out of commands and stop with normal decel.
Ive seen what you describe, usually in arcs as they can have a lot of
very tiny moves, the type of thing that used to make Mach3 stutter.
Setting a longer lookahead tunes it to that kind of code and allows much
smoother motion on micro gcode motions.
Art
What is your look ahead set to? Try 500 or so. See if that cures it.
Auggie is different in the way it plans, it will achieve whatever speed it can
up to demanded feedrate speed by adding lines and re-planning after each line
to see if it can readjust the previous lines speeds to go faster. When it starts
to move it has already planned its stop. So, if lines get added, as they always
do it will look ahead about 1/2 second, lock up to there and replan the
rest of motion to ensure its going as fast as it can, while knowing exactly
when it will run out of commands and stop with normal decel.
Ive seen what you describe, usually in arcs as they can have a lot of
very tiny moves, the type of thing that used to make Mach3 stutter.
Setting a longer lookahead tunes it to that kind of code and allows much
smoother motion on micro gcode motions.
Art
Re: reading Pokeys pins
Art
Ok will give it a try and let you know how it go's..
I was not getting alert messages for this site either, what I had to do was login to my internet provider account and shut off blocking or spam and then I started getting the alerts and all messages..
Did the look ahead change and its fine now so that was the problem..
Gary
Ok will give it a try and let you know how it go's..
I was not getting alert messages for this site either, what I had to do was login to my internet provider account and shut off blocking or spam and then I started getting the alerts and all messages..
Did the look ahead change and its fine now so that was the problem..
Gary
Last edited by gburk on Wed Jul 31, 2019 3:18 am, edited 1 time in total.
Re: reading Pokeys pins
Art
I can't figure this out anything I enter below the last print line in this script I get compile error if I remove the line after the last print it complies fine..
and I don't see anything wrong with the code..
maybe it will compile for you, it imports into the LIB and doesn't show an error in the LIB only when I try to compile in the script window..
// Library Probing
// Created Sunday, April 16, 2019
// Author Gary -- Do not edit above this line
// Z probe touch off
// ex: global mylibprobe = function(axis,distance,feedrate,touchPlate);
//Z Axis probe, distance to move down, fast feedrate, slowfeed rate, touch off plate thickness if 0 no plate
global ZreturnPos = 0;
global Z_ProbeTouch = function(distance,Ffeedrate,Sfeedrate,touchPlate,retracthight)
{
if ( Ffeedrate <= 0 || Sfeedrate <= 0 || distance <= 0 || retracthight <= 0 ) // Axis needs to be 1 to 3 feedrate can't be 0
{
print("Error: Sfeedrate - Ffeedrate - distance - retracthight all need to be higher than 0 "); // error wrong axis number or no feedrate entered
return -1; // exit probing
}
XstartPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
YstartPos = GlobalGet("Axis2CurPos"); // 2 = Y save the y start position
ZstartPos = GlobalGet("Axis3CurPos"); // 3 = Z save the z start position
print("distance = ",distance); // just a test will remove
print("Ffeedrate = ",Ffeedrate); // just a test will remove
print("Sfeedrate = ",Sfeedrate); // just a test will remove
print("touchPlate = ",touchPlate); // just a test will remove
print("startheight = ",ZstartPos); // just a test will remove
print("retracthight = ",retracthight); // just a test will remove
GlobalSet("ProbeInvert",0); // set probe to normal state = false
Gcodestring = "G90 G31 Z-" + distance + "F" + Sfeedrate; // gcode string G31, axis Z, distance, feedrate
Engine.GCode(Gcodestring); // probe DRO distance down in Z
block("MotionStill"); // wait for all motion to stop, no system delay for this.
if( !GlobalGet("ProbeHit")) // If probe not hit Error
{
print("No probe Hit..Enter a Higher Travel Distance or may have missed part/touchoff plate."); // no probe hit probe stopped to high, travel distance to small or missed plate
Gcodestring = "G90 G01 Z" + ZstartPos + " F" + Ffeedrate; // gcode string G01, Z, Zstart Position, fast feedrate
Engine.GCode(Gcodestring); // Return to Z start Position
block("MotionStill"); // wait for all motion to stop, no system delay for this.
return -2; // we didnt hit the probe during the move, exit probing with ERROR code
}
print("Probe Hit"); // Great probe was Hit
sleep(0.5); // lets take a short nap
GlobalSet("ProbeInvert",1); // invert probe switch 1 = true
ProbePos = GlobalGet("ProbePos2"); // Z probe Save position to probepos
Gcodestring = "G31 Z" + ProbePos + "F" + Sfeedrate; // gcode string G31, Z, slow feedrate just a short distance
Engine.GCode(Gcodestring); // probe upwards slowly till switch releases
block("MotionStill"); // wait for all motion to stop, no system delay for this.
if( GlobalGet("ProbeHit")) // probe released upward travel all good
{
Engine.SetAxisPos( null, null, touchPlate ); // now set Z position to touchoff plate thickmess or 0 if none
yield(); // take a break
sleep(0.5); // and a nap
Gcodestring = "G01 Z" + retracthight +" F" + Ffeedrate; // gcode string G01, Z, fast feedrate to retract height
Engine.GCode(Gcodestring); // do the retract
block("MotionStill"); // wait for all motion to stop, no system delay for this., 1,
print("Z Axis Height set, probe complete." + retracthight ); // yes show message Probe completed and retracted to
}
else // Looks like probe not released don't know why but ERROR it
{
print(" Error in Ztouch Backoff" ); // probe didn't open don't know why
return -3; // Return ERROR message
};
ZreturnPos = GlobalGet("Axis3CurPos"); // 3 = Z save the z start position
return 0; // No errors probe done return 0
};
// Find the center of X!, probe the Z first why we want to know the Z zero so the probe can
// start below the parts surface the probe will move half the parts langth plus over shoot
// then the probe will do a g31 probe move down to make sure the probe if off the parts surface
// if the probe is hit than enter a larger distance for X length, if hit the probe will
// rapid move up to Z start position and then rapid back to X start position. now enter a
// larger X distance..
// We do the g31 move down so the probe doesn't get bent or broke, the Z stops if the probe
// isn't off the part, and travels to the entered distance below surface to start the X probe
// Then g31 probe movers back to parts edge when hit rapids back and g31 probes again saves the
// X position rapids back on X then rapids up to Z start position, now rapids back to X start
// position now rapids to X- and repeats all the preious moves.. saves the X- posistion
// now the part center is half the distance between X and X-, probe rapids up to Z start
// position and to parts new center and the Z dro is set to 0.
global ZeroXCenter = function(ZDisDown,FastFeed,SlowFeed,TouchOffPlate,retractheight,belowpart,xlength)
{
print("Find the X center ");
if (FastFeed <= 0 || SlowFeed <= 0 || ZDisDown <= 0 || retractheight <= 0 || belowpart <= 0 || xlength <= 0) // Axis needs to be 1 to 3 feedrate can't be 0
{
print("Below part " + xlenght);
print("Error: Z Distance Down - FastFeed - SlowFeed - retractHeight - below part surface need to be higher than 0"); // error wrong axis number or no feedrate entered
return; // exit probing
}
XstartPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
YstartPos = GlobalGet("Axis2CurPos"); // 2 = Y save the y start position
ZstartPos = GlobalGet("Axis3CurPos"); // 3 = Z save the z start position
// touch off Z first and retract then do the X move to the X -pos first
ZTouchOK = Z_ProbeTouch(ZDisDown,FastFeed,SlowFeed,TouchOffPlate,retractheight);
if (ZTouchOK != 0) // if not 0 must have errored
{
print("Zprobe Touch Error Exiting X Centering " + ZTouchOK); // Show Error
return -1; // Exit with Error
}
// Z probe done with no errors now lets try X probing
print("Zprobe Finished No Errors Now moving X " + xlength); // No Error Continue Probing
Engine.RapidTo((xlength / 2) + belowpart, null, null, null); // move to half the part langth plus a little
block("MotionStill");
ZTouchOK = Z_ProbeTouch(ZDisDown,FastFeed,SlowFeed,TouchOffPlate,retractheight);
if (ZTouchOK != 0) // if not 0 must have errored
{
print("Zprobe Must have hit top of part enter a Larger X length Aborting X Centering " + ZTouchOK); // Show Error
Engine.RapidTo(XstartPos, null, null, null); // move to half the part langth plus a little
block("MotionStill");
return -2; // Exit with Error
}
// now we will start the X probe to parts first edge probe not hit
GlobalSet("ProbeInvert",0); // set probe to normal state = false
Gcodestring = "G31 X-" + xlength/2 + "F" + Sfeedrate; // gcode string G31, axis Z, distance, feedrate move back twards part
Engine.GCode(Gcodestring); // probe DRO distance X-
block("MotionStill");
if( !GlobalGet("ProbeHit")) // If probe not hit Error
{
print("No probe Hit..Enter a lower xlength to far off parts edge."); // no probe hit probe stopped to high, travel distance to small or missed plate
Engine.RapidTo(null, null, ZstartPos, null); // move back to safe z height
block("MotionStill");
Engine.RapidTo(XstartPos, null, null, null); // move Back to X start position
block("MotionStill");
return -2; // we didnt hit the probe during the move, exit probing with ERROR code
}
// X probe was hit so far so good
print("X Probe Was Hit Retracting Z then moving to X+ Postition");
XNegPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
Engine.RapidTo(null , null, ZstartPos, null); // Rapid to Z safe Height
block("MotionStill");
Engine.RapidTo(XstartPos, null, null, null); // Rapid to X start position
block("MotionStill");
// now move to X+ position for next probe
Engine.RapidTo(-(xlength / 2) - belowpart, null, null, null); // move to half the part langth plus a little
block("MotionStill");
// now we will start the Z probe to to make sure we are off part
GlobalSet("ProbeInvert",0); // set probe to normal state = false
Gcodestring = "G31 X" + xlength/2 + "F" + Sfeedrate; // gcode string G31, axis Z, distance, feedrate move back twards part
Engine.GCode(Gcodestring); // probe DRO distance X-
block("MotionStill"); // wait for all motion to stop, no system delay for this.
if( !GlobalGet("ProbeHit")) // If probe not hit Error
{
print("No probe Hit..Enter a lower xlength to far off parts edge."); // no probe hit probe stopped to high, travel distance to small or missed plate
Engine.RapidTo(null, null, ZstartPos, null); // move back to safe z height
block("MotionStill");
Engine.RapidTo(XstartPos, null, null, null); // move Back to X start position
block("MotionStill");
return -2; // we didnt hit the probe during the move, exit probing with ERROR code
}
// X probe was hit so far so good
print("X Probe Hit");
XPosPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
};
Gary
I can't figure this out anything I enter below the last print line in this script I get compile error if I remove the line after the last print it complies fine..
and I don't see anything wrong with the code..
maybe it will compile for you, it imports into the LIB and doesn't show an error in the LIB only when I try to compile in the script window..
// Library Probing
// Created Sunday, April 16, 2019
// Author Gary -- Do not edit above this line
// Z probe touch off
// ex: global mylibprobe = function(axis,distance,feedrate,touchPlate);
//Z Axis probe, distance to move down, fast feedrate, slowfeed rate, touch off plate thickness if 0 no plate
global ZreturnPos = 0;
global Z_ProbeTouch = function(distance,Ffeedrate,Sfeedrate,touchPlate,retracthight)
{
if ( Ffeedrate <= 0 || Sfeedrate <= 0 || distance <= 0 || retracthight <= 0 ) // Axis needs to be 1 to 3 feedrate can't be 0
{
print("Error: Sfeedrate - Ffeedrate - distance - retracthight all need to be higher than 0 "); // error wrong axis number or no feedrate entered
return -1; // exit probing
}
XstartPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
YstartPos = GlobalGet("Axis2CurPos"); // 2 = Y save the y start position
ZstartPos = GlobalGet("Axis3CurPos"); // 3 = Z save the z start position
print("distance = ",distance); // just a test will remove
print("Ffeedrate = ",Ffeedrate); // just a test will remove
print("Sfeedrate = ",Sfeedrate); // just a test will remove
print("touchPlate = ",touchPlate); // just a test will remove
print("startheight = ",ZstartPos); // just a test will remove
print("retracthight = ",retracthight); // just a test will remove
GlobalSet("ProbeInvert",0); // set probe to normal state = false
Gcodestring = "G90 G31 Z-" + distance + "F" + Sfeedrate; // gcode string G31, axis Z, distance, feedrate
Engine.GCode(Gcodestring); // probe DRO distance down in Z
block("MotionStill"); // wait for all motion to stop, no system delay for this.
if( !GlobalGet("ProbeHit")) // If probe not hit Error
{
print("No probe Hit..Enter a Higher Travel Distance or may have missed part/touchoff plate."); // no probe hit probe stopped to high, travel distance to small or missed plate
Gcodestring = "G90 G01 Z" + ZstartPos + " F" + Ffeedrate; // gcode string G01, Z, Zstart Position, fast feedrate
Engine.GCode(Gcodestring); // Return to Z start Position
block("MotionStill"); // wait for all motion to stop, no system delay for this.
return -2; // we didnt hit the probe during the move, exit probing with ERROR code
}
print("Probe Hit"); // Great probe was Hit
sleep(0.5); // lets take a short nap
GlobalSet("ProbeInvert",1); // invert probe switch 1 = true
ProbePos = GlobalGet("ProbePos2"); // Z probe Save position to probepos
Gcodestring = "G31 Z" + ProbePos + "F" + Sfeedrate; // gcode string G31, Z, slow feedrate just a short distance
Engine.GCode(Gcodestring); // probe upwards slowly till switch releases
block("MotionStill"); // wait for all motion to stop, no system delay for this.
if( GlobalGet("ProbeHit")) // probe released upward travel all good
{
Engine.SetAxisPos( null, null, touchPlate ); // now set Z position to touchoff plate thickmess or 0 if none
yield(); // take a break
sleep(0.5); // and a nap
Gcodestring = "G01 Z" + retracthight +" F" + Ffeedrate; // gcode string G01, Z, fast feedrate to retract height
Engine.GCode(Gcodestring); // do the retract
block("MotionStill"); // wait for all motion to stop, no system delay for this., 1,
print("Z Axis Height set, probe complete." + retracthight ); // yes show message Probe completed and retracted to
}
else // Looks like probe not released don't know why but ERROR it
{
print(" Error in Ztouch Backoff" ); // probe didn't open don't know why
return -3; // Return ERROR message
};
ZreturnPos = GlobalGet("Axis3CurPos"); // 3 = Z save the z start position
return 0; // No errors probe done return 0
};
// Find the center of X!, probe the Z first why we want to know the Z zero so the probe can
// start below the parts surface the probe will move half the parts langth plus over shoot
// then the probe will do a g31 probe move down to make sure the probe if off the parts surface
// if the probe is hit than enter a larger distance for X length, if hit the probe will
// rapid move up to Z start position and then rapid back to X start position. now enter a
// larger X distance..
// We do the g31 move down so the probe doesn't get bent or broke, the Z stops if the probe
// isn't off the part, and travels to the entered distance below surface to start the X probe
// Then g31 probe movers back to parts edge when hit rapids back and g31 probes again saves the
// X position rapids back on X then rapids up to Z start position, now rapids back to X start
// position now rapids to X- and repeats all the preious moves.. saves the X- posistion
// now the part center is half the distance between X and X-, probe rapids up to Z start
// position and to parts new center and the Z dro is set to 0.
global ZeroXCenter = function(ZDisDown,FastFeed,SlowFeed,TouchOffPlate,retractheight,belowpart,xlength)
{
print("Find the X center ");
if (FastFeed <= 0 || SlowFeed <= 0 || ZDisDown <= 0 || retractheight <= 0 || belowpart <= 0 || xlength <= 0) // Axis needs to be 1 to 3 feedrate can't be 0
{
print("Below part " + xlenght);
print("Error: Z Distance Down - FastFeed - SlowFeed - retractHeight - below part surface need to be higher than 0"); // error wrong axis number or no feedrate entered
return; // exit probing
}
XstartPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
YstartPos = GlobalGet("Axis2CurPos"); // 2 = Y save the y start position
ZstartPos = GlobalGet("Axis3CurPos"); // 3 = Z save the z start position
// touch off Z first and retract then do the X move to the X -pos first
ZTouchOK = Z_ProbeTouch(ZDisDown,FastFeed,SlowFeed,TouchOffPlate,retractheight);
if (ZTouchOK != 0) // if not 0 must have errored
{
print("Zprobe Touch Error Exiting X Centering " + ZTouchOK); // Show Error
return -1; // Exit with Error
}
// Z probe done with no errors now lets try X probing
print("Zprobe Finished No Errors Now moving X " + xlength); // No Error Continue Probing
Engine.RapidTo((xlength / 2) + belowpart, null, null, null); // move to half the part langth plus a little
block("MotionStill");
ZTouchOK = Z_ProbeTouch(ZDisDown,FastFeed,SlowFeed,TouchOffPlate,retractheight);
if (ZTouchOK != 0) // if not 0 must have errored
{
print("Zprobe Must have hit top of part enter a Larger X length Aborting X Centering " + ZTouchOK); // Show Error
Engine.RapidTo(XstartPos, null, null, null); // move to half the part langth plus a little
block("MotionStill");
return -2; // Exit with Error
}
// now we will start the X probe to parts first edge probe not hit
GlobalSet("ProbeInvert",0); // set probe to normal state = false
Gcodestring = "G31 X-" + xlength/2 + "F" + Sfeedrate; // gcode string G31, axis Z, distance, feedrate move back twards part
Engine.GCode(Gcodestring); // probe DRO distance X-
block("MotionStill");
if( !GlobalGet("ProbeHit")) // If probe not hit Error
{
print("No probe Hit..Enter a lower xlength to far off parts edge."); // no probe hit probe stopped to high, travel distance to small or missed plate
Engine.RapidTo(null, null, ZstartPos, null); // move back to safe z height
block("MotionStill");
Engine.RapidTo(XstartPos, null, null, null); // move Back to X start position
block("MotionStill");
return -2; // we didnt hit the probe during the move, exit probing with ERROR code
}
// X probe was hit so far so good
print("X Probe Was Hit Retracting Z then moving to X+ Postition");
XNegPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
Engine.RapidTo(null , null, ZstartPos, null); // Rapid to Z safe Height
block("MotionStill");
Engine.RapidTo(XstartPos, null, null, null); // Rapid to X start position
block("MotionStill");
// now move to X+ position for next probe
Engine.RapidTo(-(xlength / 2) - belowpart, null, null, null); // move to half the part langth plus a little
block("MotionStill");
// now we will start the Z probe to to make sure we are off part
GlobalSet("ProbeInvert",0); // set probe to normal state = false
Gcodestring = "G31 X" + xlength/2 + "F" + Sfeedrate; // gcode string G31, axis Z, distance, feedrate move back twards part
Engine.GCode(Gcodestring); // probe DRO distance X-
block("MotionStill"); // wait for all motion to stop, no system delay for this.
if( !GlobalGet("ProbeHit")) // If probe not hit Error
{
print("No probe Hit..Enter a lower xlength to far off parts edge."); // no probe hit probe stopped to high, travel distance to small or missed plate
Engine.RapidTo(null, null, ZstartPos, null); // move back to safe z height
block("MotionStill");
Engine.RapidTo(XstartPos, null, null, null); // move Back to X start position
block("MotionStill");
return -2; // we didnt hit the probe during the move, exit probing with ERROR code
}
// X probe was hit so far so good
print("X Probe Hit");
XPosPos = GlobalGet("Axis1CurPos"); // 1 = X save the x start position
};
Gary
Who is online
Users browsing this forum: No registered users and 1 guest