I've been thinking about how to program canned cycles, apparently while I was sleeping. I thought I would get this out there before I lost it. I've gone ahead and started a new thread for the canned cycles. I hope to add to this to this if anyone is interested. I've not began looking at the TinyG code yet, but maybe this weekend, or if I get enough cycle time tonight. (Running a big 2 pallet horizontal mill with Fanuc control, 80x65x47 inches working envelope)
Generic G83 peck drill cycle:
N10 G0 G90 G54 X1.0 Y1.0 Z1.0 ;
N20 G83 X1.0 Y1.0 Z-0.25 R0.1 Q0.1 F5.0 (X AND Y NOT REQUIRED, CAN BE PULLED FROM CURRENT POSITION) ;
N30 X-1.0 Y1.0 (Y LOCATION NOT REQUIRED);
N40 Y-1.0 (X LOCATION NOT REQUIRED);
N50 X1.0 ;
N60 G80 ;
This drills a 2.0 bolt square about G54 X0 Y0.
(Yah, those are inches I'm using, you'll pry my inches from my cold dead hands) :P
I've written some pseudo code for this, please excuse irregularities, general ugliness, syntax/grammar foulness. I'm not very good at programming and use the lots of monkeys with typewriters method. Also the sledgehammer method. :) Probably about clear as mud.
Pseudo code:
Canned cycle sub called passing vars from call //G83 X1.0 Y1.0 Z-0.25 R0.1 Q0.1 F5.0//
While Line != G80 //quit when G80 is reached//
If Line has X
Then store X in canned_X
Else
store current_X in canned_X
End If
If Line has Y
Then store Y in canned_Y
Else
store current_Y in canned_Y
End If //More of these type statements could be added for ABC axii//
Output "G0 X(canned_X) Y(canned_Y) ;" //moves to first hole location or goes to where it already is//
G83 sub called and passes (R Q z F) //G83 sub peck drills the hole//
store current_Z in traverse_Z //this is where it could be changed for G98,G99 function//
Output "G0 Z(R) ;" //moves to rapid plane//
drilled_distance = R //we start drilling here//
While Z != drilled_distance //when drilled_distance is the same as Z we are done//
drilled_distance = drilled_distance - Q //start subtracting pecks from drilled_distance//
If drilled_distance < Z //We don't want to drill deeper than Z so reset number to max Z depth//
Then drilled_distance = Z
End If
Output "G1 Z(drilled_distance) F(F) ;" //drill a peck//
Output "G0 Z(R) ;" //peck back out to Z0.1 in this example//
If drilled distance != Z // We don't want to go back into hole if already gone to depth //
Then Output "G0 Z(drilled_distance + .01) ;" //rapid back into hole .01 above last drilled depth//
End If //the .01 would generally be a peck return parameter set elsewhere like EEPROM//
Loop While //Get ready for the next peck or quit//
Output "G0 Z(traverse_Z) ;" //move back up to our intial Z, Z1.0 in this case//
End G83 sub
Grab next line of program //get ready to drill the next hole or quit//
Loop While
End canned
Basically this takes the parameters from the G83 line and following lines until the G80. It converts this into G0's and G1's. G17 is assumed, and does not take into account G18 and G19. This also does not provide for G98 and G99. Bad things would happen if in G91 mode and not G90.
Probably be best to convert all this to machine co-ords but not sure if that function is present, think I read that it wasn't yet.
Output would look like this for the first hole:
G0 X1.0 Y1.0
G0 Z0.1
G1 Z0.0 F5.0
G0 Z0.1
G0 z0.01
G1 Z-0.1 F5.0
G0 z0.1
G0 z-0.09
G1 z-0.2 F5.0
G0 z0.1
G0 z-0.19
G1 z-0.25 F5.0
G0 z0.1
G0 z1.0
On to next hole.
Again, this is just a rough idea but I would appreciate any input. Or tell me to get off your lawn. :)