Support => Scripts and Plugin Help => Topic started by: MrJTJinx on February 15, 2019, 12:10:48 pm

Title: Canned cycles for GRBL
Post by: MrJTJinx on February 15, 2019, 12:10:48 pm
I'm trying to find how to manually code canned cycles for GRBL.
G81, G73, G83 have been written int a post processor i found which converts these code into G0 & G1 codes.
im shocked at the non existent educational material available on the web which breaks down all machine operations in this way.

Conversational programming and canned cycles are a relatively recent thing are they not - so how did the boys back in the 50s do it.

for example i would like to do pcd holes and hole patters based on a matrix.  I can easily do them in cad and import them but where is the fun in that.

It would be very much appreciated if a list of codes could be produced for all the canned cycles which are not supported by GRBL DIY machines Shapeoko and probably TinyG and even more impressive if they were incorporated into a post.

There must be thousands of GRBL users who have purchased Cambam and wouldn't use anything else despite our controller limitations.

10Bulls wrote the GRBL Drilling functions Post processor

Title: Re: Canned cycles for GRBL
Post by: MrJTJinx on February 15, 2019, 12:24:16 pm
This was a quick application I knocked up in VB to do peck drilling for example

Dim PlungeRate As Double
Dim Retract As Double
Dim TotalDepth As Double
Dim DepthPass As Double
Dim DepthToCut As Double
Dim AmountToCut As Double

Private Sub Command1_Click()

Dim i As Integer
Text9.Text = "G21 G90" & vbCrLf & "G0 Z" & Text8.Text & vbCrLf & "G17" & vbCrLf & "M3 S" & Text10.Text & vbCrLf
Text9.Text = Text9.Text & "G0  X" & Text4.Text & " Y" & Text5.Text & vbCrLf & "G0 Z" & Text1.Text & vbCrLf
AmountToCut = DepthToCut
PlungeRate = Val(Text2)
Retract = Val(Text6)
TotalDepth = Val(Text3)
DepthPass = Val(Text7)

DepthToCut = TotalDepth / DepthPass

AmountToCut = Val(Text1)

For i = 1 To DepthToCut
AmountToCut = AmountToCut - DepthPass

Text9.Text = Text9.Text & "G0  Z" & Format((Val(Text1) + Retract), "0.00") & vbCrLf
Text9.Text = Text9.Text & "G0  Z" & Format((AmountToCut + Retract), "0.00") & vbCrLf

Text9.Text = Text9.Text & "G1 Z" & Format(AmountToCut, "0.00") & " F" & Val(Text2) & vbCrLf
Text9.Text = Text9.Text & "G0  Z" & Val(Text8) & vbCrLf & "M5" & vbCrLf

End Sub

Private Sub Command2_Click()
' Get a free file number
FileNum = FreeFile

' Create Test.txt
Open App.Path & "" For Output As FileNum

' Write the contents of TextBox1 to Test.txt
Print #FileNum, Text9.Text

' Close the file
Close FileNum
End Sub

Title: Re: Canned cycles for GRBL
Post by: lloydsp on February 15, 2019, 21:01:49 pm
Neat!  I can't try it, as I do not have a GRBL control, but that's a great addition!


Title: Re: Canned cycles for GRBL
Post by: dh42 on February 15, 2019, 21:23:57 pm

Unfortunately, we can't do math in the PP itself, so no way to do a peck drilling only with the PP .... but, I think it is possible to do that with a post treatment of the GCode. Because no math can be done in the PP, we could write the needed datas as comments in the GCode (ex: $mop.peckdistance for output the value for peek), then the post treatment can take those values to generate a replacement Gcode automatically after the GCode has be done by the PP.

those topics shows 2 post treatments where you can take a "skeleton" to do your own post treatment.


Title: Re: Canned cycles for GRBL
Post by: lloydsp on February 15, 2019, 23:14:25 pm
Or, David,

A post-build processor that scans the files for such drill cycles, and does the math in the language chosen to do the PBP.


Title: Re: Canned cycles for GRBL
Post by: MrJTJinx on February 17, 2019, 09:52:05 am
Its more the limitation of Gcodes which causes the issue.  Where 10Bulls has changed the G81 so when it appears in the code it gets broken down into G0/G1 codes.  the locations of of holes would still be the x,z coordinates of the hole location from cad the only math i see is knowing to peck and retract for a number of operations to a given depth.  depth is also known from cad/selecting the drill function.  The GRBL based machine controllers do have a macro option but unfortunately they cant be selected at run time. could Cambam have macros which do the math when a Gcode for a canned operation is selected.  perhaps an option in the machine setting which is set to recognise the user has a GRBL/clone etc. then from that point on the post checks the option and if grbl knows to use macros in place of canned cycles.

Title: Re: Canned cycles for GRBL
Post by: lloydsp on February 17, 2019, 15:15:14 pm
Whatever 'math' isn't supported by CamBam may be done in the language of your choice external to the post-processor, using the post-build-processor feature of CB.

Such can parse your .nc file for any G81/82/83 cycles, convert each of them to G0/G1 commands, and output a new nc file under a naming convention of your choice.


Title: Re: Canned cycles for GRBL
Post by: MrJTJinx on May 13, 2019, 10:27:50 am
Canned cycles for GRBL i have figured out can only be created by the machines operating software and not the offline cam editor.  i'm now considering making changes to GRBL panel.

Title: Re: Canned cycles for GRBL
Post by: Garyhlucas on May 13, 2019, 23:34:40 pm
Canned cycles have been a part of G-code forever. Back in the days of hand coding they greatly reduced the effort to program.  Another important reason was CNCs using paper tape for memory could not hold a very large program.  So built in functions like peck drilling, tool radius offset, pocketing, etc. radically reduced the amount of memory needed. When I was hand coding 20 years ago I used G41, G42, G81, G83, extensively.  CNC on PCs totally eliminated the file size problem and a million line program is feasible.  CAM changes the whole picture.  I do not care if the CAM program writes a thousand lines of code or calls a G83 to get the job done.

So an MOP in CamBam to simulate G83 on the GRBL or any machine that doesn't have it is perfectly workable.  In the same way as we don't really miss G41, G42 because CamBam applies the tool radius offsets.

Title: Re: Canned cycles for GRBL
Post by: lloydsp on May 14, 2019, 00:17:16 am
Amen, Gary!  G-code is 'free'.  It costs nothing but file-size.


Title: Re: Canned cycles for GRBL
Post by: MrJTJinx on May 14, 2019, 12:20:55 pm
Garyhlucas, Lloyd.
may I ask what your point is.

I have noticed of late that the forum is becoming quite narcissistic, I apologise if this was not your intention.

I as a customer have supported cambam and occasionally request improvements I would like to see to the application.
I may not be a fully fledged machinist yet but that does not alter the fact that the only way to learn or get support and advice is via the forum. 
As a customer, I have purchased this software and don't expect to be treated with disrespect.

Its a shame that this excellent products forum is sharp becoming a home for computer programmers.  I am starting to wonder what the future holds for this product, there has been no significant updates or improvements for some time now.  Considering the amount of programmers who are hiding out here.

Please don't forget that cambam is a product which is sold to the public and that this is not a Git open source site, otherwise cambam customers may as well ask for their money back.  Perhaps its time the forum was reigned back a little.

Title: Re: Canned cycles for GRBL
Post by: Garyhlucas on May 14, 2019, 19:02:38 pm
Seriously, you have a perception problem if you think there was ANYTHING negative in what I posted! You came here asking help with programming and both Loyd and I did nothing more than explain how you might accomplish what you want. If you are going do custom programming I suggested writing an MOP which could do this easily and be useful as a template for others to do something similar.

Title: Re: Canned cycles for GRBL
Post by: EddyCurrent on May 14, 2019, 21:20:42 pm
Just an old Yorkshire saying aimed at nobody in particular used frequently today in jest but created many years ago before some words were hijacked to have a different meaning, quite depressing really for us older folk.

In the interests of harmony I have removed the text that was here.

Title: Re: Canned cycles for GRBL
Post by: MrJTJinx on October 15, 2019, 23:43:50 pm

Your comment has been moderate ; please keep cool !


Title: Re: Canned cycles for GRBL
Post by: lloydsp on October 16, 2019, 16:12:15 pm
Seriously, Jinx... everything that was posted by everyone was in the interest of helping you.

Quite apart from your perception of "narcissism" on this site, you'll find faster, more-competent help here than on any but one site I've ever visited.

And, if you'll look at the past month's postings, you'll see there ARE significant improvements to CB available, and some tweaks coming, too.

Lighten up a little, sir.  We're only trying to help you fix your problem.

I'm sure Andy could write some extensions that would allow GRBL conversion of drilling cycles, and it's not wrong to ask him to.  In the meanwhile, YOU (or a programmer friend) can fix the problem with a post-build-processor written to-purpose.