Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: cameraman on December 09, 2007, 03:52:30 PM

Title: gcode to mill half ball with cnc mill
Post by: cameraman on December 09, 2007, 03:52:30 PM
Hello,  I'd like to make half a ball on my mill, and am trying to figure out the best way.  I don't have any good cam software.

I'd like to just create an arc on the XZ plane and then rotate the coordinates of the XY plane incrimentally by a degree for every cut.  that way I coud just copy the same few lines of code over and over and that would work.  Unfortunately Mach3 wont use  the rotated coordinates in any plane but the XY so that doesn't work.

Any ideas?  Are there any "wizards" out there that do this?  I know a lathe would be ideal for this, but I don't have one with CNC or a large enough ball turner.  Before I've mounted a rotary table on my lathe bed to hold my bit, but I'd like to avoid doing that again and there should be a way to make the cnc mill work anyway.

Thanks!
   Stewart
Title: Re: gcode to mill half ball with cnc mill
Post by: Hood on December 10, 2007, 02:21:05 AM
How big is this half ball? if not to big you could chuck the stock in the spindle and have a bit of HSS ground  like a lathe tool clamped in the vice and use the Z and X axis to move in an arc. In other words use your mill as a lathe.
Hood
Title: Re: gcode to mill half ball with cnc mill
Post by: stirling on December 10, 2007, 10:45:44 AM
Hi cameraman

try this - just replace the values of your choice up to "end of inputs" and rock n roll. Please note I knocked this up for you for fun - I haven't actually tested it on my mill so go carefully. Maybe I'll wrap it as a wizard if anyone wants it.

F3000
#1000=100 (hemisphere radius)
#1001=5 (ballmill radius)
#1002=20 (number of steps)
#1005=0 (centre X)
#1006=0 (centre Y)
#1007=150 (safe Z)
(end of inputs)
#1000=110 (total)
#1003=[90.0 / #1002]
#1004=[#1003]
G00 Z[#1007]
M98 P1 L[#1002]
M30
O1
#1008=[#1000 * sin[#1004]]
#1009=[#1008 / tan[#1004]]
g00 X[#1005 + #1008] Y#1006
G01 Z[#1009]
g02 I#1005 J#1006
#1004=[#1004+#1003]
M99
Title: Re: gcode to mill half ball with cnc mill
Post by: cameraman on December 10, 2007, 10:58:25 AM
Thanks!  I'll try the code and let you know.  My half ball is 100mm in diameter, although i'm working in inches so it is 3.937", if it was smaller chucking the material in the spindle might have worked.
Title: Re: gcode to mill half ball with cnc mill
Post by: cameraman on December 10, 2007, 11:03:29 AM
I don't know if you'll make the wizard or not (I definately could use it), but if you do in this application my half ball is only the lower part of the ball, so it will look like a half ball with the top lopped off, so it wouldn't need to start from the top.

thanks again.

stewart
Title: Re: gcode to mill half ball with cnc mill
Post by: stirling on December 10, 2007, 11:51:21 AM
erm - slight error. replace the line
 #1000=110 (total)
with
 #1000=[#1000 + #1001] (total)

I had it fixed radius but it needs the sum of the hemisphere and ballmill radius.

Title: Re: gcode to mill half ball with cnc mill
Post by: jimpinder on December 10, 2007, 12:04:45 PM
If your rotary table has a motor on it, then mount the work on the rotary table and turn that after each pass.

Yes - it is possible to make a mill do it, but surely you are making an easy job more difficult by using the wrong machine.
Surely, unless you use a very small cutter, or a shaped one, the machining will show.
Title: Re: gcode to mill half ball with cnc mill
Post by: cameraman on December 10, 2007, 12:05:38 PM
Cool.  I had taken that line out since it didn't seem right, thanks for the fix!  I also  changed G01 Z[#1009] to G01 Z[#1009 - #1000] so that it starts at the surface of the material and mills down (negatively).  This is my first venture into any gcode scripting, thanks for helping and opening my eyes to this stuff.  Now i'm trying to figure out how to make the program jump to the start z point so I don't waste cycles milling air the first half of the hemisphere.

Title: Re: gcode to mill half ball with cnc mill
Post by: stirling on December 10, 2007, 12:13:40 PM
hint: #1003 holds the definition of the first circle (90 degrees / number of steps).
Title: Re: gcode to mill half ball with cnc mill
Post by: cameraman on December 10, 2007, 12:16:00 PM
Yes, the mill isn't the perfect machine for making round cuts, but there are a lot of other cuts involved that require the mill and the time to chuck up the part in the lathe, setup the tools, and manually turn it isn't worth it in this particular case.  I've milled round cones before with great results, with a 1/2" ball endmill I was really surprised in the quality of the taper, after a light bead blasting you'd never know it wasn't a lathe.  I just haven't done a hemisphere before, it seems the quality should be the same results as a cone, but with sin and cos introduced.  I don't have a motorized rotary table.

I'll let you know the results when i'm done, still working on the code with much help from Stirling, i'm curious too.
Title: Re: gcode to mill half ball with cnc mill
Post by: cameraman on December 10, 2007, 07:06:50 PM
Got it done, thanks for help!  Here is the part... [img http://www.kickasscamera.com/cad/100mmballadapter.jpg]http://[/img]  You may see a line on there that shouldn't be, its from a slightly off roughing pass from a previous attempt, not from this code.

It is an adapter plate for a 100mm bowl tripod, the curve of the part fits into a matching bowl so you can adjust its level easy.  My g code is kind of messy, but i'll post it here anyway in case someone ever searches for something similar.

Thanks.


#1080=.125  (safe z height)
#1081=2     (plung feedrate)
#1082=15    (feedrate)
#1060=.795  (z correction from top of ball to cropped starting point)

#1001=.25   (ballmill radius)

#1000=2.125  (hemisphere radius ROUGH pass)
#1050=1.9685 (hemisphere radius FINiSH pass)

#1002=20 (number of steps ROUGH pass)
#1052=80 (number of steps FINiSH pass)

#1070= 11 (number of ROUGH steps to skip)
#1071= 44 (number of FINiSH steps to skip)

#1005=0 (centre X)
#1006=0 (centre Y)

% end of user entered variables

#1000=[#1000 + #1001] (total)
#1003=[90.0 / #1002]
#1004=[#1003]
#1053=[0 - #1050 - #1001] (the z offset)

G00 Z[#1080]
M98 P1 L[#1070]         (run program)
M98 P2 L[#1002 - #1070] (run program)

G00 Z[#1080]

#1000=[#1050]
#1002=[#1052]

#1000=[#1000 + #1001] (total)
#1003=[90.0 / #1002]
#1004=[#1003]
#1053=[0 - #1000] (the z offset)

M98 P1 L[#1071]         (run program)
M98 P2 L[#1002 - #1071] (run program)
G00 Z[#1080]
M30

O1
  #1008=[#1000 * sin[#1004]]
  #1009=[#1008 / tan[#1004]]
  #1004=[#1004+#1003]
M99

O2
  #1008=[#1000 * sin[#1004]]
  #1009=[#1008 / tan[#1004]]
  g00 X[#1005 + #1008] Y#1006
  F[#1081]
  G01 Z[#1009 + #1053 +#1060]
  F[#1082]
  g03 I#1005 J#1006
  #1004=[#1004+#1003]
M99
M0
Title: Re: gcode to mill half ball with cnc mill
Post by: cameraman on December 10, 2007, 07:10:08 PM
One more note.  This code (the good parts anyway) are all thanks to sterling.  If anyone else finds it useful they should let him know.
Title: Re: gcode to mill half ball with cnc mill
Post by: stirling on December 11, 2007, 11:53:04 AM
nice one cameraman - good job - and thanks for the credit - much appreciated  :)
Title: Re: gcode to mill half ball with cnc mill
Post by: Kabol on December 19, 2007, 04:59:08 PM
I’ve been watching this thread on and off for a few days and I wish to thank both Stirling & Cameraman for a very informative thread. I’m just learning CNC so this project was a huge help to me.

Kabol
Title: Re: gcode to mill half ball with cnc mill
Post by: Overloaded on December 19, 2007, 05:08:19 PM
DITTOS ! !
I saved this one as well.
Best darned forum I've ever seen !
Title: Re: gcode to mill half ball with cnc mill
Post by: NeilD on October 27, 2014, 11:18:07 AM
Just one question, do I type in all the code and parameters as is just adding my numbers in? I'm a newbie myself and really need to mill a hemisherical pocket. Thanks in advance!
Title: Re: gcode to mill half ball with cnc mill
Post by: stirling on October 28, 2014, 07:35:34 AM
I can't remember what I did last week - never mind 7 years ago  ;) but from a quick look - yes - the comments in the code should tell you which values to change for your particular hemisphere.