However, I thought I'd start a thread as a brainstorming session and something may come of it, hence this thread.
Keith asked about reversing / backing up a toolpath a specified distance from a lost arc position I think it was [correct me if I'm wrong].
_____________________________________________________________________________________________________________________
I was wondering...
Given Field # 866 ( Setnextlinefield ) gives the next line number (therefore the current line is technically Setnextlinefield + 1 if you are actually counting line numbers as Field 866 starts at line zero)
Hence Setnextlinefield - 1 would give you the previous line (which is the start point for the current g-code line).
Given we know the current co-ordinates with:
Field# 226 (XDRO) and Field#227 (YDRO)
We could backtrack a given distance to the previous line from our current position {in theory --> see complications #1 & #2}
We would also need to know what the current Group 01 modal command is (presumed to be G1, G2 or G3 only as this is a plasma only application)
This could be done by parsing field#877 (active modal) which will provide the currant group 01 modal command {---> see complications #3}
G1 backup will no doubt be the easiest.... (straight line to previous co-ordinates)
G2 & G3 will require knowing the present co-ordinates, the commanded I & J + correcting for the current co-ordinates offset from the previous co-ordinates start point (previous line X&Y), and then flipping the direction of motion from say G2 to G3 to visa versa for the backup...... and if the backup distance is insufficent.... carry over to the next line up.
.................................................
Given the complications over working out the backup distance in relation to the current co-ordinates, previous g-code line desitination and insufficent backup distance, it may be easier just to backup a few lines (of unknown distance) and insert a code snippet which inserts those previous lines, and an M10 at the correct Lost Arc position, and then insert a run from here which co-encides with the line where the lost arc occured.... (note once and M3 / M10 is given the torch will fire, but it will take a [unknown] while before the ArcOK signal is recieved and the arc stabalises, and the cut is correctly resumed).
______________________________________
Complications:
1) this is hoping that the previous line is a X Y co-ordinate.... not a Z co-ordinate or an M3 or M11 or some other Mcode.....
2) this presumes that the backup distance is less than the distance from the present co-ordinates to the previous G-code line end co-ordinates (otherwise we need to back up another line)
3) as item 1 above (current line and an X Y destination co-ordinate) + add to that although we know the current X & Y co-ordinates and hoping that the current Group#1 modal command is G1, G02 or G03 and not some M-code (which means we would need to backup a line).
Bit of code here to show the use of streamreader with the currently loaded gcode file, and also splitting a string (Field#877 [active modal]), and the use of carriage return in a message box (or two line space)
- Code: Select all
MessageBox.Show( "Previous File Line Read " + fnStreamToLine( AS3.Getfield(866), exec.Getgcodefilename() ) + "\r\r" +
"Current Co-Ordinates " + "X " + AS3.Getfield(226) + " Y" + AS3.Getfield(227) + "\r" +
"Current Active Modal Groups " + AS3.Getfield(877) + "\r" +
"Current Group 01 Mode Active " + fnModalGp(1)
);
#Events
private string fnStreamToLine(string strLineNumber , string GcodeFilename)
{
int intLineNumber = Convert.ToInt32(strLineNumber);
System.IO.StreamReader reader = new System.IO.StreamReader(@GcodeFilename);
for (int i = 0; i < intLineNumber - 1; i++)
{
reader.ReadLine();
}
string line = reader.ReadLine();
reader.Close();
return line;
}
private string fnModalGp(int intGroup)
{
string s = AS3.Getfield(877);
// Split string on "|".
string[] modalgroups = s.Split('|');
return modalgroups[intGroup-1];
}